Fixes for autoconf to have a clean `./autogen.sh`.

pull/279/head
David Garske 2023-07-10 13:59:28 -07:00
parent 8ca55eae71
commit 2e72da7d75
2 changed files with 164 additions and 143 deletions

View File

@ -15,12 +15,17 @@ AC_CONFIG_AUX_DIR([build-aux])
xxx_ar_flags=$((ar --help) 2>&1) xxx_ar_flags=$((ar --help) 2>&1)
AS_CASE([$xxx_ar_flags],[*'use actual timestamps and uids/gids'*],[: ${AR_FLAGS="Ucru"}]) AS_CASE([$xxx_ar_flags],[*'use actual timestamps and uids/gids'*],[: ${AR_FLAGS="Ucru"}])
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_CANONICAL_HOST AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects no-define color-tests]) AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects no-define color-tests])
AC_ARG_PROGRAM AC_ARG_PROGRAM
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_HEADERS([src/config.h])
WOLFTPM_LIBRARY_VERSION=15:0:0 WOLFTPM_LIBRARY_VERSION=15:0:0
@ -50,13 +55,7 @@ AS_IF([test -n "$CFLAG_VISIBILITY"],
# silent # silent
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_INSTALL
# Checks for header files. # Checks for header files.
AC_HEADER_STDC
AC_CHECK_SIZEOF([long long], 8) AC_CHECK_SIZEOF([long long], 8)
AC_CHECK_SIZEOF([long], 4) AC_CHECK_SIZEOF([long], 4)
@ -142,7 +141,7 @@ fi
AC_MSG_NOTICE([prefix ${prefix}]) AC_MSG_NOTICE([prefix ${prefix}])
WOLFSSL_URL="http://www.wolfssl.com/download.html" WOLFSSL_URL="http://www.wolfssl.com/download.html"
AC_ARG_WITH(wolfcrypt, AC_ARG_WITH(wolfcrypt,
[AC_HELP_STRING([--with-wolfcrypt=PATH], [PATH to wolfssl install (default /usr/local)])], [AS_HELP_STRING([--with-wolfcrypt=PATH], [PATH to wolfssl install (default /usr/local)])],
[ [
if test "x$withval" != "xno" ; then if test "x$withval" != "xno" ; then
if test -d "${withval}/lib" && test -d "${withval}/include"; then if test -d "${withval}/lib" && test -d "${withval}/include"; then
@ -166,25 +165,9 @@ then
LDFLAGS="$LDFLAGS -L${wcpath}/lib" LDFLAGS="$LDFLAGS -L${wcpath}/lib"
CPPFLAGS="$CPPFLAGS -I${wcpath}/include" CPPFLAGS="$CPPFLAGS -I${wcpath}/include"
AC_LIB_HAVE_LINKFLAGS(wolfssl,, AC_CHECK_LIB([wolfssl],[wolfCrypt_Init],,
[ [AC_MSG_ERROR([WolfSSL library not found. You can get it from $WOLFSSL_URL
#include <wolfssl/wolfcrypt/wc_port.h> If its already installed, specify its path using --with-wolfcrypt=/dir or --prefix=/dir])])
],[
wolfCrypt_Init();
])
AM_CONDITIONAL(HAVE_LIBWOLFSSL, [test "x${ac_cv_libwolfssl}" = "xyes"])
AS_IF([test "x${ac_cv_libwolfssl}" = "xyes"],[
save_LIBS="${LIBS}"
LIBS="${LIBS} ${LTLIBWOLFSSL}"
AC_CHECK_FUNCS(wolfCrypt_Cleanup)
LIBS="$save_LIBS"
])
if test "x$ac_cv_libwolfssl" = "xno" && test "x$ENABLED_WOLFCRYPT" != "xno"; then
AC_MSG_ERROR([WolfSSL library not found. You can get it from $WOLFSSL_URL
If it's already installed, specify its path using --with-wolfcrypt=/dir or --prefix=/dir])
fi
else else
AM_CFLAGS="$AM_CFLAGS -DWOLFTPM2_NO_WOLFCRYPT" AM_CFLAGS="$AM_CFLAGS -DWOLFTPM2_NO_WOLFCRYPT"
fi fi
@ -427,6 +410,7 @@ OPTION_FLAGS="$CFLAGS $CPPFLAGS $AM_CFLAGS"
# The following AM_CONDITIONAL statements set flags for use in the Makefiles. # The following AM_CONDITIONAL statements set flags for use in the Makefiles.
AM_CONDITIONAL([HAVE_LIBWOLFSSL], [test "x$ENABLED_WOLFCRYPT" = "xyes"])
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$ENABLED_EXAMPLES" = "xyes"]) AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$ENABLED_EXAMPLES" = "xyes"])
AM_CONDITIONAL([BUILD_WRAPPER], [test "x$ENABLED_WRAPPER" = "xyes"]) AM_CONDITIONAL([BUILD_WRAPPER], [test "x$ENABLED_WRAPPER" = "xyes"])
AM_CONDITIONAL([HAVE_LIBWOLFSSL], [test "x$ENABLED_WOLFCRYPT" = "xyes"]) AM_CONDITIONAL([HAVE_LIBWOLFSSL], [test "x$ENABLED_WOLFCRYPT" = "xyes"])

View File

@ -14,20 +14,24 @@
# flags that are needed. (The user can also force certain compiler # flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.) # flags/libs to be tested by setting these environment variables.)
# #
# Also sets PTHREAD_CC to any special C compiler that is needed for # Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is
# multi-threaded programs (defaults to the value of CC otherwise). (This # needed for multi-threaded programs (defaults to the value of CC
# is necessary on AIX to use the special cc_r compiler alias.) # 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, # 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 # but also to link with them as well. For example, you might link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # $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 # If you are only building threaded programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC: # variables in your default LIBS, CFLAGS, and CC:
# #
# LIBS="$PTHREAD_LIBS $LIBS" # LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC" # CC="$PTHREAD_CC"
# CXX="$PTHREAD_CXX"
# #
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to # has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
@ -55,6 +59,7 @@
# #
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu> # Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG> # Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
# Copyright (c) 2019 Marc Stevens <marc.stevens@cwi.nl>
# #
# This program is free software: you can redistribute it and/or modify it # 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 # 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 # modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well. # exception to the GPL to apply to your modified version as well.
#serial 24 #serial 30
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([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_CC])
AC_REQUIRE([AC_PROG_SED]) AC_REQUIRE([AC_PROG_SED])
AC_LANG_PUSH([C]) 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_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS" ax_pthread_save_LIBS="$LIBS"
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"])
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS" LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_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 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX). # libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are # Create a list of thread flags to try. Items with a "," contain both
# C compiler flags, and other items are library names, except for "none" # C compiler flags (before ",") and linker flags (after ","). Other items
# which indicates that we try without any flags at all, and "pthread-config" # starting with a "-" are C compiler flags, and remaining items are
# which is a program returning the flags for the Pth emulation library. # 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" 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++ # --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library) # pthread-config: use pthread-config program (for GNU Pth library)
case $host_os in case $target_os in
freebsd*) freebsd*)
@ -194,36 +202,10 @@ case $host_os in
# that too in a future libc.) So we'll check first for the # that too in a future libc.) So we'll check first for the
# standard Solaris way of linking pthreads (-mt -lpthread). # 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 esac
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
AS_IF([test "x$GCC" = "xyes"],
[ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
# 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
darwin* | hpux* | linux* | osf* | solaris*)
ax_pthread_check_macro="_REENTRANT"
;;
aix*)
ax_pthread_check_macro="_THREAD_SAFE"
;;
*)
ax_pthread_check_macro="--"
;;
esac
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? # Are we compiling with Clang?
AC_CACHE_CHECK([whether $CC is Clang], AC_CACHE_CHECK([whether $CC is Clang],
@ -242,83 +224,47 @@ AC_CACHE_CHECK([whether $CC is Clang],
]) ])
ax_pthread_clang="$ax_cv_PTHREAD_CLANG" ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
ax_pthread_clang_warning=no
# Clang needs special handling, because older versions handle the -pthread # GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
# option in a rather... idiosyncratic way
if test "x$ax_pthread_clang" = "xyes"; then # 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
# Clang takes -pthread; it has never supported any other flag AS_IF([test "x$GCC" = "xyes"],
[ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"])
# (Note 1: This will need to be revisited if a system that Clang # Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first
# supports has POSIX threads in a separate library. This tends not
# to be the way of modern systems, but it's conceivable.)
# (Note 2: On some systems, notably Darwin, -pthread is not needed AS_IF([test "x$ax_pthread_clang" = "xyes"],
# to get POSIX threads support; the API is always present and [ax_pthread_flags="-pthread,-lpthread -pthread"])
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
# -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 # 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
# However, older versions of Clang make a point of warning the user case $target_os in
# that, in an invocation where only linking and no compilation is darwin* | hpux* | linux* | osf* | solaris*)
# taking place, the -pthread option has no effect ("argument unused ax_pthread_check_macro="_REENTRANT"
# during compilation"). They expect -pthread to be passed in only ;;
# when source code is being compiled.
#
# Problem is, this is at odds with the way Automake and most other
# C build frameworks function, which is that the same flags used in
# compilation (CFLAGS) are also used in linking. Many systems
# supported by AX_PTHREAD require exactly this for POSIX threads
# support, and in fact it is often not straightforward to specify a
# flag that is used only in the compilation phase and not in
# linking. Such a scenario is extremely rare in practice.
#
# Even though use of the -pthread flag in linking would only print
# a warning, this can be a nuisance for well-run software projects
# that build with -Werror. So if the active version of Clang has
# this misfeature, we search for an option to squash it.
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], aix*)
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], ax_pthread_check_macro="_THREAD_SAFE"
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown ;;
# Create an alternate version of $ac_link that compiles and
# links in two steps (.c -> .o, .o -> exe) instead of one
# (.c -> exe), because the warning occurs only in the second
# 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_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
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
ac_link="$ax_pthread_save_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[ac_link="$ax_pthread_2step_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[break])
])
done
ac_link="$ax_pthread_save_ac_link"
CFLAGS="$ax_pthread_save_CFLAGS"
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
])
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in *)
no | unknown) ;; ax_pthread_check_macro="--"
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; ;;
esac esac
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
[ax_pthread_check_cond=0],
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
fi # $ax_pthread_clang = yes
if test "x$ax_pthread_ok" = "xno"; then if test "x$ax_pthread_ok" = "xno"; then
for ax_pthread_try_flag in $ax_pthread_flags; do for ax_pthread_try_flag in $ax_pthread_flags; do
@ -328,10 +274,10 @@ for ax_pthread_try_flag in $ax_pthread_flags; do
AC_MSG_CHECKING([whether pthreads work without any flags]) AC_MSG_CHECKING([whether pthreads work without any flags])
;; ;;
-mt,pthread) *,*)
AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"`
PTHREAD_CFLAGS="-mt" PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"`
PTHREAD_LIBS="-lpthread" AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"])
;; ;;
-*) -*)
@ -368,10 +314,16 @@ for ax_pthread_try_flag in $ax_pthread_flags; do
# We try pthread_create on general principles. # We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h> AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
dnl# if $ax_pthread_check_cond # if $ax_pthread_check_cond
dnl# error "$ax_pthread_check_macro must be defined" # error "$ax_pthread_check_macro must be defined"
dnl# endif # endif
static void routine(void *a) { a = 0; } 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; }], static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr; [pthread_t th; pthread_attr_t attr;
pthread_create(&th, 0, start_routine, 0); pthread_create(&th, 0, start_routine, 0);
@ -393,6 +345,80 @@ dnl# endif
done done
fi fi
# Clang needs special handling, because older versions handle the -pthread
# option in a rather... idiosyncratic way
if test "x$ax_pthread_clang" = "xyes"; then
# Clang takes -pthread; it has never supported any other flag
# (Note 1: This will need to be revisited if a system that Clang
# supports has POSIX threads in a separate library. This tends not
# to be the way of modern systems, but it's conceivable.)
# (Note 2: On some systems, notably Darwin, -pthread is not needed
# to get POSIX threads support; the API is always present and
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
# -pthread does define _REENTRANT, and while the Darwin headers
# ignore this macro, third-party headers might not.)
# 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
# during compilation"). They expect -pthread to be passed in only
# when source code is being compiled.
#
# Problem is, this is at odds with the way Automake and most other
# C build frameworks function, which is that the same flags used in
# compilation (CFLAGS) are also used in linking. Many systems
# supported by AX_PTHREAD require exactly this for POSIX threads
# support, and in fact it is often not straightforward to specify a
# flag that is used only in the compilation phase and not in
# linking. Such a scenario is extremely rare in practice.
#
# Even though use of the -pthread flag in linking would only print
# a warning, this can be a nuisance for well-run software projects
# that build with -Werror. So if the active version of Clang has
# this misfeature, we search for an option to squash it.
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
# Create an alternate version of $ac_link that compiles and
# links in two steps (.c -> .o, .o -> exe) instead of one
# (.c -> exe), because the warning occurs only in the second
# 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_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
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
ac_link="$ax_pthread_save_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[ac_link="$ax_pthread_2step_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[break])
])
done
ac_link="$ax_pthread_save_ac_link"
CFLAGS="$ax_pthread_save_CFLAGS"
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
])
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
no | unknown) ;;
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
esac
fi # $ax_pthread_clang = yes
# Various other checks: # Various other checks:
if test "x$ax_pthread_ok" = "xyes"; then if test "x$ax_pthread_ok" = "xyes"; then
ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_CFLAGS="$CFLAGS"
@ -424,7 +450,7 @@ if test "x$ax_pthread_ok" = "xyes"; then
AC_CACHE_CHECK([whether more special flags are required for pthreads], AC_CACHE_CHECK([whether more special flags are required for pthreads],
[ax_cv_PTHREAD_SPECIAL_FLAGS], [ax_cv_PTHREAD_SPECIAL_FLAGS],
[ax_cv_PTHREAD_SPECIAL_FLAGS=no [ax_cv_PTHREAD_SPECIAL_FLAGS=no
case $host_os in case $target_os in
solaris*) solaris*)
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" 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], AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
[ax_cv_PTHREAD_PRIO_INHERIT], [ax_cv_PTHREAD_PRIO_INHERIT],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_PRIO_INHERIT;]])], [[int i = PTHREAD_PRIO_INHERIT;
return i;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no]) [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 # More AIX lossage: compile with *_r variant
if test "x$GCC" != "xyes"; then if test "x$GCC" != "xyes"; then
case $host_os in case $target_os in
aix*) aix*)
AS_CASE(["x/$CC"], 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], [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 [#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"], AS_CASE(["x$CC"],
[x/*], [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 esac
fi fi
fi fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX"
AC_SUBST([PTHREAD_LIBS]) AC_SUBST([PTHREAD_LIBS])
AC_SUBST([PTHREAD_CFLAGS]) AC_SUBST([PTHREAD_CFLAGS])
AC_SUBST([PTHREAD_CC]) AC_SUBST([PTHREAD_CC])
AC_SUBST([PTHREAD_CXX])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "x$ax_pthread_ok" = "xyes"; then if test "x$ax_pthread_ok" = "xyes"; then