Check whether pthreads are available without any options before checking

that -Kpthread is supported. Fixes #470781.
Port to autoconf 2.52.
This commit is contained in:
Martin v. Löwis 2001-10-15 08:06:29 +00:00
parent cdc632cfdb
commit a5f73f9bab
2 changed files with 529 additions and 410 deletions

875
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -152,9 +152,18 @@ AC_MSG_RESULT($with_cxx)
dnl The following fragment works similar to AC_PROG_CXX. dnl The following fragment works similar to AC_PROG_CXX.
dnl It does not fail if CXX is not found, and it is not executed if dnl It does not fail if CXX is not found, and it is not executed if
dnl --with-cxx was given. dnl --without-cxx was given.
dnl Finally, it does not test whether CXX is g++. dnl Finally, it does not test whether CXX is g++.
dnl Autoconf 2.5x does not have AC_PROG_CXX_WORKS anymore
ifdef([AC_PROG_CXX_WORKS],[],
[AC_DEFUN([AC_PROG_CXX_WORKS],
[AC_LANG_PUSH(C++)dnl
_AC_COMPILER_EXEEXT
AC_LANG_POP()
]
)])
if test "$check_cxx" = "yes" if test "$check_cxx" = "yes"
then then
AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound) AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
@ -405,6 +414,36 @@ else
fi fi
fi fi
# On some compilers, pthreads are available without further options
# (e.g. MacOS X). On some of these systems, the compiler will not
# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
# So we have to see first whether pthreads are available without
# options before we can check whether -Kpthread improves anything.
AC_MSG_CHECKING(whether pthreads are available without options)
AC_CACHE_VAL(ac_cv_pthread_is_default,
[AC_TRY_RUN([
#include <pthread.h>
void* routine(void* p){return NULL;}
int main(){
pthread_t p;
if(pthread_create(&p,NULL,routine,NULL)!=0)
return 1;
return 0;
}
],
ac_cv_pthread_is_default=yes,
ac_cv_pthread_is_default=no,
ac_cv_pthread_is_default=no)
])
AC_MSG_RESULT($ac_cv_pthread_is_default)
if test $ac_cv_pthread_is_default = yes
then
ac_cv_kpthread=no
else
# -Kpthread, if available, provides the right #defines # -Kpthread, if available, provides the right #defines
# and linker options to make pthread_create available # and linker options to make pthread_create available
# Some compilers won't report that they do not support -Kpthread, # Some compilers won't report that they do not support -Kpthread,
@ -431,6 +470,7 @@ int main(){
ac_cv_kpthread=no) ac_cv_kpthread=no)
CC="$ac_save_cc"]) CC="$ac_save_cc"])
AC_MSG_RESULT($ac_cv_kpthread) AC_MSG_RESULT($ac_cv_kpthread)
fi
dnl # check for ANSI or K&R ("traditional") preprocessor dnl # check for ANSI or K&R ("traditional") preprocessor
dnl AC_MSG_CHECKING(for C preprocessor type) dnl AC_MSG_CHECKING(for C preprocessor type)
@ -925,6 +965,14 @@ AC_MSG_RESULT($with_threads)
if test "$with_threads" = "no" if test "$with_threads" = "no"
then then
USE_THREAD_MODULE="#" USE_THREAD_MODULE="#"
elif test "$ac_cv_pthread_is_default" = yes
then
AC_DEFINE(WITH_THREAD)
AC_DEFINE(_POSIX_THREADS)
# Defining _REENTRANT on system with POSIX threads should not hurt.
AC_DEFINE(_REENTRANT)
posix_threads=yes
LIBOBJS="$LIBOBJS thread.o"
elif test "$ac_cv_kpthread" = "yes" elif test "$ac_cv_kpthread" = "yes"
then then
CC="$CC -Kpthread" CC="$CC -Kpthread"
@ -1120,7 +1168,7 @@ if test "$ipv6" = "yes"; then
case $i in case $i in
inria) inria)
dnl http://www.kame.net/ dnl http://www.kame.net/
AC_EGREP_CPP(yes, [dnl AC_EGREP_CPP(yes, [
#include <netinet/in.h> #include <netinet/in.h>
#ifdef IPV6_INRIA_VERSION #ifdef IPV6_INRIA_VERSION
yes yes
@ -1130,7 +1178,7 @@ yes
;; ;;
kame) kame)
dnl http://www.kame.net/ dnl http://www.kame.net/
AC_EGREP_CPP(yes, [dnl AC_EGREP_CPP(yes, [
#include <netinet/in.h> #include <netinet/in.h>
#ifdef __KAME__ #ifdef __KAME__
yes yes
@ -1143,7 +1191,7 @@ yes
;; ;;
linux-glibc) linux-glibc)
dnl http://www.v6.linux.or.jp/ dnl http://www.v6.linux.or.jp/
AC_EGREP_CPP(yes, [dnl AC_EGREP_CPP(yes, [
#include <features.h> #include <features.h>
#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)) #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
yes yes
@ -1171,7 +1219,7 @@ yes
fi fi
;; ;;
toshiba) toshiba)
AC_EGREP_CPP(yes, [dnl AC_EGREP_CPP(yes, [
#include <sys/param.h> #include <sys/param.h>
#ifdef _TOSHIBA_INET6 #ifdef _TOSHIBA_INET6
yes yes
@ -1182,7 +1230,7 @@ yes
OPT="-DINET6 $OPT"]) OPT="-DINET6 $OPT"])
;; ;;
v6d) v6d)
AC_EGREP_CPP(yes, [dnl AC_EGREP_CPP(yes, [
#include </usr/local/v6/include/sys/v6config.h> #include </usr/local/v6/include/sys/v6config.h>
#ifdef __V6D__ #ifdef __V6D__
yes yes
@ -1193,7 +1241,7 @@ yes
OPT="-I/usr/local/v6/include $OPT"]) OPT="-I/usr/local/v6/include $OPT"])
;; ;;
zeta) zeta)
AC_EGREP_CPP(yes, [dnl AC_EGREP_CPP(yes, [
#include <sys/param.h> #include <sys/param.h>
#ifdef _ZETA_MINAMI_INET6 #ifdef _ZETA_MINAMI_INET6
yes yes