Bug 1112904 - Backport bug 125857 to LDAP C SDK. r=glandium, f=jcranmer
authorJan Beich <jbeich@FreeBSD.org>
Fri, 27 Feb 2015 03:58:00 -0500
changeset 45 0f7c3698a961
parent 44 ff2dacee5458
child 46 f9d7552c8188
push id30
push userryanvm@gmail.com
push dateMon, 09 Mar 2015 14:15:16 +0000
reviewersglandium
bugs1112904, 125857
Bug 1112904 - Backport bug 125857 to LDAP C SDK. r=glandium, f=jcranmer
c-sdk/config/FreeBSD.mk
c-sdk/configure
c-sdk/configure.in
--- a/c-sdk/config/FreeBSD.mk
+++ b/c-sdk/config/FreeBSD.mk
@@ -74,13 +74,13 @@ MOZ_OBJFORMAT          := $(shell test -
 
 ifeq ($(MOZ_OBJFORMAT),elf)
 DLL_SUFFIX		= so
 else
 DLL_SUFFIX		= so.1.0
 endif
 
 DSO_CFLAGS		= -fPIC
-DSO_LDOPTS		= -Bshareable
+DSO_LDOPTS		= -shared -Wl,-soname,$(notdir $@)
 
-MKSHLIB			= $(LD) $(DSO_LDOPTS)
+MKSHLIB			= $(CC) $(DSO_LDOPTS)
 
 G++INCLUDES		= -I/usr/include/g++
--- a/c-sdk/configure
+++ b/c-sdk/configure
@@ -4238,18 +4238,20 @@ EOF
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define DRAGONFLY 1
 EOF
 
+    LD='$(CC)'
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     DSO_CFLAGS=-fPIC
-    DSO_LDOPTS='-shared'
+    DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
 	;;
 
 *-freebsd*)
     if test -z "$USE_NSPR_THREADS"; then
         USE_PTHREADS=1
     fi
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
@@ -4258,25 +4260,27 @@ EOF
     cat >> confdefs.h <<\EOF
 #define FREEBSD 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define HAVE_BSD_FLOCK 1
 EOF
 
+    LD='$(CC)'
     CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
     MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
     if test "$MOZ_OBJFORMAT" = "elf"; then
         DLL_SUFFIX=so
     else
         DLL_SUFFIX=so.1.0
     fi
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     DSO_CFLAGS=-fPIC
-    DSO_LDOPTS=-Bshareable
+    DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
     ;;
 
 *-hpux*)
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
     cat >> confdefs.h <<\EOF
@@ -6509,18 +6513,25 @@ if test -n "$USE_PTHREADS"; then
    ac_cv_have_dash_pthread=no
    echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6
 echo "configure:6510: 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
+        dragonfly*|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*
     echo "$ac_t""$ac_cv_have_dash_pthread" 1>&6
 
 			    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
@@ -6539,17 +6550,32 @@ echo "configure:6526: checking whether $
     fi
 
     case "$target" in
     *-solaris*)
         if test "$ac_cv_have_dash_pthreads" = "yes"; then
             _PTHREAD_LDFLAGS=
         fi
 	    ;;
-    *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*)
+    *-dragonfly*|*-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
 
 	    	    if test "$ac_cv_have_dash_pthread" = "yes"; then
 	        _PTHREAD_LDFLAGS=
 	    fi
 	    ;;
--- a/c-sdk/configure.in
+++ b/c-sdk/configure.in
@@ -1222,36 +1222,40 @@ tools are selected during the Xcode/Deve
     ;;
 
 *-dragonfly*)
     if test -z "$USE_NSPR_THREADS"; then
         USE_PTHREADS=1
     fi
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(DRAGONFLY)
+    LD='$(CC)'
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     DSO_CFLAGS=-fPIC
-    DSO_LDOPTS='-shared'
+    DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
 	;;
 
 *-freebsd*)
     if test -z "$USE_NSPR_THREADS"; then
         USE_PTHREADS=1
     fi
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(FREEBSD)
     AC_DEFINE(HAVE_BSD_FLOCK)
+    LD='$(CC)'
     CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
     MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
     if test "$MOZ_OBJFORMAT" = "elf"; then
         DLL_SUFFIX=so
     else
         DLL_SUFFIX=so.1.0
     fi
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     DSO_CFLAGS=-fPIC
-    DSO_LDOPTS=-Bshareable
+    DSO_LDOPTS='-shared -Wl,-soname,$(notdir $@)'
     ;;
 
 *-hpux*)
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(HPUX)
     AC_DEFINE(_HPUX_SOURCE)
     if test "$OS_TEST" = "ia64" ; then
         AC_DEFINE(ia64)
@@ -2326,18 +2330,25 @@ if test -n "$USE_PTHREADS"; then
    rm -f conftest*
    ac_cv_have_dash_pthread=no
    AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
    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
+        dragonfly*|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*
     AC_MSG_RESULT($ac_cv_have_dash_pthread)
 
 	dnl
 	dnl See if -pthreads is supported.
 	dnl
@@ -2358,17 +2369,27 @@ if test -n "$USE_PTHREADS"; then
     fi
 
     case "$target" in
     *-solaris*)
         if test "$ac_cv_have_dash_pthreads" = "yes"; then
             _PTHREAD_LDFLAGS=
         fi
 	    ;;
-    *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*)
+    *-dragonfly*|*-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
 	        _PTHREAD_LDFLAGS=
 	    fi
 	    ;;
     *-linux*)
         AC_DEFINE(_REENTRANT)