-AC_CHECK_FUNCS([bzero gettimeofday munmap strtoul])
-
-# Find arch type
-case $target_cpu in
- i386) ARCHTYPE="x86"; SUBARCHTYPE="x86compat" ;;
- i486) ARCHTYPE="x86"; SUBARCHTYPE="x86compat" ;;
- i586) ARCHTYPE="x86"; SUBARCHTYPE="x86compat" ;;
- i686) ARCHTYPE="x86"; SUBARCHTYPE="x86compat" ;;
- x86_64) ARCHTYPE="x86";;
- powerpc) ARCHTYPE="ppc" ;;
- ppc64) ARCHTYPE="ppc" ;;
- powerpc64) ARCHTYPE="ppc" ;;
- ppc) ARCHTYPE="ppc" ;;
- s390) ARCHTYPE="s390" ;;
- s390x) ARCHTYPE="s390" ;;
- *) ARCHTYPE="unknown";;
-esac
-
-if test "$ARCHTYPE" = "unknown"; then
- AC_MSG_ERROR([Unable to detect the architecture.])
-fi
-AC_SUBST(ARCHTYPE)
-AC_SUBST(SUBARCHTYPE)
-
-[
-if test "x$ARCHTYPE" = "xx86" -a "x$target_cpu" != "xi386" -a "x$target_cpu" !=
-"xi486" -a "x$target_cpu" != "xi586"; then
-]
- AC_DEFINE([CONFIG_HAVE_FENCE], [1])
-[
-fi
-]
-
-AM_CONDITIONAL([GCC_API], [test "x$ARCHTYPE" != xx86 -a "x$ARCHTYPE" != xppc])
-
-AM_CONDITIONAL([COMPAT_ARCH], [test "x$SUBARCHTYPE" == xx86compat ])
-
-AC_ARG_ENABLE([smp-support], [ --disable-smp-support Disable SMP support. Warning: only use this
- on uniprocessor systems. [[default=enabled]]], [def_smp_support=$enableval], [def_smp_support="yes"])
-
-[
-if test "$def_smp_support" = "no"; then
- echo "SMP support disabled."
-else
-]
- AC_DEFINE([CONFIG_SMP], [1])
-[
- echo "SMP support enabled."
-fi
-]
+AC_FUNC_FORK
+AC_CHECK_FUNCS([ \
+ atexit \
+ getcpuid \
+ gettid \
+ gettimeofday \
+ memeset \
+ memset \
+ munmap \
+ rand_r \
+ sched_getcpu \
+ sched_setaffinity \
+ strerror \
+ strtoul \
+ sysconf \
+])
+
+# AC_FUNC_MALLOC causes problems when cross-compiling.
+#AC_FUNC_MALLOC
+
+# Search for clock_gettime() in -lrt
+AC_SEARCH_LIBS([clock_gettime], [rt], [
+ AC_DEFINE([CONFIG_RCU_HAVE_CLOCK_GETTIME], [1], [clock_gettime() is detected.])
+])
+
+
+## ##
+## Optional features selection ##
+## ##
+
+# Allow to fallback to FIXME if the membarrier syscall is unavailable on the
+# running kernel, when disabled, abort if the syscall is unavailable. Applies
+# to default and bulletproof flavors.
+# Enabled by default
+AE_FEATURE_DEFAULT_ENABLE
+AE_FEATURE([sys-membarrier-fallback], [Abort if sys-membarrier is needed but not available rather than using a fallback.])
+
+# Use compiler Thread Local Storage, when disabled use pthread_getspecific() to emulate TLS.
+# Enabled by default
+AE_FEATURE_DEFAULT_ENABLE
+AE_FEATURE([compiler-tls], [Use pthread_getspecific() to emulate Thread Local Storage (TLS) variables.])
+
+# smp-support configure option
+# Enabled by default
+AE_FEATURE_DEFAULT_ENABLE
+AE_FEATURE([smp-support], [Disable SMP support. Warning: only use this on uniprocessor systems.])
+
+# RCU debugging option
+# Disabled by default
+AE_FEATURE_DEFAULT_DISABLE
+AE_FEATURE([rcu-debug], [Enable internal debugging self-checks. Introduces a performance penalty.])
+
+# rculfhash iterator debugging
+# Disabled by default
+AE_FEATURE_DEFAULT_DISABLE
+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.])
+
+# When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS.
+# Disabled by default
+AE_FEATURE_DEFAULT_DISABLE
+AE_FEATURE([Werror],[Treat compiler warnings as errors.])
+
+## ##
+## Set defines for optional features conditionnals in the source code ##
+## ##
+
+AE_IF_FEATURE_DISABLED([sys-membarrier-fallback], [
+ AC_DEFINE([CONFIG_RCU_FORCE_SYS_MEMBARRIER], [1], [Require the operating system to support the membarrier system call for default and bulletproof flavors.])
+])
+
+AE_IF_FEATURE_ENABLED([compiler-tls], [
+ AC_DEFINE([CONFIG_RCU_TLS], [1], [Use compiler provided Thread Local Storage.])
+])
+
+AE_IF_FEATURE_ENABLED([smp-support], [
+ 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.])
+])
+
+AE_IF_FEATURE_ENABLED([rcu-debug], [
+ AC_DEFINE([CONFIG_RCU_DEBUG], [1], [Enable internal debugging self-checks. Introduces a performance penalty.])
+])
+
+AE_IF_FEATURE_ENABLED([cds-lfht-iter-debug], [
+ 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.])
+])
+
+
+## ##
+## Set automake variables for optional feature conditionnals in Makefile.am ##
+## ##
+
+# Building the examples requires the shared libraries to be enabled
+AM_CONDITIONAL([ENABLE_EXAMPLES], AE_IS_FEATURE_ENABLED([shared]))
+
+
+## ##
+## Substitute variables for use in Makefile.am ##
+## ##
+
+# Library versions for libtool
+AC_SUBST([URCU_LIBRARY_VERSION], [urcu_lib_version])
+
+AC_SUBST(LT_NO_UNDEFINED)
+
+# The order in which the include folders are searched is important.
+# The top_builddir should always be searched first in the event that a build
+# time generated file is included.
+AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h"
+AC_SUBST(AM_CPPFLAGS)
+
+AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS"
+AC_SUBST(AM_CFLAGS)
+
+AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS"
+AC_SUBST(AM_CXXFLAGS)
+
+
+## ##
+## Output files generated by configure ##
+## ##