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
This commit is contained in:
seawood%netscape.com 2002-02-26 09:44:34 +00:00
Родитель 234f0380a3
Коммит 543a721959
2 изменённых файлов: 70 добавлений и 29 удалений

73
nsprpub/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
;;
@ -4149,17 +4150,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:4153: checking for machine/builtins.h" >&5
echo "configure:4154: 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 4158 "configure"
#line 4159 "configure"
#include "confdefs.h"
#include <machine/builtins.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4163: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4164: \"$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*
@ -4669,12 +4670,12 @@ esac
if test -z "$SKIP_LIBRARY_CHECKS"; then
echo $ac_n "checking for dlopen""... $ac_c" 1>&6
echo "configure:4673: checking for dlopen" >&5
echo "configure:4674: 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 4678 "configure"
#line 4679 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dlopen(); below. */
@ -4697,7 +4698,7 @@ dlopen();
; return 0; }
EOF
if { (eval echo configure:4701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4702: \"$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
@ -4716,7 +4717,7 @@ else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
echo "configure:4720: checking for dlopen in -ldl" >&5
echo "configure:4721: 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
@ -4724,7 +4725,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
#line 4728 "configure"
#line 4729 "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
@ -4735,7 +4736,7 @@ int main() {
dlopen()
; return 0; }
EOF
if { (eval echo configure:4739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4740: \"$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
@ -4763,13 +4764,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:4767: checking whether ${CC-cc} needs -traditional" >&5
echo "configure:4768: 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 4773 "configure"
#line 4774 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@ -4787,7 +4788,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
#line 4791 "configure"
#line 4792 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@ -4811,12 +4812,12 @@ fi
for ac_func in lchown strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:4815: checking for $ac_func" >&5
echo "configure:4816: 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 4820 "configure"
#line 4821 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -4839,7 +4840,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:4843: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4844: \"$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
@ -4877,7 +4878,7 @@ fi
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
echo "configure:4881: checking for pthread_create in -lpthreads" >&5
echo "configure:4882: checking for pthread_create in -lpthreads" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4899,7 +4900,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
echo "configure:4903: checking for pthread_create in -lpthread" >&5
echo "configure:4904: checking for pthread_create in -lpthread" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4921,7 +4922,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
echo "configure:4925: checking for pthread_create in -lc_r" >&5
echo "configure:4926: checking for pthread_create in -lc_r" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4943,7 +4944,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
echo "configure:4947: checking for pthread_create in -lc" >&5
echo "configure:4948: checking for pthread_create in -lc" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -5093,14 +5094,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:5097: checking whether ${CC-cc} accepts -pthread" >&5
echo "configure:5098: 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*
@ -5109,7 +5117,7 @@ echo "configure:5097: 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:5113: checking whether ${CC-cc} accepts -pthreads" >&5
echo "configure:5121: 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
@ -5129,7 +5137,22 @@ echo "configure:5113: 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

Просмотреть файл

@ -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
;;
@ -1997,8 +1998,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*
@ -2029,7 +2037,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