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