summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-04-05 18:39:25 +0200
committerGitHub <noreply@github.com>2017-04-05 18:39:25 +0200
commit6492ed5369a7bd833e8add952af35a3c9d7f2528 (patch)
tree402654c2b39c15ce30dd0643607031d4bf652bd9 /configure.ac
parentMerge pull request #334 from pichuang/typo (diff)
parentbuild: find & use threading library (diff)
downloadfrr-6492ed5369a7bd833e8add952af35a3c9d7f2528.tar.xz
frr-6492ed5369a7bd833e8add952af35a3c9d7f2528.zip
Merge pull request #310 from opensourcerouting/thread-prep
MT preparations
Diffstat (limited to 'configure.ac')
-rwxr-xr-xconfigure.ac92
1 files changed, 91 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 6eac0e3c8..b4a3e37fd 100755
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,10 @@ LIBS="$LIBS -ltcmalloc_minimal"
esac],[tcmalloc_enabled=false])
+dnl Thanks autoconf, but we don't want a default -g -O2. We have our own
+dnl flag determination logic.
+CFLAGS="${CFLAGS:-}"
+
dnl --------------------
dnl Check CC and friends
dnl --------------------
@@ -85,6 +89,7 @@ AM_PROG_CC_C_O
dnl remove autoconf default "-g -O2"
CFLAGS="$orig_cflags"
AC_PROG_CC_C99
+dnl NB: see C11 below
AC_PROG_EGREP
PKG_PROG_PKG_CONFIG
@@ -96,7 +101,7 @@ AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
dnl try and enable CFLAGS that are useful for Quagga
dnl - specifically, options to control warnings
-AC_USE_SYSTEM_EXTENSIONS()
+AC_USE_SYSTEM_EXTENSIONS
AC_DEFUN([AC_C_FLAG], [{
AC_LANG_PUSH(C)
ac_c_flag_save="$CFLAGS"
@@ -122,6 +127,13 @@ dnl ICC won't bail on unknown options without -diag-error 10006
dnl need to do this first so we get useful results for the other options
AC_C_FLAG([-diag-error 10006])
+dnl AC_PROG_CC_C99 may change CC to include -std=gnu99 or something
+ac_cc="$CC"
+CC="${CC% -std=gnu99}"
+CC="${CC% -std=c99}"
+
+AC_C_FLAG([-std=gnu11], [CC="$ac_cc"], [CC="$CC -std=gnu11"])
+
dnl if the user specified any CFLAGS, we don't add "-g -Os/-O2" here
if test "z$orig_cflags" = "z"; then
AC_C_FLAG([-g])
@@ -177,6 +189,18 @@ AC_LINK_IFELSE(
])
AC_LANG_POP(C)
+dnl ----------
+dnl Essentials
+dnl ----------
+
+AX_PTHREAD([
+ CC="$PTHREAD_CC"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+], [
+ AC_MSG_FAILURE([This Quagga version needs pthreads])
+])
+
dnl --------------
dnl Check programs
dnl --------------
@@ -539,6 +563,72 @@ AC_CHECK_HEADERS([stropts.h sys/ksym.h \
linux/version.h asm/types.h \
sys/cdefs.h])
+ac_stdatomic_ok=false
+AC_DEFINE(FRR_AUTOCONF_ATOMIC, 1, [did autoconf checks for atomic funcs])
+AC_CHECK_HEADER([stdatomic.h],[
+
+ AC_MSG_CHECKING([whether _Atomic qualifier works])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+#include <stdatomic.h>
+int main(int argc, char **argv) {
+ _Atomic int i = 0;
+ return i;
+}
+]])], [
+ AC_DEFINE(HAVE_STDATOMIC_H, 1, [found stdatomic.h])
+ AC_MSG_RESULT([yes])
+ ac_stdatomic_ok=true
+ ], [
+ AC_MSG_RESULT([no])
+ ])
+])
+
+AS_IF([$ac_stdatomic_ok], [true], [
+ AC_MSG_CHECKING([for __atomic_* builtins])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+int main(int argc, char **argv) {
+ volatile int i = 1;
+ __atomic_store_n (&i, 0, __ATOMIC_RELEASE);
+ return __atomic_load_n (&i, __ATOMIC_ACQUIRE);
+}
+]])], [
+ AC_DEFINE(HAVE___ATOMIC, 1, [found __atomic builtins])
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+
+ dnl FreeBSD 9 has a broken stdatomic.h where _Atomic doesn't work
+ AC_MSG_CHECKING([for __sync_* builtins])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+int main(int argc, char **argv) {
+ volatile int i = 1;
+ __sync_fetch_and_sub (&i, 1);
+ return __sync_val_compare_and_swap (&i, 0, 1);
+}
+]])], [
+ AC_DEFINE(HAVE___SYNC, 1, [found __sync builtins])
+ AC_MSG_RESULT([yes])
+
+ AC_MSG_CHECKING([for __sync_swap builtin])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+int main(int argc, char **argv) {
+ volatile int i = 1;
+ return __sync_swap (&i, 2);
+}
+]])], [
+ AC_DEFINE(HAVE___SYNC_SWAP, 1, [found __sync_swap builtin])
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+ ])
+
+ ], [
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE([stdatomic.h unavailable and $CC has neither __atomic nor __sync builtins])
+ ])
+ ])
+])
+
dnl Utility macro to avoid retyping includes all the time
m4_define([FRR_INCLUDES],
[#ifdef SUNOS_5