kopia lustrzana https://github.com/Hamlib/Hamlib
Use newer version, to enable OpenSolaris to find the correct '-pthreads' switch.
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2487 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.9
rodzic
2dc81a0203
commit
918040e720
|
@ -1,6 +1,84 @@
|
||||||
dnl Available from the GNU Autoconf Macro Archive at:
|
# ===========================================================================
|
||||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/acx_pthread.html
|
# http://autoconf-archive.cryp.to/acx_pthread.html
|
||||||
dnl
|
# ===========================================================================
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# This macro figures out how to build C programs using POSIX threads. It
|
||||||
|
# sets the PTHREAD_LIBS output variable to the threads library and linker
|
||||||
|
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
|
||||||
|
# flags that are needed. (The user can also force certain compiler
|
||||||
|
# flags/libs to be tested by setting these environment variables.)
|
||||||
|
#
|
||||||
|
# Also sets PTHREAD_CC to any special C compiler that is needed for
|
||||||
|
# multi-threaded programs (defaults to the value of CC otherwise). (This
|
||||||
|
# is necessary on AIX to use the special cc_r compiler alias.)
|
||||||
|
#
|
||||||
|
# NOTE: You are assumed to not only compile your program with these flags,
|
||||||
|
# but also link it with them as well. e.g. you should link with
|
||||||
|
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
|
||||||
|
#
|
||||||
|
# If you are only building threads programs, you may wish to use these
|
||||||
|
# variables in your default LIBS, CFLAGS, and CC:
|
||||||
|
#
|
||||||
|
# LIBS="$PTHREAD_LIBS $LIBS"
|
||||||
|
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
|
# CC="$PTHREAD_CC"
|
||||||
|
#
|
||||||
|
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
|
||||||
|
# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
|
||||||
|
# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||||
|
#
|
||||||
|
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
|
||||||
|
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
|
||||||
|
# is not found. If ACTION-IF-FOUND is not specified, the default action
|
||||||
|
# will define HAVE_PTHREAD.
|
||||||
|
#
|
||||||
|
# Please let the authors know if this macro fails on any platform, or if
|
||||||
|
# you have any other suggestions or comments. This macro was based on work
|
||||||
|
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
|
||||||
|
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
|
||||||
|
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
|
||||||
|
# grateful for the helpful feedback of numerous users.
|
||||||
|
#
|
||||||
|
# LAST MODIFICATION
|
||||||
|
#
|
||||||
|
# 2008-04-12
|
||||||
|
#
|
||||||
|
# COPYLEFT
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
# option) any later version.
|
||||||
|
#
|
||||||
|
# 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 Macro 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.
|
||||||
|
|
||||||
AC_DEFUN([ACX_PTHREAD], [
|
AC_DEFUN([ACX_PTHREAD], [
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||||
AC_LANG_SAVE
|
AC_LANG_SAVE
|
||||||
|
@ -37,9 +115,10 @@ fi
|
||||||
|
|
||||||
# Create a list of thread flags to try. Items starting with a "-" are
|
# Create a list of thread flags to try. Items starting with a "-" are
|
||||||
# C compiler flags, and other items are library names, except for "none"
|
# C compiler flags, and other items are library names, except for "none"
|
||||||
# which indicates that we try without any flags at all.
|
# 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.
|
||||||
|
|
||||||
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt"
|
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
||||||
|
|
||||||
# The ordering *is* (sometimes) important. Some notes on the
|
# The ordering *is* (sometimes) important. Some notes on the
|
||||||
# individual items follow:
|
# individual items follow:
|
||||||
|
@ -56,21 +135,23 @@ acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -m
|
||||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||||
# doesn't hurt to check since this sometimes defines pthreads too;
|
# doesn't hurt to check since this sometimes defines pthreads too;
|
||||||
# also defines -D_REENTRANT)
|
# also defines -D_REENTRANT)
|
||||||
|
# ... -mt is also the pthreads flag for HP/aCC
|
||||||
# pthread: Linux, etcetera
|
# pthread: Linux, etcetera
|
||||||
# --thread-safe: KAI C++
|
# --thread-safe: KAI C++
|
||||||
|
# pthread-config: use pthread-config program (for GNU Pth library)
|
||||||
|
|
||||||
case "${host_cpu}-${host_os}" in
|
case "${host_cpu}-${host_os}" in
|
||||||
*solaris*)
|
*solaris*)
|
||||||
|
|
||||||
# On Solaris (at least, for some versions), libc contains stubbed
|
# On Solaris (at least, for some versions), libc contains stubbed
|
||||||
# (non-functional) versions of the pthreads routines, so link-based
|
# (non-functional) versions of the pthreads routines, so link-based
|
||||||
# tests will erroneously succeed. (We need to link with -pthread or
|
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
|
||||||
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
||||||
# a function called by this macro, so we could check for that, but
|
# a function called by this macro, so we could check for that, but
|
||||||
# who knows whether they'll stub that too in a future libc.) So,
|
# who knows whether they'll stub that too in a future libc.) So,
|
||||||
# we'll just look for -pthreads and -lpthread first:
|
# we'll just look for -pthreads and -lpthread first:
|
||||||
|
|
||||||
acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
|
acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -87,6 +168,13 @@ for flag in $acx_pthread_flags; do
|
||||||
PTHREAD_CFLAGS="$flag"
|
PTHREAD_CFLAGS="$flag"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
pthread-config)
|
||||||
|
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
|
||||||
|
if test x"$acx_pthread_config" = xno; then continue; fi
|
||||||
|
PTHREAD_CFLAGS="`pthread-config --cflags`"
|
||||||
|
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
AC_MSG_CHECKING([for the pthreads library -l$flag])
|
AC_MSG_CHECKING([for the pthreads library -l$flag])
|
||||||
PTHREAD_LIBS="-l$flag"
|
PTHREAD_LIBS="-l$flag"
|
||||||
|
@ -133,43 +221,40 @@ if test "x$acx_pthread_ok" = xyes; then
|
||||||
save_CFLAGS="$CFLAGS"
|
save_CFLAGS="$CFLAGS"
|
||||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
|
|
||||||
# Detect AIX lossage: threads are created detached by default
|
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
||||||
# and the JOINABLE attribute has a nonstandard name (UNDETACHED).
|
AC_MSG_CHECKING([for joinable pthread attribute])
|
||||||
AC_MSG_CHECKING([for joinable pthread attribute])
|
attr_name=unknown
|
||||||
AC_TRY_LINK([#include <pthread.h>],
|
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||||
[int attr=PTHREAD_CREATE_JOINABLE;],
|
AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
|
||||||
ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
|
[attr_name=$attr; break])
|
||||||
if test x"$ok" = xunknown; then
|
done
|
||||||
AC_TRY_LINK([#include <pthread.h>],
|
AC_MSG_RESULT($attr_name)
|
||||||
[int attr=PTHREAD_CREATE_UNDETACHED;],
|
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
|
||||||
ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
|
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
|
||||||
fi
|
[Define to necessary symbol if this constant
|
||||||
if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
|
uses a non-standard name on your system.])
|
||||||
AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
|
|
||||||
[Define to the necessary symbol if this constant
|
|
||||||
uses a non-standard name on your system.])
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT(${ok})
|
|
||||||
if test x"$ok" = xunknown; then
|
|
||||||
AC_MSG_WARN([we do not know how to create joinable pthreads])
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
||||||
flag=no
|
flag=no
|
||||||
case "${host_cpu}-${host_os}" in
|
case "${host_cpu}-${host_os}" in
|
||||||
*-aix* | *-freebsd*) flag="-D_THREAD_SAFE";;
|
*-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
|
||||||
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
|
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
|
||||||
esac
|
esac
|
||||||
AC_MSG_RESULT(${flag})
|
AC_MSG_RESULT(${flag})
|
||||||
if test "x$flag" != xno; then
|
if test "x$flag" != xno; then
|
||||||
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LIBS="$save_LIBS"
|
LIBS="$save_LIBS"
|
||||||
CFLAGS="$save_CFLAGS"
|
CFLAGS="$save_CFLAGS"
|
||||||
|
|
||||||
# More AIX lossage: must compile with cc_r
|
# More AIX lossage: must compile with xlc_r or cc_r
|
||||||
AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
|
if test x"$GCC" != xyes; then
|
||||||
|
AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
|
||||||
|
else
|
||||||
|
PTHREAD_CC=$CC
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
PTHREAD_CC="$CC"
|
PTHREAD_CC="$CC"
|
||||||
fi
|
fi
|
||||||
|
|
Ładowanie…
Reference in New Issue