Default to ELF on FreeBSD when objformat is not there
[p5sagit/p5-mst-13.2.git] / hints / linux.sh
index 98bdc9c..bd6afd2 100644 (file)
@@ -77,9 +77,9 @@ esac
 case "`${cc:-cc} -V 2>&1`" in
 *"Intel(R) C++ Compiler"*|*"Intel(R) C Compiler"*)
     # This is needed for Configure's prototype checks to work correctly
-    # The -mp1 flag is needed to pass cmp related tests
+    # The -mp flag is needed to pass various floating point related tests
     # The -no-gcc flag is needed otherwise, icc pretends (poorly) to be gcc
-    ccflags="-we147 -mp1 -no-gcc $ccflags"
+    ccflags="-we147 -mp -no-gcc $ccflags"
     # If we're using ICC, we usually want the best performance
     case "$optimize" in
     '') optimize='-O3' ;;
@@ -131,6 +131,7 @@ cat >try.c <<'EOM'
 /* Test for whether ELF binaries are produced */
 #include <fcntl.h>
 #include <stdlib.h>
+#include <unistd.h>
 main() {
        char buffer[4];
        int i=open("a.out",O_RDONLY);
@@ -310,9 +311,12 @@ cat > UU/usethreads.cbu <<'EOCBU'
 case "$usethreads" in
 $define|true|[yY]*)
         ccflags="-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS $ccflags"
-        set `echo X "$libswanted "| sed -e 's/ c / pthread c /'`
-        shift
-        libswanted="$*"
+        if echo $libswanted | grep -v pthread >/dev/null
+        then
+            set `echo X "$libswanted "| sed -e 's/ c / pthread c /'`
+            shift
+            libswanted="$*"
+        fi
 
        # Somehow at least in Debian 2.2 these manage to escape
        # the #define forest of <features.h> and <time.h> so that
@@ -352,3 +356,56 @@ $define|true|[yY]*)
     libswanted="$*"
     ;;
 esac
+
+# If we are using g++ we must use nm and force ourselves to use
+# the /usr/lib/libc.a (resetting the libc below to an empty string
+# makes Configure to look for the right one) because the symbol
+# scanning tricks of Configure will crash and burn horribly.
+case "$cc" in
+*g++*) usenm=true
+       libc=''
+       ;;
+esac
+
+# If using g++, the Configure scan for dlopen() and (especially)
+# dlerror() might fail, easier just to forcibly hint them in.
+case "$cc" in
+*g++*)
+  d_dlopen='define'
+  d_dlerror='define'
+  ;;
+esac
+
+# Under some circumstances libdb can get built in such a way as to
+# need pthread explicitly linked.
+
+libdb_needs_pthread="N"
+
+if echo " $libswanted " | grep -v " pthread " >/dev/null
+then
+   if echo " $libswanted " | grep " db " >/dev/null
+   then
+     for DBDIR in $glibpth
+     do
+       DBLIB="$DBDIR/libdb.so"
+       if [ -f $DBLIB ]
+       then
+         if nm -u $DBLIB | grep pthread >/dev/null
+         then
+           if ldd $DBLIB | grep pthread >/dev/null
+           then
+             libdb_needs_pthread="N"
+           else
+             libdb_needs_pthread="Y"
+           fi
+         fi
+       fi
+     done
+   fi
+fi
+
+case "$libdb_needs_pthread" in
+  "Y")
+    libswanted="$libswanted pthread"
+    ;;
+esac