You've already forked macports-base
mirror of
https://github.com/macports/macports-base.git
synced 2026-07-12 18:18:43 -07:00
Remove checks for ObjC runtime and foundation
After removal of cflib and tclobjc, there is no code requiring a Objective-C runtime or oundation libraries in base anymore. The autoconf macros PTHREAD_LIBS or PTHREAD_CFLAGS are not used and have no other references in the configure script. Therefore this is now also unused code and can safely be removed.
This commit is contained in:
committed by
Clemens Lang
parent
8d12c7fdad
commit
2fb8f13a3e
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
builtin(include,m4/tcl.m4)
|
||||
builtin(include,m4/pthread.m4)
|
||||
builtin(include,m4/foundation.m4)
|
||||
|
||||
dnl Search for a variable in a list. Run ACTION-IF-FOUND if it is in the list,
|
||||
|
||||
@@ -196,10 +196,7 @@ MP_WERROR
|
||||
MP_COMPILER_ATTRIBUTE_UNUSED
|
||||
MP_COMPILER_ATTRIBUTE_LF_PRIVATE
|
||||
|
||||
# Foundation checks
|
||||
ACX_PTHREAD
|
||||
MP_OBJC_RUNTIME
|
||||
MP_OBJC_FOUNDATION
|
||||
|
||||
MP_PROG_DAEMONDO
|
||||
|
||||
|
||||
@@ -49,394 +49,3 @@ AC_DEFUN([MP_COMPILER_ATTRIBUTE_LF_PRIVATE], [
|
||||
|
||||
AC_DEFINE_UNQUOTED(MP_PRIVATE, $MP_PRIVATE, [Mark private symbols])
|
||||
])
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# MP_OBJC_RUNTIME --
|
||||
#
|
||||
# Determine the default, working Objective C runtime
|
||||
#
|
||||
# Arguments:
|
||||
# None.
|
||||
#
|
||||
# Requires:
|
||||
# none
|
||||
#
|
||||
# Depends:
|
||||
# AC_PROG_OBJC from objc.m4
|
||||
#
|
||||
# Results:
|
||||
#
|
||||
# Adds a --with-objc-runtime switch to configure.
|
||||
# Result is cached.
|
||||
#
|
||||
# Defines one of the following preprocessor macros:
|
||||
# APPLE_RUNTIME GNU_RUNTIME
|
||||
#
|
||||
# Substitutes the following variables:
|
||||
# OBJC_RUNTIME OBJC_RUNTIME_FLAGS OBJC_LIBS
|
||||
# OBJC_PTHREAD_CFLAGS OBJC_PTHREAD_LIBS
|
||||
#------------------------------------------------------------------------
|
||||
AC_DEFUN([MP_OBJC_RUNTIME],[
|
||||
AC_REQUIRE([AC_PROG_OBJC])
|
||||
AC_ARG_WITH(objc-runtime, AS_HELP_STRING([--with-objc-runtime],[Specify either "GNU" or "apple"]), [with_objc_runtime=${withval}])
|
||||
|
||||
if test x"${with_objc_runtime}" != x; then
|
||||
case "${with_objc_runtime}" in
|
||||
GNU)
|
||||
;;
|
||||
apple)
|
||||
;;
|
||||
no)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([${with_objc_runtime} is not a valid argument to --with-objc-runtime. Please specify either "GNU" or "apple"])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
AC_LANG_PUSH([Objective C])
|
||||
|
||||
if test x"${with_objc_runtime}" != x"no"; then
|
||||
|
||||
# Check for common header, objc/objc.h
|
||||
AC_CHECK_HEADERS([objc/objc.h], ,[AC_MSG_ERROR([Can't locate Objective C runtime headers])])
|
||||
|
||||
# Save LIBS & OBJCFLAGS
|
||||
# depending on whether the cache is used,
|
||||
# the variables may or may not be modified.
|
||||
OLD_LIBS="${LIBS}"
|
||||
OLD_OBJCFLAGS="${OBJCFLAGS}"
|
||||
|
||||
# Add -lobjc. The following tests will ensure that the library exists and functions with the detected Objective C compiler
|
||||
LIBS="${LIBS} -lobjc"
|
||||
|
||||
# Test if pthreads are required to link against
|
||||
# libobjc - this is the case on FreeBSD.
|
||||
|
||||
AC_MSG_CHECKING([if linking libobjc requires pthreads])
|
||||
AC_CACHE_VAL(mp_cv_objc_req_pthread, [
|
||||
# First, test if objc links without pthreads
|
||||
# The following uses quadrigraphs
|
||||
# '@<:@' = '['
|
||||
# '@:>@' = ']'
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([
|
||||
#include <objc/objc.h>
|
||||
#include <objc/Object.h>
|
||||
], [
|
||||
Object *obj = @<:@Object alloc@:>@;
|
||||
puts(@<:@obj name@:>@);
|
||||
])
|
||||
], [
|
||||
# Linked without -pthread
|
||||
mp_cv_objc_req_pthread="no"
|
||||
], [
|
||||
# Failed to link without -pthread
|
||||
mp_cv_objc_req_pthread="yes"
|
||||
]
|
||||
)
|
||||
|
||||
# If the above failed, try with pthreads
|
||||
if test x"${mp_cv_objc_req_pthread}" = x"yes"; then
|
||||
LIBS="${LIBS} ${PTHREAD_LIBS}"
|
||||
OBJCFLAGS="${OBJCFLAGS} ${PTHREAD_CFLAGS}"
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([
|
||||
#include <objc/objc.h>
|
||||
#include <objc/Object.h>
|
||||
], [
|
||||
Object *obj = @<:@Object alloc@:>@;
|
||||
puts(@<:@obj name@:>@);
|
||||
])
|
||||
], [
|
||||
# Linked with -lpthread
|
||||
mp_cv_objc_req_pthread="yes"
|
||||
], [
|
||||
# Failed to link against objc at all
|
||||
# This will be caught in the runtime
|
||||
# checks below
|
||||
mp_cv_objc_req_pthread="no"
|
||||
]
|
||||
)
|
||||
fi
|
||||
])
|
||||
AC_MSG_RESULT(${mp_cv_objc_req_pthread})
|
||||
|
||||
if test x"${mp_cv_objc_req_pthread}" = x"no"; then
|
||||
OBJC_LIBS="-lobjc"
|
||||
OBJC_PTHREAD_LIBS="${PTHREAD_LIBS}"
|
||||
OBJC_PTHREAD_CFLAGS="${PTHREAD_CFLAGS}"
|
||||
elif test x"${mp_cv_objc_req_pthread}" = x"yes"; then
|
||||
OBJC_LIBS="-lobjc ${PTHREAD_LIBS}"
|
||||
OBJCFLAGS="${OBJCFLAGS} ${PTHREAD_CFLAGS}"
|
||||
fi
|
||||
|
||||
if test x"${with_objc_runtime}" = x || test x"${with_objc_runtime}" = x"apple"; then
|
||||
AC_MSG_CHECKING([for Apple Objective-C runtime])
|
||||
AC_CACHE_VAL(mp_cv_objc_runtime_apple, [
|
||||
# The following uses quadrigraphs
|
||||
# '@<:@' = '['
|
||||
# '@:>@' = ']'
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([
|
||||
#include <objc/objc.h>
|
||||
#include <objc/objc-api.h>
|
||||
], [
|
||||
id class = objc_lookUpClass("Object");
|
||||
id obj = @<:@class alloc@:>@;
|
||||
puts(@<:@obj name@:>@);
|
||||
])
|
||||
], [
|
||||
mp_cv_objc_runtime_apple="yes"
|
||||
], [
|
||||
mp_cv_objc_runtime_apple="no"
|
||||
]
|
||||
)
|
||||
])
|
||||
AC_MSG_RESULT(${mp_cv_objc_runtime_apple})
|
||||
else
|
||||
mp_cv_objc_runtime_apple="no"
|
||||
fi
|
||||
|
||||
if test x"${with_objc_runtime}" = x || test x"${with_objc_runtime}" = x"GNU"; then
|
||||
AC_MSG_CHECKING([for GNU Objective C runtime])
|
||||
AC_CACHE_VAL(mp_cv_objc_runtime_gnu, [
|
||||
# The following uses quadrigraphs
|
||||
# '@<:@' = '['
|
||||
# '@:>@' = ']'
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([
|
||||
#include <objc/objc.h>
|
||||
], [
|
||||
id class = objc_lookup_class("Object");
|
||||
id obj = @<:@class alloc@:>@;
|
||||
puts(@<:@obj name@:>@);
|
||||
])
|
||||
], [
|
||||
mp_cv_objc_runtime_gnu="yes"
|
||||
], [
|
||||
mp_cv_objc_runtime_gnu="no"
|
||||
]
|
||||
)
|
||||
])
|
||||
AC_MSG_RESULT(${mp_cv_objc_runtime_gnu})
|
||||
else
|
||||
mp_cv_objc_runtime_gnu="no"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# Apple runtime is prefered
|
||||
if test x"${mp_cv_objc_runtime_apple}" = x"yes"; then
|
||||
OBJC_RUNTIME="APPLE_RUNTIME"
|
||||
OBJC_RUNTIME_FLAGS="-fnext-runtime"
|
||||
AC_MSG_NOTICE([Using Apple Objective-C runtime])
|
||||
AC_DEFINE([APPLE_RUNTIME], 1, [Define if using the Apple Objective-C runtime and compiler.])
|
||||
elif test x"${mp_cv_objc_runtime_gnu}" = x"yes"; then
|
||||
OBJC_RUNTIME="GNU_RUNTIME"
|
||||
OBJC_RUNTIME_FLAGS="-fgnu-runtime"
|
||||
AC_MSG_NOTICE([Using GNU Objective-C runtime])
|
||||
AC_DEFINE([GNU_RUNTIME], 1, [Define if using the GNU Objective-C runtime and compiler.])
|
||||
elif test x"${with_objc_runtime}" = x"no"; then
|
||||
OBJC_RUNTIME="none"
|
||||
AC_MSG_NOTICE([Not using Objective-C runtime])
|
||||
else
|
||||
AC_MSG_FAILURE([Could not locate a working Objective-C runtime.])
|
||||
fi
|
||||
|
||||
# Restore LIBS & OBJCFLAGS
|
||||
LIBS="${OLD_LIBS}"
|
||||
OBJCFLAGS="${OLD_OBJCFLAGS}"
|
||||
|
||||
AC_SUBST([OBJC_RUNTIME])
|
||||
AC_SUBST([OBJC_RUNTIME_FLAGS])
|
||||
AC_SUBST([OBJC_LIBS])
|
||||
|
||||
AC_SUBST([OBJC_PTHREAD_LIBS])
|
||||
AC_SUBST([OBJC_PTHREAD_CFLAGS])
|
||||
|
||||
AC_LANG_POP([Objective C])
|
||||
])
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# MP_OBJC_FOUNDATION --
|
||||
#
|
||||
# Find a functional Foundation implementation.
|
||||
# The NeXT Foundation implementation is prefered,
|
||||
# as it is most likely to be the system provided
|
||||
# Foundation.
|
||||
#
|
||||
# Arguments:
|
||||
# None.
|
||||
#
|
||||
# Requires:
|
||||
# OBJC_RUNTIME
|
||||
#
|
||||
# Depends:
|
||||
# AC_PROG_OBJC from objc.m4
|
||||
#
|
||||
# Results:
|
||||
#
|
||||
# Adds a --with-objc-foundation switch to configure.
|
||||
# Result is cached.
|
||||
#
|
||||
# Defines one of the following preprocessor macros:
|
||||
# APPLE_FOUNDATION GNUSTEP_FOUNDATION
|
||||
#
|
||||
# Substitutes the following variables:
|
||||
# OBJC_FOUNDATION OBJC_FOUNDATION_LDFLAGS
|
||||
# OBJC_FOUNDATION_CPPFLAGS OBJC_FOUNDATION_LIBS
|
||||
#------------------------------------------------------------------------
|
||||
AC_DEFUN([MP_OBJC_FOUNDATION],[
|
||||
AC_REQUIRE([AC_PROG_OBJC])
|
||||
AC_ARG_WITH(objc-foundation, [ --with-objc-foundation Specify either "GNUstep" or "apple"], [with_objc_foundation=${withval}])
|
||||
|
||||
if test x"${with_objc_foundation}" != x; then
|
||||
case "${with_objc_foundation}" in
|
||||
GNUstep)
|
||||
;;
|
||||
GNU)
|
||||
with_objc_foundation="GNUstep"
|
||||
;;
|
||||
apple)
|
||||
;;
|
||||
no)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([${with_objc_foundation} is not a valid argument to --with-objc-foundation. Please specify either "GNU" or "apple"])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
AC_LANG_PUSH([Objective C])
|
||||
|
||||
if test x"${with_objc_foundation}" != x"no"; then
|
||||
|
||||
if test x"${with_objc_foundation}" = x || test x"${with_objc_foundation}" = x"apple"; then
|
||||
# '@<:@' = '['
|
||||
# '@:>@' = ']'
|
||||
AC_MSG_CHECKING([for Apple Foundation library])
|
||||
|
||||
# Set NeXT LIBS and CFLAGS
|
||||
APPLE_FOUNDATION_CFLAGS=""
|
||||
APPLE_FOUNDATION_LIBS="-framework Foundation"
|
||||
|
||||
AC_CACHE_VAL(ac_cv_objc_foundation_apple, [
|
||||
# Save old LIBS and CFLAGS
|
||||
LIBS_OLD="${LIBS}"
|
||||
CFLAGS_OLD="${CFLAGS}"
|
||||
|
||||
CFLAGS="${APPLE_FOUNDATION_CFLAGS} ${CFLAGS}"
|
||||
LIBS="${APPLE_FOUNDATION_LIBS} ${LIBS}"
|
||||
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([
|
||||
#include <Foundation/Foundation.h>
|
||||
], [
|
||||
NSString *string = @<:@@<:@NSString alloc@:>@ initWithCString: "Hello World"@:>@;
|
||||
@<:@NSString length@:>@;
|
||||
])
|
||||
],[
|
||||
ac_cv_objc_foundation_apple="yes"
|
||||
],[
|
||||
ac_cv_objc_foundation_apple="no"
|
||||
]
|
||||
)
|
||||
# Restore LIBS and CFLAGS
|
||||
LIBS="${LIBS_OLD}"
|
||||
CFLAGS="${CFLAGS_OLD}"
|
||||
])
|
||||
AC_MSG_RESULT(${ac_cv_objc_foundation_apple})
|
||||
else
|
||||
ac_cv_objc_foundation_apple="no"
|
||||
fi
|
||||
|
||||
if test x"${with_objc_foundation}" = x || test x"${with_objc_foundation}" = x"GNUstep"; then
|
||||
GNUSTEP_CONFIG=/usr/bin/gnustep-config
|
||||
if test ! -x "${GNUSTEP_CONFIG}" -a x"${GNUSTEP_SYSTEM_ROOT}" = x; then
|
||||
if test x"${with_objc_foundation}" = x"GNUstep"; then
|
||||
AC_MSG_ERROR([GNUSTEP_SYSTEM_ROOT is not defined in your environment, preventing the use of GNUstep's Foundation library])
|
||||
else
|
||||
AC_MSG_WARN([GNUSTEP_SYSTEM_ROOT is not defined in your environment, preventing the use of GNUstep's Foundation library])
|
||||
fi
|
||||
else
|
||||
|
||||
AC_MSG_CHECKING([for GNUstep Foundation library])
|
||||
|
||||
# Set GNUstep LDFLAGS, CPPFLAGS, and LIBS
|
||||
if test -x ${GNUSTEP_CONFIG}; then
|
||||
GNUSTEP_LDFLAGS=`sh -c "MAKELEVEL=0 ${GNUSTEP_CONFIG} --objc-libs"`
|
||||
GNUSTEP_CPPFLAGS=`sh -c "MAKELEVEL=0 ${GNUSTEP_CONFIG} --objc-flags"`
|
||||
GNUSTEP_LIBS=`sh -c "MAKELEVEL=0 ${GNUSTEP_CONFIG} --base-libs"`
|
||||
else
|
||||
GNUSTEP_LDFLAGS="-L${GNUSTEP_SYSTEM_ROOT}/Library/Libraries/"
|
||||
GNUSTEP_CPPFLAGS="-I${GNUSTEP_SYSTEM_ROOT}/Library/Headers/"
|
||||
GNUSTEP_LIBS="-lgnustep-base"
|
||||
fi
|
||||
|
||||
AC_CACHE_VAL(ac_cv_objc_foundation_gnustep, [
|
||||
# Save old LDFLAGS, CPPFLAGS, and LIBS
|
||||
LDFLAGS_OLD="${LDFLAGS}"
|
||||
CPPFLAGS_OLD="${CPPFLAGS}"
|
||||
LIBS_OLD="${LIBS}"
|
||||
|
||||
LDFLAGS="${GNUSTEP_LDFLAGS} ${LDFLAGS}"
|
||||
CPPFLAGS="${GNUSTEP_CPPFLAGS} ${CPPFLAGS}"
|
||||
LIBS="${GNUSTEP_LIBS} ${LIBS}"
|
||||
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([
|
||||
#include <Foundation/Foundation.h>
|
||||
], [
|
||||
NSString *string = @<:@@<:@NSString alloc@:>@ initWithCString: "Hello World"@:>@;
|
||||
@<:@NSString length@:>@;
|
||||
])
|
||||
],[
|
||||
ac_cv_objc_foundation_gnustep="yes"
|
||||
],[
|
||||
ac_cv_objc_foundation_gnustep="no"
|
||||
]
|
||||
)
|
||||
# Restore LDFLAGS, CPPFLAGS, and LIBS
|
||||
LDFLAGS="${LDFLAGS_OLD}"
|
||||
CPPFLAGS="${CPPFLAGS_OLD}"
|
||||
LIBS="${LIBS_OLD}"
|
||||
])
|
||||
AC_MSG_RESULT(${ac_cv_objc_foundation_gnustep})
|
||||
fi
|
||||
else
|
||||
ac_cv_objc_foundation_gnustep="no"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# NeXT Foundation is prefered
|
||||
if test x"${ac_cv_objc_foundation_apple}" = x"yes"; then
|
||||
OBJC_FOUNDATION="Apple"
|
||||
OBJC_FOUNDATION_CPPFLAGS="${APPLE_FOUNDATION_CFLAGS}"
|
||||
OBJC_FOUNDATION_LIBS="${APPLE_FOUNDATION_LIBS}"
|
||||
OBJC_FOUNDATION_LDFLAGS=""
|
||||
AC_DEFINE([APPLE_FOUNDATION], 1, [Define if using the Apple Foundation framework])
|
||||
AC_MSG_NOTICE([Using Apple Foundation library])
|
||||
elif test x"${ac_cv_objc_foundation_gnustep}" = x"yes"; then
|
||||
OBJC_FOUNDATION="GNUstep"
|
||||
OBJC_FOUNDATION_CPPFLAGS="${GNUSTEP_CPPFLAGS}"
|
||||
OBJC_FOUNDATION_LIBS="${GNUSTEP_LIBS}"
|
||||
OBJC_FOUNDATION_LDFLAGS="${GNUSTEP_LDFLAGS}"
|
||||
AC_DEFINE([GNUSTEP_FOUNDATION], 1, [Define if using the GNUstep Foundation library])
|
||||
AC_MSG_NOTICE([Using GNUstep Foundation library])
|
||||
elif test x"${with_objc_foundation}" = x"no" || test x"$MACOSX_VERSION" = x; then
|
||||
OBJC_FOUNDATION="none"
|
||||
AC_MSG_NOTICE([Not using Foundation implementation])
|
||||
else
|
||||
AC_MSG_ERROR([Could not find a working Foundation implementation])
|
||||
fi
|
||||
|
||||
AC_SUBST([OBJC_FOUNDATION])
|
||||
AC_SUBST([OBJC_FOUNDATION_LDFLAGS])
|
||||
AC_SUBST([OBJC_FOUNDATION_CPPFLAGS])
|
||||
AC_SUBST([OBJC_FOUNDATION_LIBS])
|
||||
|
||||
AC_LANG_POP([Objective C])
|
||||
])
|
||||
|
||||
-234
@@ -1,234 +0,0 @@
|
||||
dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
dnl
|
||||
dnl Modified from the original version:
|
||||
dnl * Removed pthread-specific CC support
|
||||
dnl * Added FreeBSD specific -pthread/-lpthread flags
|
||||
dnl Notes:
|
||||
dnl * -D_THREAD_SAFE may not be necessary on FreeBSD
|
||||
dnl and elsewhere.
|
||||
dnl - landonf March 25th, 2005
|
||||
dnl
|
||||
dnl This macro figures out how to build C programs using POSIX threads.
|
||||
dnl It sets the PTHREAD_LIBS output variable to the threads library and
|
||||
dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
|
||||
dnl C compiler flags that are needed. (The user can also force certain
|
||||
dnl compiler flags/libs to be tested by setting these environment
|
||||
dnl variables.)
|
||||
dnl
|
||||
dnl NOTE: You are assumed to not only compile your program with these
|
||||
dnl flags, but also link it with them as well. e.g. you should link
|
||||
dnl with $CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
|
||||
dnl $LIBS
|
||||
dnl
|
||||
dnl If you are only building threads programs, you may wish to use
|
||||
dnl these variables in your default LIBS, and CFLAGS:
|
||||
dnl
|
||||
dnl LIBS="$PTHREAD_LIBS $LIBS"
|
||||
dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
dnl
|
||||
dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
|
||||
dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
|
||||
dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||
dnl
|
||||
dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
|
||||
dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
|
||||
dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
|
||||
dnl default action will define HAVE_PTHREAD.
|
||||
dnl
|
||||
dnl Please let the authors know if this macro fails on any platform, or
|
||||
dnl if you have any other suggestions or comments. This macro was based
|
||||
dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
|
||||
dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
|
||||
dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
|
||||
dnl We are also grateful for the helpful feedback of numerous users.
|
||||
dnl
|
||||
dnl @category InstalledPackages
|
||||
dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
|
||||
dnl @version 2005-01-14
|
||||
dnl @license GPLWithACException
|
||||
|
||||
AC_DEFUN([ACX_PTHREAD], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_LANG_PUSH([C])
|
||||
acx_pthread_ok=no
|
||||
|
||||
# We used to check for pthread.h first, but this fails if pthread.h
|
||||
# requires special compiler flags (e.g. on True64 or Sequent).
|
||||
# It gets checked for in the link test anyway.
|
||||
|
||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||
# etcetera environment variables, and if threads linking works using
|
||||
# them:
|
||||
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
|
||||
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
fi
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
fi
|
||||
|
||||
# We must check for the threads library under a number of different
|
||||
# names; the ordering is very important because some systems
|
||||
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
||||
# libraries is broken (non-POSIX).
|
||||
|
||||
# Create a list of thread flags to try. Items starting with a "-" are
|
||||
# C compiler flags, and other items are library names, except for "none"
|
||||
# which indicates that we try without any flags at all, and "pthread-config"
|
||||
# which is a program returning the flags for the Pth emulation library.
|
||||
|
||||
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
|
||||
# individual items follow:
|
||||
|
||||
# pthreads: AIX (must check this before -lpthread)
|
||||
# none: in case threads are in libc; should be tried before -Kthread and
|
||||
# other compiler flags to prevent continual compiler warnings
|
||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
|
||||
# -pthreads: Solaris/gcc
|
||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||
# doesn't hurt to check since this sometimes defines pthreads too;
|
||||
# also defines -D_REENTRANT)
|
||||
# pthread: Linux, etcetera
|
||||
# --thread-safe: KAI C++
|
||||
# pthread-config: use pthread-config program (for GNU Pth library)
|
||||
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*solaris*)
|
||||
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (We need to link with -pthread or
|
||||
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
||||
# 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,
|
||||
# we'll just look for -pthreads and -lpthread first:
|
||||
|
||||
acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
|
||||
;;
|
||||
|
||||
*freebsd*)
|
||||
# freebsd 4 uses -pthread, freebsd 5 uses -lpthread
|
||||
acx_pthread_flags="pthread -pthread"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
for flag in $acx_pthread_flags; do
|
||||
|
||||
case $flag in
|
||||
none)
|
||||
AC_MSG_CHECKING([whether pthreads work without any flags])
|
||||
;;
|
||||
|
||||
-*)
|
||||
AC_MSG_CHECKING([whether pthreads work with $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])
|
||||
PTHREAD_LIBS="-l$flag"
|
||||
;;
|
||||
esac
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# 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>]], [[pthread_t th; pthread_join(th, 0);
|
||||
pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
||||
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ]])],[acx_pthread_ok=yes],[])
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
break;
|
||||
fi
|
||||
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
done
|
||||
fi
|
||||
|
||||
# Various other checks:
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
||||
AC_MSG_CHECKING([for joinable pthread attribute])
|
||||
attr_name=unknown
|
||||
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[int attr=$attr;]])],[attr_name=$attr; break],[])
|
||||
done
|
||||
AC_MSG_RESULT($attr_name)
|
||||
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
|
||||
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
|
||||
[Define to necessary symbol if this constant
|
||||
uses a non-standard name on your system.])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
||||
flag=no
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
|
||||
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
|
||||
esac
|
||||
AC_MSG_RESULT(${flag})
|
||||
if test "x$flag" != xno; then
|
||||
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
||||
fi
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
fi
|
||||
|
||||
AC_SUBST(PTHREAD_LIBS)
|
||||
AC_SUBST(PTHREAD_CFLAGS)
|
||||
|
||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||
if test x"$acx_pthread_ok" = xyes; then
|
||||
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
|
||||
:
|
||||
else
|
||||
acx_pthread_ok=no
|
||||
$2
|
||||
fi
|
||||
AC_LANG_POP([C])
|
||||
])dnl ACX_PTHREAD
|
||||
Reference in New Issue
Block a user