uatomic/x86: Remove redundant memory barriers
[urcu.git] / configure.ac
... / ...
CommitLineData
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])
9m4_define([urcu_version_minor], [15])
10m4_define([urcu_version_patch], [0])
11m4_define([urcu_version_dev_stage], [-pre])
12m4_define([urcu_version], urcu_version_major[.]urcu_version_minor[.]urcu_version_patch[]urcu_version_dev_stage)
13
14# Library version information of "liburcu"
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
17m4_define([urcu_lib_version_current], [9])
18m4_define([urcu_lib_version_revision], [0])
19m4_define([urcu_lib_version_age], [1])
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
27AC_PREREQ([2.69])
28AC_INIT([userspace-rcu],[urcu_version],[mathieu dot desnoyers at efficios dot com],[],[http://liburcu.org/])
29
30AC_CONFIG_HEADERS([include/config.h include/urcu/config.h])
31AC_CONFIG_AUX_DIR([config])
32AC_CONFIG_MACRO_DIR([m4])
33
34AC_CANONICAL_TARGET
35AC_CANONICAL_HOST
36
37
38## ##
39## Automake base setup ##
40## ##
41
42AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip nostdinc -Wall -Wno-portability -Werror])
43AM_MAINTAINER_MODE([enable])
44
45# Enable silent rules by default
46AM_SILENT_RULES([yes])
47
48
49## ##
50## OS and Arch specific defaults ##
51## ##
52
53AS_CASE([$host],
54 [*-cygwin* | *-msys*], [LT_NO_UNDEFINED="-no-undefined"]
55)
56
57
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
74# Check if the selected C compiler supports atomic builtins
75AE_CC_ATOMIC_BUILTINS
76
77
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
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
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
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
138AC_LANG_PUSH([C++])
139AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CXXFLAGS], [-Werror])
140AC_LANG_POP([C++])
141
142AE_IF_FEATURE_ENABLED([Werror], [WARN_CFLAGS="${WARN_CFLAGS} -Werror"])
143AE_IF_FEATURE_ENABLED([Werror], [WARN_CXXFLAGS="${WARN_CXXFLAGS} -Werror"])
144
145
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])
167AC_CHECK_PROGS(GETCONF, [getconf])
168AC_CHECK_PROGS(TIME, [time])
169
170# Initialize and configure libtool
171LT_INIT
172
173
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 \
191 sched_setaffinity \
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
206## ##
207## Optional features selection ##
208## ##
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.])
221
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.])
226
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.])
231
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.])
236
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
242# emit legacy memory barriers
243# Enable by default
244AE_FEATURE_DEFAULT_ENABLE
245AE_FEATURE([legacy-mb], [Disable legacy memory barriers.])
246
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.])
251
252## ##
253## Set defines for optional features conditionnals in the source code ##
254## ##
255
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])
259
260AE_IF_FEATURE_ENABLED([compiler-tls], [
261 AC_DEFINE([CONFIG_RCU_TLS], [1], [Use compiler provided Thread Local Storage.])
262])
263
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])
267
268AE_IF_FEATURE_ENABLED([rcu-debug], [
269 AC_DEFINE([CONFIG_RCU_DEBUG], [1], [Enable internal debugging self-checks. Introduces a performance penalty.])
270])
271
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.])
274])
275
276AE_IF_FEATURE_ENABLED([compiler-atomic-builtins], [
277 AC_DEFINE([CONFIG_RCU_USE_ATOMIC_BUILTINS], [1], [Use compiler atomic builtins.])
278])
279
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
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
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
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
310AC_SUBST(LT_NO_UNDEFINED)
311
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"
316AC_SUBST(AM_CPPFLAGS)
317
318AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS"
319AC_SUBST(AM_CFLAGS)
320
321AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS"
322AC_SUBST(AM_CXXFLAGS)
323
324
325## ##
326## Output files generated by configure ##
327## ##
328
329AC_CONFIG_FILES([
330 Makefile
331 doc/Makefile
332 doc/examples/Makefile
333 extras/Makefile
334 include/Makefile
335 src/Makefile
336 tests/Makefile
337 tests/common/Makefile
338 tests/unit/Makefile
339 tests/benchmark/Makefile
340 tests/regression/Makefile
341 tests/utils/Makefile
342 src/liburcu.pc
343 src/liburcu-bp.pc
344 src/liburcu-cds.pc
345 src/liburcu-qsbr.pc
346 src/liburcu-mb.pc
347 src/liburcu-memb.pc
348])
349
350AC_CONFIG_FILES([tests/utils/env.sh],[chmod +x tests/utils/env.sh])
351
352
353AC_OUTPUT
354
355#
356# Mini-report on what will be built.
357#
358
359AE_PPRINT_INIT
360AE_PPRINT_SET_INDENT(1)
361AE_PPRINT_SET_TS(38)
362
363AS_ECHO
364AS_ECHO("${AE_PPRINT_COLOR_BLDBLU}Userspace-RCU $PACKAGE_VERSION${AE_PPRINT_COLOR_RST}")
365AS_ECHO
366
367AE_PPRINT_SUBTITLE([Features])
368
369AE_PPRINT_PROP_STRING([Target architecture], $host_cpu)
370
371# SMP support enabled/disabled
372AE_IS_FEATURE_ENABLED([smp-support]) && value=1 || value=0
373AE_PPRINT_PROP_BOOL([SMP support], $value)
374
375# TLS
376AE_IS_FEATURE_ENABLED([compiler-tls]) && value="compiler TLS" || value="pthread_getspecific()"
377AE_PPRINT_PROP_STRING([Thread Local Storage (TLS)], [$value])
378
379# clock_gettime() available
380test "x$ac_cv_search_function_clock_gettime" != "xno" && value=1 || value=0
381AE_PPRINT_PROP_BOOL([clock_gettime()], $value)
382
383# Require membarrier
384AE_IS_FEATURE_ENABLED([sys-membarrier-fallback]) && value=0 || value=1
385AE_PPRINT_PROP_BOOL([Require membarrier], $value)
386
387# RCU debug enabled/disabled
388AE_IS_FEATURE_ENABLED([rcu-debug]) && value=1 || value=0
389AE_PPRINT_PROP_BOOL([Internal debugging], $value)
390
391# rculfhash iterator debug enabled/disabled
392AE_IS_FEATURE_ENABLED([cds-lfht-iter-debug]) && value=1 || value=0
393AE_PPRINT_PROP_BOOL([Lock-free HT iterator debugging], $value)
394
395AE_PPRINT_PROP_BOOL([Multi-flavor support], 1)
396
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
401# legacy memory barriers
402AE_IS_FEATURE_ENABLED([legacy-mb]) && value=1 || value=0
403AE_PPRINT_PROP_BOOL([Emit legacy memory barriers], $value)
404
405report_bindir="`eval eval echo $bindir`"
406report_libdir="`eval eval echo $libdir`"
407
408# Print the bindir and libdir this 'make install' will install into.
409AS_ECHO
410AE_PPRINT_SUBTITLE([Install directories])
411AE_PPRINT_PROP_STRING([Binaries], [$report_bindir])
412AE_PPRINT_PROP_STRING([Libraries], [$report_libdir])
413
This page took 0.024261 seconds and 5 git commands to generate.