benchmark: Use uatomic for accessing global states
[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
35701ce9
SM
242# When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS.
243# Disabled by default
244AE_FEATURE_DEFAULT_DISABLE
245AE_FEATURE([Werror],[Treat compiler warnings as errors.])
48d848c7 246
86bc2ad8
MJ
247## ##
248## Set defines for optional features conditionnals in the source code ##
249## ##
48d848c7 250
86bc2ad8
MJ
251AE_IF_FEATURE_DISABLED([sys-membarrier-fallback], [
252 AC_DEFINE([CONFIG_RCU_FORCE_SYS_MEMBARRIER], [1], [Require the operating system to support the membarrier system call for default and bulletproof flavors.])
253])
cdadd34c 254
86bc2ad8
MJ
255AE_IF_FEATURE_ENABLED([compiler-tls], [
256 AC_DEFINE([CONFIG_RCU_TLS], [1], [Use compiler provided Thread Local Storage.])
257])
0854ccff 258
86bc2ad8
MJ
259AE_IF_FEATURE_ENABLED([smp-support], [
260 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.])
261])
7d413817 262
86bc2ad8
MJ
263AE_IF_FEATURE_ENABLED([rcu-debug], [
264 AC_DEFINE([CONFIG_RCU_DEBUG], [1], [Enable internal debugging self-checks. Introduces a performance penalty.])
d4e640c0 265])
48d848c7 266
86bc2ad8
MJ
267AE_IF_FEATURE_ENABLED([cds-lfht-iter-debug], [
268 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
269])
270
3afcf5a0
OD
271AE_IF_FEATURE_ENABLED([compiler-atomic-builtins], [
272 AC_DEFINE([CONFIG_RCU_USE_ATOMIC_BUILTINS], [1], [Use compiler atomic builtins.])
273])
86bc2ad8 274
1136f454
MJ
275## ##
276## Set automake variables for optional feature conditionnals in Makefile.am ##
277## ##
278
279# Building the examples requires the shared libraries to be enabled
280AM_CONDITIONAL([ENABLE_EXAMPLES], AE_IS_FEATURE_ENABLED([shared]))
281
282
3afcf5a0
OD
283## ##
284## Check for optional features dependencies ##
285## ##
286
287
288AE_IF_FEATURE_ENABLED([compiler-atomic-builtins], [
289 AS_IF([test "x$ae_cv_cc_atomic_builtins" != xyes], [
290 AC_MSG_ERROR([The compiler does not support atomic builtins.])
291 ])
292])
293
23975ca7
MJ
294## ##
295## Substitute variables for use in Makefile.am ##
296## ##
297
298# Library versions for libtool
299AC_SUBST([URCU_LIBRARY_VERSION], [urcu_lib_version])
300
514079bb
MJ
301AC_SUBST(LT_NO_UNDEFINED)
302
01956342
MJ
303# The order in which the include folders are searched is important.
304# The top_builddir should always be searched first in the event that a build
305# time generated file is included.
306AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h"
9a79c612
MJ
307AC_SUBST(AM_CPPFLAGS)
308
ee334e48 309AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS"
9a79c612 310AC_SUBST(AM_CFLAGS)
d8540fc5 311
153b081a
SM
312AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS"
313AC_SUBST(AM_CXXFLAGS)
314
0614a2e6
MJ
315
316## ##
317## Output files generated by configure ##
318## ##
319
48d848c7
PMF
320AC_CONFIG_FILES([
321 Makefile
fe999c05 322 doc/Makefile
8bad63a0 323 doc/examples/Makefile
c0ecb6ea 324 extras/Makefile
6893800a
MJ
325 include/Makefile
326 src/Makefile
48d848c7 327 tests/Makefile
f5ab766e
MD
328 tests/common/Makefile
329 tests/unit/Makefile
330 tests/benchmark/Makefile
331 tests/regression/Makefile
1b387491 332 tests/utils/Makefile
6893800a
MJ
333 src/liburcu.pc
334 src/liburcu-bp.pc
335 src/liburcu-cds.pc
336 src/liburcu-qsbr.pc
337 src/liburcu-mb.pc
799d344f 338 src/liburcu-memb.pc
6893800a 339 src/liburcu-signal.pc
48d848c7 340])
03c5782e 341
de6cb9d5 342AC_CONFIG_FILES([tests/utils/env.sh],[chmod +x tests/utils/env.sh])
03c5782e
MJ
343
344
48d848c7 345AC_OUTPUT
a6412536 346
628a1a72
MJ
347#
348# Mini-report on what will be built.
349#
350
d001c886
MJ
351AE_PPRINT_INIT
352AE_PPRINT_SET_INDENT(1)
353AE_PPRINT_SET_TS(38)
628a1a72
MJ
354
355AS_ECHO
d001c886 356AS_ECHO("${AE_PPRINT_COLOR_BLDBLU}Userspace-RCU $PACKAGE_VERSION${AE_PPRINT_COLOR_RST}")
628a1a72
MJ
357AS_ECHO
358
d001c886 359AE_PPRINT_SUBTITLE([Features])
628a1a72 360
d001c886 361AE_PPRINT_PROP_STRING([Target architecture], $host_cpu)
628a1a72
MJ
362
363# SMP support enabled/disabled
86bc2ad8 364AE_IS_FEATURE_ENABLED([smp-support]) && value=1 || value=0
d001c886 365AE_PPRINT_PROP_BOOL([SMP support], $value)
628a1a72 366
628a1a72 367# TLS
86bc2ad8 368AE_IS_FEATURE_ENABLED([compiler-tls]) && value="compiler TLS" || value="pthread_getspecific()"
d001c886 369AE_PPRINT_PROP_STRING([Thread Local Storage (TLS)], [$value])
628a1a72
MJ
370
371# clock_gettime() available
c673679b 372test "x$ac_cv_search_function_clock_gettime" != "xno" && value=1 || value=0
d001c886 373AE_PPRINT_PROP_BOOL([clock_gettime()], $value)
628a1a72
MJ
374
375# Require membarrier
86bc2ad8 376AE_IS_FEATURE_ENABLED([sys-membarrier-fallback]) && value=0 || value=1
d001c886 377AE_PPRINT_PROP_BOOL([Require membarrier], $value)
628a1a72
MJ
378
379# RCU debug enabled/disabled
86bc2ad8 380AE_IS_FEATURE_ENABLED([rcu-debug]) && value=1 || value=0
d001c886 381AE_PPRINT_PROP_BOOL([Internal debugging], $value)
628a1a72 382
d7c76f85 383# rculfhash iterator debug enabled/disabled
86bc2ad8 384AE_IS_FEATURE_ENABLED([cds-lfht-iter-debug]) && value=1 || value=0
d001c886 385AE_PPRINT_PROP_BOOL([Lock-free HT iterator debugging], $value)
d7c76f85 386
d001c886 387AE_PPRINT_PROP_BOOL([Multi-flavor support], 1)
4477a870 388
3afcf5a0
OD
389# atomic builtins enabled/disabled
390AE_IS_FEATURE_ENABLED([compiler-atomic-builtins]) && value=1 || value=0
391AE_PPRINT_PROP_BOOL([Use compiler atomic builtins], $value)
392
628a1a72
MJ
393report_bindir="`eval eval echo $bindir`"
394report_libdir="`eval eval echo $libdir`"
395
86bc2ad8 396# Print the bindir and libdir this 'make install' will install into.
628a1a72 397AS_ECHO
d001c886
MJ
398AE_PPRINT_SUBTITLE([Install directories])
399AE_PPRINT_PROP_STRING([Binaries], [$report_bindir])
400AE_PPRINT_PROP_STRING([Libraries], [$report_libdir])
75478b32 401
This page took 0.06757 seconds and 4 git commands to generate.