Commit | Line | Data |
---|---|---|
23975ca7 MJ |
1 | dnl SPDX-License-Identifier: LGPL-2.1-only |
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([urcu_version_major], [0]) | |
5beb5548 | 9 | m4_define([urcu_version_minor], [14]) |
23975ca7 | 10 | m4_define([urcu_version_patch], [0]) |
5beb5548 | 11 | m4_define([urcu_version_dev_stage], [-pre]) |
23975ca7 MJ |
12 | m4_define([urcu_version], urcu_version_major[.]urcu_version_minor[.]urcu_version_patch[]urcu_version_dev_stage) |
13 | ||
14 | # Library version information of "liburcu" | |
98bc124a YB |
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 | |
3a50dfc2 | 17 | m4_define([urcu_lib_version_current], [8]) |
23975ca7 | 18 | m4_define([urcu_lib_version_revision], [0]) |
3a50dfc2 | 19 | m4_define([urcu_lib_version_age], [0]) |
23975ca7 MJ |
20 | m4_define([urcu_lib_version], urcu_lib_version_current[:]urcu_lib_version_revision[:]urcu_lib_version_age) |
21 | ||
22 | ||
23 | ## ## | |
24 | ## Autoconf base setup ## | |
25 | ## ## | |
26 | ||
afb6113f | 27 | AC_PREREQ([2.69]) |
23975ca7 | 28 | AC_INIT([userspace-rcu],[urcu_version],[mathieu dot desnoyers at efficios dot com],[],[http://liburcu.org/]) |
98bc124a | 29 | |
6893800a | 30 | AC_CONFIG_HEADERS([include/config.h include/urcu/config.h]) |
48d848c7 | 31 | AC_CONFIG_AUX_DIR([config]) |
074c3a1b MJ |
32 | AC_CONFIG_MACRO_DIR([m4]) |
33 | ||
7d413817 MD |
34 | AC_CANONICAL_TARGET |
35 | AC_CANONICAL_HOST | |
074c3a1b | 36 | |
afb6113f MJ |
37 | |
38 | ## ## | |
39 | ## Automake base setup ## | |
40 | ## ## | |
41 | ||
42 | AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip nostdinc -Wall -Wno-portability -Werror]) | |
35eb2d6c | 43 | AM_MAINTAINER_MODE([enable]) |
7d413817 | 44 | |
afb6113f MJ |
45 | # Enable silent rules by default |
46 | AM_SILENT_RULES([yes]) | |
e72596d1 | 47 | |
514079bb MJ |
48 | |
49 | ## ## | |
50 | ## OS and Arch specific defaults ## | |
51 | ## ## | |
52 | ||
53 | AS_CASE([$host], | |
54 | [*-cygwin*], [LT_NO_UNDEFINED="-no-undefined"] | |
55 | ) | |
56 | ||
57 | ||
8b2f0590 MJ |
58 | ## ## |
59 | ## C compiler checks ## | |
60 | ## ## | |
61 | ||
62 | # Choose the C compiler | |
63 | AC_PROG_CC | |
64 | # AC_PROG_CC_STDC was merged in AC_PROG_CC in autoconf 2.70 | |
65 | m4_version_prereq([2.70], [], [AC_PROG_CC_STDC]) | |
66 | ||
67 | # Make sure the C compiler supports C99 | |
68 | AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])]) | |
69 | ||
70 | # Enable available system extensions and LFS support | |
71 | AC_USE_SYSTEM_EXTENSIONS | |
72 | AC_SYS_LARGEFILE | |
73 | ||
153b081a SM |
74 | ## ## |
75 | ## C++ compiler checks ## | |
76 | ## ## | |
77 | ||
78 | # Require a C++11 compiler without GNU extensions (-std=c++11) | |
79 | AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) | |
80 | ||
8b2f0590 MJ |
81 | # Make sure the C compiler supports __attribute__ |
82 | AX_C___ATTRIBUTE__ | |
83 | AS_IF([test "x$ax_cv___attribute__" != "xyes"], | |
84 | [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])]) | |
85 | ||
86 | # Make sure we have pthread support | |
87 | AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])]) | |
88 | ||
8b2f0590 MJ |
89 | # Checks for typedefs, structures, and compiler characteristics. |
90 | AC_C_INLINE | |
91 | AC_C_TYPEOF | |
92 | AC_TYPE_INT32_T | |
93 | AC_TYPE_PID_T | |
94 | AC_TYPE_SIZE_T | |
95 | AC_TYPE_SSIZE_T | |
96 | AC_TYPE_UINT16_T | |
97 | AC_TYPE_UINT32_T | |
98 | AC_TYPE_UINT64_T | |
99 | AC_TYPE_UINT8_T | |
100 | ||
ee334e48 MJ |
101 | # Detect warning flags supported by the C compiler and append them to |
102 | # WARN_CFLAGS. | |
103 | m4_define([WARN_FLAGS_LIST], [ dnl | |
104 | -Wall dnl | |
105 | -Wextra dnl | |
106 | -Wmissing-prototypes dnl | |
107 | -Wmissing-declarations dnl | |
108 | -Wnull-dereference dnl | |
109 | -Wundef dnl | |
110 | -Wshadow dnl | |
111 | -Wjump-misses-init dnl | |
112 | -Wsuggest-attribute=format dnl | |
113 | -Wtautological-constant-out-of-range-compare dnl | |
114 | -Wnested-externs dnl | |
115 | -Wwrite-strings dnl | |
116 | -Wformat=2 dnl | |
117 | -Wstrict-aliasing dnl | |
118 | -Wmissing-noreturn dnl | |
119 | -Winit-self dnl | |
120 | -Wduplicated-cond dnl | |
121 | -Wduplicated-branches dnl | |
122 | -Wlogical-op dnl | |
123 | dnl | |
124 | dnl-Wredundant-decls dnl | |
125 | -Wno-null-dereference dnl | |
126 | ]) | |
127 | ||
128 | # Pass -Werror as an extra flag during the test: this is needed to make the | |
129 | # -Wunknown-warning-option diagnostic fatal with clang. | |
130 | AC_LANG_PUSH([C]) | |
131 | AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CFLAGS], [-Werror]) | |
132 | AC_LANG_POP([C]) | |
133 | ||
153b081a SM |
134 | AC_LANG_PUSH([C++]) |
135 | AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CXXFLAGS], [-Werror]) | |
136 | AC_LANG_POP([C++]) | |
137 | ||
35701ce9 | 138 | AE_IF_FEATURE_ENABLED([Werror], [WARN_CFLAGS="${WARN_CFLAGS} -Werror"]) |
153b081a | 139 | AE_IF_FEATURE_ENABLED([Werror], [WARN_CXXFLAGS="${WARN_CXXFLAGS} -Werror"]) |
35701ce9 | 140 | |
8b2f0590 | 141 | |
6b5533b0 MJ |
142 | ## ## |
143 | ## Header checks ## | |
144 | ## ## | |
145 | ||
146 | AC_HEADER_STDBOOL | |
147 | AC_CHECK_HEADERS([ \ | |
148 | limits.h \ | |
149 | stddef.h \ | |
150 | sys/param.h \ | |
151 | sys/time.h \ | |
152 | ]) | |
153 | ||
154 | ||
155 | ## ## | |
156 | ## Programs checks ## | |
157 | ## ## | |
158 | ||
159 | AC_PROG_AWK | |
160 | AC_PROG_GREP | |
161 | AC_PROG_MAKE_SET | |
162 | AC_CHECK_PROGS(NPROC, [nproc gnproc]) | |
f0124a5a | 163 | AC_CHECK_PROGS(GETCONF, [getconf]) |
de6cb9d5 | 164 | AC_CHECK_PROGS(TIME, [time]) |
6b5533b0 MJ |
165 | |
166 | # Initialize and configure libtool | |
167 | LT_INIT | |
168 | ||
169 | ||
c673679b MJ |
170 | ## ## |
171 | ## Library checks ## | |
172 | ## ## | |
173 | ||
174 | # Checks for library functions. | |
175 | AC_FUNC_MMAP | |
176 | AC_FUNC_FORK | |
177 | AC_CHECK_FUNCS([ \ | |
178 | atexit \ | |
179 | getcpuid \ | |
180 | gettid \ | |
181 | gettimeofday \ | |
182 | memeset \ | |
183 | memset \ | |
184 | munmap \ | |
185 | rand_r \ | |
186 | sched_getcpu \ | |
0614a2e6 | 187 | sched_setaffinity \ |
c673679b MJ |
188 | strerror \ |
189 | strtoul \ | |
190 | sysconf \ | |
191 | ]) | |
192 | ||
193 | # AC_FUNC_MALLOC causes problems when cross-compiling. | |
194 | #AC_FUNC_MALLOC | |
195 | ||
196 | # Search for clock_gettime() in -lrt | |
197 | AC_SEARCH_LIBS([clock_gettime], [rt], [ | |
198 | AC_DEFINE([CONFIG_RCU_HAVE_CLOCK_GETTIME], [1], [clock_gettime() is detected.]) | |
199 | ]) | |
200 | ||
201 | ||
f99c6e92 MJ |
202 | ## ## |
203 | ## Optional features selection ## | |
204 | ## ## | |
86bc2ad8 MJ |
205 | |
206 | # Allow to fallback to FIXME if the membarrier syscall is unavailable on the | |
207 | # running kernel, when disabled, abort if the syscall is unavailable. Applies | |
208 | # to default and bulletproof flavors. | |
209 | # Enabled by default | |
210 | AE_FEATURE_DEFAULT_ENABLE | |
211 | AE_FEATURE([sys-membarrier-fallback], [Abort if sys-membarrier is needed but not available rather than using a fallback.]) | |
212 | ||
213 | # Use compiler Thread Local Storage, when disabled use pthread_getspecific() to emulate TLS. | |
214 | # Enabled by default | |
215 | AE_FEATURE_DEFAULT_ENABLE | |
216 | AE_FEATURE([compiler-tls], [Use pthread_getspecific() to emulate Thread Local Storage (TLS) variables.]) | |
c673679b | 217 | |
86bc2ad8 MJ |
218 | # smp-support configure option |
219 | # Enabled by default | |
220 | AE_FEATURE_DEFAULT_ENABLE | |
221 | AE_FEATURE([smp-support], [Disable SMP support. Warning: only use this on uniprocessor systems.]) | |
d8d9a340 | 222 | |
86bc2ad8 MJ |
223 | # RCU debugging option |
224 | # Disabled by default | |
225 | AE_FEATURE_DEFAULT_DISABLE | |
226 | AE_FEATURE([rcu-debug], [Enable internal debugging self-checks. Introduces a performance penalty.]) | |
a767fdc3 | 227 | |
86bc2ad8 MJ |
228 | # rculfhash iterator debugging |
229 | # Disabled by default | |
230 | AE_FEATURE_DEFAULT_DISABLE | |
231 | AE_FEATURE([cds-lfht-iter-debug], [Enable extra debugging checks for lock-free hash table iterator traversal. Alters the rculfhash ABI. Make sure to compile both library and application with matching configuration.]) | |
75478b32 | 232 | |
35701ce9 SM |
233 | # When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS. |
234 | # Disabled by default | |
235 | AE_FEATURE_DEFAULT_DISABLE | |
236 | AE_FEATURE([Werror],[Treat compiler warnings as errors.]) | |
48d848c7 | 237 | |
86bc2ad8 MJ |
238 | ## ## |
239 | ## Set defines for optional features conditionnals in the source code ## | |
240 | ## ## | |
48d848c7 | 241 | |
86bc2ad8 MJ |
242 | AE_IF_FEATURE_DISABLED([sys-membarrier-fallback], [ |
243 | AC_DEFINE([CONFIG_RCU_FORCE_SYS_MEMBARRIER], [1], [Require the operating system to support the membarrier system call for default and bulletproof flavors.]) | |
244 | ]) | |
cdadd34c | 245 | |
86bc2ad8 MJ |
246 | AE_IF_FEATURE_ENABLED([compiler-tls], [ |
247 | AC_DEFINE([CONFIG_RCU_TLS], [1], [Use compiler provided Thread Local Storage.]) | |
248 | ]) | |
0854ccff | 249 | |
86bc2ad8 MJ |
250 | AE_IF_FEATURE_ENABLED([smp-support], [ |
251 | AC_DEFINE([CONFIG_RCU_SMP], [1], [Enable SMP support. With SMP support enabled, uniprocessors are also supported. With SMP support disabled, UP systems work fine, but the behavior of SMP systems is undefined.]) | |
252 | ]) | |
7d413817 | 253 | |
86bc2ad8 MJ |
254 | AE_IF_FEATURE_ENABLED([rcu-debug], [ |
255 | AC_DEFINE([CONFIG_RCU_DEBUG], [1], [Enable internal debugging self-checks. Introduces a performance penalty.]) | |
d4e640c0 | 256 | ]) |
48d848c7 | 257 | |
86bc2ad8 MJ |
258 | AE_IF_FEATURE_ENABLED([cds-lfht-iter-debug], [ |
259 | AC_DEFINE([CONFIG_CDS_LFHT_ITER_DEBUG], [1], [Enable extra debugging checks for lock-free hash table iterator traversal. Alters the rculfhash ABI. Make sure to compile both library and application with matching configuration.]) | |
d7c76f85 MD |
260 | ]) |
261 | ||
86bc2ad8 | 262 | |
1136f454 MJ |
263 | ## ## |
264 | ## Set automake variables for optional feature conditionnals in Makefile.am ## | |
265 | ## ## | |
266 | ||
267 | # Building the examples requires the shared libraries to be enabled | |
268 | AM_CONDITIONAL([ENABLE_EXAMPLES], AE_IS_FEATURE_ENABLED([shared])) | |
269 | ||
270 | ||
23975ca7 MJ |
271 | ## ## |
272 | ## Substitute variables for use in Makefile.am ## | |
273 | ## ## | |
274 | ||
275 | # Library versions for libtool | |
276 | AC_SUBST([URCU_LIBRARY_VERSION], [urcu_lib_version]) | |
277 | ||
514079bb MJ |
278 | AC_SUBST(LT_NO_UNDEFINED) |
279 | ||
01956342 MJ |
280 | # The order in which the include folders are searched is important. |
281 | # The top_builddir should always be searched first in the event that a build | |
282 | # time generated file is included. | |
283 | AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h" | |
9a79c612 MJ |
284 | AC_SUBST(AM_CPPFLAGS) |
285 | ||
ee334e48 | 286 | AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS" |
9a79c612 | 287 | AC_SUBST(AM_CFLAGS) |
d8540fc5 | 288 | |
153b081a SM |
289 | AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS" |
290 | AC_SUBST(AM_CXXFLAGS) | |
291 | ||
0614a2e6 MJ |
292 | |
293 | ## ## | |
294 | ## Output files generated by configure ## | |
295 | ## ## | |
296 | ||
48d848c7 PMF |
297 | AC_CONFIG_FILES([ |
298 | Makefile | |
fe999c05 | 299 | doc/Makefile |
8bad63a0 | 300 | doc/examples/Makefile |
c0ecb6ea | 301 | extras/Makefile |
6893800a MJ |
302 | include/Makefile |
303 | src/Makefile | |
48d848c7 | 304 | tests/Makefile |
f5ab766e MD |
305 | tests/common/Makefile |
306 | tests/unit/Makefile | |
307 | tests/benchmark/Makefile | |
308 | tests/regression/Makefile | |
1b387491 | 309 | tests/utils/Makefile |
6893800a MJ |
310 | src/liburcu.pc |
311 | src/liburcu-bp.pc | |
312 | src/liburcu-cds.pc | |
313 | src/liburcu-qsbr.pc | |
314 | src/liburcu-mb.pc | |
799d344f | 315 | src/liburcu-memb.pc |
6893800a | 316 | src/liburcu-signal.pc |
48d848c7 | 317 | ]) |
03c5782e | 318 | |
de6cb9d5 | 319 | AC_CONFIG_FILES([tests/utils/env.sh],[chmod +x tests/utils/env.sh]) |
03c5782e MJ |
320 | |
321 | ||
48d848c7 | 322 | AC_OUTPUT |
a6412536 | 323 | |
628a1a72 MJ |
324 | # |
325 | # Mini-report on what will be built. | |
326 | # | |
327 | ||
328 | PPRINT_INIT | |
329 | PPRINT_SET_INDENT(1) | |
330 | PPRINT_SET_TS(38) | |
331 | ||
332 | AS_ECHO | |
333 | AS_ECHO("${PPRINT_COLOR_BLDBLU}Userspace-RCU $PACKAGE_VERSION${PPRINT_COLOR_RST}") | |
334 | AS_ECHO | |
335 | ||
336 | PPRINT_SUBTITLE([Features]) | |
337 | ||
338 | PPRINT_PROP_STRING([Target architecture], $host_cpu) | |
339 | ||
340 | # SMP support enabled/disabled | |
86bc2ad8 | 341 | AE_IS_FEATURE_ENABLED([smp-support]) && value=1 || value=0 |
628a1a72 MJ |
342 | PPRINT_PROP_BOOL([SMP support], $value) |
343 | ||
628a1a72 | 344 | # TLS |
86bc2ad8 | 345 | AE_IS_FEATURE_ENABLED([compiler-tls]) && value="compiler TLS" || value="pthread_getspecific()" |
628a1a72 MJ |
346 | PPRINT_PROP_STRING([Thread Local Storage (TLS)], [$value]) |
347 | ||
348 | # clock_gettime() available | |
c673679b | 349 | test "x$ac_cv_search_function_clock_gettime" != "xno" && value=1 || value=0 |
628a1a72 MJ |
350 | PPRINT_PROP_BOOL([clock_gettime()], $value) |
351 | ||
352 | # Require membarrier | |
86bc2ad8 | 353 | AE_IS_FEATURE_ENABLED([sys-membarrier-fallback]) && value=0 || value=1 |
628a1a72 MJ |
354 | PPRINT_PROP_BOOL([Require membarrier], $value) |
355 | ||
356 | # RCU debug enabled/disabled | |
86bc2ad8 | 357 | AE_IS_FEATURE_ENABLED([rcu-debug]) && value=1 || value=0 |
628a1a72 MJ |
358 | PPRINT_PROP_BOOL([Internal debugging], $value) |
359 | ||
d7c76f85 | 360 | # rculfhash iterator debug enabled/disabled |
86bc2ad8 MJ |
361 | AE_IS_FEATURE_ENABLED([cds-lfht-iter-debug]) && value=1 || value=0 |
362 | PPRINT_PROP_BOOL([Lock-free HT iterator debugging], $value) | |
d7c76f85 | 363 | |
4477a870 MD |
364 | PPRINT_PROP_BOOL([Multi-flavor support], 1) |
365 | ||
628a1a72 MJ |
366 | report_bindir="`eval eval echo $bindir`" |
367 | report_libdir="`eval eval echo $libdir`" | |
368 | ||
86bc2ad8 | 369 | # Print the bindir and libdir this 'make install' will install into. |
628a1a72 MJ |
370 | AS_ECHO |
371 | PPRINT_SUBTITLE([Install directories]) | |
372 | PPRINT_PROP_STRING([Binaries], [$report_bindir]) | |
373 | PPRINT_PROP_STRING([Libraries], [$report_libdir]) | |
75478b32 | 374 |