summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseawood%netscape.com <devnull@localhost>2002-02-26 09:41:25 +0000
committerseawood%netscape.com <devnull@localhost>2002-02-26 09:41:25 +0000
commit5d91cbd5862a9949d59734d1f6a929d71ce4090c (patch)
tree3a122e8318a82c0445844cf5729e40bd084a7017
parent0420e3cdc83713f1cdd0a8be2365bf8a99ba39cd (diff)
downloadnspr-hg-5d91cbd5862a9949d59734d1f6a929d71ce4090c.tar.gz
Create shared libraries using $(CC) for FreeBSD.
Use -pthread as a linker flag instead of a compile flag on FreeBSD. Thanks to Jeremy Lea <reg@shale.csir.co.za> for the patch. bug #125857 r=wtc/cls a=asa
-rwxr-xr-xconfigure73
-rw-r--r--configure.in26
2 files changed, 70 insertions, 29 deletions
diff --git a/configure b/configure
index 59bad369..6a1090db 100755
--- a/configure
+++ b/configure
@@ -3288,8 +3288,9 @@ EOF
else
DLL_SUFFIX=so.1.0
fi
+ MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
DSO_CFLAGS=-fPIC
- DSO_LDOPTS=-Bshareable
+ DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
MDCPUCFG_H=_freebsd.cfg
PR_MD_CSRCS=freebsd.c
;;
@@ -4141,17 +4142,17 @@ EOF
ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6
-echo "configure:4145: checking for machine/builtins.h" >&5
+echo "configure:4146: checking for machine/builtins.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4150 "configure"
+#line 4151 "configure"
#include "confdefs.h"
#include <machine/builtins.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4155: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4156: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -4661,12 +4662,12 @@ esac
if test -z "$SKIP_LIBRARY_CHECKS"; then
echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:4665: checking for dlopen" >&5
+echo "configure:4666: 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 4670 "configure"
+#line 4671 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dlopen(); below. */
@@ -4689,7 +4690,7 @@ dlopen();
; return 0; }
EOF
-if { (eval echo configure:4693: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4694: \"$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
@@ -4708,7 +4709,7 @@ else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:4712: checking for dlopen in -ldl" >&5
+echo "configure:4713: 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
@@ -4716,7 +4717,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4720 "configure"
+#line 4721 "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
@@ -4727,7 +4728,7 @@ int main() {
dlopen()
; return 0; }
EOF
-if { (eval echo configure:4731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4732: \"$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
@@ -4755,13 +4756,13 @@ fi
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:4759: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:4760: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
-#line 4765 "configure"
+#line 4766 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -4779,7 +4780,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
-#line 4783 "configure"
+#line 4784 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -4803,12 +4804,12 @@ fi
for ac_func in lchown strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4807: checking for $ac_func" >&5
+echo "configure:4808: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4812 "configure"
+#line 4813 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -4831,7 +4832,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:4835: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -4869,7 +4870,7 @@ fi
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:4873: checking for pthread_create in -lpthreads" >&5
+echo "configure:4874: checking for pthread_create in -lpthreads" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@@ -4891,7 +4892,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:4895: checking for pthread_create in -lpthread" >&5
+echo "configure:4896: checking for pthread_create in -lpthread" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@@ -4913,7 +4914,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
-echo "configure:4917: checking for pthread_create in -lc_r" >&5
+echo "configure:4918: checking for pthread_create in -lc_r" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@@ -4935,7 +4936,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
-echo "configure:4939: checking for pthread_create in -lc" >&5
+echo "configure:4940: checking for pthread_create in -lc" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@@ -5085,14 +5086,21 @@ 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:5089: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5090: 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
if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
ac_cv_have_dash_pthread=yes
- CFLAGS="$CFLAGS -pthread"
- CXXFLAGS="$CXXFLAGS -pthread"
+ case "$target_os" in
+ freebsd*)
+# Freebsd doesn't use -pthread for compiles, it uses them for linking
+ ;;
+ *)
+ CFLAGS="$CFLAGS -pthread"
+ CXXFLAGS="$CXXFLAGS -pthread"
+ ;;
+ esac
fi
fi
rm -f conftest*
@@ -5101,7 +5109,7 @@ echo "configure:5089: 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:5105: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5113: 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
@@ -5121,7 +5129,22 @@ echo "configure:5105: checking whether ${CC-cc} accepts -pthreads" >&5
_PTHREAD_LDFLAGS=
fi
;;
- *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*)
+ *-freebsd*)
+ cat >> confdefs.h <<\EOF
+#define _REENTRANT 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define _THREAD_SAFE 1
+EOF
+
+ if test "$ac_cv_have_dash_pthread" = "yes"; then
+ _PTHREAD_LDFLAGS="-pthread"
+ else
+ _PTHREAD_LDFLAGS="-lc_r"
+ fi
+ ;;
+ *-openbsd*|*-bsdi*|*-netbsd*)
cat >> confdefs.h <<\EOF
#define _THREAD_SAFE 1
EOF
diff --git a/configure.in b/configure.in
index 978c6266..5a7884c1 100644
--- a/configure.in
+++ b/configure.in
@@ -876,8 +876,9 @@ case "$target" in
else
DLL_SUFFIX=so.1.0
fi
+ MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
DSO_CFLAGS=-fPIC
- DSO_LDOPTS=-Bshareable
+ DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
MDCPUCFG_H=_freebsd.cfg
PR_MD_CSRCS=freebsd.c
;;
@@ -1986,8 +1987,15 @@ if test -n "$USE_PTHREADS"; then
if test $? -eq 0; then
if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
ac_cv_have_dash_pthread=yes
- CFLAGS="$CFLAGS -pthread"
- CXXFLAGS="$CXXFLAGS -pthread"
+ case "$target_os" in
+ freebsd*)
+# Freebsd doesn't use -pthread for compiles, it uses them for linking
+ ;;
+ *)
+ CFLAGS="$CFLAGS -pthread"
+ CXXFLAGS="$CXXFLAGS -pthread"
+ ;;
+ esac
fi
fi
rm -f conftest*
@@ -2018,7 +2026,17 @@ if test -n "$USE_PTHREADS"; then
_PTHREAD_LDFLAGS=
fi
;;
- *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*)
+ *-freebsd*)
+ AC_DEFINE(_REENTRANT)
+ AC_DEFINE(_THREAD_SAFE)
+ dnl -pthread links in -lc_r, so don't specify it explicitly.
+ if test "$ac_cv_have_dash_pthread" = "yes"; then
+ _PTHREAD_LDFLAGS="-pthread"
+ else
+ _PTHREAD_LDFLAGS="-lc_r"
+ fi
+ ;;
+ *-openbsd*|*-bsdi*|*-netbsd*)
AC_DEFINE(_THREAD_SAFE)
dnl -pthread links in -lc_r, so don't specify it explicitly.
if test "$ac_cv_have_dash_pthread" = "yes"; then