From: Arran Cudbard-Bell Date: Tue, 19 Apr 2022 13:36:04 +0000 (-0500) Subject: Split macros out of acinclude X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4eff6a1feaf1b0944ff82a9f2d07f767b3d2960a;p=thirdparty%2Ffreeradius-server.git Split macros out of acinclude Use COMPILE_IFELSE in more places to speed up configure --- diff --git a/acinclude.m4 b/acinclude.m4 index f65dcf9e038..9222be26818 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -15,405 +15,6 @@ else ac_cv_prog_suncc=no fi])]) -dnl # -dnl # FR_CHECK_TYPE_INCLUDE([#includes ...], type, default-C-types) -dnl # -dnl # This function is like AC_CHECK_TYPE, but you can give this one -dnl # a list of include files to check. -dnl # -AC_DEFUN([FR_CHECK_TYPE_INCLUDE], -[ -AC_CACHE_CHECK(for $2, ac_cv_type_$2, - [ ac_cv_type_$2=no - AC_TRY_COMPILE($1, - [$2 foo], - ac_cv_type_$2=yes, - ) - ] -) - -if test "$ac_cv_type_$2" != "yes"; then - AC_DEFINE($2, $3, $4) -fi -]) - -dnl # -dnl # Locate the directory in which a particular file is found. -dnl # -dnl # Usage: FR_LOCATE_DIR(MYSQLLIB_DIR, libmysqlclient.a) -dnl # -dnl # Defines the variable MYSQLLIB_DIR to be the directory(s) in -dnl # which the file libmysqlclient.a is to be found. -dnl # -dnl # -AC_DEFUN([FR_LOCATE_DIR], -[ -dnl # If we have the program 'locate', then the problem of finding a -dnl # particular file becomes MUCH easier. -dnl # - -dnl # -dnl # No 'locate' defined, do NOT do anything. -dnl # -if test "x$LOCATE" != "x"; then -dnl # -dnl # Root through a series of directories, looking for the given file. -dnl # -DIRS= -file=$2 - -for x in `${LOCATE} $file 2>/dev/null`; do - dnl # - dnl # When asked for 'foo', locate will also find 'foo_bar', which we - dnl # don't want. We want that EXACT filename. - dnl # - dnl # We ALSO want to be able to look for files like 'mysql/mysql.h', - dnl # and properly match them, too. So we try to strip off the last - dnl # part of the filename, using the name of the file we're looking - dnl # for. If we CANNOT strip it off, then the name will be unchanged. - dnl # - base=`echo $x | sed "s%/${file}%%"` - if test "x$x" = "x$base"; then - continue; - fi - - dir=`${DIRNAME} $x 2>/dev/null` - dnl # - dnl # Exclude a number of directories. - dnl # - exclude=`echo ${dir} | ${GREP} /home` - if test "x$exclude" != "x"; then - continue - fi - - dnl # - dnl # OK, we have an exact match. Let's be sure that we only find ONE - dnl # matching directory. - dnl # - already=`echo \$$1 ${DIRS} | ${GREP} ${dir}` - if test "x$already" = "x"; then - DIRS="$DIRS $dir" - fi -done -fi - -dnl # -dnl # And remember the directory in which we found the file. -dnl # -eval "$1=\"\$$1 $DIRS\"" -]) - - -dnl # -dnl # Auto-populate smart_try_dir for includes -dnl # -AC_DEFUN([FR_SMART_PKGCONFIG_INCLUDE], [ -AC_MSG_CHECKING([for pkg-config $1 include paths]) -if pkg-config --exists "$1"; then - _pkgconfig_include_path=$(pkg-config --cflags-only-I $1 | sed -e 's/-I//g') - AC_MSG_RESULT(${_pkgconfig_include_path}) - smart_try_dir="${_pkgconfig_include_path} $2" -else - smart_try_dir="$2" - AC_MSG_RESULT(no) -fi -]) - -dnl # -dnl # Auto-populate smart_try_dir for libs -dnl # -AC_DEFUN([FR_SMART_PKGCONFIG_LIB], [ -AC_MSG_CHECKING([for pkg-config $1 linker paths]) -if pkg-config --exists "$1"; then - _pkgconfig_lib_path="$(pkg-config --libs-only-L $1 | sed -e 's/-L//g')" - AC_MSG_RESULT(${_pkgconfig_lib_path}) - smart_try_dir="${_pkgconfig_lib_path} $2" -else - smart_try_dir="$2" - AC_MSG_RESULT(no) -fi -]) - -dnl ####################################################################### -dnl # -dnl # Look for a library in a number of places. -dnl # -dnl # FR_SMART_CHECK_LIB(library, function) -dnl # -AC_DEFUN([FR_SMART_CHECK_LIB], [ - -sm_lib_safe=`echo "$1" | sed 'y%./+-%__p_%'` -sm_func_safe=`echo "$2" | sed 'y%./+-%__p_%'` - -dnl # -dnl # We pass all arguments for linker testing in CCPFLAGS as these -dnl # will be passed to the compiler (then linker) first. -dnl # -dnl # The linker will search through -L directories in the order they -dnl # appear on the command line. Unfortunately the same rules appear -dnl # to apply to directories specified with --sysroot, so we must -dnl # pass the user specified directory first. -dnl # -dnl # Really we should be using LDFLAGS (-L) for this. -dnl # -old_LIBS="$LIBS" -old_CPPFLAGS="$CPPFLAGS" -smart_lib= -smart_ldflags= -smart_lib_dir= - -dnl # -dnl # Try first any user-specified directory, otherwise we may pick up -dnl # the wrong version. -dnl # -if test "x$smart_try_dir" != "x"; then -for try in $smart_try_dir; do - AC_MSG_CHECKING([for $2 in -l$1 in $try]) - LIBS="-l$1 $old_LIBS" - CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS" - AC_TRY_LINK([extern char $2();], - [$2()], - [ - smart_lib="-l$1" - smart_ldflags="-L$try -Wl,-rpath,$try" - AC_MSG_RESULT(yes) - break - ], - [AC_MSG_RESULT(no)]) -done -LIBS="$old_LIBS" -CPPFLAGS="$old_CPPFLAGS" -fi - -dnl # -dnl # Try using the default library path -dnl # -if test "x$smart_lib" = "x"; then -AC_MSG_CHECKING([for $2 in -l$1]) -LIBS="-l$1 $old_LIBS" -AC_TRY_LINK([extern char $2();], - [$2()], - [ - smart_lib="-l$1" - AC_MSG_RESULT(yes) - ], - [AC_MSG_RESULT(no)]) -LIBS="$old_LIBS" -fi - -dnl # -dnl # Try to guess possible locations. -dnl # -if test "x$smart_lib" = "x"; then -FR_LOCATE_DIR(smart_lib_dir,[lib$1${libltdl_cv_shlibext}]) -FR_LOCATE_DIR(smart_lib_dir,[lib$1.a]) - -for try in $smart_lib_dir /usr/local/lib /opt/lib; do - AC_MSG_CHECKING([for $2 in -l$1 in $try]) - LIBS="-l$1 $old_LIBS" - CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS" - AC_TRY_LINK([extern char $2();], - [$2()], - [ - smart_lib="-l$1" - smart_ldflags="-L$try -Wl,-rpath,$try" - AC_MSG_RESULT(yes) - break - ], - [AC_MSG_RESULT(no)]) -done -LIBS="$old_LIBS" -CPPFLAGS="$old_CPPFLAGS" -fi - -dnl # -dnl # Found it, set the appropriate variable. -dnl # -if test "x$smart_lib" != "x"; then -eval "ac_cv_lib_${sm_lib_safe}_${sm_func_safe}=yes" -LIBS="$smart_ldflags $smart_lib $old_LIBS" -SMART_LIBS="$smart_ldflags $smart_lib $SMART_LIBS" -fi -]) - -dnl ####################################################################### -dnl # -dnl # Look for a header file in a number of places. -dnl # -dnl # FR_SMART_CHECK_INCLUDE(foo.h, [ #include ]) -dnl # -AC_DEFUN([FR_SMART_CHECK_INCLUDE], [ - -ac_safe=`echo "$1" | sed 'y%./+-%__pm%'` -old_CPPFLAGS="$CPPFLAGS" -smart_include= -dnl # The default directories we search in (in addition to the compilers search path) -smart_include_dir="/usr/local/include /opt/include" - -dnl # Our local versions -_smart_try_dir= -_smart_include_dir= - -dnl # Add variants with the different prefixes and one with no prefix -for _prefix in $smart_prefix ""; do -for _dir in $smart_try_dir; do - _smart_try_dir="${_smart_try_dir} ${_dir}/${_prefix}" -done - -for _dir in $smart_include_dir; do - _smart_include_dir="${_smart_include_dir} ${_dir}/${_prefix}" -done -done - -dnl # -dnl # Try any user-specified directory first otherwise we may pick up -dnl # the wrong version. -dnl # -if test "x$_smart_try_dir" != "x"; then -for try in $_smart_try_dir; do - AC_MSG_CHECKING([for $1 in $try]) - CPPFLAGS="-isystem $try $old_CPPFLAGS" - AC_TRY_COMPILE([$2 - #include <$1>], - [int a = 1;], - [ - smart_include="-isystem $try" - AC_MSG_RESULT(yes) - break - ], - [ - smart_include= - AC_MSG_RESULT(no) - ]) -done -CPPFLAGS="$old_CPPFLAGS" -fi - -dnl # -dnl # Try using the default includes (with prefixes). -dnl # -if test "x$smart_include" = "x"; then -for _prefix in $smart_prefix; do - AC_MSG_CHECKING([for ${_prefix}/$1]) - - AC_TRY_COMPILE([$2 - #include <$1>], - [int a = 1;], - [ - smart_include="-isystem ${_prefix}/" - AC_MSG_RESULT(yes) - break - ], - [ - smart_include= - AC_MSG_RESULT(no) - ]) -done -fi - -dnl # -dnl # Try using the default includes (without prefixes). -dnl # -if test "x$smart_include" = "x"; then - AC_MSG_CHECKING([for $1]) - - AC_TRY_COMPILE([$2 - #include <$1>], - [int a = 1;], - [ - smart_include=" " - AC_MSG_RESULT(yes) - break - ], - [ - smart_include= - AC_MSG_RESULT(no) - ]) -fi - -dnl # -dnl # Try to guess possible locations. -dnl # -if test "x$smart_include" = "x"; then - -for prefix in $smart_prefix; do - FR_LOCATE_DIR(_smart_include_dir,"${_prefix}/${1}") -done -FR_LOCATE_DIR(_smart_include_dir, $1) - -for try in $_smart_include_dir; do - AC_MSG_CHECKING([for $1 in $try]) - CPPFLAGS="-isystem $try $old_CPPFLAGS" - AC_TRY_COMPILE([$2 - #include <$1>], - [int a = 1;], - [ - smart_include="-isystem $try" - AC_MSG_RESULT(yes) - break - ], - [ - smart_include= - AC_MSG_RESULT(no) - ]) -done -CPPFLAGS="$old_CPPFLAGS" -fi - -dnl # -dnl # Found it, set the appropriate variable. -dnl # -if test "x$smart_include" != "x"; then -eval "ac_cv_header_$ac_safe=yes" -CPPFLAGS="$smart_include $old_CPPFLAGS" -SMART_CPPFLAGS="$smart_include $SMART_CPPFLAGS" -fi - -dnl # -dnl # Consume prefix, it's not likely to be used -dnl # between multiple calls. -dnl # -smart_prefix= -]) - -dnl ####################################################################### -dnl # -dnl # Look for a header file in a number of places. -dnl # -dnl # Usage: FR_CHECK_STRUCT_HAS_MEMBER([#include ], [struct foo], member) -dnl # If the member is defined, then the variable -dnl # ac_cv_type_struct_foo_has_member is set to 'yes' -dnl # -AC_DEFUN([FR_CHECK_STRUCT_HAS_MEMBER], [ -AC_MSG_CHECKING([for $3 in $2]) - -dnl BASED on 'offsetof': -dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -dnl - -AC_TRY_COMPILE([ -$1 -#ifdef HAVE_STDDEF_H -#include -#endif -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER) -#endif -], - [ int foo = offsetof($2, $3) ], - has_element=" ", - has_element=) - -ac_safe_type=`echo "$2" | sed 'y% %_%'` -if test "x$has_element" != "x"; then - AC_MSG_RESULT(yes) - eval "ac_cv_type_${ac_safe_type}_has_$3=yes" -else - AC_MSG_RESULT(no) - eval "ac_cv_type_${ac_safe_type}_has_$3=" - fi -]) - dnl Autoconf 2.61 breaks the support for chained configure scripts dnl in combination with config.cache m4_pushdef([AC_OUTPUT], @@ -424,73 +25,6 @@ m4_popdef([AC_OUTPUT]) AC_OUTPUT([$1],[$2],[$3]) ]) -dnl # -dnl # Figure out which storage class specifier for Thread Local Storage is supported by the compiler -dnl # -AC_DEFUN([FR_TLS], -[ -dnl # -dnl # _Thread_local does exactly the same thing as __thread, but it's standards compliant with C11. -dnl # - AC_MSG_CHECKING(for _Thread_local support in compiler) - AC_RUN_IFELSE( - [AC_LANG_SOURCE( - [[ - static _Thread_local int val; - int main(int argc, char **argv) { - val = 0; - return val; - } - ]]) - ],[have_tls=yes],[have_tls=no],[have_tls=no]) - AC_MSG_RESULT($have_tls) - if test "x$have_tls" = "xyes"; then - AC_DEFINE([TLS_STORAGE_CLASS],[_Thread_local],[Define if the compiler supports a thread local storage class]) - fi - -dnl # -dnl # __declspec(thread) does exactly the same thing as __thread, but is supported by MSVS -dnl # -if test "x$have_tls" = "xno"; then - AC_MSG_CHECKING(for __declspec(thread) support in compiler) - AC_RUN_IFELSE( - [AC_LANG_SOURCE( - [[ - static _Thread_local int val; - int main(int argc, char **argv) { - val = 0; - return val; - } - ]]) - ],[have_tls=yes],[have_tls=no],[have_tls=no]) - AC_MSG_RESULT($have_tls) - if test "x$have_tls" = "xyes"; then - AC_DEFINE([TLS_STORAGE_CLASS],[__declspec(thread)],[Define if the compiler supports a thread local storage class]) - fi -fi -dnl # -dnl # See if the compilation works with __thread, for thread-local storage -dnl # This is used by earlier versions of GCC and clang. -dnl # -if test "x$have_tls" = "xno"; then - AC_MSG_CHECKING(for __thread support in compiler) - AC_RUN_IFELSE( - [AC_LANG_SOURCE( - [[ - static __thread int val; - int main(int argc, char **argv) { - val = 0; - return val; - } - ]]) - ],[have_tls=yes],[have_tls=no],[have_tls=no]) - AC_MSG_RESULT($have_tls) - if test "x$have_tls" = "xyes"; then - AC_DEFINE([TLS_STORAGE_CLASS],[__thread],[Define if the compiler supports a thread local storage class]) - fi -fi -]) - AC_DEFUN([VL_LIB_READLINE], [ AC_CACHE_CHECK([for a readline compatible library], vl_cv_lib_readline, [ diff --git a/configure b/configure index 20d69da4070..67f61b611ef 100755 --- a/configure +++ b/configure @@ -3091,6 +3091,22 @@ ac_config_headers="$ac_config_headers src/include/autoconf.h" + + + + + + + + + + + + + + + + @@ -3111,28 +3127,28 @@ ac_config_headers="$ac_config_headers src/include/autoconf.h" # # SYNOPSIS # -# AX_WITH_LIB_ARGS(LIBRARY) -# AX_WITH_LIB_ARGS_OPT(LIBRARY, DEFAULT) +# AX_WITH_FEATURE_ARGS(FEATURE) # # DESCRIPTION # -# Adds boilerplate arguments for controlling the location of library lib and -# include directories. +# Adds boilerplate arguments for controlling whether a feature is built # - # # SYNOPSIS # -# AX_WITH_FEATURE_ARGS(FEATURE) +# AX_WITH_LIB_ARGS(LIBRARY) +# AX_WITH_LIB_ARGS_OPT(LIBRARY, DEFAULT) # # DESCRIPTION # -# Adds boilerplate arguments for controlling whether a feature is built +# Adds boilerplate arguments for controlling the location of library lib and +# include directories. # + # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_prog_perl_modules.html # =========================================================================== @@ -5855,14 +5871,7 @@ else $as_nop CFLAGS_SAVED=$CFLAGS CFLAGS="$CFLAGS -Werror --rtlib=compiler-rt --unwindlib=libunwind" - if test "$cross_compiling" = yes -then : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5872,17 +5881,14 @@ else $as_nop _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : ax_cv_cc_unwindlib_arg=yes else $as_nop ax_cv_cc_unwindlib_arg=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext CFLAGS="$CFLAGS_SAVED" @@ -8627,7 +8633,6 @@ then : fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sqrt in -lm" >&5 printf %s "checking for sqrt in -lm... " >&6; } if test ${ac_cv_lib_m_sqrt+y} @@ -15117,10 +15122,6 @@ export EXPERIMENTAL { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _Thread_local support in compiler" >&5 printf %s "checking for _Thread_local support in compiler... " >&6; } - if test "$cross_compiling" = yes -then : - have_tls=no -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15132,16 +15133,13 @@ else $as_nop _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : have_tls=yes else $as_nop have_tls=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_tls" >&5 printf "%s\n" "$have_tls" >&6; } if test "x$have_tls" = "xyes"; then @@ -15153,10 +15151,6 @@ printf "%s\n" "#define TLS_STORAGE_CLASS _Thread_local" >>confdefs.h if test "x$have_tls" = "xno"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for __declspec(thread) support in compiler" >&5 printf %s "checking for __declspec(thread) support in compiler... " >&6; } - if test "$cross_compiling" = yes -then : - have_tls=no -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15168,16 +15162,13 @@ else $as_nop _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : have_tls=yes else $as_nop have_tls=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_tls" >&5 printf "%s\n" "$have_tls" >&6; } if test "x$have_tls" = "xyes"; then @@ -15189,10 +15180,6 @@ fi if test "x$have_tls" = "xno"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for __thread support in compiler" >&5 printf %s "checking for __thread support in compiler... " >&6; } - if test "$cross_compiling" = yes -then : - have_tls=no -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15204,16 +15191,13 @@ else $as_nop _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : have_tls=yes else $as_nop have_tls=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_tls" >&5 printf "%s\n" "$have_tls" >&6; } if test "x$have_tls" = "xyes"; then @@ -15231,13 +15215,6 @@ then : printf %s "(cached) " >&6 else $as_nop - if test "$cross_compiling" = yes -then : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15249,17 +15226,14 @@ else $as_nop _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : ax_cv_cc_builtin_choose_expr=yes else $as_nop ax_cv_cc_builtin_choose_expr=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cc_builtin_choose_expr" >&5 @@ -15278,13 +15252,6 @@ then : printf %s "(cached) " >&6 else $as_nop - if test "$cross_compiling" = yes -then : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15296,17 +15263,14 @@ else $as_nop _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : ax_cv_cc_builtin_types_compatible_p=yes else $as_nop ax_cv_cc_builtin_types_compatible_p=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cc_builtin_types_compatible_p" >&5 @@ -15325,13 +15289,6 @@ then : printf %s "(cached) " >&6 else $as_nop - if test "$cross_compiling" = yes -then : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15343,17 +15300,14 @@ else $as_nop _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : ax_cv_cc_builtin_bswap64=yes else $as_nop ax_cv_cc_builtin_bswap64=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cc_builtin_bswap64" >&5 @@ -15372,13 +15326,6 @@ then : printf %s "(cached) " >&6 else $as_nop - if test "$cross_compiling" = yes -then : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15390,17 +15337,14 @@ else $as_nop _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : ax_cv_cc_builtin_clzll=yes else $as_nop ax_cv_cc_builtin_clzll=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cc_builtin_clzll" >&5 @@ -15419,13 +15363,6 @@ then : printf %s "(cached) " >&6 else $as_nop - if test "$cross_compiling" = yes -then : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15437,17 +15374,14 @@ else $as_nop _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : ax_cv_cc_c11_generic=yes else $as_nop ax_cv_cc_c11_generic=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cc_c11_generic" >&5 @@ -15470,13 +15404,6 @@ then : printf %s "(cached) " >&6 else $as_nop - if test "$cross_compiling" = yes -then : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15485,22 +15412,19 @@ else $as_nop #include int main(int argc, char **argv) { - return _Generic((size_t)(0), uint64_t: 1, default: 0); + return _Generic((size_t)(0), uint64_t: 1, size_t: 0); } _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : ax_cv_cc_size_same_as_uint64=no else $as_nop ax_cv_cc_size_same_as_uint64=yes fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cc_size_same_as_uint64" >&5 @@ -15519,13 +15443,6 @@ then : printf %s "(cached) " >&6 else $as_nop - if test "$cross_compiling" = yes -then : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15535,22 +15452,19 @@ else $as_nop #include int main(int argc, char **argv) { - return _Generic((ssize_t)(0), int64_t: 1, default: 0); + return _Generic((ssize_t)(0), int64_t: 1, ssize_t: 0); } _ACEOF -if ac_fn_c_try_run "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : ax_cv_cc_ssize_same_as_int64=no else $as_nop ax_cv_cc_ssize_same_as_int64=yes fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cc_ssize_same_as_int64" >&5 diff --git a/configure.ac b/configure.ac index bf9dd398fd9..2fb748058df 100644 --- a/configure.ac +++ b/configure.ac @@ -27,8 +27,11 @@ AC_INIT([freeradius],[$]Id[$],[http://bugs.freeradius.org],,[http://www.freeradi AC_CONFIG_SRCDIR([src/bin/radiusd.c]) AC_CONFIG_HEADER([src/include/autoconf.h]) m4_include([m4/ax_cc.m4]) -m4_include([m4/ax_with_lib_args.m4]) +m4_include([m4/ax_smart_try.m4]) +m4_include([m4/ax_thread_local.m4]) +m4_include([m4/ax_type.m4]) m4_include([m4/ax_with_feature_args.m4]) +m4_include([m4/ax_with_lib_args.m4]) m4_include([m4/ax_prog_perl_modules.m4]) dnl ############################################################# @@ -1438,7 +1441,7 @@ AC_TYPE_UID_T dnl # dnl # Check for socklen_t dnl # -FR_CHECK_TYPE_INCLUDE( +AX_CHECK_TYPE_INCLUDE( [ #ifdef HAVE_SYS_TYPES_H # include @@ -1454,7 +1457,7 @@ FR_CHECK_TYPE_INCLUDE( dnl # dnl # Check for uint8_t dnl # -FR_CHECK_TYPE_INCLUDE( +AX_CHECK_TYPE_INCLUDE( [ #ifdef HAVE_INTTYPES_H # include @@ -1470,7 +1473,7 @@ FR_CHECK_TYPE_INCLUDE( dnl # dnl # Check for uint16_t dnl # -FR_CHECK_TYPE_INCLUDE( +AX_CHECK_TYPE_INCLUDE( [ #ifdef HAVE_INTTYPES_H # include @@ -1486,7 +1489,7 @@ FR_CHECK_TYPE_INCLUDE( dnl # dnl # Check for uint32_t dnl # -FR_CHECK_TYPE_INCLUDE( +AX_CHECK_TYPE_INCLUDE( [ #ifdef HAVE_INTTYPES_H # include @@ -1502,7 +1505,7 @@ FR_CHECK_TYPE_INCLUDE( dnl # dnl # Check for uint64_t dnl # -FR_CHECK_TYPE_INCLUDE( +AX_CHECK_TYPE_INCLUDE( [ #ifdef HAVE_INTTYPES_H # include @@ -1580,7 +1583,7 @@ AC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Generic DNS l dnl # dnl # Check for sig_t dnl # -dnl # FR_CHECK_TYPE_INCLUDE doesn't work for callbacks as it doesn't produce typedefs +dnl # AX_CHECK_TYPE_INCLUDE doesn't work for callbacks as it doesn't produce typedefs dnl # AC_MSG_CHECKING([if sig_t is defined]) AC_LINK_IFELSE( @@ -1668,7 +1671,7 @@ dnl # if so, check if struct utmpx has entry ut_xtime dnl # if not, set it to define ut_xtime = ut_tv.tv_sec dnl # if test "x$ac_cv_header_utmpx_h" = "xyes"; then - FR_CHECK_STRUCT_HAS_MEMBER([#include ], [struct utmpx], ut_xtime) + AX_CHECK_STRUCT_HAS_MEMBER([#include ], [struct utmpx], ut_xtime) if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"; then AC_DEFINE(ut_xtime, ut_tv.tv_sec, [define to something if you don't have ut_xtime in struct utmpx]) fi @@ -1677,7 +1680,7 @@ fi dnl # dnl # struct ip_pktinfo dnl # -FR_CHECK_STRUCT_HAS_MEMBER([#include ], [struct in_pktinfo], ipi_addr) +AX_CHECK_STRUCT_HAS_MEMBER([#include ], [struct in_pktinfo], ipi_addr) if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"; then AC_DEFINE(HAVE_IP_PKTINFO, [], [define if you have IP_PKTINFO (Linux)]) fi @@ -1685,7 +1688,7 @@ fi dnl # dnl # struct in6_pktinfo dnl # -FR_CHECK_STRUCT_HAS_MEMBER([#include ], [struct in6_pktinfo], ipi6_addr) +AX_CHECK_STRUCT_HAS_MEMBER([#include ], [struct in6_pktinfo], ipi6_addr) if test "x$ac_cv_type_struct_in6_pktinfo_has_ipi6_addr" = "xyes"; then AC_DEFINE(HAVE_IN6_PKTINFO, [], [define if you have IN6_PKTINFO (Linux)]) fi @@ -1960,7 +1963,7 @@ export EXPERIMENTAL dnl # dnl # check for some compiler features dnl # -FR_TLS +AX_THREAD_LOCAL_SUPPORT AX_CC_BUILTIN_CHOOSE_EXPR AX_CC_BUILTIN_TYPES_COMPATIBLE_P AX_CC_BUILTIN_BSWAP64 diff --git a/m4/ax_cc.m4 b/m4/ax_cc.m4 index 5dcc71fbba2..f46da7d0f17 100644 --- a/m4/ax_cc.m4 +++ b/m4/ax_cc.m4 @@ -66,7 +66,7 @@ AC_DEFUN([AX_CC_UNWINDLIB_ARG],[ CFLAGS_SAVED=$CFLAGS CFLAGS="$CFLAGS -Werror --rtlib=compiler-rt --unwindlib=libunwind" - AC_RUN_IFELSE( + AC_COMPILE_IFELSE( [ AC_LANG_SOURCE( [ @@ -90,7 +90,7 @@ dnl # AC_DEFUN([AX_CC_HAVE_C11_GENERIC], [ AC_CACHE_CHECK([for _Generic support in compiler], [ax_cv_cc_c11_generic],[ - AC_RUN_IFELSE( + AC_COMPILE_IFELSE( [ AC_LANG_SOURCE( [ @@ -269,7 +269,7 @@ dnl # AC_DEFUN([AX_CC_BUILTIN_CHOOSE_EXPR], [ AC_CACHE_CHECK([for __builtin_choose_expr support in compiler], [ax_cv_cc_builtin_choose_expr],[ - AC_RUN_IFELSE( + AC_COMPILE_IFELSE( [ AC_LANG_SOURCE( [ @@ -294,7 +294,7 @@ dnl # AC_DEFUN([AX_CC_BUILTIN_TYPES_COMPATIBLE_P], [ AC_CACHE_CHECK([for __builtin_types_compatible_p support in compiler], [ax_cv_cc_builtin_types_compatible_p],[ - AC_RUN_IFELSE( + AC_COMPILE_IFELSE( [ AC_LANG_SOURCE( [ @@ -319,7 +319,7 @@ dnl # AC_DEFUN([AX_CC_BUILTIN_BSWAP64], [ AC_CACHE_CHECK([for __builtin_bswap64 support in compiler], [ax_cv_cc_builtin_bswap64],[ - AC_RUN_IFELSE( + AC_COMPILE_IFELSE( [ AC_LANG_SOURCE([ int main(int argc, char **argv) { @@ -343,7 +343,7 @@ dnl # AC_DEFUN([AX_CC_BUILTIN_CLZLL], [ AC_CACHE_CHECK([for __builtin_clzll support in compiler], [ax_cv_cc_builtin_clzll],[ - AC_RUN_IFELSE( + AC_COMPILE_IFELSE( [ AC_LANG_SOURCE([ int main(int argc, char **argv) { @@ -367,14 +367,14 @@ dnl # AC_DEFUN([AX_CC_SIZE_SAME_AS_UINT64], [ AC_CACHE_CHECK([if size_t == uint64_t], [ax_cv_cc_size_same_as_uint64],[ - AC_RUN_IFELSE( + AC_COMPILE_IFELSE( [ AC_LANG_SOURCE([ #include #include int main(int argc, char **argv) { - return _Generic((size_t)(0), uint64_t: 1, default: 0); + return _Generic((size_t)(0), uint64_t: 1, size_t: 0); } ]) ], @@ -393,7 +393,7 @@ dnl # AC_DEFUN([AX_CC_SSIZE_SAME_AS_INT64], [ AC_CACHE_CHECK([if ssize_t == int64_t], [ax_cv_cc_ssize_same_as_int64],[ - AC_RUN_IFELSE( + AC_COMPILE_IFELSE( [ AC_LANG_SOURCE([ #include @@ -401,7 +401,7 @@ AC_CACHE_CHECK([if ssize_t == int64_t], [ax_cv_cc_ssize_same_as_int64],[ #include int main(int argc, char **argv) { - return _Generic((ssize_t)(0), int64_t: 1, default: 0); + return _Generic((ssize_t)(0), int64_t: 1, ssize_t: 0); } ]) ], diff --git a/m4/ax_smart_try.m4 b/m4/ax_smart_try.m4 new file mode 100644 index 00000000000..2234d4dde77 --- /dev/null +++ b/m4/ax_smart_try.m4 @@ -0,0 +1,337 @@ +dnl # +dnl # Locate the directory in which a particular file is found. +dnl # +dnl # Usage: FR_LOCATE_DIR(MYSQLLIB_DIR, libmysqlclient.a) +dnl # +dnl # Defines the variable MYSQLLIB_DIR to be the directory(s) in +dnl # which the file libmysqlclient.a is to be found. +dnl # +dnl # +AC_DEFUN([FR_LOCATE_DIR], +[ +dnl # If we have the program 'locate', then the problem of finding a +dnl # particular file becomes MUCH easier. +dnl # + +dnl # +dnl # No 'locate' defined, do NOT do anything. +dnl # +if test "x$LOCATE" != "x"; then +dnl # +dnl # Root through a series of directories, looking for the given file. +dnl # +DIRS= +file=$2 + +for x in `${LOCATE} $file 2>/dev/null`; do + dnl # + dnl # When asked for 'foo', locate will also find 'foo_bar', which we + dnl # don't want. We want that EXACT filename. + dnl # + dnl # We ALSO want to be able to look for files like 'mysql/mysql.h', + dnl # and properly match them, too. So we try to strip off the last + dnl # part of the filename, using the name of the file we're looking + dnl # for. If we CANNOT strip it off, then the name will be unchanged. + dnl # + base=`echo $x | sed "s%/${file}%%"` + if test "x$x" = "x$base"; then + continue; + fi + + dir=`${DIRNAME} $x 2>/dev/null` + dnl # + dnl # Exclude a number of directories. + dnl # + exclude=`echo ${dir} | ${GREP} /home` + if test "x$exclude" != "x"; then + continue + fi + + dnl # + dnl # OK, we have an exact match. Let's be sure that we only find ONE + dnl # matching directory. + dnl # + already=`echo \$$1 ${DIRS} | ${GREP} ${dir}` + if test "x$already" = "x"; then + DIRS="$DIRS $dir" + fi +done +fi + +dnl # +dnl # And remember the directory in which we found the file. +dnl # +eval "$1=\"\$$1 $DIRS\"" +]) + +dnl # +dnl # Auto-populate smart_try_dir for includes +dnl # +AC_DEFUN([FR_SMART_PKGCONFIG_INCLUDE], [ +AC_MSG_CHECKING([for pkg-config $1 include paths]) +if pkg-config --exists "$1"; then + _pkgconfig_include_path=$(pkg-config --cflags-only-I $1 | sed -e 's/-I//g') + AC_MSG_RESULT(${_pkgconfig_include_path}) + smart_try_dir="${_pkgconfig_include_path} $2" +else + smart_try_dir="$2" + AC_MSG_RESULT(no) +fi +]) + +dnl # +dnl # Auto-populate smart_try_dir for libs +dnl # +AC_DEFUN([FR_SMART_PKGCONFIG_LIB], [ +AC_MSG_CHECKING([for pkg-config $1 linker paths]) +if pkg-config --exists "$1"; then + _pkgconfig_lib_path="$(pkg-config --libs-only-L $1 | sed -e 's/-L//g')" + AC_MSG_RESULT(${_pkgconfig_lib_path}) + smart_try_dir="${_pkgconfig_lib_path} $2" +else + smart_try_dir="$2" + AC_MSG_RESULT(no) +fi +]) + +dnl ####################################################################### +dnl # +dnl # Look for a library in a number of places. +dnl # +dnl # FR_SMART_CHECK_LIB(library, function) +dnl # +AC_DEFUN([FR_SMART_CHECK_LIB], [ + +sm_lib_safe=`echo "$1" | sed 'y%./+-%__p_%'` +sm_func_safe=`echo "$2" | sed 'y%./+-%__p_%'` + +dnl # +dnl # We pass all arguments for linker testing in CCPFLAGS as these +dnl # will be passed to the compiler (then linker) first. +dnl # +dnl # The linker will search through -L directories in the order they +dnl # appear on the command line. Unfortunately the same rules appear +dnl # to apply to directories specified with --sysroot, so we must +dnl # pass the user specified directory first. +dnl # +dnl # Really we should be using LDFLAGS (-L) for this. +dnl # +old_LIBS="$LIBS" +old_CPPFLAGS="$CPPFLAGS" +smart_lib= +smart_ldflags= +smart_lib_dir= + +dnl # +dnl # Try first any user-specified directory, otherwise we may pick up +dnl # the wrong version. +dnl # +if test "x$smart_try_dir" != "x"; then +for try in $smart_try_dir; do + AC_MSG_CHECKING([for $2 in -l$1 in $try]) + LIBS="-l$1 $old_LIBS" + CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS" + AC_TRY_LINK([extern char $2();], + [$2()], + [ + smart_lib="-l$1" + smart_ldflags="-L$try -Wl,-rpath,$try" + AC_MSG_RESULT(yes) + break + ], + [AC_MSG_RESULT(no)]) +done +LIBS="$old_LIBS" +CPPFLAGS="$old_CPPFLAGS" +fi + +dnl # +dnl # Try using the default library path +dnl # +if test "x$smart_lib" = "x"; then +AC_MSG_CHECKING([for $2 in -l$1]) +LIBS="-l$1 $old_LIBS" +AC_TRY_LINK([extern char $2();], + [$2()], + [ + smart_lib="-l$1" + AC_MSG_RESULT(yes) + ], + [AC_MSG_RESULT(no)]) +LIBS="$old_LIBS" +fi + +dnl # +dnl # Try to guess possible locations. +dnl # +if test "x$smart_lib" = "x"; then +FR_LOCATE_DIR(smart_lib_dir,[lib$1${libltdl_cv_shlibext}]) +FR_LOCATE_DIR(smart_lib_dir,[lib$1.a]) + +for try in $smart_lib_dir /usr/local/lib /opt/lib; do + AC_MSG_CHECKING([for $2 in -l$1 in $try]) + LIBS="-l$1 $old_LIBS" + CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS" + AC_TRY_LINK([extern char $2();], + [$2()], + [ + smart_lib="-l$1" + smart_ldflags="-L$try -Wl,-rpath,$try" + AC_MSG_RESULT(yes) + break + ], + [AC_MSG_RESULT(no)]) +done +LIBS="$old_LIBS" +CPPFLAGS="$old_CPPFLAGS" +fi + +dnl # +dnl # Found it, set the appropriate variable. +dnl # +if test "x$smart_lib" != "x"; then +eval "ac_cv_lib_${sm_lib_safe}_${sm_func_safe}=yes" +LIBS="$smart_ldflags $smart_lib $old_LIBS" +SMART_LIBS="$smart_ldflags $smart_lib $SMART_LIBS" +fi +]) + +dnl ####################################################################### +dnl # +dnl # Look for a header file in a number of places. +dnl # +dnl # FR_SMART_CHECK_INCLUDE(foo.h, [ #include ]) +dnl # +AC_DEFUN([FR_SMART_CHECK_INCLUDE], [ + +ac_safe=`echo "$1" | sed 'y%./+-%__pm%'` +old_CPPFLAGS="$CPPFLAGS" +smart_include= +dnl # The default directories we search in (in addition to the compilers search path) +smart_include_dir="/usr/local/include /opt/include" + +dnl # Our local versions +_smart_try_dir= +_smart_include_dir= + +dnl # Add variants with the different prefixes and one with no prefix +for _prefix in $smart_prefix ""; do +for _dir in $smart_try_dir; do + _smart_try_dir="${_smart_try_dir} ${_dir}/${_prefix}" +done + +for _dir in $smart_include_dir; do + _smart_include_dir="${_smart_include_dir} ${_dir}/${_prefix}" +done +done + +dnl # +dnl # Try any user-specified directory first otherwise we may pick up +dnl # the wrong version. +dnl # +if test "x$_smart_try_dir" != "x"; then +for try in $_smart_try_dir; do + AC_MSG_CHECKING([for $1 in $try]) + CPPFLAGS="-isystem $try $old_CPPFLAGS" + AC_TRY_COMPILE([$2 + #include <$1>], + [int a = 1;], + [ + smart_include="-isystem $try" + AC_MSG_RESULT(yes) + break + ], + [ + smart_include= + AC_MSG_RESULT(no) + ]) +done +CPPFLAGS="$old_CPPFLAGS" +fi + +dnl # +dnl # Try using the default includes (with prefixes). +dnl # +if test "x$smart_include" = "x"; then +for _prefix in $smart_prefix; do + AC_MSG_CHECKING([for ${_prefix}/$1]) + + AC_TRY_COMPILE([$2 + #include <$1>], + [int a = 1;], + [ + smart_include="-isystem ${_prefix}/" + AC_MSG_RESULT(yes) + break + ], + [ + smart_include= + AC_MSG_RESULT(no) + ]) +done +fi + +dnl # +dnl # Try using the default includes (without prefixes). +dnl # +if test "x$smart_include" = "x"; then + AC_MSG_CHECKING([for $1]) + + AC_TRY_COMPILE([$2 + #include <$1>], + [int a = 1;], + [ + smart_include=" " + AC_MSG_RESULT(yes) + break + ], + [ + smart_include= + AC_MSG_RESULT(no) + ]) +fi + +dnl # +dnl # Try to guess possible locations. +dnl # +if test "x$smart_include" = "x"; then + +for prefix in $smart_prefix; do + FR_LOCATE_DIR(_smart_include_dir,"${_prefix}/${1}") +done +FR_LOCATE_DIR(_smart_include_dir, $1) + +for try in $_smart_include_dir; do + AC_MSG_CHECKING([for $1 in $try]) + CPPFLAGS="-isystem $try $old_CPPFLAGS" + AC_TRY_COMPILE([$2 + #include <$1>], + [int a = 1;], + [ + smart_include="-isystem $try" + AC_MSG_RESULT(yes) + break + ], + [ + smart_include= + AC_MSG_RESULT(no) + ]) +done +CPPFLAGS="$old_CPPFLAGS" +fi + +dnl # +dnl # Found it, set the appropriate variable. +dnl # +if test "x$smart_include" != "x"; then +eval "ac_cv_header_$ac_safe=yes" +CPPFLAGS="$smart_include $old_CPPFLAGS" +SMART_CPPFLAGS="$smart_include $SMART_CPPFLAGS" +fi + +dnl # +dnl # Consume prefix, it's not likely to be used +dnl # between multiple calls. +dnl # +smart_prefix= +]) diff --git a/m4/ax_thread_local.m4 b/m4/ax_thread_local.m4 new file mode 100644 index 00000000000..a94ff146a15 --- /dev/null +++ b/m4/ax_thread_local.m4 @@ -0,0 +1,66 @@ +dnl # +dnl # Figure out which storage class specifier for Thread Local Storage is supported by the compiler +dnl # +AC_DEFUN([AX_THREAD_LOCAL_SUPPORT], +[ +dnl # +dnl # _Thread_local does exactly the same thing as __thread, but it's standards compliant with C11. +dnl # + AC_MSG_CHECKING(for _Thread_local support in compiler) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[ + static _Thread_local int val; + int main(int argc, char **argv) { + val = 0; + return val; + } + ]]) + ],[have_tls=yes],[have_tls=no]) + AC_MSG_RESULT($have_tls) + if test "x$have_tls" = "xyes"; then + AC_DEFINE([TLS_STORAGE_CLASS],[_Thread_local],[Define if the compiler supports a thread local storage class]) + fi + +dnl # +dnl # __declspec(thread) does exactly the same thing as __thread, but is supported by MSVS +dnl # +if test "x$have_tls" = "xno"; then + AC_MSG_CHECKING(for __declspec(thread) support in compiler) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[ + static _Thread_local int val; + int main(int argc, char **argv) { + val = 0; + return val; + } + ]]) + ],[have_tls=yes],[have_tls=no]) + AC_MSG_RESULT($have_tls) + if test "x$have_tls" = "xyes"; then + AC_DEFINE([TLS_STORAGE_CLASS],[__declspec(thread)],[Define if the compiler supports a thread local storage class]) + fi +fi +dnl # +dnl # See if the compilation works with __thread, for thread-local storage +dnl # This is used by earlier versions of GCC and clang. +dnl # +if test "x$have_tls" = "xno"; then + AC_MSG_CHECKING(for __thread support in compiler) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[ + static __thread int val; + int main(int argc, char **argv) { + val = 0; + return val; + } + ]]) + ],[have_tls=yes],[have_tls=no]) + AC_MSG_RESULT($have_tls) + if test "x$have_tls" = "xyes"; then + AC_DEFINE([TLS_STORAGE_CLASS],[__thread],[Define if the compiler supports a thread local storage class]) + fi +fi +]) diff --git a/m4/ax_type.m4 b/m4/ax_type.m4 new file mode 100644 index 00000000000..7375348ffe6 --- /dev/null +++ b/m4/ax_type.m4 @@ -0,0 +1,59 @@ +dnl # +dnl # AX_CHECK_TYPE_INCLUDE([#includes ...], type, default-C-types) +dnl # +dnl # This function is like AC_CHECK_TYPE, but you can give this one +dnl # a list of include files to check. +dnl # +AC_DEFUN([AX_CHECK_TYPE_INCLUDE], +[ +AC_CACHE_CHECK(for $2, ac_cv_type_$2, + [ ac_cv_type_$2=no + AC_TRY_COMPILE($1, + [$2 foo], + ac_cv_type_$2=yes, + ) + ] +) + +if test "$ac_cv_type_$2" != "yes"; then + AC_DEFINE($2, $3, $4) +fi +]) + +dnl ####################################################################### +dnl # +dnl # Look for a header file in a number of places. +dnl # +dnl # Usage: AX_CHECK_STRUCT_HAS_MEMBER([#include ], [struct foo], member) +dnl # If the member is defined, then the variable +dnl # ac_cv_type_struct_foo_has_member is set to 'yes' +dnl # +AC_DEFUN([AX_CHECK_STRUCT_HAS_MEMBER], [ +AC_MSG_CHECKING([for $3 in $2]) + +dnl BASED on 'offsetof': +dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +dnl + +AC_TRY_COMPILE([ +$1 +#ifdef HAVE_STDDEF_H +#include +#endif +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER) +#endif +], + [ int foo = offsetof($2, $3) ], + has_element=" ", + has_element=) + +ac_safe_type=`echo "$2" | sed 'y% %_%'` +if test "x$has_element" != "x"; then + AC_MSG_RESULT(yes) + eval "ac_cv_type_${ac_safe_type}_has_$3=yes" +else + AC_MSG_RESULT(no) + eval "ac_cv_type_${ac_safe_type}_has_$3=" + fi +]) diff --git a/src/include/autoconf.h.in b/src/include/autoconf.h.in index 24927410735..da79d1f1f11 100644 --- a/src/include/autoconf.h.in +++ b/src/include/autoconf.h.in @@ -248,12 +248,12 @@ /* Define to 1 if you have the `mallopt' function. */ #undef HAVE_MALLOPT -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - /* Define to 1 if you have the `memrchr' function. */ #undef HAVE_MEMRCHR +/* Define to 1 if you have the header file. */ +#undef HAVE_MINIX_CONFIG_H + /* Define to 1 if you have the `mkdirat' function. */ #undef HAVE_MKDIRAT @@ -551,6 +551,9 @@ /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF +/* Define to 1 if you have the header file. */ +#undef HAVE_WCHAR_H + /* Define if the compiler supports -Wdocumentation */ #undef HAVE_WDOCUMENTATION @@ -606,16 +609,20 @@ /* Solaris-Style ctime_r */ #undef SOLARISSTYLE -/* Define to 1 if you have the ANSI C header files. */ /* Define if the compiler supports ssize_t has the same underlying type as int64 */ #undef SSIZE_SAME_AS_INT64 + +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #undef STDC_HEADERS /* SYSV-Style get*byaddr_r */ #undef SYSVSTYLE -/* Define to 1 if you can safely include both and . */ +/* Define to 1 if you can safely include both and . This + macro is obsolete. */ #undef TIME_WITH_SYS_TIME /* Define if the compiler supports a thread local storage class */ @@ -625,21 +632,87 @@ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif +/* Enable general extensions on macOS. */ +#ifndef _DARWIN_C_SOURCE +# undef _DARWIN_C_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif -/* Enable threading extensions on Solaris. */ +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +#ifndef _HPUX_ALT_XOPEN_SOCKET_API +# undef _HPUX_ALT_XOPEN_SOCKET_API +#endif +/* Identify the host operating system as Minix. + This macro does not affect the system headers' behavior. + A future release of Autoconf may stop defining this macro. */ +#ifndef _MINIX +# undef _MINIX +#endif +/* Enable general extensions on NetBSD. + Enable NetBSD compatibility extensions on Minix. */ +#ifndef _NETBSD_SOURCE +# undef _NETBSD_SOURCE +#endif +/* Enable OpenBSD compatibility extensions on NetBSD. + Oddly enough, this does nothing on OpenBSD. */ +#ifndef _OPENBSD_SOURCE +# undef _OPENBSD_SOURCE +#endif +/* Define to 1 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_SOURCE +# undef _POSIX_SOURCE +#endif +/* Define to 2 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_1_SOURCE +# undef _POSIX_1_SOURCE +#endif +/* Enable POSIX-compatible threading on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif +/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ +#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ +#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ +# undef __STDC_WANT_IEC_60559_BFP_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ +#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ +# undef __STDC_WANT_IEC_60559_DFP_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ +#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ +# undef __STDC_WANT_IEC_60559_FUNCS_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ +#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +# undef __STDC_WANT_IEC_60559_TYPES_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ +#ifndef __STDC_WANT_LIB_EXT2__ +# undef __STDC_WANT_LIB_EXT2__ +#endif +/* Enable extensions specified by ISO/IEC 24747:2009. */ +#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ +# undef __STDC_WANT_MATH_SPEC_FUNCS__ +#endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ +/* Enable X/Open extensions. Define to 500 only if necessary + to make mbstate_t available. */ +#ifndef _XOPEN_SOURCE +# undef _XOPEN_SOURCE #endif @@ -658,27 +731,12 @@ # endif #endif -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES -/* Define to 1 if on MINIX. */ -#undef _MINIX - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -#undef _POSIX_1_SOURCE - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -#undef _POSIX_SOURCE - /* Force OSX >= 10.7 Lion to use RFC2292 IPv6 socket options */ #undef __APPLE_USE_RFC_3542 @@ -691,7 +749,7 @@ /* Define to `long int' if does not define. */ #undef off_t -/* Define to `int' if does not define. */ +/* Define as a signed integer type capable of holding a process identifier. */ #undef pid_t /* Define to `unsigned int' if does not define. */