Commit | Line | Data |
---|---|---|
4a97c059 MJ |
1 | dnl SPDX-License-Identifier: MIT |
2 | dnl | |
3 | dnl Copyright (C) 2021 EfficiOS, Inc. | |
4 | dnl | |
5 | dnl Process this file with autoconf to produce a configure script. | |
6 | ||
7 | # Project version information | |
8 | m4_define([rseq_version_major], [0]) | |
9 | m4_define([rseq_version_minor], [1]) | |
10 | m4_define([rseq_version_patch], [0]) | |
11 | m4_define([rseq_version_dev_stage], [-pre]) | |
12 | m4_define([rseq_version], rseq_version_major[.]rseq_version_minor[.]rseq_version_patch[]rseq_version_dev_stage) | |
13 | ||
14 | # Library version information of "librseq" | |
2cbca301 MJ |
15 | # Following the numbering scheme proposed by libtool for the library version |
16 | # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html | |
4a97c059 MJ |
17 | m4_define([rseq_lib_version_current], [0]) |
18 | m4_define([rseq_lib_version_revision], [0]) | |
19 | m4_define([rseq_lib_version_age], [0]) | |
20 | m4_define([rseq_lib_version], rseq_lib_version_current[:]rseq_lib_version_revision[:]rseq_lib_version_age) | |
21 | ||
22 | ||
23 | ## ## | |
24 | ## Autoconf base setup ## | |
25 | ## ## | |
26 | ||
27 | AC_PREREQ([2.69]) | |
28 | AC_INIT([librseq],[rseq_version],[mathieu dot desnoyers at efficios dot com],[],[https://github.com/compudj/librseq/]) | |
2cbca301 MJ |
29 | |
30 | AC_CONFIG_HEADERS([include/config.h]) | |
31 | AC_CONFIG_AUX_DIR([config]) | |
32 | AC_CONFIG_MACRO_DIR([m4]) | |
33 | ||
34 | AC_CANONICAL_TARGET | |
35 | AC_CANONICAL_HOST | |
36 | ||
4a97c059 MJ |
37 | |
38 | ## ## | |
39 | ## Automake base setup ## | |
40 | ## ## | |
41 | ||
42 | AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip nostdinc -Wall -Werror]) | |
2cbca301 MJ |
43 | AM_MAINTAINER_MODE([enable]) |
44 | ||
4a97c059 MJ |
45 | # Enable silent rules by default |
46 | AM_SILENT_RULES([yes]) | |
2cbca301 | 47 | |
4a97c059 MJ |
48 | |
49 | ## ## | |
50 | ## C compiler checks ## | |
51 | ## ## | |
52 | ||
53 | # Choose the C compiler | |
2cbca301 | 54 | AC_PROG_CC |
4a97c059 MJ |
55 | # AC_PROG_CC_STDC was merged in AC_PROG_CC in autoconf 2.70 |
56 | m4_version_prereq([2.70], [], [AC_PROG_CC_STDC]) | |
2cbca301 | 57 | |
4a97c059 MJ |
58 | # Make sure the C compiler supports C99 |
59 | AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])]) | |
2cbca301 | 60 | |
4a97c059 MJ |
61 | # Enable available system extensions and LFS support |
62 | AC_USE_SYSTEM_EXTENSIONS | |
63 | AC_SYS_LARGEFILE | |
64 | ||
65 | # Make sure the C compiler supports __attribute__ | |
66 | AX_C___ATTRIBUTE__ | |
67 | AS_IF([test "x$ax_cv___attribute__" != "xyes"], | |
68 | [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])]) | |
69 | ||
70 | # Make sure we have pthread support | |
71 | AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])]) | |
2cbca301 MJ |
72 | |
73 | # Checks for typedefs, structures, and compiler characteristics. | |
74 | AC_C_INLINE | |
4a97c059 | 75 | AC_C_TYPEOF |
2cbca301 MJ |
76 | AC_TYPE_INT32_T |
77 | AC_TYPE_INT64_T | |
78 | AC_TYPE_OFF_T | |
79 | AC_TYPE_SIZE_T | |
80 | AC_TYPE_UINT32_T | |
81 | AC_TYPE_UINT64_T | |
82 | ||
6e284b80 MJ |
83 | # Detect warning flags supported by the C compiler and append them to |
84 | # WARN_CFLAGS. | |
85 | m4_define([WARN_FLAGS_LIST], [ dnl | |
86 | -Wall dnl | |
87 | -Wextra dnl | |
88 | -Wmissing-prototypes dnl | |
89 | -Wmissing-declarations dnl | |
90 | -Wnull-dereference dnl | |
91 | -Wundef dnl | |
92 | -Wshadow dnl | |
93 | -Wjump-misses-init dnl | |
94 | -Wsuggest-attribute=format dnl | |
95 | -Wtautological-constant-out-of-range-compare dnl | |
96 | -Wnested-externs dnl | |
97 | -Wwrite-strings dnl | |
98 | -Wformat=2 dnl | |
99 | -Wstrict-aliasing dnl | |
100 | -Wmissing-noreturn dnl | |
101 | -Winit-self dnl | |
102 | -Wduplicated-cond dnl | |
103 | -Wduplicated-branches dnl | |
104 | -Wlogical-op dnl | |
105 | -Wredundant-decls dnl | |
106 | ]) | |
107 | ||
108 | # Pass -Werror as an extra flag during the test: this is needed to make the | |
109 | # -Wunknown-warning-option diagnostic fatal with clang. | |
110 | AC_LANG_PUSH([C]) | |
111 | AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CFLAGS], [-Werror]) | |
112 | AC_LANG_POP([C]) | |
113 | ||
114 | AC_LANG_PUSH([C++]) | |
115 | AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CXXFLAGS], [-Werror]) | |
116 | AC_LANG_POP([C++]) | |
117 | ||
118 | AE_IF_FEATURE_ENABLED([Werror], [WARN_CFLAGS="${WARN_CFLAGS} -Werror"]) | |
119 | AE_IF_FEATURE_ENABLED([Werror], [WARN_CXXFLAGS="${WARN_CXXFLAGS} -Werror"]) | |
120 | ||
2cbca301 | 121 | |
d268885a MJ |
122 | ## ## |
123 | ## C++ compiler checks ## | |
124 | ## ## | |
125 | ||
126 | # Require a C++11 compiler without GNU extensions (-std=c++11) | |
127 | AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) | |
128 | ||
129 | ||
4a97c059 MJ |
130 | ## ## |
131 | ## Header checks ## | |
132 | ## ## | |
133 | ||
134 | AC_HEADER_STDBOOL | |
135 | AC_CHECK_HEADERS([ \ | |
136 | limits.h \ | |
137 | stddef.h \ | |
138 | sys/time.h \ | |
139 | ]) | |
140 | ||
141 | AC_CHECK_HEADER([linux/rseq.h], [], | |
142 | [AC_MSG_ERROR([Cannot find 'linux/rseq.h'.]) | |
143 | ]) | |
144 | ||
145 | ||
146 | ## ## | |
147 | ## Programs checks ## | |
148 | ## ## | |
149 | ||
150 | AM_PROG_AR | |
151 | AC_PROG_AWK | |
152 | AC_PROG_MAKE_SET | |
153 | ||
154 | # Initialize and configure libtool | |
155 | LT_INIT | |
2cbca301 | 156 | |
4a97c059 MJ |
157 | |
158 | ## ## | |
159 | ## Library checks ## | |
160 | ## ## | |
2cbca301 MJ |
161 | |
162 | # Checks for library functions. | |
163 | AC_FUNC_MMAP | |
164 | AC_FUNC_FORK | |
165 | AC_CHECK_FUNCS([ \ | |
4a97c059 | 166 | atexit \ |
2cbca301 MJ |
167 | memset \ |
168 | strerror \ | |
169 | ]) | |
170 | ||
171 | # AC_FUNC_MALLOC causes problems when cross-compiling. | |
172 | #AC_FUNC_MALLOC | |
173 | ||
9698c399 MD |
174 | # Check dor dlopen() in -ldl or -lc |
175 | AC_CHECK_LIB([dl], [dlopen], [ | |
176 | libdl_name=dl | |
177 | DL_LIBS="-ldl" | |
178 | ], [ | |
179 | # dlopen not found in libdl, check in libc | |
180 | AC_CHECK_LIB([c], [dlopen], [ | |
181 | libdl_name=c | |
182 | DL_LIBS="-lc" | |
183 | ], [ | |
184 | AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.]) | |
185 | ]) | |
186 | ]) | |
187 | AC_SUBST(DL_LIBS) | |
2cbca301 | 188 | |
6e284b80 MJ |
189 | |
190 | ## ## | |
191 | ## Optional features selection ## | |
192 | ## ## | |
193 | ||
194 | # When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS. | |
195 | # Disabled by default | |
196 | AE_FEATURE_DEFAULT_DISABLE | |
197 | AE_FEATURE([Werror], [Treat compiler warnings as errors.]) | |
198 | ||
199 | ||
4a97c059 MJ |
200 | ## ## |
201 | ## Substitute variables for use in Makefile.am ## | |
202 | ## ## | |
203 | ||
204 | # Library versions for libtool | |
205 | AC_SUBST([RSEQ_LIBRARY_VERSION], [rseq_lib_version]) | |
2cbca301 | 206 | |
4a97c059 MJ |
207 | # The order in which the include folders are searched is important. |
208 | # The top_builddir should always be searched first in the event that a build | |
209 | # time generated file is included. | |
210 | AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h" | |
2cbca301 MJ |
211 | AC_SUBST(AM_CPPFLAGS) |
212 | ||
6e284b80 | 213 | AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS" |
2cbca301 MJ |
214 | AC_SUBST(AM_CFLAGS) |
215 | ||
6e284b80 | 216 | AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS" |
d268885a MJ |
217 | AC_SUBST(AM_CXXFLAGS) |
218 | ||
4a97c059 MJ |
219 | |
220 | ## ## | |
221 | ## Output files generated by configure ## | |
222 | ## ## | |
223 | ||
2cbca301 MJ |
224 | AC_CONFIG_FILES([ |
225 | Makefile | |
6146efae MD |
226 | doc/Makefile |
227 | doc/man/Makefile | |
2cbca301 MJ |
228 | include/Makefile |
229 | src/Makefile | |
2cbca301 | 230 | src/librseq.pc |
b848736e | 231 | tests/Makefile |
544cdc88 | 232 | tests/utils/Makefile |
2cbca301 MJ |
233 | ]) |
234 | ||
235 | AC_OUTPUT | |
aa4ed6d6 | 236 | |
4a97c059 | 237 | |
aa4ed6d6 MJ |
238 | # |
239 | # Mini-report on what will be built. | |
240 | # | |
241 | ||
242 | PPRINT_INIT | |
243 | PPRINT_SET_INDENT(1) | |
244 | PPRINT_SET_TS(38) | |
245 | ||
246 | AS_ECHO | |
247 | AS_ECHO("${PPRINT_COLOR_BLDBLU}librseq $PACKAGE_VERSION${PPRINT_COLOR_RST}") | |
248 | AS_ECHO | |
249 | ||
250 | PPRINT_SUBTITLE([Features]) | |
251 | ||
252 | PPRINT_PROP_STRING([Target architecture], $host_cpu) | |
253 | ||
aa4ed6d6 MJ |
254 | report_bindir="`eval eval echo $bindir`" |
255 | report_libdir="`eval eval echo $libdir`" | |
256 | ||
257 | # Print the bindir and libdir this `make install' will install into. | |
258 | AS_ECHO | |
259 | PPRINT_SUBTITLE([Install directories]) | |
260 | PPRINT_PROP_STRING([Binaries], [$report_bindir]) | |
261 | PPRINT_PROP_STRING([Libraries], [$report_libdir]) |