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