1 dnl SPDX-License-Identifier: LGPL-2.1-only
3 dnl Copyright (C) 2021 EfficiOS, Inc.
5 dnl Process this file with autoconf to produce a configure script.
7 # Project version information
8 m4_define([urcu_version_major], [0])
9 m4_define([urcu_version_minor], [15])
10 m4_define([urcu_version_patch], [0])
11 m4_define([urcu_version_dev_stage], [-pre])
12 m4_define([urcu_version], urcu_version_major[.]urcu_version_minor[.]urcu_version_patch[]urcu_version_dev_stage)
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
17 m4_define([urcu_lib_version_current], [9])
18 m4_define([urcu_lib_version_revision], [0])
19 m4_define([urcu_lib_version_age], [1])
20 m4_define([urcu_lib_version], urcu_lib_version_current[:]urcu_lib_version_revision[:]urcu_lib_version_age)
24 ## Autoconf base setup ##
28 AC_INIT([userspace-rcu],[urcu_version],[mathieu dot desnoyers at efficios dot com],[],[http://liburcu.org/])
30 AC_CONFIG_HEADERS([include/config.h include/urcu/config.h])
31 AC_CONFIG_AUX_DIR([config])
32 AC_CONFIG_MACRO_DIR([m4])
39 ## Automake base setup ##
42 AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip nostdinc -Wall -Wno-portability -Werror])
43 AM_MAINTAINER_MODE([enable])
45 # Enable silent rules by default
46 AM_SILENT_RULES([yes])
50 ## OS and Arch specific defaults ##
54 [*-cygwin* | *-msys*], [LT_NO_UNDEFINED="-no-undefined"]
59 ## C compiler checks ##
62 # Choose the C compiler
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])
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])])
70 # Enable available system extensions and LFS support
71 AC_USE_SYSTEM_EXTENSIONS
74 # Check if the selected C compiler supports atomic builtins
79 ## C++ compiler checks ##
82 # Require a C++11 compiler without GNU extensions (-std=c++11)
83 AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
85 # Make sure the C compiler supports __attribute__
87 AS_IF([test "x$ax_cv___attribute__" != "xyes"],
88 [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])])
90 # Make sure we have pthread support
91 AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])])
93 # Checks for typedefs, structures, and compiler characteristics.
105 # Detect warning flags supported by the C compiler and append them to
107 m4_define([WARN_FLAGS_LIST], [ dnl
110 -Wmissing-prototypes dnl
111 -Wmissing-declarations dnl
112 -Wnull-dereference dnl
115 -Wjump-misses-init dnl
116 -Wsuggest-attribute=format dnl
117 -Wtautological-constant-out-of-range-compare dnl
121 -Wstrict-aliasing dnl
122 -Wmissing-noreturn dnl
124 -Wduplicated-cond dnl
125 -Wduplicated-branches dnl
128 dnl-Wredundant-decls dnl
129 -Wno-null-dereference dnl
132 # Pass -Werror as an extra flag during the test: this is needed to make the
133 # -Wunknown-warning-option diagnostic fatal with clang.
135 AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CFLAGS], [-Werror])
139 AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CXXFLAGS], [-Werror])
142 AE_IF_FEATURE_ENABLED([Werror], [WARN_CFLAGS="${WARN_CFLAGS} -Werror"])
143 AE_IF_FEATURE_ENABLED([Werror], [WARN_CXXFLAGS="${WARN_CXXFLAGS} -Werror"])
160 ## Programs checks ##
166 AC_CHECK_PROGS(NPROC, [nproc gnproc])
167 AC_CHECK_PROGS(GETCONF, [getconf])
168 AC_CHECK_PROGS(TIME, [time])
170 # Initialize and configure libtool
178 # Checks for library functions.
197 # AC_FUNC_MALLOC causes problems when cross-compiling.
200 # Search for clock_gettime() in -lrt
201 AC_SEARCH_LIBS([clock_gettime], [rt], [
202 AC_DEFINE([CONFIG_RCU_HAVE_CLOCK_GETTIME], [1], [clock_gettime() is detected.])
207 ## Optional features selection ##
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.
214 AE_FEATURE_DEFAULT_ENABLE
215 AE_FEATURE([sys-membarrier-fallback], [Abort if sys-membarrier is needed but not available rather than using a fallback.])
217 # Use compiler Thread Local Storage, when disabled use pthread_getspecific() to emulate TLS.
219 AE_FEATURE_DEFAULT_ENABLE
220 AE_FEATURE([compiler-tls], [Use pthread_getspecific() to emulate Thread Local Storage (TLS) variables.])
222 # smp-support configure option
224 AE_FEATURE_DEFAULT_ENABLE
225 AE_FEATURE([smp-support], [Disable SMP support. Warning: only use this on uniprocessor systems.])
227 # RCU debugging option
228 # Disabled by default
229 AE_FEATURE_DEFAULT_DISABLE
230 AE_FEATURE([rcu-debug], [Enable internal debugging self-checks. Introduces a performance penalty.])
232 # rculfhash iterator debugging
233 # Disabled by default
234 AE_FEATURE_DEFAULT_DISABLE
235 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.])
237 # Use compiler atomic builtins, when disabled use our legacy uatomic implementation.
238 # Disabled by default
239 AE_FEATURE_DEFAULT_DISABLE
240 AE_FEATURE([compiler-atomic-builtins], [Enable the use of compiler atomic builtins.])
242 # When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS.
243 # Disabled by default
244 AE_FEATURE_DEFAULT_DISABLE
245 AE_FEATURE([Werror],[Treat compiler warnings as errors.])
248 ## Set defines for optional features conditionnals in the source code ##
251 AE_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.])
255 AE_IF_FEATURE_ENABLED([compiler-tls], [
256 AC_DEFINE([CONFIG_RCU_TLS], [1], [Use compiler provided Thread Local Storage.])
259 AE_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.])
263 AE_IF_FEATURE_ENABLED([rcu-debug], [
264 AC_DEFINE([CONFIG_RCU_DEBUG], [1], [Enable internal debugging self-checks. Introduces a performance penalty.])
267 AE_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.])
271 AE_IF_FEATURE_ENABLED([compiler-atomic-builtins], [
272 AC_DEFINE([CONFIG_RCU_USE_ATOMIC_BUILTINS], [1], [Use compiler atomic builtins.])
276 ## Set automake variables for optional feature conditionnals in Makefile.am ##
279 # Building the examples requires the shared libraries to be enabled
280 AM_CONDITIONAL([ENABLE_EXAMPLES], AE_IS_FEATURE_ENABLED([shared]))
284 ## Check for optional features dependencies ##
288 AE_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.])
295 ## Substitute variables for use in Makefile.am ##
298 # Library versions for libtool
299 AC_SUBST([URCU_LIBRARY_VERSION], [urcu_lib_version])
301 AC_SUBST(LT_NO_UNDEFINED)
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.
306 AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h"
307 AC_SUBST(AM_CPPFLAGS)
309 AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS"
312 AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS"
313 AC_SUBST(AM_CXXFLAGS)
317 ## Output files generated by configure ##
323 doc/examples/Makefile
328 tests/common/Makefile
330 tests/benchmark/Makefile
331 tests/regression/Makefile
339 src/liburcu-signal.pc
342 AC_CONFIG_FILES([tests/utils/env.sh],[chmod +x tests/utils/env.sh])
348 # Mini-report on what will be built.
352 AE_PPRINT_SET_INDENT(1)
356 AS_ECHO("${AE_PPRINT_COLOR_BLDBLU}Userspace-RCU $PACKAGE_VERSION${AE_PPRINT_COLOR_RST}")
359 AE_PPRINT_SUBTITLE([Features])
361 AE_PPRINT_PROP_STRING([Target architecture], $host_cpu)
363 # SMP support enabled/disabled
364 AE_IS_FEATURE_ENABLED([smp-support]) && value=1 || value=0
365 AE_PPRINT_PROP_BOOL([SMP support], $value)
368 AE_IS_FEATURE_ENABLED([compiler-tls]) && value="compiler TLS" || value="pthread_getspecific()"
369 AE_PPRINT_PROP_STRING([Thread Local Storage (TLS)], [$value])
371 # clock_gettime() available
372 test "x$ac_cv_search_function_clock_gettime" != "xno" && value=1 || value=0
373 AE_PPRINT_PROP_BOOL([clock_gettime()], $value)
376 AE_IS_FEATURE_ENABLED([sys-membarrier-fallback]) && value=0 || value=1
377 AE_PPRINT_PROP_BOOL([Require membarrier], $value)
379 # RCU debug enabled/disabled
380 AE_IS_FEATURE_ENABLED([rcu-debug]) && value=1 || value=0
381 AE_PPRINT_PROP_BOOL([Internal debugging], $value)
383 # rculfhash iterator debug enabled/disabled
384 AE_IS_FEATURE_ENABLED([cds-lfht-iter-debug]) && value=1 || value=0
385 AE_PPRINT_PROP_BOOL([Lock-free HT iterator debugging], $value)
387 AE_PPRINT_PROP_BOOL([Multi-flavor support], 1)
389 # atomic builtins enabled/disabled
390 AE_IS_FEATURE_ENABLED([compiler-atomic-builtins]) && value=1 || value=0
391 AE_PPRINT_PROP_BOOL([Use compiler atomic builtins], $value)
393 report_bindir="`eval eval echo $bindir`"
394 report_libdir="`eval eval echo $libdir`"
396 # Print the bindir and libdir this 'make install' will install into.
398 AE_PPRINT_SUBTITLE([Install directories])
399 AE_PPRINT_PROP_STRING([Binaries], [$report_bindir])
400 AE_PPRINT_PROP_STRING([Libraries], [$report_libdir])