summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcls%seawood.org <devnull@localhost>2001-01-27 22:47:09 +0000
committercls%seawood.org <devnull@localhost>2001-01-27 22:47:09 +0000
commita0ba75ca5595c82dd58ba2abb686c47e05abd200 (patch)
treec4f940a75535f0e71af4c376787582932607d5c6
parent0e9a9344adc70e0ff3991afec495edf28b9dbf4d (diff)
downloadnspr-hg-a0ba75ca5595c82dd58ba2abb686c47e05abd200.tar.gz
Create MOZ_CHECK_PTHREADS() macro that compiles a small test case using <pthread.h> so that systems like hpux & osf/1 will properly detect pthreads.
-rwxr-xr-xconfigure263
-rw-r--r--configure.in42
2 files changed, 138 insertions, 167 deletions
diff --git a/configure b/configure
index c5182bae..fe9dd43e 100755
--- a/configure
+++ b/configure
@@ -3714,171 +3714,110 @@ done
-echo $ac_n "checking for pthread_attr_init in -lpthreads""... $ac_c" 1>&6
-echo "configure:3719: checking for pthread_attr_init in -lpthreads" >&5
-ac_lib_var=`echo pthreads'_'pthread_attr_init | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lpthreads $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3727 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char pthread_attr_init();
-
-int main() {
-pthread_attr_init()
-; return 0; }
-EOF
-if { (eval echo configure:3738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads"
-else
- echo "$ac_t""no" 1>&6
-echo $ac_n "checking for pthread_attr_init in -lpthread""... $ac_c" 1>&6
-echo "configure:3757: checking for pthread_attr_init in -lpthread" >&5
-ac_lib_var=`echo pthread'_'pthread_attr_init | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lpthread $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3765 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char pthread_attr_init();
-
-int main() {
-pthread_attr_init()
-; return 0; }
-EOF
-if { (eval echo configure:3776: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread"
-else
- echo "$ac_t""no" 1>&6
-echo $ac_n "checking for pthread_attr_init in -lc_r""... $ac_c" 1>&6
-echo "configure:3795: checking for pthread_attr_init in -lc_r" >&5
-ac_lib_var=`echo c_r'_'pthread_attr_init | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lc_r $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3803 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char pthread_attr_init();
-int main() {
-pthread_attr_init()
-; return 0; }
-EOF
-if { (eval echo configure:3814: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r"
-else
- echo "$ac_t""no" 1>&6
-echo $ac_n "checking for pthread_attr_init in -lc""... $ac_c" 1>&6
-echo "configure:3833: checking for pthread_attr_init in -lc" >&5
-ac_lib_var=`echo c'_'pthread_attr_init | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lc $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3841 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char pthread_attr_init();
-int main() {
-pthread_attr_init()
-; return 0; }
-EOF
-if { (eval echo configure:3852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- _HAVE_PTHREADS=1
+echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
+echo "configure:3722: checking for pthread_create in -lpthreads" >&5
+echo "
+ #include <pthread.h>
+ void *foo(void *v) { int a = 1; }
+ int main() {
+ pthread_t t;
+ if (!pthread_create(&t, 0, &foo, 0)) {
+ pthread_join(t, 0);
+ }
+ exit(0);
+ }" > dummy.c ;
+ echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthreads $LDFLAGS $LIBS" 1>&5;
+ ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthreads $LDFLAGS $LIBS 2>&5;
+ _res=$? ;
+ rm -f dummy.c dummy${ac_exeext} ;
+ if test "$_res" = "0"; then
+ echo "$ac_t""yes" 1>&6
+ _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads"
+ else
+ echo "$ac_t""no" 1>&6
+
+echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
+echo "configure:3744: checking for pthread_create in -lpthread" >&5
+echo "
+ #include <pthread.h>
+ void *foo(void *v) { int a = 1; }
+ int main() {
+ pthread_t t;
+ if (!pthread_create(&t, 0, &foo, 0)) {
+ pthread_join(t, 0);
+ }
+ exit(0);
+ }" > dummy.c ;
+ echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthread $LDFLAGS $LIBS" 1>&5;
+ ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthread $LDFLAGS $LIBS 2>&5;
+ _res=$? ;
+ rm -f dummy.c dummy${ac_exeext} ;
+ if test "$_res" = "0"; then
+ echo "$ac_t""yes" 1>&6
+ _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread"
+ else
+ echo "$ac_t""no" 1>&6
+
+echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
+echo "configure:3766: checking for pthread_create in -lc_r" >&5
+echo "
+ #include <pthread.h>
+ void *foo(void *v) { int a = 1; }
+ int main() {
+ pthread_t t;
+ if (!pthread_create(&t, 0, &foo, 0)) {
+ pthread_join(t, 0);
+ }
+ exit(0);
+ }" > dummy.c ;
+ echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc_r $LDFLAGS $LIBS" 1>&5;
+ ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc_r $LDFLAGS $LIBS 2>&5;
+ _res=$? ;
+ rm -f dummy.c dummy${ac_exeext} ;
+ if test "$_res" = "0"; then
+ echo "$ac_t""yes" 1>&6
+ _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r"
+ else
+ echo "$ac_t""no" 1>&6
+
+echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
+echo "configure:3788: checking for pthread_create in -lc" >&5
+echo "
+ #include <pthread.h>
+ void *foo(void *v) { int a = 1; }
+ int main() {
+ pthread_t t;
+ if (!pthread_create(&t, 0, &foo, 0)) {
+ pthread_join(t, 0);
+ }
+ exit(0);
+ }" > dummy.c ;
+ echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS" 1>&5;
+ ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS 2>&5;
+ _res=$? ;
+ rm -f dummy.c dummy${ac_exeext} ;
+ if test "$_res" = "0"; then
+ echo "$ac_t""yes" 1>&6
+ _HAVE_PTHREADS=1
-else
- echo "$ac_t""no" 1>&6
-fi
+ else
+ echo "$ac_t""no" 1>&6
+
+ fi
-fi
+ fi
-fi
-
+ fi
-fi
+ fi
+
# Check whether --with-pthreads or --without-pthreads was given.
if test "${with_pthreads+set}" = set; then
withval="$with_pthreads"
@@ -3995,7 +3934,7 @@ if test -n "$USE_PTHREADS"; then
rm -f conftest*
ac_cv_have_dash_pthread=no
echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6
-echo "configure:3999: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:3938: checking whether ${CC-cc} accepts -pthread" >&5
echo 'int main() { return 0; }' | cat > conftest.c
${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
if test $? -eq 0; then
@@ -4011,7 +3950,7 @@ echo "configure:3999: checking whether ${CC-cc} accepts -pthread" >&5
ac_cv_have_dash_pthreads=no
if test "$ac_cv_have_dash_pthread" = "no"; then
echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6
-echo "configure:4015: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:3954: checking whether ${CC-cc} accepts -pthreads" >&5
echo 'int main() { return 0; }' | cat > conftest.c
${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
if test $? -eq 0; then
@@ -4182,12 +4121,12 @@ OS_LIBS="$_PTHREAD_LDFLAGS $OS_LIBS"
if test -z "$SKIP_LIBRARY_CHECKS"; then
echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:4186: checking for dlopen" >&5
+echo "configure:4125: checking for dlopen" >&5
if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4191 "configure"
+#line 4130 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dlopen(); below. */
@@ -4210,7 +4149,7 @@ dlopen();
; return 0; }
EOF
-if { (eval echo configure:4214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_dlopen=yes"
else
@@ -4229,7 +4168,7 @@ else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:4233: checking for dlopen in -ldl" >&5
+echo "configure:4172: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -4237,7 +4176,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4241 "configure"
+#line 4180 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -4248,7 +4187,7 @@ int main() {
dlopen()
; return 0; }
EOF
-if { (eval echo configure:4252: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4191: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
diff --git a/configure.in b/configure.in
index b30effe2..128c3e54 100644
--- a/configure.in
+++ b/configure.in
@@ -1171,19 +1171,51 @@ dnl ========================================================
dnl Check options
dnl ========================================================
-AC_CHECK_LIB(pthreads, pthread_attr_init,
+dnl
+dnl Apparently, some systems cannot properly check for the pthread
+dnl library unless <pthread.h> is included so we need to test
+dnl using it
+dnl
+dnl MOZ_CHECK_PTHREADS(lib, success, failure)
+AC_DEFUN(MOZ_CHECK_PTHREADS,
+[
+AC_MSG_CHECKING([for pthread_create in -l$1])
+echo "
+ #include <pthread.h>
+ void *foo(void *v) { int a = 1; }
+ int main() {
+ pthread_t t;
+ if (!pthread_create(&t, 0, &foo, 0)) {
+ pthread_join(t, 0);
+ }
+ exit(0);
+ }" > dummy.c ;
+ echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5;
+ ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5;
+ _res=$? ;
+ rm -f dummy.c dummy${ac_exeext} ;
+ if test "$_res" = "0"; then
+ AC_MSG_RESULT([yes])
+ [$2]
+ else
+ AC_MSG_RESULT([no])
+ [$3]
+ fi
+])
+
+MOZ_CHECK_PTHREADS(pthreads,
_HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
- AC_CHECK_LIB(pthread, pthread_attr_init,
+ MOZ_CHECK_PTHREADS(pthread,
_HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
- AC_CHECK_LIB(c_r, pthread_attr_init,
+ MOZ_CHECK_PTHREADS(c_r,
_HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
- AC_CHECK_LIB(c, pthread_attr_init,
+ MOZ_CHECK_PTHREADS(c,
_HAVE_PTHREADS=1
)
)
)
)
-
+
AC_ARG_WITH(pthreads,
[ --with-pthreads Use system pthreads library as thread subsystem],
[ if test "$withval" = "yes"; then