prevent attempts to load extension libraries more than once on darwin.
[p5sagit/p5-mst-13.2.git] / hints / netbsd.sh
index 6a2ff11..741413e 100644 (file)
@@ -1,11 +1,7 @@
 # hints/netbsd.sh
 #
-# talk to packages@netbsd.org if you want to change this file.
-#
-# netbsd keeps dynamic loading dl*() functions in /usr/lib/crt0.o,
-# so Configure doesn't find them (unless you abandon the nm scan).
-# this should be *just* 0.9 below as netbsd 0.9a was the first to
-# introduce shared libraries.
+# Please check with packages@netbsd.org before making modifications
+# to this file.
 
 case "$archname" in
 '')
@@ -13,38 +9,54 @@ case "$archname" in
     ;;
 esac
 
+# NetBSD keeps dynamic loading dl*() functions in /usr/lib/crt0.o,
+# so Configure doesn't find them (unless you abandon the nm scan).
+# Also, NetBSD 0.9a was the first release to introduce shared
+# libraries.
+#
 case "$osvers" in
 0.9|0.8*)
        usedl="$undef"
        ;;
 *)
-       if [ -f /usr/libexec/ld.elf_so ]; then
-               d_dlopen=$define
-               d_dlerror=$define
-               # Include the whole libgcc.a, required for Xerces-P, which
-               # needs __eh_alloc, __pure_virtual, and others.
-               # XXX This should be obsoleted by gcc-3.0.
-               ccdlflags="-Wl,-whole-archive -lgcc -Wl,-no-whole-archive \
-                       -Wl,-E -Wl,-R${PREFIX}/lib $ccdlflags"
-               cccdlflags="-DPIC -fPIC $cccdlflags"
-               lddlflags="--whole-archive -shared $lddlflags"
-       elif [ "`uname -m`" = "pmax" ]; then
-# NetBSD 1.3 and 1.3.1 on pmax shipped an `old' ld.so, which will not work.
+       case `uname -m` in
+       pmax)
+               # NetBSD 1.3 and 1.3.1 on pmax shipped an `old' ld.so,
+               # which will not work.
                case "$osvers" in
                1.3|1.3.1)
                        d_dlopen=$undef
                        ;;
                esac
-       elif [ -f /usr/libexec/ld.so ]; then
+               ;;
+       esac
+       if test -f /usr/libexec/ld.elf_so; then
+               # ELF
+               d_dlopen=$define
+               d_dlerror=$define
+               cccdlflags="-DPIC -fPIC $cccdlflags"
+               lddlflags="--whole-archive -shared $lddlflags"
+               rpathflag="-Wl,-rpath,"
+               #
+               # Include the whole libgcc.a into the perl executable so
+               # that certain symbols needed by loadable modules built as
+               # C++ objects (__eh_alloc, __pure_virtual, etc.) will always
+               # be defined.
+               #
+               # XXX This should be obsoleted by gcc-3.0.
+               #
+               ccdlflags="-Wl,-whole-archive -lgcc -Wl,-no-whole-archive \
+                       -Wl,-E $ccdlflags"
+       elif test -f /usr/libexec/ld.so; then
+               # a.out
                d_dlopen=$define
                d_dlerror=$define
-               ccdlflags="-Wl,-R${PREFIX}/lib $ccdlflags"
-# we use -fPIC here because -fpic is *NOT* enough for some of the
-# extensions like Tk on some netbsd platforms (the sparc is one)
                cccdlflags="-DPIC -fPIC $cccdlflags"
                lddlflags="-Bshareable $lddlflags"
+               rpathflag="-R"
        else
                d_dlopen=$undef
+               rpathflag=
        fi
        ;;
 esac
@@ -69,12 +81,6 @@ d_setruid="$undef"
 # there's no problem with vfork.
 usevfork=true
 
-# Using perl's malloc leads to trouble on some toolchain versions.
-usemymalloc="$undef"
-
-# Pre-empt the /usr/bin/perl question of installperl.
-installusrbinperl="$undef"
-
 # This is there but in machine/ieeefp_h.
 ieeefp_h="define"
 
@@ -83,24 +89,58 @@ ieeefp_h="define"
 cat > UU/usethreads.cbu <<'EOCBU' 
 case "$usethreads" in 
 $define|true|[yY]*) 
-        # The GNU pth is the recommended user-level pthreads implementation. 
-        # As of NetBSD 1.5.2 there are no kernel pthreads. 
-        if pkg_info -qe pth; then 
-            # Add -lpthread. 
-            libswanted="$libswanted pthread" 
-            # There is no libc_r as of NetBSD 1.5.2, so no c -> c_r. 
+       lpthread=
+       for xxx in pthread; do
+               for yyy in $loclibpth $plibpth $glibpth dummy; do
+                       zzz=$yyy/lib$xxx.a
+                       if test -f "$zzz"; then
+                               lpthread=$xxx
+                               break;
+                       fi
+                       zzz=$yyy/lib$xxx.so
+                       if test -f "$zzz"; then
+                               lpthread=$xxx
+                               break;
+                       fi
+                       zzz=`ls $yyy/lib$xxx.so.* 2>/dev/null`
+                       if test "X$zzz" != X; then
+                               lpthread=$xxx
+                               break;
+                       fi
+               done
+               if test "X$lpthread" != X; then
+                       break;
+               fi
+       done
+       if test "X$lpthread" != X; then
+               # Add -lpthread. 
+               libswanted="$libswanted $lpthread" 
+               # There is no libc_r as of NetBSD 1.5.2, so no c -> c_r.
+               # This will be revisited when NetBSD gains a native pthreads
+               # implementation.
         else 
-            echo "$0: You need to install the GNU pth.  Aborting." >&4 
-            exit 1 
-        fi 
+               echo "$0: No POSIX threads library (-lpthread) found.  " \
+                    "You may want to install GNU pth.  Aborting." >&4 
+               exit 1 
+        fi
+       unset lpthread
         ;; 
 esac 
 EOCBU
 
-# Recognize the NetBSD packages collection.
-# GDBM might be here, pth might be there.
-if test -d /usr/pkg/lib; then
-       loclibpth="$loclibpth /usr/pkg/lib"
-       ldflags="$ldflags -R/usr/pkg/lib"
-fi
-test -d /usr/pkg/include && locincpth="$locincpth /usr/pkg/include"
+# Set sensible defaults for NetBSD: look for local software in
+# /usr/pkg (NetBSD Packages Collection) and in /usr/local.
+#
+loclibpth="/usr/pkg/lib /usr/local/lib"
+locincpth="/usr/pkg/include /usr/local/include"
+case "$rpathflag" in
+'')
+       ldflags=
+       ;;
+*)
+       ldflags=
+       for yyy in $loclibpth; do
+               ldflags="$ldflags $rpathflag$yyy"
+       done
+       ;;
+esac