Changeset 26710 for trunk/base/configure


Ignore:
Timestamp:
Jul 4, 2007, 8:48:17 PM (13 years ago)
Author:
landonf@…
Message:

Add missing macro for detecting pthread compiler/linker flags.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/configure

    r26709 r26710  
    696696CFLAGS_QUICHEEATERS
    697697CFLAGS_WERROR
     698acx_pthread_config
     699PTHREAD_LIBS
     700PTHREAD_CFLAGS
    698701OBJCPP
    699702GREP
     
    39923995# Foundation checks
    39933996
     3997
     3998
     3999ac_ext=c
     4000ac_cpp='$CPP $CPPFLAGS'
     4001ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
     4002ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
     4003ac_compiler_gnu=$ac_cv_c_compiler_gnu
     4004
     4005acx_pthread_ok=no
     4006
     4007# We used to check for pthread.h first, but this fails if pthread.h
     4008# requires special compiler flags (e.g. on True64 or Sequent).
     4009# It gets checked for in the link test anyway.
     4010
     4011# First of all, check if the user has set any of the PTHREAD_LIBS,
     4012# etcetera environment variables, and if threads linking works using
     4013# them:
     4014if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
     4015        save_CFLAGS="$CFLAGS"
     4016        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
     4017        save_LIBS="$LIBS"
     4018        LIBS="$PTHREAD_LIBS $LIBS"
     4019        { echo "$as_me:$LINENO: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5
     4020echo $ECHO_N "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... $ECHO_C" >&6; }
     4021        cat >conftest.$ac_ext <<_ACEOF
     4022/* confdefs.h.  */
     4023_ACEOF
     4024cat confdefs.h >>conftest.$ac_ext
     4025cat >>conftest.$ac_ext <<_ACEOF
     4026/* end confdefs.h.  */
     4027
     4028/* Override any GCC internal prototype to avoid an error.
     4029   Use char because int might match the return type of a GCC
     4030   builtin and then its argument prototype would still apply.  */
     4031#ifdef __cplusplus
     4032extern "C"
     4033#endif
     4034char pthread_join ();
     4035int
     4036main ()
     4037{
     4038return pthread_join ();
     4039  ;
     4040  return 0;
     4041}
     4042_ACEOF
     4043rm -f conftest.$ac_objext conftest$ac_exeext
     4044if { (ac_try="$ac_link"
     4045case "(($ac_try" in
     4046  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
     4047  *) ac_try_echo=$ac_try;;
     4048esac
     4049eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
     4050  (eval "$ac_link") 2>conftest.er1
     4051  ac_status=$?
     4052  grep -v '^ *+' conftest.er1 >conftest.err
     4053  rm -f conftest.er1
     4054  cat conftest.err >&5
     4055  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     4056  (exit $ac_status); } && {
     4057         test -z "$ac_c_werror_flag" ||
     4058         test ! -s conftest.err
     4059       } && test -s conftest$ac_exeext &&
     4060       $as_test_x conftest$ac_exeext; then
     4061  acx_pthread_ok=yes
     4062else
     4063  echo "$as_me: failed program was:" >&5
     4064sed 's/^/| /' conftest.$ac_ext >&5
     4065
     4066
     4067fi
     4068
     4069rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
     4070      conftest$ac_exeext conftest.$ac_ext
     4071        { echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
     4072echo "${ECHO_T}$acx_pthread_ok" >&6; }
     4073        if test x"$acx_pthread_ok" = xno; then
     4074                PTHREAD_LIBS=""
     4075                PTHREAD_CFLAGS=""
     4076        fi
     4077        LIBS="$save_LIBS"
     4078        CFLAGS="$save_CFLAGS"
     4079fi
     4080
     4081# We must check for the threads library under a number of different
     4082# names; the ordering is very important because some systems
     4083# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
     4084# libraries is broken (non-POSIX).
     4085
     4086# Create a list of thread flags to try.  Items starting with a "-" are
     4087# C compiler flags, and other items are library names, except for "none"
     4088# which indicates that we try without any flags at all, and "pthread-config"
     4089# which is a program returning the flags for the Pth emulation library.
     4090
     4091acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
     4092
     4093# The ordering *is* (sometimes) important.  Some notes on the
     4094# individual items follow:
     4095
     4096# pthreads: AIX (must check this before -lpthread)
     4097# none: in case threads are in libc; should be tried before -Kthread and
     4098#       other compiler flags to prevent continual compiler warnings
     4099# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
     4100# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
     4101# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
     4102# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
     4103# -pthreads: Solaris/gcc
     4104# -mthreads: Mingw32/gcc, Lynx/gcc
     4105# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
     4106#      doesn't hurt to check since this sometimes defines pthreads too;
     4107#      also defines -D_REENTRANT)
     4108# pthread: Linux, etcetera
     4109# --thread-safe: KAI C++
     4110# pthread-config: use pthread-config program (for GNU Pth library)
     4111
     4112case "${host_cpu}-${host_os}" in
     4113        *solaris*)
     4114
     4115        # On Solaris (at least, for some versions), libc contains stubbed
     4116        # (non-functional) versions of the pthreads routines, so link-based
     4117        # tests will erroneously succeed.  (We need to link with -pthread or
     4118        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
     4119        # a function called by this macro, so we could check for that, but
     4120        # who knows whether they'll stub that too in a future libc.)  So,
     4121        # we'll just look for -pthreads and -lpthread first:
     4122
     4123        acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
     4124        ;;
     4125
     4126        *freebsd*)
     4127        # freebsd 4 uses -pthread, freebsd 5 uses -lpthread
     4128        acx_pthread_flags="pthread -pthread"
     4129        ;;
     4130esac
     4131
     4132if test x"$acx_pthread_ok" = xno; then
     4133for flag in $acx_pthread_flags; do
     4134
     4135        case $flag in
     4136                none)
     4137                { echo "$as_me:$LINENO: checking whether pthreads work without any flags" >&5
     4138echo $ECHO_N "checking whether pthreads work without any flags... $ECHO_C" >&6; }
     4139                ;;
     4140
     4141                -*)
     4142                { echo "$as_me:$LINENO: checking whether pthreads work with $flag" >&5
     4143echo $ECHO_N "checking whether pthreads work with $flag... $ECHO_C" >&6; }
     4144                PTHREAD_CFLAGS="$flag"
     4145                ;;
     4146
     4147                pthread-config)
     4148                # Extract the first word of "pthread-config", so it can be a program name with args.
     4149set dummy pthread-config; ac_word=$2
     4150{ echo "$as_me:$LINENO: checking for $ac_word" >&5
     4151echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
     4152if test "${ac_cv_prog_acx_pthread_config+set}" = set; then
     4153  echo $ECHO_N "(cached) $ECHO_C" >&6
     4154else
     4155  if test -n "$acx_pthread_config"; then
     4156  ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test.
     4157else
     4158as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
     4159for as_dir in $PATH
     4160do
     4161  IFS=$as_save_IFS
     4162  test -z "$as_dir" && as_dir=.
     4163  for ac_exec_ext in '' $ac_executable_extensions; do
     4164  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     4165    ac_cv_prog_acx_pthread_config="yes"
     4166    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     4167    break 2
     4168  fi
     4169done
     4170done
     4171IFS=$as_save_IFS
     4172
     4173  test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no"
     4174fi
     4175fi
     4176acx_pthread_config=$ac_cv_prog_acx_pthread_config
     4177if test -n "$acx_pthread_config"; then
     4178  { echo "$as_me:$LINENO: result: $acx_pthread_config" >&5
     4179echo "${ECHO_T}$acx_pthread_config" >&6; }
     4180else
     4181  { echo "$as_me:$LINENO: result: no" >&5
     4182echo "${ECHO_T}no" >&6; }
     4183fi
     4184
     4185
     4186                if test x"$acx_pthread_config" = xno; then continue; fi
     4187                PTHREAD_CFLAGS="`pthread-config --cflags`"
     4188                PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
     4189                ;;
     4190
     4191                *)
     4192                { echo "$as_me:$LINENO: checking for the pthreads library -l$flag" >&5
     4193echo $ECHO_N "checking for the pthreads library -l$flag... $ECHO_C" >&6; }
     4194                PTHREAD_LIBS="-l$flag"
     4195                ;;
     4196        esac
     4197
     4198        save_LIBS="$LIBS"
     4199        save_CFLAGS="$CFLAGS"
     4200        LIBS="$PTHREAD_LIBS $LIBS"
     4201        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
     4202
     4203        # Check for various functions.  We must include pthread.h,
     4204        # since some functions may be macros.  (On the Sequent, we
     4205        # need a special flag -Kthread to make this header compile.)
     4206        # We check for pthread_join because it is in -lpthread on IRIX
     4207        # while pthread_create is in libc.  We check for pthread_attr_init
     4208        # due to DEC craziness with -lpthreads.  We check for
     4209        # pthread_cleanup_push because it is one of the few pthread
     4210        # functions on Solaris that doesn't have a non-functional libc stub.
     4211        # We try pthread_create on general principles.
     4212        cat >conftest.$ac_ext <<_ACEOF
     4213/* confdefs.h.  */
     4214_ACEOF
     4215cat confdefs.h >>conftest.$ac_ext
     4216cat >>conftest.$ac_ext <<_ACEOF
     4217/* end confdefs.h.  */
     4218#include <pthread.h>
     4219int
     4220main ()
     4221{
     4222pthread_t th; pthread_join(th, 0);
     4223                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
     4224                     pthread_create(0,0,0,0); pthread_cleanup_pop(0);
     4225  ;
     4226  return 0;
     4227}
     4228_ACEOF
     4229rm -f conftest.$ac_objext conftest$ac_exeext
     4230if { (ac_try="$ac_link"
     4231case "(($ac_try" in
     4232  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
     4233  *) ac_try_echo=$ac_try;;
     4234esac
     4235eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
     4236  (eval "$ac_link") 2>conftest.er1
     4237  ac_status=$?
     4238  grep -v '^ *+' conftest.er1 >conftest.err
     4239  rm -f conftest.er1
     4240  cat conftest.err >&5
     4241  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     4242  (exit $ac_status); } && {
     4243         test -z "$ac_c_werror_flag" ||
     4244         test ! -s conftest.err
     4245       } && test -s conftest$ac_exeext &&
     4246       $as_test_x conftest$ac_exeext; then
     4247  acx_pthread_ok=yes
     4248else
     4249  echo "$as_me: failed program was:" >&5
     4250sed 's/^/| /' conftest.$ac_ext >&5
     4251
     4252
     4253fi
     4254
     4255rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
     4256      conftest$ac_exeext conftest.$ac_ext
     4257
     4258        LIBS="$save_LIBS"
     4259        CFLAGS="$save_CFLAGS"
     4260
     4261        { echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
     4262echo "${ECHO_T}$acx_pthread_ok" >&6; }
     4263        if test "x$acx_pthread_ok" = xyes; then
     4264                break;
     4265        fi
     4266
     4267        PTHREAD_LIBS=""
     4268        PTHREAD_CFLAGS=""
     4269done
     4270fi
     4271
     4272# Various other checks:
     4273if test "x$acx_pthread_ok" = xyes; then
     4274        save_LIBS="$LIBS"
     4275        LIBS="$PTHREAD_LIBS $LIBS"
     4276        save_CFLAGS="$CFLAGS"
     4277        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
     4278
     4279        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
     4280        { echo "$as_me:$LINENO: checking for joinable pthread attribute" >&5
     4281echo $ECHO_N "checking for joinable pthread attribute... $ECHO_C" >&6; }
     4282        attr_name=unknown
     4283        for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
     4284            cat >conftest.$ac_ext <<_ACEOF
     4285/* confdefs.h.  */
     4286_ACEOF
     4287cat confdefs.h >>conftest.$ac_ext
     4288cat >>conftest.$ac_ext <<_ACEOF
     4289/* end confdefs.h.  */
     4290#include <pthread.h>
     4291int
     4292main ()
     4293{
     4294int attr=$attr;
     4295  ;
     4296  return 0;
     4297}
     4298_ACEOF
     4299rm -f conftest.$ac_objext conftest$ac_exeext
     4300if { (ac_try="$ac_link"
     4301case "(($ac_try" in
     4302  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
     4303  *) ac_try_echo=$ac_try;;
     4304esac
     4305eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
     4306  (eval "$ac_link") 2>conftest.er1
     4307  ac_status=$?
     4308  grep -v '^ *+' conftest.er1 >conftest.err
     4309  rm -f conftest.er1
     4310  cat conftest.err >&5
     4311  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     4312  (exit $ac_status); } && {
     4313         test -z "$ac_c_werror_flag" ||
     4314         test ! -s conftest.err
     4315       } && test -s conftest$ac_exeext &&
     4316       $as_test_x conftest$ac_exeext; then
     4317  attr_name=$attr; break
     4318else
     4319  echo "$as_me: failed program was:" >&5
     4320sed 's/^/| /' conftest.$ac_ext >&5
     4321
     4322
     4323fi
     4324
     4325rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
     4326      conftest$ac_exeext conftest.$ac_ext
     4327        done
     4328        { echo "$as_me:$LINENO: result: $attr_name" >&5
     4329echo "${ECHO_T}$attr_name" >&6; }
     4330        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
     4331
     4332cat >>confdefs.h <<_ACEOF
     4333#define PTHREAD_CREATE_JOINABLE $attr_name
     4334_ACEOF
     4335
     4336        fi
     4337
     4338        { echo "$as_me:$LINENO: checking if more special flags are required for pthreads" >&5
     4339echo $ECHO_N "checking if more special flags are required for pthreads... $ECHO_C" >&6; }
     4340        flag=no
     4341        case "${host_cpu}-${host_os}" in
     4342            *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
     4343            *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
     4344        esac
     4345        { echo "$as_me:$LINENO: result: ${flag}" >&5
     4346echo "${ECHO_T}${flag}" >&6; }
     4347        if test "x$flag" != xno; then
     4348            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
     4349        fi
     4350
     4351        LIBS="$save_LIBS"
     4352        CFLAGS="$save_CFLAGS"
     4353
     4354fi
     4355
     4356
     4357
     4358
     4359# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
     4360if test x"$acx_pthread_ok" = xyes; then
     4361
     4362cat >>confdefs.h <<\_ACEOF
     4363#define HAVE_PTHREAD 1
     4364_ACEOF
     4365
     4366        :
     4367else
     4368        acx_pthread_ok=no
     4369
     4370fi
     4371ac_ext=c
     4372ac_cpp='$CPP $CPPFLAGS'
     4373ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
     4374ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
     4375ac_compiler_gnu=$ac_cv_c_compiler_gnu
     4376
     4377
     4378
    39944379ac_ext=m
    39954380ac_cpp='$OBJCPP $CPPFLAGS'
     
    1197012355CFLAGS_QUICHEEATERS!$CFLAGS_QUICHEEATERS$ac_delim
    1197112356CFLAGS_WERROR!$CFLAGS_WERROR$ac_delim
     12357acx_pthread_config!$acx_pthread_config$ac_delim
     12358PTHREAD_LIBS!$PTHREAD_LIBS$ac_delim
     12359PTHREAD_CFLAGS!$PTHREAD_CFLAGS$ac_delim
    1197212360OBJCPP!$OBJCPP$ac_delim
    1197312361GREP!$GREP$ac_delim
     
    1198512373HAVE_FRAMEWORK_SYSTEMCONFIGURATION!$HAVE_FRAMEWORK_SYSTEMCONFIGURATION$ac_delim
    1198612374HAVE_FRAMEWORK_IOKIT!$HAVE_FRAMEWORK_IOKIT$ac_delim
    11987 HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER!$HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER$ac_delim
    11988 REPLACEMENT_PROGS!$REPLACEMENT_PROGS$ac_delim
    11989 EXTRA_PROGS!$EXTRA_PROGS$ac_delim
    1199012375_ACEOF
    1199112376
     
    1202912414for ac_last_try in false false false false false :; do
    1203012415  cat >conf$$subs.sed <<_ACEOF
     12416HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER!$HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER$ac_delim
     12417REPLACEMENT_PROGS!$REPLACEMENT_PROGS$ac_delim
     12418EXTRA_PROGS!$EXTRA_PROGS$ac_delim
    1203112419PORTSDIR!$PORTSDIR$ac_delim
    1203212420MPCONFIGDIR!$MPCONFIGDIR$ac_delim
     
    1207812466_ACEOF
    1207912467
    12080   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 47; then
     12468  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 50; then
    1208112469    break
    1208212470  elif $ac_last_try; then
Note: See TracChangeset for help on using the changeset viewer.