aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-04-24 16:17:53 +0000
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-04-24 16:17:53 +0000
commite4d2c15c8dcb956c6e9bedd6e10b03ed979ae482 (patch)
treeb0aa6192e7d0113a8ed7411dd24447c50375eb8b
parent7f737a3f10d03c8c3a34076c29c3b0556b61f8c4 (diff)
downloadlibmicrohttpd-e4d2c15c8dcb956c6e9bedd6e10b03ed979ae482.tar.gz
libmicrohttpd-e4d2c15c8dcb956c6e9bedd6e10b03ed979ae482.zip
Updated m4 macros to latest versions
-rw-r--r--m4/ax_append_compile_flags.m48
-rw-r--r--m4/ax_append_flag.m430
-rw-r--r--m4/ax_append_link_flags.m48
-rw-r--r--m4/ax_check_compile_flag.m46
-rw-r--r--m4/ax_check_link_flag.m47
-rw-r--r--m4/ax_count_cpus.m4108
-rw-r--r--m4/ax_pthread.m4385
-rw-r--r--m4/pkg.m4217
8 files changed, 510 insertions, 259 deletions
diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4
index dc7b8660..2bb27ef2 100644
--- a/m4/ax_append_compile_flags.m4
+++ b/m4/ax_append_compile_flags.m4
@@ -4,7 +4,7 @@
4# 4#
5# SYNOPSIS 5# SYNOPSIS
6# 6#
7# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS]) 7# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
8# 8#
9# DESCRIPTION 9# DESCRIPTION
10# 10#
@@ -20,6 +20,8 @@
20# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to 20# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
21# force the compiler to issue an error when a bad flag is given. 21# force the compiler to issue an error when a bad flag is given.
22# 22#
23# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
24#
23# NOTE: This macro depends on the AX_APPEND_FLAG and 25# NOTE: This macro depends on the AX_APPEND_FLAG and
24# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with 26# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
25# AX_APPEND_LINK_FLAGS. 27# AX_APPEND_LINK_FLAGS.
@@ -54,12 +56,12 @@
54# modified version of the Autoconf Macro, you may extend this special 56# modified version of the Autoconf Macro, you may extend this special
55# exception to the GPL to apply to your modified version as well. 57# exception to the GPL to apply to your modified version as well.
56 58
57#serial 4 59#serial 5
58 60
59AC_DEFUN([AX_APPEND_COMPILE_FLAGS], 61AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
60[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) 62[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
61AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) 63AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
62for flag in $1; do 64for flag in $1; do
63 AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3]) 65 AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
64done 66done
65])dnl AX_APPEND_COMPILE_FLAGS 67])dnl AX_APPEND_COMPILE_FLAGS
diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4
index 1d38b76f..08f2e07e 100644
--- a/m4/ax_append_flag.m4
+++ b/m4/ax_append_flag.m4
@@ -49,21 +49,23 @@
49# modified version of the Autoconf Macro, you may extend this special 49# modified version of the Autoconf Macro, you may extend this special
50# exception to the GPL to apply to your modified version as well. 50# exception to the GPL to apply to your modified version as well.
51 51
52#serial 2 52#serial 6
53 53
54AC_DEFUN([AX_APPEND_FLAG], 54AC_DEFUN([AX_APPEND_FLAG],
55[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX 55[dnl
56AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl 56AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
57AS_VAR_SET_IF(FLAGS, 57AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
58 [case " AS_VAR_GET(FLAGS) " in 58AS_VAR_SET_IF(FLAGS,[
59 *" $1 "*) 59 AS_CASE([" AS_VAR_GET(FLAGS) "],
60 AC_RUN_LOG([: FLAGS already contains $1]) 60 [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
61 ;; 61 [
62 *) 62 AS_VAR_APPEND(FLAGS,[" $1"])
63 AC_RUN_LOG([: FLAGS="$FLAGS $1"]) 63 AC_RUN_LOG([: FLAGS="$FLAGS"])
64 AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"]) 64 ])
65 ;; 65 ],
66 esac], 66 [
67 [AS_VAR_SET(FLAGS,["$1"])]) 67 AS_VAR_SET(FLAGS,[$1])
68 AC_RUN_LOG([: FLAGS="$FLAGS"])
69 ])
68AS_VAR_POPDEF([FLAGS])dnl 70AS_VAR_POPDEF([FLAGS])dnl
69])dnl AX_APPEND_FLAG 71])dnl AX_APPEND_FLAG
diff --git a/m4/ax_append_link_flags.m4 b/m4/ax_append_link_flags.m4
index c73ddafc..fd70fc72 100644
--- a/m4/ax_append_link_flags.m4
+++ b/m4/ax_append_link_flags.m4
@@ -4,7 +4,7 @@
4# 4#
5# SYNOPSIS 5# SYNOPSIS
6# 6#
7# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS]) 7# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
8# 8#
9# DESCRIPTION 9# DESCRIPTION
10# 10#
@@ -19,6 +19,8 @@
19# EXTRA-FLAGS FLAG". This can for example be used to force the linker to 19# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20# issue an error when a bad flag is given. 20# issue an error when a bad flag is given.
21# 21#
22# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
23#
22# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG. 24# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
23# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS. 25# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
24# 26#
@@ -52,12 +54,12 @@
52# modified version of the Autoconf Macro, you may extend this special 54# modified version of the Autoconf Macro, you may extend this special
53# exception to the GPL to apply to your modified version as well. 55# exception to the GPL to apply to your modified version as well.
54 56
55#serial 4 57#serial 5
56 58
57AC_DEFUN([AX_APPEND_LINK_FLAGS], 59AC_DEFUN([AX_APPEND_LINK_FLAGS],
58[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) 60[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
59AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) 61AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
60for flag in $1; do 62for flag in $1; do
61 AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3]) 63 AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
62done 64done
63])dnl AX_APPEND_LINK_FLAGS 65])dnl AX_APPEND_LINK_FLAGS
diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4
index 51df0c09..ca363971 100644
--- a/m4/ax_check_compile_flag.m4
+++ b/m4/ax_check_compile_flag.m4
@@ -55,10 +55,10 @@
55# modified version of the Autoconf Macro, you may extend this special 55# modified version of the Autoconf Macro, you may extend this special
56# exception to the GPL to apply to your modified version as well. 56# exception to the GPL to apply to your modified version as well.
57 57
58#serial 3 58#serial 4
59 59
60AC_DEFUN([AX_CHECK_COMPILE_FLAG], 60AC_DEFUN([AX_CHECK_COMPILE_FLAG],
61[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX 61[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
62AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl 62AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
63AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ 63AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
64 ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS 64 ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
@@ -67,7 +67,7 @@ AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
67 [AS_VAR_SET(CACHEVAR,[yes])], 67 [AS_VAR_SET(CACHEVAR,[yes])],
68 [AS_VAR_SET(CACHEVAR,[no])]) 68 [AS_VAR_SET(CACHEVAR,[no])])
69 _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) 69 _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
70AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], 70AS_VAR_IF(CACHEVAR,yes,
71 [m4_default([$2], :)], 71 [m4_default([$2], :)],
72 [m4_default([$3], :)]) 72 [m4_default([$3], :)])
73AS_VAR_POPDEF([CACHEVAR])dnl 73AS_VAR_POPDEF([CACHEVAR])dnl
diff --git a/m4/ax_check_link_flag.m4 b/m4/ax_check_link_flag.m4
index db899ddd..eb01a6ce 100644
--- a/m4/ax_check_link_flag.m4
+++ b/m4/ax_check_link_flag.m4
@@ -55,10 +55,11 @@
55# modified version of the Autoconf Macro, you may extend this special 55# modified version of the Autoconf Macro, you may extend this special
56# exception to the GPL to apply to your modified version as well. 56# exception to the GPL to apply to your modified version as well.
57 57
58#serial 3 58#serial 4
59 59
60AC_DEFUN([AX_CHECK_LINK_FLAG], 60AC_DEFUN([AX_CHECK_LINK_FLAG],
61[AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl 61[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
62AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
62AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ 63AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
63 ax_check_save_flags=$LDFLAGS 64 ax_check_save_flags=$LDFLAGS
64 LDFLAGS="$LDFLAGS $4 $1" 65 LDFLAGS="$LDFLAGS $4 $1"
@@ -66,7 +67,7 @@ AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
66 [AS_VAR_SET(CACHEVAR,[yes])], 67 [AS_VAR_SET(CACHEVAR,[yes])],
67 [AS_VAR_SET(CACHEVAR,[no])]) 68 [AS_VAR_SET(CACHEVAR,[no])])
68 LDFLAGS=$ax_check_save_flags]) 69 LDFLAGS=$ax_check_save_flags])
69AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], 70AS_VAR_IF(CACHEVAR,yes,
70 [m4_default([$2], :)], 71 [m4_default([$2], :)],
71 [m4_default([$3], :)]) 72 [m4_default([$3], :)])
72AS_VAR_POPDEF([CACHEVAR])dnl 73AS_VAR_POPDEF([CACHEVAR])dnl
diff --git a/m4/ax_count_cpus.m4 b/m4/ax_count_cpus.m4
index 39b68d32..2f5ba70a 100644
--- a/m4/ax_count_cpus.m4
+++ b/m4/ax_count_cpus.m4
@@ -4,18 +4,21 @@
4# 4#
5# SYNOPSIS 5# SYNOPSIS
6# 6#
7# AX_COUNT_CPUS 7# AX_COUNT_CPUS([ACTION-IF-DETECTED],[ACTION-IF-NOT-DETECTED])
8# 8#
9# DESCRIPTION 9# DESCRIPTION
10# 10#
11# Attempt to count the number of processors present on the machine. If the 11# Attempt to count the number of logical processor cores (including
12# detection fails, then a value of 1 is assumed. 12# virtual and HT cores) currently available to use on the machine and
13# place detected value in CPU_COUNT variable.
13# 14#
14# The value is placed in the CPU_COUNT variable. 15# On successful detection, ACTION-IF-DETECTED is executed if present. If
16# the detection fails, then ACTION-IF-NOT-DETECTED is triggered. The
17# default ACTION-IF-NOT-DETECTED is to set CPU_COUNT to 1.
15# 18#
16# LICENSE 19# LICENSE
17# 20#
18# Copyright (c) 2014 Karlson2k (Evgeny Grin) <k2k@narod.ru> 21# Copyright (c) 2014,2016 Karlson2k (Evgeny Grin) <k2k@narod.ru>
19# Copyright (c) 2012 Brian Aker <brian@tangent.org> 22# Copyright (c) 2012 Brian Aker <brian@tangent.org>
20# Copyright (c) 2008 Michael Paul Bailey <jinxidoru@byu.net> 23# Copyright (c) 2008 Michael Paul Bailey <jinxidoru@byu.net>
21# Copyright (c) 2008 Christophe Tournayre <turn3r@users.sourceforge.net> 24# Copyright (c) 2008 Christophe Tournayre <turn3r@users.sourceforge.net>
@@ -25,42 +28,69 @@
25# and this notice are preserved. This file is offered as-is, without any 28# and this notice are preserved. This file is offered as-is, without any
26# warranty. 29# warranty.
27 30
28#serial 10 31#serial 17
29 32
30 AC_DEFUN([AX_COUNT_CPUS],[ 33 AC_DEFUN([AX_COUNT_CPUS],[dnl
31 AC_REQUIRE([AC_CANONICAL_HOST]) 34 AC_REQUIRE([AC_CANONICAL_HOST])dnl
32 AC_REQUIRE([AC_PROG_EGREP]) 35 AC_REQUIRE([AC_PROG_EGREP])dnl
33 AC_MSG_CHECKING([the number of available CPUs]) 36 AC_MSG_CHECKING([the number of available CPUs])
34 CPU_COUNT="0" 37 CPU_COUNT="0"
35 38
36 AS_CASE([$host_os],[ 39 # Try generic methods
37 *darwin*],[
38 AS_IF([test -x /usr/sbin/sysctl],[
39 sysctl_a=`/usr/sbin/sysctl -a 2>/dev/null| grep -c hw.cpu`
40 AS_IF([test sysctl_a],[
41 CPU_COUNT=`/usr/sbin/sysctl -n hw.ncpu`
42 ])
43 ])],[
44 *linux*],[
45 AS_IF([test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo],[
46 AS_IF([test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo],[
47 CPU_COUNT=`$EGREP -c '^processor' /proc/cpuinfo`
48 ])
49 ])],[
50 *mingw*],[
51 AS_IF([test -n "$NUMBER_OF_PROCESSORS"],[
52 CPU_COUNT="$NUMBER_OF_PROCESSORS"
53 ])],[
54 *cygwin*],[
55 AS_IF([test -n "$NUMBER_OF_PROCESSORS"],[
56 CPU_COUNT="$NUMBER_OF_PROCESSORS"
57 ])
58 ])
59 40
60 AS_IF([test "x$CPU_COUNT" = "x0"],[ 41 # 'getconf' is POSIX utility, '_SC_NPROCESSORS_ONLN' is optional
61 CPU_COUNT="1" 42 CPU_COUNT=`getconf _NPROCESSORS_ONLN 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+'` || CPU_COUNT="0"
62 AC_MSG_RESULT( [unable to detect (assuming 1)] ) 43 AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null]],[[# empty]],[dnl
63 ],[ 44 # 'nproc' is part of GNU Coreutils and is widely available
64 AC_MSG_RESULT( $CPU_COUNT ) 45 CPU_COUNT=`OMP_NUM_THREADS='' nproc 2>/dev/null` || CPU_COUNT=`nproc 2>/dev/null` || CPU_COUNT="0"
65 ]) 46 ])dnl
66 ]) 47
48 AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null]],[[# empty]],[dnl
49 # Try platform-specific preferred methods
50 AS_CASE([[$host_os]],dnl
51 [[*linux*]],[[CPU_COUNT=`lscpu -p 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+,' -c` || CPU_COUNT="0"]],dnl
52 [[*darwin*]],[[CPU_COUNT=`sysctl -n hw.logicalcpu 2>/dev/null` || CPU_COUNT="0"]],dnl
53 [[freebsd*]],[[CPU_COUNT=`sysctl -n kern.smp.cpus 2>/dev/null` || CPU_COUNT="0"]],dnl
54 [[solaris*]],[[CPU_COUNT=`psrinfo 2>/dev/null | $EGREP -e '^@<:@0-9@:>@.*on-line' -c 2>/dev/null` || CPU_COUNT="0"]],dnl
55 [[mingw*]],[[CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+/' -c` || CPU_COUNT="0"]],dnl
56 [[msys*]],[[CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+/' -c` || CPU_COUNT="0"]],dnl
57 [[cygwin*]],[[CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^@<:@0-9@:>@+/' -c` || CPU_COUNT="0"]]dnl
58 )dnl
59 ])dnl
60
61 AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null]],[[# empty]],[dnl
62 # Try less preferred generic method
63 # 'hw.ncpu' exist on many platforms, but not on GNU/Linux
64 CPU_COUNT=`sysctl -n hw.ncpu 2>/dev/null` || CPU_COUNT="0"
65 ])dnl
66
67 AS_IF([[test "$CPU_COUNT" -gt "0" 2>/dev/null]],[[# empty]],[dnl
68 # Try platform-specific fallback methods
69 # They can be less accurate and slower then preferred methods
70 AS_CASE([[$host_os]],dnl
71 [[*linux*]],[[CPU_COUNT=`$EGREP -e '^processor' -c /proc/cpuinfo 2>/dev/null` || CPU_COUNT="0"]],dnl
72 [[*darwin*]],[[CPU_COUNT=`system_profiler SPHardwareDataType 2>/dev/null | $EGREP -i -e 'number of cores:'|cut -d : -f 2 -s|tr -d ' '` || CPU_COUNT="0"]],dnl
73 [[freebsd*]],[[CPU_COUNT=`dmesg 2>/dev/null| $EGREP -e '^cpu@<:@0-9@:>@+: '|sort -u|$EGREP -e '^' -c` || CPU_COUNT="0"]],dnl
74 [[solaris*]],[[CPU_COUNT=`kstat -m cpu_info -s state -p 2>/dev/null | $EGREP -c -e 'on-line'` || \
75 CPU_COUNT=`kstat -m cpu_info 2>/dev/null | $EGREP -c -e 'module: cpu_info'` || CPU_COUNT="0"]],dnl
76 [[mingw*]],[AS_IF([[CPU_COUNT=`reg query 'HKLM\\Hardware\\Description\\System\\CentralProcessor' 2>/dev/null | $EGREP -e '\\\\@<:@0-9@:>@+$' -c`]],dnl
77 [[# empty]],[[test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS"]])],dnl
78 [[msys*]],[[test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS"]],dnl
79 [[cygwin*]],[[test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS"]]dnl
80 )dnl
81 ])dnl
82
83 AS_IF([[test "x$CPU_COUNT" != "x0" && test "$CPU_COUNT" -gt 0 2>/dev/null]],[dnl
84 AC_MSG_RESULT([[$CPU_COUNT]])
85 m4_ifvaln([$1],[$1],)dnl
86 ],[dnl
87 m4_ifval([$2],[dnl
88 AS_UNSET([[CPU_COUNT]])
89 AC_MSG_RESULT([[unable to detect]])
90 $2
91 ], [dnl
92 CPU_COUNT="1"
93 AC_MSG_RESULT([[unable to detect (assuming 1)]])
94 ])dnl
95 ])dnl
96 ])dnl
diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4
index d383ad5c..4c4051ea 100644
--- a/m4/ax_pthread.m4
+++ b/m4/ax_pthread.m4
@@ -19,10 +19,10 @@
19# is necessary on AIX to use the special cc_r compiler alias.) 19# is necessary on AIX to use the special cc_r compiler alias.)
20# 20#
21# NOTE: You are assumed to not only compile your program with these flags, 21# NOTE: You are assumed to not only compile your program with these flags,
22# but also link it with them as well. e.g. you should link with 22# but also to link with them as well. For example, you might link with
23# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS 23# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
24# 24#
25# If you are only building threads programs, you may wish to use these 25# If you are only building threaded programs, you may wish to use these
26# variables in your default LIBS, CFLAGS, and CC: 26# variables in your default LIBS, CFLAGS, and CC:
27# 27#
28# LIBS="$PTHREAD_LIBS $LIBS" 28# LIBS="$PTHREAD_LIBS $LIBS"
@@ -30,8 +30,8 @@
30# CC="$PTHREAD_CC" 30# CC="$PTHREAD_CC"
31# 31#
32# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant 32# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
33# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name 33# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
34# (e.g. PTHREAD_CREATE_UNDETACHED on AIX). 34# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
35# 35#
36# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the 36# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
37# PTHREAD_PRIO_INHERIT symbol is defined when compiling with 37# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
@@ -82,35 +82,40 @@
82# modified version of the Autoconf Macro, you may extend this special 82# modified version of the Autoconf Macro, you may extend this special
83# exception to the GPL to apply to your modified version as well. 83# exception to the GPL to apply to your modified version as well.
84 84
85#serial 21 85#serial 23
86 86
87AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) 87AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
88AC_DEFUN([AX_PTHREAD], [ 88AC_DEFUN([AX_PTHREAD], [
89AC_REQUIRE([AC_CANONICAL_HOST]) 89AC_REQUIRE([AC_CANONICAL_HOST])
90AC_REQUIRE([AC_PROG_CC])
91AC_REQUIRE([AC_PROG_SED])
90AC_LANG_PUSH([C]) 92AC_LANG_PUSH([C])
91ax_pthread_ok=no 93ax_pthread_ok=no
92 94
93# We used to check for pthread.h first, but this fails if pthread.h 95# We used to check for pthread.h first, but this fails if pthread.h
94# requires special compiler flags (e.g. on True64 or Sequent). 96# requires special compiler flags (e.g. on Tru64 or Sequent).
95# It gets checked for in the link test anyway. 97# It gets checked for in the link test anyway.
96 98
97# First of all, check if the user has set any of the PTHREAD_LIBS, 99# First of all, check if the user has set any of the PTHREAD_LIBS,
98# etcetera environment variables, and if threads linking works using 100# etcetera environment variables, and if threads linking works using
99# them: 101# them:
100if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then 102if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
101 save_CFLAGS="$CFLAGS" 103 ax_pthread_save_CC="$CC"
104 ax_pthread_save_CFLAGS="$CFLAGS"
105 ax_pthread_save_LIBS="$LIBS"
106 AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
102 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 107 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
103 save_LIBS="$LIBS"
104 LIBS="$PTHREAD_LIBS $LIBS" 108 LIBS="$PTHREAD_LIBS $LIBS"
105 AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) 109 AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
106 AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes]) 110 AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
107 AC_MSG_RESULT([$ax_pthread_ok]) 111 AC_MSG_RESULT([$ax_pthread_ok])
108 if test x"$ax_pthread_ok" = xno; then 112 if test "x$ax_pthread_ok" = "xno"; then
109 PTHREAD_LIBS="" 113 PTHREAD_LIBS=""
110 PTHREAD_CFLAGS="" 114 PTHREAD_CFLAGS=""
111 fi 115 fi
112 LIBS="$save_LIBS" 116 CC="$ax_pthread_save_CC"
113 CFLAGS="$save_CFLAGS" 117 CFLAGS="$ax_pthread_save_CFLAGS"
118 LIBS="$ax_pthread_save_LIBS"
114fi 119fi
115 120
116# We must check for the threads library under a number of different 121# We must check for the threads library under a number of different
@@ -123,7 +128,7 @@ fi
123# which indicates that we try without any flags at all, and "pthread-config" 128# which indicates that we try without any flags at all, and "pthread-config"
124# which is a program returning the flags for the Pth emulation library. 129# which is a program returning the flags for the Pth emulation library.
125 130
126ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" 131ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
127 132
128# The ordering *is* (sometimes) important. Some notes on the 133# The ordering *is* (sometimes) important. Some notes on the
129# individual items follow: 134# individual items follow:
@@ -132,82 +137,225 @@ ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mt
132# none: in case threads are in libc; should be tried before -Kthread and 137# none: in case threads are in libc; should be tried before -Kthread and
133# other compiler flags to prevent continual compiler warnings 138# other compiler flags to prevent continual compiler warnings
134# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) 139# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
135# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) 140# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
136# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) 141# (Note: HP C rejects this with "bad form for `-t' option")
137# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) 142# -pthreads: Solaris/gcc (Note: HP C also rejects)
138# -pthreads: Solaris/gcc
139# -mthreads: Mingw32/gcc, Lynx/gcc
140# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it 143# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
141# doesn't hurt to check since this sometimes defines pthreads too; 144# doesn't hurt to check since this sometimes defines pthreads and
142# also defines -D_REENTRANT) 145# -D_REENTRANT too), HP C (must be checked before -lpthread, which
143# ... -mt is also the pthreads flag for HP/aCC 146# is present but should not be used directly; and before -mthreads,
147# because the compiler interprets this as "-mt" + "-hreads")
148# -mthreads: Mingw32/gcc, Lynx/gcc
144# pthread: Linux, etcetera 149# pthread: Linux, etcetera
145# --thread-safe: KAI C++ 150# --thread-safe: KAI C++
146# pthread-config: use pthread-config program (for GNU Pth library) 151# pthread-config: use pthread-config program (for GNU Pth library)
147 152
148case ${host_os} in 153case $host_os in
154
155 freebsd*)
156
157 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
158 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
159
160 ax_pthread_flags="-kthread lthread $ax_pthread_flags"
161 ;;
162
163 hpux*)
164
165 # From the cc(1) man page: "[-mt] Sets various -D flags to enable
166 # multi-threading and also sets -lpthread."
167
168 ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
169 ;;
170
171 openedition*)
172
173 # IBM z/OS requires a feature-test macro to be defined in order to
174 # enable POSIX threads at all, so give the user a hint if this is
175 # not set. (We don't define these ourselves, as they can affect
176 # other portions of the system API in unpredictable ways.)
177
178 AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
179 [
180# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
181 AX_PTHREAD_ZOS_MISSING
182# endif
183 ],
184 [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
185 ;;
186
149 solaris*) 187 solaris*)
150 188
151 # On Solaris (at least, for some versions), libc contains stubbed 189 # On Solaris (at least, for some versions), libc contains stubbed
152 # (non-functional) versions of the pthreads routines, so link-based 190 # (non-functional) versions of the pthreads routines, so link-based
153 # tests will erroneously succeed. (We need to link with -pthreads/-mt/ 191 # tests will erroneously succeed. (N.B.: The stubs are missing
154 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather 192 # pthread_cleanup_push, or rather a function called by this macro,
155 # a function called by this macro, so we could check for that, but 193 # so we could check for that, but who knows whether they'll stub
156 # who knows whether they'll stub that too in a future libc.) So, 194 # that too in a future libc.) So we'll check first for the
157 # we'll just look for -pthreads and -lpthread first: 195 # standard Solaris way of linking pthreads (-mt -lpthread).
196
197 ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
198 ;;
199esac
200
201# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
158 202
159 ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" 203AS_IF([test "x$GCC" = "xyes"],
204 [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
205
206# The presence of a feature test macro requesting re-entrant function
207# definitions is, on some systems, a strong hint that pthreads support is
208# correctly enabled
209
210case $host_os in
211 darwin* | hpux* | linux* | osf* | solaris*)
212 ax_pthread_check_macro="_REENTRANT"
160 ;; 213 ;;
161 214
162 darwin*) 215 aix*)
163 ax_pthread_flags="-pthread $ax_pthread_flags" 216 ax_pthread_check_macro="_THREAD_SAFE"
217 ;;
218
219 *)
220 ax_pthread_check_macro="--"
164 ;; 221 ;;
165esac 222esac
223AS_IF([test "x$ax_pthread_check_macro" = "x--"],
224 [ax_pthread_check_cond=0],
225 [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
226
227# Are we compiling with Clang?
228
229AC_CACHE_CHECK([whether $CC is Clang],
230 [ax_cv_PTHREAD_CLANG],
231 [ax_cv_PTHREAD_CLANG=no
232 # Note that Autoconf sets GCC=yes for Clang as well as GCC
233 if test "x$GCC" = "xyes"; then
234 AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
235 [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
236# if defined(__clang__) && defined(__llvm__)
237 AX_PTHREAD_CC_IS_CLANG
238# endif
239 ],
240 [ax_cv_PTHREAD_CLANG=yes])
241 fi
242 ])
243ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
244
245ax_pthread_clang_warning=no
246
247# Clang needs special handling, because older versions handle the -pthread
248# option in a rather... idiosyncratic way
249
250if test "x$ax_pthread_clang" = "xyes"; then
251
252 # Clang takes -pthread; it has never supported any other flag
253
254 # (Note 1: This will need to be revisited if a system that Clang
255 # supports has POSIX threads in a separate library. This tends not
256 # to be the way of modern systems, but it's conceivable.)
257
258 # (Note 2: On some systems, notably Darwin, -pthread is not needed
259 # to get POSIX threads support; the API is always present and
260 # active. We could reasonably leave PTHREAD_CFLAGS empty. But
261 # -pthread does define _REENTRANT, and while the Darwin headers
262 # ignore this macro, third-party headers might not.)
263
264 PTHREAD_CFLAGS="-pthread"
265 PTHREAD_LIBS=
266
267 ax_pthread_ok=yes
268
269 # However, older versions of Clang make a point of warning the user
270 # that, in an invocation where only linking and no compilation is
271 # taking place, the -pthread option has no effect ("argument unused
272 # during compilation"). They expect -pthread to be passed in only
273 # when source code is being compiled.
274 #
275 # Problem is, this is at odds with the way Automake and most other
276 # C build frameworks function, which is that the same flags used in
277 # compilation (CFLAGS) are also used in linking. Many systems
278 # supported by AX_PTHREAD require exactly this for POSIX threads
279 # support, and in fact it is often not straightforward to specify a
280 # flag that is used only in the compilation phase and not in
281 # linking. Such a scenario is extremely rare in practice.
282 #
283 # Even though use of the -pthread flag in linking would only print
284 # a warning, this can be a nuisance for well-run software projects
285 # that build with -Werror. So if the active version of Clang has
286 # this misfeature, we search for an option to squash it.
287
288 AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
289 [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
290 [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
291 # Create an alternate version of $ac_link that compiles and
292 # links in two steps (.c -> .o, .o -> exe) instead of one
293 # (.c -> exe), because the warning occurs only in the second
294 # step
295 ax_pthread_save_ac_link="$ac_link"
296 ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
297 ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
298 ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
299 ax_pthread_save_CFLAGS="$CFLAGS"
300 for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
301 AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
302 CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
303 ac_link="$ax_pthread_save_ac_link"
304 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
305 [ac_link="$ax_pthread_2step_ac_link"
306 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
307 [break])
308 ])
309 done
310 ac_link="$ax_pthread_save_ac_link"
311 CFLAGS="$ax_pthread_save_CFLAGS"
312 AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
313 ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
314 ])
166 315
167# Clang doesn't consider unrecognized options an error unless we specify 316 case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
168# -Werror. We throw in some extra Clang-specific options to ensure that 317 no | unknown) ;;
169# this doesn't happen for GCC, which also accepts -Werror. 318 *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
319 esac
170 320
171AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags]) 321fi # $ax_pthread_clang = yes
172save_CFLAGS="$CFLAGS"
173ax_pthread_extra_flags="-Werror"
174CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
175AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
176 [AC_MSG_RESULT([yes])],
177 [ax_pthread_extra_flags=
178 AC_MSG_RESULT([no])])
179CFLAGS="$save_CFLAGS"
180 322
181if test x"$ax_pthread_ok" = xno; then 323if test "x$ax_pthread_ok" = "xno"; then
182for flag in $ax_pthread_flags; do 324for ax_pthread_try_flag in $ax_pthread_flags; do
183 325
184 case $flag in 326 case $ax_pthread_try_flag in
185 none) 327 none)
186 AC_MSG_CHECKING([whether pthreads work without any flags]) 328 AC_MSG_CHECKING([whether pthreads work without any flags])
187 ;; 329 ;;
188 330
331 -mt,pthread)
332 AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
333 PTHREAD_CFLAGS="-mt"
334 PTHREAD_LIBS="-lpthread"
335 ;;
336
189 -*) 337 -*)
190 AC_MSG_CHECKING([whether pthreads work with $flag]) 338 AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
191 PTHREAD_CFLAGS="$flag" 339 PTHREAD_CFLAGS="$ax_pthread_try_flag"
192 ;; 340 ;;
193 341
194 pthread-config) 342 pthread-config)
195 AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) 343 AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
196 if test x"$ax_pthread_config" = xno; then continue; fi 344 AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
197 PTHREAD_CFLAGS="`pthread-config --cflags`" 345 PTHREAD_CFLAGS="`pthread-config --cflags`"
198 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" 346 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
199 ;; 347 ;;
200 348
201 *) 349 *)
202 AC_MSG_CHECKING([for the pthreads library -l$flag]) 350 AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
203 PTHREAD_LIBS="-l$flag" 351 PTHREAD_LIBS="-l$ax_pthread_try_flag"
204 ;; 352 ;;
205 esac 353 esac
206 354
207 save_LIBS="$LIBS" 355 ax_pthread_save_CFLAGS="$CFLAGS"
208 save_CFLAGS="$CFLAGS" 356 ax_pthread_save_LIBS="$LIBS"
357 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
209 LIBS="$PTHREAD_LIBS $LIBS" 358 LIBS="$PTHREAD_LIBS $LIBS"
210 CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
211 359
212 # Check for various functions. We must include pthread.h, 360 # Check for various functions. We must include pthread.h,
213 # since some functions may be macros. (On the Sequent, we 361 # since some functions may be macros. (On the Sequent, we
@@ -218,7 +366,11 @@ for flag in $ax_pthread_flags; do
218 # pthread_cleanup_push because it is one of the few pthread 366 # pthread_cleanup_push because it is one of the few pthread
219 # functions on Solaris that doesn't have a non-functional libc stub. 367 # functions on Solaris that doesn't have a non-functional libc stub.
220 # We try pthread_create on general principles. 368 # We try pthread_create on general principles.
369
221 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h> 370 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
371# if $ax_pthread_check_cond
372# error "$ax_pthread_check_macro must be defined"
373# endif
222 static void routine(void *a) { a = 0; } 374 static void routine(void *a) { a = 0; }
223 static void *start_routine(void *a) { return a; }], 375 static void *start_routine(void *a) { return a; }],
224 [pthread_t th; pthread_attr_t attr; 376 [pthread_t th; pthread_attr_t attr;
@@ -227,16 +379,14 @@ for flag in $ax_pthread_flags; do
227 pthread_attr_init(&attr); 379 pthread_attr_init(&attr);
228 pthread_cleanup_push(routine, 0); 380 pthread_cleanup_push(routine, 0);
229 pthread_cleanup_pop(0) /* ; */])], 381 pthread_cleanup_pop(0) /* ; */])],
230 [ax_pthread_ok=yes], 382 [ax_pthread_ok=yes],
231 []) 383 [])
232 384
233 LIBS="$save_LIBS" 385 CFLAGS="$ax_pthread_save_CFLAGS"
234 CFLAGS="$save_CFLAGS" 386 LIBS="$ax_pthread_save_LIBS"
235 387
236 AC_MSG_RESULT([$ax_pthread_ok]) 388 AC_MSG_RESULT([$ax_pthread_ok])
237 if test "x$ax_pthread_ok" = xyes; then 389 AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
238 break;
239 fi
240 390
241 PTHREAD_LIBS="" 391 PTHREAD_LIBS=""
242 PTHREAD_CFLAGS="" 392 PTHREAD_CFLAGS=""
@@ -244,71 +394,74 @@ done
244fi 394fi
245 395
246# Various other checks: 396# Various other checks:
247if test "x$ax_pthread_ok" = xyes; then 397if test "x$ax_pthread_ok" = "xyes"; then
248 save_LIBS="$LIBS" 398 ax_pthread_save_CFLAGS="$CFLAGS"
249 LIBS="$PTHREAD_LIBS $LIBS" 399 ax_pthread_save_LIBS="$LIBS"
250 save_CFLAGS="$CFLAGS"
251 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 400 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
401 LIBS="$PTHREAD_LIBS $LIBS"
252 402
253 # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. 403 # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
254 AC_MSG_CHECKING([for joinable pthread attribute]) 404 AC_CACHE_CHECK([for joinable pthread attribute],
255 attr_name=unknown 405 [ax_cv_PTHREAD_JOINABLE_ATTR],
256 for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do 406 [ax_cv_PTHREAD_JOINABLE_ATTR=unknown
257 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], 407 for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
258 [int attr = $attr; return attr /* ; */])], 408 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
259 [attr_name=$attr; break], 409 [int attr = $ax_pthread_attr; return attr /* ; */])],
260 []) 410 [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
261 done 411 [])
262 AC_MSG_RESULT([$attr_name]) 412 done
263 if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then 413 ])
264 AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name], 414 AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
265 [Define to necessary symbol if this constant 415 test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
266 uses a non-standard name on your system.]) 416 test "x$ax_pthread_joinable_attr_defined" != "xyes"],
267 fi 417 [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
268 418 [$ax_cv_PTHREAD_JOINABLE_ATTR],
269 AC_MSG_CHECKING([if more special flags are required for pthreads]) 419 [Define to necessary symbol if this constant
270 flag=no 420 uses a non-standard name on your system.])
271 case ${host_os} in 421 ax_pthread_joinable_attr_defined=yes
272 aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; 422 ])
273 osf* | hpux*) flag="-D_REENTRANT";; 423
274 solaris*) 424 AC_CACHE_CHECK([whether more special flags are required for pthreads],
275 if test "$GCC" = "yes"; then 425 [ax_cv_PTHREAD_SPECIAL_FLAGS],
276 flag="-D_REENTRANT" 426 [ax_cv_PTHREAD_SPECIAL_FLAGS=no
277 else 427 case $host_os in
278 # TODO: What about Clang on Solaris? 428 solaris*)
279 flag="-mt -D_REENTRANT" 429 ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
280 fi 430 ;;
281 ;; 431 esac
282 esac 432 ])
283 AC_MSG_RESULT([$flag]) 433 AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
284 if test "x$flag" != xno; then 434 test "x$ax_pthread_special_flags_added" != "xyes"],
285 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" 435 [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
286 fi 436 ax_pthread_special_flags_added=yes])
287 437
288 AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], 438 AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
289 [ax_cv_PTHREAD_PRIO_INHERIT], [ 439 [ax_cv_PTHREAD_PRIO_INHERIT],
290 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], 440 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
291 [[int i = PTHREAD_PRIO_INHERIT;]])], 441 [[int i = PTHREAD_PRIO_INHERIT;]])],
292 [ax_cv_PTHREAD_PRIO_INHERIT=yes], 442 [ax_cv_PTHREAD_PRIO_INHERIT=yes],
293 [ax_cv_PTHREAD_PRIO_INHERIT=no]) 443 [ax_cv_PTHREAD_PRIO_INHERIT=no])
294 ]) 444 ])
295 AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], 445 AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
296 [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])]) 446 test "x$ax_pthread_prio_inherit_defined" != "xyes"],
447 [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
448 ax_pthread_prio_inherit_defined=yes
449 ])
297 450
298 LIBS="$save_LIBS" 451 CFLAGS="$ax_pthread_save_CFLAGS"
299 CFLAGS="$save_CFLAGS" 452 LIBS="$ax_pthread_save_LIBS"
300 453
301 # More AIX lossage: compile with *_r variant 454 # More AIX lossage: compile with *_r variant
302 if test "x$GCC" != xyes; then 455 if test "x$GCC" != "xyes"; then
303 case $host_os in 456 case $host_os in
304 aix*) 457 aix*)
305 AS_CASE(["x/$CC"], 458 AS_CASE(["x/$CC"],
306 [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], 459 [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
307 [#handle absolute path differently from PATH based program lookup 460 [#handle absolute path differently from PATH based program lookup
308 AS_CASE(["x$CC"], 461 AS_CASE(["x$CC"],
309 [x/*], 462 [x/*],
310 [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], 463 [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
311 [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) 464 [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
312 ;; 465 ;;
313 esac 466 esac
314 fi 467 fi
@@ -321,7 +474,7 @@ AC_SUBST([PTHREAD_CFLAGS])
321AC_SUBST([PTHREAD_CC]) 474AC_SUBST([PTHREAD_CC])
322 475
323# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: 476# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
324if test x"$ax_pthread_ok" = xyes; then 477if test "x$ax_pthread_ok" = "xyes"; then
325 ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) 478 ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
326 : 479 :
327else 480else
diff --git a/m4/pkg.m4 b/m4/pkg.m4
index c5b26b52..82bea96e 100644
--- a/m4/pkg.m4
+++ b/m4/pkg.m4
@@ -1,29 +1,60 @@
1# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- 1dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
2# serial 1 (pkg-config-0.24) 2dnl serial 11 (pkg-config-0.29.1)
3# 3dnl
4# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. 4dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
5# 5dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
6# This program is free software; you can redistribute it and/or modify 6dnl
7# it under the terms of the GNU General Public License as published by 7dnl This program is free software; you can redistribute it and/or modify
8# the Free Software Foundation; either version 2 of the License, or 8dnl it under the terms of the GNU General Public License as published by
9# (at your option) any later version. 9dnl the Free Software Foundation; either version 2 of the License, or
10# 10dnl (at your option) any later version.
11# This program is distributed in the hope that it will be useful, but 11dnl
12# WITHOUT ANY WARRANTY; without even the implied warranty of 12dnl This program is distributed in the hope that it will be useful, but
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13dnl WITHOUT ANY WARRANTY; without even the implied warranty of
14# General Public License for more details. 14dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15# 15dnl General Public License for more details.
16# You should have received a copy of the GNU General Public License 16dnl
17# along with this program; if not, write to the Free Software 17dnl You should have received a copy of the GNU General Public License
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18dnl along with this program; if not, write to the Free Software
19# 19dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20# As a special exception to the GNU General Public License, if you 20dnl 02111-1307, USA.
21# distribute this file as part of a program that contains a 21dnl
22# configuration script generated by Autoconf, you may include it under 22dnl As a special exception to the GNU General Public License, if you
23# the same distribution terms that you use for the rest of that program. 23dnl distribute this file as part of a program that contains a
24 24dnl configuration script generated by Autoconf, you may include it under
25# PKG_PROG_PKG_CONFIG([MIN-VERSION]) 25dnl the same distribution terms that you use for the rest of that
26# ---------------------------------- 26dnl program.
27
28dnl PKG_PREREQ(MIN-VERSION)
29dnl -----------------------
30dnl Since: 0.29
31dnl
32dnl Verify that the version of the pkg-config macros are at least
33dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
34dnl installed version of pkg-config, this checks the developer's version
35dnl of pkg.m4 when generating configure.
36dnl
37dnl To ensure that this macro is defined, also add:
38dnl m4_ifndef([PKG_PREREQ],
39dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
40dnl
41dnl See the "Since" comment for each macro you use to see what version
42dnl of the macros you require.
43m4_defun([PKG_PREREQ],
44[m4_define([PKG_MACROS_VERSION], [0.29.1])
45m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
46 [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
47])dnl PKG_PREREQ
48
49dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
50dnl ----------------------------------
51dnl Since: 0.16
52dnl
53dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
54dnl first found in the path. Checks that the version of pkg-config found
55dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
56dnl used since that's the first version where most current features of
57dnl pkg-config existed.
27AC_DEFUN([PKG_PROG_PKG_CONFIG], 58AC_DEFUN([PKG_PROG_PKG_CONFIG],
28[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) 59[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
29m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) 60m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
@@ -45,18 +76,19 @@ if test -n "$PKG_CONFIG"; then
45 PKG_CONFIG="" 76 PKG_CONFIG=""
46 fi 77 fi
47fi[]dnl 78fi[]dnl
48])# PKG_PROG_PKG_CONFIG 79])dnl PKG_PROG_PKG_CONFIG
49 80
50# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 81dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
51# 82dnl -------------------------------------------------------------------
52# Check to see whether a particular set of modules exists. Similar 83dnl Since: 0.18
53# to PKG_CHECK_MODULES(), but does not set variables or print errors. 84dnl
54# 85dnl Check to see whether a particular set of modules exists. Similar to
55# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 86dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
56# only at the first occurence in configure.ac, so if the first place 87dnl
57# it's called might be skipped (such as if it is within an "if", you 88dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
58# have to call PKG_CHECK_EXISTS manually 89dnl only at the first occurence in configure.ac, so if the first place
59# -------------------------------------------------------------- 90dnl it's called might be skipped (such as if it is within an "if", you
91dnl have to call PKG_CHECK_EXISTS manually
60AC_DEFUN([PKG_CHECK_EXISTS], 92AC_DEFUN([PKG_CHECK_EXISTS],
61[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 93[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
62if test -n "$PKG_CONFIG" && \ 94if test -n "$PKG_CONFIG" && \
@@ -66,8 +98,10 @@ m4_ifvaln([$3], [else
66 $3])dnl 98 $3])dnl
67fi]) 99fi])
68 100
69# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) 101dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
70# --------------------------------------------- 102dnl ---------------------------------------------
103dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
104dnl pkg_failed based on the result.
71m4_define([_PKG_CONFIG], 105m4_define([_PKG_CONFIG],
72[if test -n "$$1"; then 106[if test -n "$$1"; then
73 pkg_cv_[]$1="$$1" 107 pkg_cv_[]$1="$$1"
@@ -79,10 +113,11 @@ m4_define([_PKG_CONFIG],
79 else 113 else
80 pkg_failed=untried 114 pkg_failed=untried
81fi[]dnl 115fi[]dnl
82])# _PKG_CONFIG 116])dnl _PKG_CONFIG
83 117
84# _PKG_SHORT_ERRORS_SUPPORTED 118dnl _PKG_SHORT_ERRORS_SUPPORTED
85# ----------------------------- 119dnl ---------------------------
120dnl Internal check to see if pkg-config supports short errors.
86AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], 121AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
87[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 122[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
88if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then 123if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -90,19 +125,17 @@ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
90else 125else
91 _pkg_short_errors_supported=no 126 _pkg_short_errors_supported=no
92fi[]dnl 127fi[]dnl
93])# _PKG_SHORT_ERRORS_SUPPORTED 128])dnl _PKG_SHORT_ERRORS_SUPPORTED
94 129
95 130
96# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], 131dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
97# [ACTION-IF-NOT-FOUND]) 132dnl [ACTION-IF-NOT-FOUND])
98# 133dnl --------------------------------------------------------------
99# 134dnl Since: 0.4.0
100# Note that if there is a possibility the first call to 135dnl
101# PKG_CHECK_MODULES might not happen, you should be sure to include an 136dnl Note that if there is a possibility the first call to
102# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac 137dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
103# 138dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
104#
105# --------------------------------------------------------------
106AC_DEFUN([PKG_CHECK_MODULES], 139AC_DEFUN([PKG_CHECK_MODULES],
107[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 140[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
108AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl 141AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
@@ -156,16 +189,40 @@ else
156 AC_MSG_RESULT([yes]) 189 AC_MSG_RESULT([yes])
157 $3 190 $3
158fi[]dnl 191fi[]dnl
159])# PKG_CHECK_MODULES 192])dnl PKG_CHECK_MODULES
193
194
195dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
196dnl [ACTION-IF-NOT-FOUND])
197dnl ---------------------------------------------------------------------
198dnl Since: 0.29
199dnl
200dnl Checks for existence of MODULES and gathers its build flags with
201dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
202dnl and VARIABLE-PREFIX_LIBS from --libs.
203dnl
204dnl Note that if there is a possibility the first call to
205dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
206dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
207dnl configure.ac.
208AC_DEFUN([PKG_CHECK_MODULES_STATIC],
209[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
210_save_PKG_CONFIG=$PKG_CONFIG
211PKG_CONFIG="$PKG_CONFIG --static"
212PKG_CHECK_MODULES($@)
213PKG_CONFIG=$_save_PKG_CONFIG[]dnl
214])dnl PKG_CHECK_MODULES_STATIC
160 215
161 216
162# PKG_INSTALLDIR(DIRECTORY) 217dnl PKG_INSTALLDIR([DIRECTORY])
163# ------------------------- 218dnl -------------------------
164# Substitutes the variable pkgconfigdir as the location where a module 219dnl Since: 0.27
165# should install pkg-config .pc files. By default the directory is 220dnl
166# $libdir/pkgconfig, but the default can be changed by passing 221dnl Substitutes the variable pkgconfigdir as the location where a module
167# DIRECTORY. The user can override through the --with-pkgconfigdir 222dnl should install pkg-config .pc files. By default the directory is
168# parameter. 223dnl $libdir/pkgconfig, but the default can be changed by passing
224dnl DIRECTORY. The user can override through the --with-pkgconfigdir
225dnl parameter.
169AC_DEFUN([PKG_INSTALLDIR], 226AC_DEFUN([PKG_INSTALLDIR],
170[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) 227[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
171m4_pushdef([pkg_description], 228m4_pushdef([pkg_description],
@@ -176,16 +233,18 @@ AC_ARG_WITH([pkgconfigdir],
176AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) 233AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
177m4_popdef([pkg_default]) 234m4_popdef([pkg_default])
178m4_popdef([pkg_description]) 235m4_popdef([pkg_description])
179]) dnl PKG_INSTALLDIR 236])dnl PKG_INSTALLDIR
180 237
181 238
182# PKG_NOARCH_INSTALLDIR(DIRECTORY) 239dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
183# ------------------------- 240dnl --------------------------------
184# Substitutes the variable noarch_pkgconfigdir as the location where a 241dnl Since: 0.27
185# module should install arch-independent pkg-config .pc files. By 242dnl
186# default the directory is $datadir/pkgconfig, but the default can be 243dnl Substitutes the variable noarch_pkgconfigdir as the location where a
187# changed by passing DIRECTORY. The user can override through the 244dnl module should install arch-independent pkg-config .pc files. By
188# --with-noarch-pkgconfigdir parameter. 245dnl default the directory is $datadir/pkgconfig, but the default can be
246dnl changed by passing DIRECTORY. The user can override through the
247dnl --with-noarch-pkgconfigdir parameter.
189AC_DEFUN([PKG_NOARCH_INSTALLDIR], 248AC_DEFUN([PKG_NOARCH_INSTALLDIR],
190[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) 249[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
191m4_pushdef([pkg_description], 250m4_pushdef([pkg_description],
@@ -196,13 +255,15 @@ AC_ARG_WITH([noarch-pkgconfigdir],
196AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) 255AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
197m4_popdef([pkg_default]) 256m4_popdef([pkg_default])
198m4_popdef([pkg_description]) 257m4_popdef([pkg_description])
199]) dnl PKG_NOARCH_INSTALLDIR 258])dnl PKG_NOARCH_INSTALLDIR
200 259
201 260
202# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, 261dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
203# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 262dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
204# ------------------------------------------- 263dnl -------------------------------------------
205# Retrieves the value of the pkg-config variable for the given module. 264dnl Since: 0.28
265dnl
266dnl Retrieves the value of the pkg-config variable for the given module.
206AC_DEFUN([PKG_CHECK_VAR], 267AC_DEFUN([PKG_CHECK_VAR],
207[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 268[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
208AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl 269AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
@@ -211,4 +272,4 @@ _PKG_CONFIG([$1], [variable="][$3]["], [$2])
211AS_VAR_COPY([$1], [pkg_cv_][$1]) 272AS_VAR_COPY([$1], [pkg_cv_][$1])
212 273
213AS_VAR_IF([$1], [""], [$5], [$4])dnl 274AS_VAR_IF([$1], [""], [$5], [$4])dnl
214])# PKG_CHECK_VAR 275])dnl PKG_CHECK_VAR