* libtool.m4: Update support for NetBSD
* ltdl.m4: Make sure that libltdl_cv_func_dlopen and
libltdl_cv_lib_dl_dlopen are set and used instead of the
ac_cv_ versions. Also, use lt_cv_sys_global_symbol_pipe
instread of global_symbol_pipe. This fixes the detection of
dlopen on BSD derived plaforms and more importantly fixes
need_uscore detection.
diff --git a/ChangeLog b/ChangeLog
index dd214e2..010dafc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2002-05-09  Nick Hudson  <skrll@netbsd.org>
+
+	* libtool.m4: Update support for NetBSD
+	* ltdl.m4: Make sure that libltdl_cv_func_dlopen and
+	libltdl_cv_lib_dl_dlopen are set and used instead of the
+	ac_cv_ versions. Also, use lt_cv_sys_global_symbol_pipe
+	instread of global_symbol_pipe. This fixes the detection of
+	dlopen on BSD derived plaforms and more importantly fixes
+	need_uscore detection.
+
 2002-05-06  Paul Eggert  <eggert@twinsun.com>
 
 	* libtool.m4 (AC_LIBTOOL_PROG_LD_SHLIBS): head -1 -> sed 1q to
diff --git a/libtool.m4 b/libtool.m4
index 7c8add4..b238a8e 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -1974,9 +1974,9 @@
 
 netbsd*)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so\.[[0-9]]+\.[[0-9]]+$'
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
   else
-    lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so$'
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
   fi
   ;;
 
@@ -2789,7 +2789,15 @@
     esac
     ;;
   netbsd*)
-    # NetBSD uses g++ - do we need to do anything?
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+      wlarc=
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    fi
+    # Workaround some broken pre-1.5 toolchains
+    output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep conftest.$objext | sed -e "s:-lgcc -lc -lgcc::"'
     ;;
   osf3*)
     case $cc_basename in
diff --git a/ltdl.m4 b/ltdl.m4
index d24745f..dd7e239 100644
--- a/ltdl.m4
+++ b/ltdl.m4
@@ -279,7 +279,7 @@
 [AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
 AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen],
   [libltdl_cv_preloaded_symbols],
-  [if test -n "$global_symbol_pipe"; then
+  [if test -n "$lt_cv_sys_global_symbol_pipe"; then
     libltdl_cv_preloaded_symbols=yes
   else
     libltdl_cv_preloaded_symbols=no
@@ -309,18 +309,18 @@
     [AC_CHECK_LIB([dl], [dlopen],
 	  [AC_DEFINE([HAVE_LIBDL], [1],
 		     [Define if you have the libdl library or equivalent.])
-	  LIBADD_DL="-ldl"],
+	        LIBADD_DL="-ldl" libltdl_cv_lib_dl_dlopen="yes"],
       [AC_TRY_LINK([#if HAVE_DLFCN_H
 #  include <dlfcn.h>
 #endif
       ],
 	[dlopen(0, 0);],
 	    [AC_DEFINE([HAVE_LIBDL], [1],
-		       [Define if you have the libdl library or equivalent.])],
+		             [Define if you have the libdl library or equivalent.]) libltdl_cv_func_dlopen="yes"],
 	[AC_CHECK_LIB([svld], [dlopen],
 	      [AC_DEFINE([HAVE_LIBDL], [1],
 			 [Define if you have the libdl library or equivalent.])
-	      LIBADD_DL="-lsvld"],
+	            LIBADD_DL="-lsvld" libltdl_cv_func_dlopen="yes"],
 	  [AC_CHECK_LIB([dld], [dld_link],
 	        [AC_DEFINE([HAVE_DLD], [1],
 			   [Define if you have the GNU dld library.])
@@ -332,7 +332,7 @@
   ])
 ])
 
-if test x"$ac_cv_func_dlopen" = xyes || test x"$ac_cv_lib_dl_dlopen" = xyes
+if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes
 then
   lt_save_LIBS="$LIBS"
   LIBS="$LIBS $LIBADD_DL"
@@ -358,7 +358,7 @@
   if AC_TRY_EVAL(ac_compile); then
     # Now try to grab the symbols.
     ac_nlist=conftest.nm
-    if AC_TRY_EVAL(NM conftest.$ac_objext \| $global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
       # See whether the symbols have a leading underscore.
       if egrep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
         ac_cv_sys_symbol_underscore=yes
@@ -370,7 +370,7 @@
         fi
       fi
     else
-      echo "configure: cannot run $global_symbol_pipe" >&AC_FD_CC
+      echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC
     fi
   else
     echo "configure: failed program was:" >&AC_FD_CC
@@ -386,8 +386,8 @@
 AC_DEFUN([AC_LTDL_DLSYM_USCORE],
 [AC_REQUIRE([AC_LTDL_SYMBOL_USCORE])
 if test x"$ac_cv_sys_symbol_underscore" = xyes; then
-  if test x"$ac_cv_func_dlopen" = xyes ||
-     test x"$ac_cv_lib_dl_dlopen" = xyes ; then
+  if test x"$libltdl_cv_func_dlopen" = xyes ||
+     test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then
 	AC_CACHE_CHECK([whether we have to add an underscore for dlsym],
 	  [libltdl_cv_need_uscore],
 	  [libltdl_cv_need_uscore=unknown