Commit c8bb85b5 authored by Nils Goroll's avatar Nils Goroll Committed by Dridi Boukelmoune

Update autoconf macros

... except for ax_with_curses.m4 which requires PKG_CHECK_EXISTS which,
apparently, cci does not have

should we consider again to not have them and rather require autoconf-archive
be installed?
parent 507ca25e
# =========================================================================== # ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html # https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# =========================================================================== # ===========================================================================
# #
# SYNOPSIS # SYNOPSIS
# #
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
# #
# DESCRIPTION # DESCRIPTION
# #
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given. # force the compiler to issue an error when a bad flag is given.
# #
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
# #
...@@ -27,45 +29,24 @@ ...@@ -27,45 +29,24 @@
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
# #
# This program is free software: you can redistribute it and/or modify it # Copying and distribution of this file, with or without modification, are
# under the terms of the GNU General Public License as published by the # permitted in any medium without royalty provided the copyright notice
# Free Software Foundation, either version 3 of the License, or (at your # and this notice are preserved. This file is offered as-is, without any
# option) any later version. # warranty.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 2 #serial 6
AC_DEFUN([AX_CHECK_COMPILE_FLAG], AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])], [AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])]) [AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)], [m4_default([$2], :)],
[m4_default([$3], :)]) [m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl AS_VAR_POPDEF([CACHEVAR])dnl
......
# =========================================================================== # ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html # https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
# =========================================================================== # ===========================================================================
# #
# SYNOPSIS # SYNOPSIS
...@@ -29,36 +29,16 @@ ...@@ -29,36 +29,16 @@
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
# #
# This program is free software: you can redistribute it and/or modify it # Copying and distribution of this file, with or without modification, are
# under the terms of the GNU General Public License as published by the # permitted in any medium without royalty provided the copyright notice
# Free Software Foundation, either version 3 of the License, or (at your # and this notice are preserved. This file is offered as-is, without any
# option) any later version. # warranty.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 3 #serial 6
AC_DEFUN([AX_CHECK_LINK_FLAG], AC_DEFUN([AX_CHECK_LINK_FLAG],
[AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
ax_check_save_flags=$LDFLAGS ax_check_save_flags=$LDFLAGS
LDFLAGS="$LDFLAGS $4 $1" LDFLAGS="$LDFLAGS $4 $1"
...@@ -66,7 +46,7 @@ AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ ...@@ -66,7 +46,7 @@ AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
[AS_VAR_SET(CACHEVAR,[yes])], [AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])]) [AS_VAR_SET(CACHEVAR,[no])])
LDFLAGS=$ax_check_save_flags]) LDFLAGS=$ax_check_save_flags])
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)], [m4_default([$2], :)],
[m4_default([$3], :)]) [m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl AS_VAR_POPDEF([CACHEVAR])dnl
......
# =========================================================================== # ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_lib_readline.html # https://www.gnu.org/software/autoconf-archive/ax_lib_readline.html
# =========================================================================== # ===========================================================================
# #
# SYNOPSIS # SYNOPSIS
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
# and this notice are preserved. This file is offered as-is, without any # and this notice are preserved. This file is offered as-is, without any
# warranty. # warranty.
#serial 6 #serial 8
AU_ALIAS([VL_LIB_READLINE], [AX_LIB_READLINE]) AU_ALIAS([VL_LIB_READLINE], [AX_LIB_READLINE])
AC_DEFUN([AX_LIB_READLINE], [ AC_DEFUN([AX_LIB_READLINE], [
...@@ -73,7 +73,7 @@ AC_DEFUN([AX_LIB_READLINE], [ ...@@ -73,7 +73,7 @@ AC_DEFUN([AX_LIB_READLINE], [
TRY_LIB="-l$readline_lib -l$termcap_lib" TRY_LIB="-l$readline_lib -l$termcap_lib"
fi fi
LIBS="$ORIG_LIBS $TRY_LIB" LIBS="$ORIG_LIBS $TRY_LIB"
AC_TRY_LINK_FUNC(readline, ax_cv_lib_readline="$TRY_LIB") AC_LINK_IFELSE([AC_LANG_CALL([], [readline])], [ax_cv_lib_readline="$TRY_LIB"])
if test -n "$ax_cv_lib_readline"; then if test -n "$ax_cv_lib_readline"; then
break break
fi fi
...@@ -96,7 +96,7 @@ AC_DEFUN([AX_LIB_READLINE], [ ...@@ -96,7 +96,7 @@ AC_DEFUN([AX_LIB_READLINE], [
AC_CACHE_CHECK([whether readline supports history], AC_CACHE_CHECK([whether readline supports history],
ax_cv_lib_readline_history, [ ax_cv_lib_readline_history, [
ax_cv_lib_readline_history="no" ax_cv_lib_readline_history="no"
AC_TRY_LINK_FUNC(add_history, ax_cv_lib_readline_history="yes") AC_LINK_IFELSE([AC_LANG_CALL([], [add_history])], [ax_cv_lib_readline_history="yes"])
]) ])
if test "$ax_cv_lib_readline_history" = "yes"; then if test "$ax_cv_lib_readline_history" = "yes"; then
AC_DEFINE(HAVE_READLINE_HISTORY, 1, AC_DEFINE(HAVE_READLINE_HISTORY, 1,
......
# =========================================================================== # ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_pthread.html # https://www.gnu.org/software/autoconf-archive/ax_pthread.html
# =========================================================================== # ===========================================================================
# #
# SYNOPSIS # SYNOPSIS
...@@ -14,20 +14,24 @@ ...@@ -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 @@ ...@@ -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
...@@ -67,7 +72,7 @@ ...@@ -67,7 +72,7 @@
# Public License for more details. # Public License for more details.
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <https://www.gnu.org/licenses/>.
# #
# As a special exception, the respective Autoconf Macro's copyright owner # As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure # gives unlimited permission to copy, distribute and modify the configure
...@@ -82,7 +87,7 @@ ...@@ -82,7 +87,7 @@
# 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 23 #serial 31
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [ AC_DEFUN([AX_PTHREAD], [
...@@ -104,6 +109,7 @@ if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ...@@ -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 ...@@ -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"
...@@ -194,14 +202,47 @@ case $host_os in ...@@ -194,14 +202,47 @@ 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
# 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) # 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"], 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 # The presence of a feature test macro requesting re-entrant function
# definitions is, on some systems, a strong hint that pthreads support is # definitions is, on some systems, a strong hint that pthreads support is
...@@ -224,25 +265,86 @@ AS_IF([test "x$ax_pthread_check_macro" = "x--"], ...@@ -224,25 +265,86 @@ AS_IF([test "x$ax_pthread_check_macro" = "x--"],
[ax_pthread_check_cond=0], [ax_pthread_check_cond=0],
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
# Are we compiling with Clang?
AC_CACHE_CHECK([whether $CC is Clang], if test "x$ax_pthread_ok" = "xno"; then
[ax_cv_PTHREAD_CLANG], for ax_pthread_try_flag in $ax_pthread_flags; do
[ax_cv_PTHREAD_CLANG=no
# Note that Autoconf sets GCC=yes for Clang as well as GCC case $ax_pthread_try_flag in
if test "x$GCC" = "xyes"; then none)
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], AC_MSG_CHECKING([whether pthreads work without any flags])
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ ;;
# if defined(__clang__) && defined(__llvm__)
AX_PTHREAD_CC_IS_CLANG *,*)
# endif PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"`
], PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"`
[ax_cv_PTHREAD_CLANG=yes]) AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"])
fi ;;
])
ax_pthread_clang="$ax_cv_PTHREAD_CLANG" -*)
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 <pthread.h>
# 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 # Clang needs special handling, because older versions handle the -pthread
# option in a rather... idiosyncratic way # option in a rather... idiosyncratic way
...@@ -261,11 +363,6 @@ if test "x$ax_pthread_clang" = "xyes"; then ...@@ -261,11 +363,6 @@ if test "x$ax_pthread_clang" = "xyes"; then
# -pthread does define _REENTRANT, and while the Darwin headers # -pthread does define _REENTRANT, and while the Darwin headers
# ignore this macro, third-party headers might not.) # 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 # However, older versions of Clang make a point of warning the user
# that, in an invocation where only linking and no compilation is # that, in an invocation where only linking and no compilation is
# taking place, the -pthread option has no effect ("argument unused # taking place, the -pthread option has no effect ("argument unused
...@@ -294,7 +391,7 @@ if test "x$ax_pthread_clang" = "xyes"; then ...@@ -294,7 +391,7 @@ if test "x$ax_pthread_clang" = "xyes"; then
# step # step
ax_pthread_save_ac_link="$ac_link" ax_pthread_save_ac_link="$ac_link"
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' 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_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_CFLAGS="$CFLAGS"
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do 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 ...@@ -320,78 +417,7 @@ if test "x$ax_pthread_clang" = "xyes"; then
fi # $ax_pthread_clang = yes 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 <pthread.h>
# if $ax_pthread_check_cond
# error "$ax_pthread_check_macro must be defined"
# 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: # Various other checks:
if test "x$ax_pthread_ok" = "xyes"; then if test "x$ax_pthread_ok" = "xyes"; then
...@@ -438,7 +464,8 @@ if test "x$ax_pthread_ok" = "xyes"; then ...@@ -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])
]) ])
...@@ -460,18 +487,28 @@ if test "x$ax_pthread_ok" = "xyes"; then ...@@ -460,18 +487,28 @@ if test "x$ax_pthread_ok" = "xyes"; then
[#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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment