From dbea6e6a472ea3e4be176b8a58961e3b953dbd84 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 1 Jul 2021 14:42:49 -0700 Subject: [PATCH] M4 Update 1. Update the m4 files we updated in wolfSSL. 2. Update the configure.ac. --- configure.ac | 4 +- m4/ax_am_jobserver.m4 | 6 +- m4/ax_create_generic_config.m4 | 4 +- m4/ax_harden_compiler_flags.m4 | 110 +++++++------- m4/ax_pthread.m4 | 261 +++++++++++++++++++-------------- m4/ax_vcs_checkout.m4 | 7 +- 6 files changed, 220 insertions(+), 172 deletions(-) diff --git a/configure.ac b/configure.ac index 693d2a42b..44d871c24 100644 --- a/configure.ac +++ b/configure.ac @@ -10,6 +10,7 @@ AC_CONFIG_AUX_DIR([build-aux]) : ${CFLAGS=""} AC_CANONICAL_HOST +AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects no-define color-tests]) @@ -45,8 +46,7 @@ AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL -# Checks for header files. -AC_HEADER_STDC +# Checks for type sizes. AC_CHECK_SIZEOF([long long]) AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([off_t]) diff --git a/m4/ax_am_jobserver.m4 b/m4/ax_am_jobserver.m4 index dfbcdbb2f..7da8d5e71 100644 --- a/m4/ax_am_jobserver.m4 +++ b/m4/ax_am_jobserver.m4 @@ -33,7 +33,9 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 8 +#serial 8.1 +# Local update: Make the increment of enable-jobserver so it isn't executable +# and is more posix syntax. AC_DEFUN([AX_AM_JOBSERVER], [ AC_REQUIRE([AX_COUNT_CPUS]) @@ -45,7 +47,7 @@ AC_DEFUN([AX_AM_JOBSERVER], [ ],, [enable_jobserver=m4_ifval([$1],[$1],[yes])]) if test "x$enable_jobserver" = "xyes"; then enable_jobserver=$CPU_COUNT - ((enable_jobserver++)) + : $((enable_jobserver+=1)) fi m4_pattern_allow(AM_MAKEFLAGS) if test "x$enable_jobserver" != "xno"; then diff --git a/m4/ax_create_generic_config.m4 b/m4/ax_create_generic_config.m4 index 535838f46..59aeee617 100644 --- a/m4/ax_create_generic_config.m4 +++ b/m4/ax_create_generic_config.m4 @@ -9,7 +9,7 @@ # DESCRIPTION # # Creates a generic PACKAGE-config file that has all the things that you -# want, hmm, well, atleast it has --cflags, --version, --libs. Ahhm, did +# want, hmm, well, at least it has --cflags, --version, --libs. Ahhm, did # you see ax_path_generic in the autoconf-archive? ;-) # # this macros saves you all the typing for a pkg-config.in script, you @@ -78,7 +78,7 @@ echo 'package="'$P'"' >>$F echo 'version="'$V'"' >>$F echo 'libs="'$L'"' >>$F echo ' ' >>$F -# in the order of occurence a standard automake Makefile +# in the order of occurrence a standard automake Makefile echo 'prefix="'$prefix'"' >>$F echo 'exec_prefix="'$exec_prefix'"' >>$F echo 'bindir="'$bindir'"' >>$F diff --git a/m4/ax_harden_compiler_flags.m4 b/m4/ax_harden_compiler_flags.m4 index a2067f07d..908855626 100644 --- a/m4/ax_harden_compiler_flags.m4 +++ b/m4/ax_harden_compiler_flags.m4 @@ -60,8 +60,11 @@ # AX_APPEND_COMPILE_FLAGS([-Wlogical-op],,[$ax_append_compile_cflags_extra]) # AX_APPEND_COMPILE_FLAGS([-fstack-check],,[$ax_append_compile_cflags_extra]) -- problems with fastmath stack size checks # AX_APPEND_COMPILE_FLAGS([-floop-parallelize-all],,[$ax_append_compile_cflags_extra]) -- causes RSA verify problem on x64 +# AX_APPEND_COMPILE_FLAGS([-Wunreachable-code],,[$ax_append_compile_cflags_extra]) -- older clang and when gcc had it are buggy +# AX_APPEND_COMPILE_FLAGS([-fPIE],,[$ax_append_compile_cflags_extra]) -- Flag for executables not libraries -#serial 4 +#serial 4.2 +# changes: deleted the clearing of CFLAGS AC_DEFUN([AX_HARDEN_LINKER_FLAGS], [ AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) @@ -100,63 +103,66 @@ ac_cv_warnings_as_errors=no ax_append_compile_cflags_extra= - AX_APPEND_COMPILE_FLAGS([-Werror],[ax_append_compile_cflags_extra]) - AS_IF([test "x$ac_cv_vcs_checkout" = "xyes"], - [AX_APPEND_COMPILE_FLAGS([-Werror],[AM_CFLAGS]) - ac_cv_warnings_as_errors="yes"]) - -dnl The main configure script handles setting the debugging flags. -dnl AS_IF([test "$ax_enable_debug" = "yes"], [ -dnl AX_APPEND_COMPILE_FLAGS([-g],[AM_CFLAGS]) -dnl AX_APPEND_COMPILE_FLAGS([-ggdb],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) -dnl AX_APPEND_COMPILE_FLAGS([-O0],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) -dnl ],[]) - - AX_APPEND_COMPILE_FLAGS([-Wno-pragmas],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - - AX_APPEND_COMPILE_FLAGS([-Wall],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wno-strict-aliasing],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wextra],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wunknown-pragmas],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wthis-test-should-fail],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) + AS_IF([test "$ac_cv_vcs_checkout" = "yes"],[ + AX_APPEND_COMPILE_FLAGS([-Werror]) + ac_cv_warnings_as_errors=yes + ],[ + AX_APPEND_COMPILE_FLAGS([-Werror],[ax_append_compile_cflags_extra]) + ]) + + AS_IF([test "$ax_enable_debug" = "yes"], [ + AX_APPEND_COMPILE_FLAGS([-g]) + AX_APPEND_COMPILE_FLAGS([-ggdb],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-O0],,[$ax_append_compile_cflags_extra]) + ],[]) + + AX_APPEND_COMPILE_FLAGS([-Wno-pragmas],,[$ax_append_compile_cflags_extra]) + + AX_APPEND_COMPILE_FLAGS([-Wall],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wno-strict-aliasing],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wextra],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wunknown-pragmas],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wthis-test-should-fail],,[$ax_append_compile_cflags_extra]) dnl Anything below this comment please keep sorted. - AS_IF([test "x$CC" != "xclang"], - [AX_APPEND_COMPILE_FLAGS([--param=ssp-buffer-size=1],[AM_CFLAGS],[$ax_append_compile_cflags_extra])]) - AX_APPEND_COMPILE_FLAGS([-Waddress],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Warray-bounds],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) + AS_IF([test "$CC" = "clang"],[],[ + AX_APPEND_COMPILE_FLAGS([--param=ssp-buffer-size=1],,[$ax_append_compile_cflags_extra]) + ]) + AX_APPEND_COMPILE_FLAGS([-Waddress],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Warray-bounds],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast],,[$ax_append_compile_cflags_extra]) dnl Not in use -Wc++-compat - AX_APPEND_COMPILE_FLAGS([-Wchar-subscripts],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wcomment],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wfloat-equal],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wformat-security],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wformat=2],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wmaybe-uninitialized],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wmissing-field-initializers],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wmissing-noreturn],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wnested-externs],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wnormalized=id],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Woverride-init],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wpointer-arith],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wpointer-sign],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wredundant-decls],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wshadow],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wsign-compare],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wswitch-enum],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wundef],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wunused],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wunused-result],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wunused-variable],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-Wwrite-strings],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) - AX_APPEND_COMPILE_FLAGS([-fwrapv],[AM_CFLAGS],[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wchar-subscripts],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wcomment],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wfloat-equal],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wformat-security],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wformat=2],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wmaybe-uninitialized],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wmissing-field-initializers],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wmissing-noreturn],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wnested-externs],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wnormalized=id],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Woverride-init],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wpointer-arith],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wpointer-sign],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wredundant-decls],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wshadow],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wsign-compare],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wswitch-enum],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wundef],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wunused],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wunused-result],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wunused-variable],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-Wwrite-strings],,[$ax_append_compile_cflags_extra]) + AX_APPEND_COMPILE_FLAGS([-fwrapv],,[$ax_append_compile_cflags_extra]) AC_LANG_POP ]) AC_DEFUN([AX_HARDEN_CXX_COMPILER_FLAGS], [ + AC_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) AC_REQUIRE([AX_HARDEN_CC_COMPILER_FLAGS]) AC_LANG_PUSH([C++]) diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 index ada7071f2..e5858e50c 100644 --- a/m4/ax_pthread.m4 +++ b/m4/ax_pthread.m4 @@ -14,20 +14,24 @@ # flags that are needed. (The user can also force certain compiler # flags/libs to be tested by setting these environment variables.) # -# Also sets PTHREAD_CC to any special C compiler that is needed for -# multi-threaded programs (defaults to the value of CC otherwise). (This -# is necessary on AIX to use the special cc_r compiler alias.) +# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is +# needed for multi-threaded programs (defaults to the value of CC +# respectively CXX otherwise). (This is necessary on e.g. AIX to use the +# special cc_r/CC_r compiler alias.) # # NOTE: You are assumed to not only compile your program with these flags, # but also to link with them as well. For example, you might link with # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # # If you are only building threaded programs, you may wish to use these # variables in your default LIBS, CFLAGS, and CC: # # LIBS="$PTHREAD_LIBS $LIBS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" # CC="$PTHREAD_CC" +# CXX="$PTHREAD_CXX" # # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to @@ -55,6 +59,7 @@ # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2011 Daniel Richard G. +# Copyright (c) 2019 Marc Stevens # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -82,11 +87,11 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 24 +#serial 30 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ -AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_CANONICAL_TARGET]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_PROG_SED]) AC_LANG_PUSH([C]) @@ -104,6 +109,7 @@ if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) + AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"]) CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) @@ -123,10 +129,12 @@ fi # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. +# Create a list of thread flags to try. Items with a "," contain both +# C compiler flags (before ",") and linker flags (after ","). Other items +# starting with a "-" are C compiler flags, and remaining items are +# library names, except for "none" which indicates that we try without +# any flags at all, and "pthread-config" which is a program returning +# the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" @@ -150,7 +158,7 @@ ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread -- # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) -case $host_os in +case $target_os in freebsd*) @@ -194,20 +202,53 @@ case $host_os in # that too in a future libc.) So we'll check first for the # standard Solaris way of linking pthreads (-mt -lpthread). - ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" + ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags" ;; esac +# Are we compiling with Clang? + +AC_CACHE_CHECK([whether $CC is Clang], + [ax_cv_PTHREAD_CLANG], + [ax_cv_PTHREAD_CLANG=no + # Note that Autoconf sets GCC=yes for Clang as well as GCC + if test "x$GCC" = "xyes"; then + AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], + [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ +# if defined(__clang__) && defined(__llvm__) + AX_PTHREAD_CC_IS_CLANG +# endif + ], + [ax_cv_PTHREAD_CLANG=yes]) + fi + ]) +ax_pthread_clang="$ax_cv_PTHREAD_CLANG" + + # GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) +# Note that for GCC and Clang -pthread generally implies -lpthread, +# except when -nostdlib is passed. +# This is problematic using libtool to build C++ shared libraries with pthread: +# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 +# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 +# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 +# To solve this, first try -pthread together with -lpthread for GCC + AS_IF([test "x$GCC" = "xyes"], - [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) + [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"]) + +# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first + +AS_IF([test "x$ax_pthread_clang" = "xyes"], + [ax_pthread_flags="-pthread,-lpthread -pthread"]) + # The presence of a feature test macro requesting re-entrant function # definitions is, on some systems, a strong hint that pthreads support is # correctly enabled -case $host_os in +case $target_os in darwin* | hpux* | linux* | osf* | solaris*) ax_pthread_check_macro="_REENTRANT" ;; @@ -224,25 +265,86 @@ AS_IF([test "x$ax_pthread_check_macro" = "x--"], [ax_pthread_check_cond=0], [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) -# Are we compiling with Clang? -AC_CACHE_CHECK([whether $CC is Clang], - [ax_cv_PTHREAD_CLANG], - [ax_cv_PTHREAD_CLANG=no - # Note that Autoconf sets GCC=yes for Clang as well as GCC - if test "x$GCC" = "xyes"; then - AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], - [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ -# if defined(__clang__) && defined(__llvm__) - AX_PTHREAD_CC_IS_CLANG -# endif - ], - [ax_cv_PTHREAD_CLANG=yes]) - fi - ]) -ax_pthread_clang="$ax_cv_PTHREAD_CLANG" +if test "x$ax_pthread_ok" = "xno"; then +for ax_pthread_try_flag in $ax_pthread_flags; do + + case $ax_pthread_try_flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + *,*) + PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` + PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` + AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) + PTHREAD_CFLAGS="$ax_pthread_try_flag" + ;; + + pthread-config) + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) + AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) + PTHREAD_LIBS="-l$ax_pthread_try_flag" + ;; + esac + + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include +# if $ax_pthread_check_cond +# error "$ax_pthread_check_macro must be defined" +# endif + static void *some_global = NULL; + static void routine(void *a) + { + /* To avoid any unused-parameter or + unused-but-set-parameter warning. */ + some_global = a; + } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], + [ax_pthread_ok=yes], + []) + + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" + + AC_MSG_RESULT([$ax_pthread_ok]) + AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi -ax_pthread_clang_warning=no # Clang needs special handling, because older versions handle the -pthread # option in a rather... idiosyncratic way @@ -261,11 +363,6 @@ if test "x$ax_pthread_clang" = "xyes"; then # -pthread does define _REENTRANT, and while the Darwin headers # ignore this macro, third-party headers might not.) - PTHREAD_CFLAGS="-pthread" - PTHREAD_LIBS= - - ax_pthread_ok=yes - # However, older versions of Clang make a point of warning the user # that, in an invocation where only linking and no compilation is # taking place, the -pthread option has no effect ("argument unused @@ -294,7 +391,7 @@ if test "x$ax_pthread_clang" = "xyes"; then # step ax_pthread_save_ac_link="$ac_link" ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' - ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` + ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"` ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" ax_pthread_save_CFLAGS="$CFLAGS" for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do @@ -320,78 +417,7 @@ if test "x$ax_pthread_clang" = "xyes"; then fi # $ax_pthread_clang = yes -if test "x$ax_pthread_ok" = "xno"; then -for ax_pthread_try_flag in $ax_pthread_flags; do - - case $ax_pthread_try_flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -mt,pthread) - AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) - PTHREAD_CFLAGS="-mt" - PTHREAD_LIBS="-lpthread" - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) - PTHREAD_CFLAGS="$ax_pthread_try_flag" - ;; - - pthread-config) - AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) - AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) - PTHREAD_LIBS="-l$ax_pthread_try_flag" - ;; - esac - - ax_pthread_save_CFLAGS="$CFLAGS" - ax_pthread_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include -dnl# if $ax_pthread_check_cond -dnl# error "$ax_pthread_check_macro must be defined" -dnl# endif - static void routine(void *a) { a = 0; } - static void *start_routine(void *a) { return a; }], - [pthread_t th; pthread_attr_t attr; - pthread_create(&th, 0, start_routine, 0); - pthread_join(th, 0); - pthread_attr_init(&attr); - pthread_cleanup_push(routine, 0); - pthread_cleanup_pop(0) /* ; */])], - [ax_pthread_ok=yes], - []) - CFLAGS="$ax_pthread_save_CFLAGS" - LIBS="$ax_pthread_save_LIBS" - - AC_MSG_RESULT([$ax_pthread_ok]) - AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi # Various other checks: if test "x$ax_pthread_ok" = "xyes"; then @@ -424,7 +450,7 @@ if test "x$ax_pthread_ok" = "xyes"; then AC_CACHE_CHECK([whether more special flags are required for pthreads], [ax_cv_PTHREAD_SPECIAL_FLAGS], [ax_cv_PTHREAD_SPECIAL_FLAGS=no - case $host_os in + case $target_os in solaris*) ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" ;; @@ -438,7 +464,8 @@ if test "x$ax_pthread_ok" = "xyes"; then AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], [ax_cv_PTHREAD_PRIO_INHERIT], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[int i = PTHREAD_PRIO_INHERIT;]])], + [[int i = PTHREAD_PRIO_INHERIT; + return i;]])], [ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=no]) ]) @@ -453,25 +480,35 @@ if test "x$ax_pthread_ok" = "xyes"; then # More AIX lossage: compile with *_r variant if test "x$GCC" != "xyes"; then - case $host_os in + case $target_os in aix*) AS_CASE(["x/$CC"], [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], [#handle absolute path differently from PATH based program lookup AS_CASE(["x$CC"], [x/*], - [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], - [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) + [ + AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"]) + AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])]) + ], + [ + AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC]) + AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])]) + ] + ) + ]) ;; esac fi fi test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" +test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" AC_SUBST([PTHREAD_LIBS]) AC_SUBST([PTHREAD_CFLAGS]) AC_SUBST([PTHREAD_CC]) +AC_SUBST([PTHREAD_CXX]) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test "x$ax_pthread_ok" = "xyes"; then diff --git a/m4/ax_vcs_checkout.m4 b/m4/ax_vcs_checkout.m4 index 8047b65ec..4636b58ed 100644 --- a/m4/ax_vcs_checkout.m4 +++ b/m4/ax_vcs_checkout.m4 @@ -45,7 +45,10 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#serial 6 +#serial 6.1 +# +# Added tweak for git. The base repo's .git is a directory. Any worktree's +# .git is a file. Use -e to check for either dir or file. AC_DEFUN([AX_VCS_SYSTEM], [AC_PREREQ([2.63])dnl @@ -54,7 +57,7 @@ AC_DEFUN([AX_VCS_SYSTEM], AS_IF([test -d ".bzr"],[ac_cv_vcs_system="bazaar"]) AS_IF([test -d ".svn"],[ac_cv_vcs_system="svn"]) AS_IF([test -d ".hg"],[ac_cv_vcs_system="mercurial"]) - AS_IF([test -d ".git"],[ac_cv_vcs_system="git"]) + AS_IF([test -e ".git"],[ac_cv_vcs_system="git"]) ]) AC_DEFINE_UNQUOTED([VCS_SYSTEM],["$ac_cv_vcs_system"],[VCS system]) ])