* configure.ac: Check for libdl. If it is not available link against
authorMaxim Kuvyrkov <maxim@kugelworks.com>
Tue, 23 Feb 2010 19:16:16 +0000 (19:16 +0000)
committerMaxim Kuvyrkov <maxim@kugelworks.com>
Tue, 23 Feb 2010 19:16:16 +0000 (19:16 +0000)
static libthread_db.
* configure: Regenerate.

gdb/gdbserver/ChangeLog
gdb/gdbserver/configure
gdb/gdbserver/configure.ac

index f7f96cf..b16c95c 100644 (file)
@@ -1,3 +1,9 @@
+2010-02-23  Maxim Kuvyrkov  <maxim@codesourcery.com>
+
+       * configure.ac: Check for libdl.  If it is not available link against
+       static libthread_db.
+       * configure: Regenerate.
+
 2010-02-22  Pedro Alves  <pedro@codesourcery.com>
 
        PR9605
index 47bd81a..79470f2 100755 (executable)
@@ -4286,15 +4286,64 @@ $as_echo "$bfd_cv_have_sys_procfs_type_elf_fpregset_t" >&6; }
 
 fi
 
+old_LIBS="$LIBS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDL 1
+_ACEOF
+
+  LIBS="-ldl $LIBS"
+
+fi
+
+LIBS="$old_LIBS"
+
 srv_thread_depfiles=
 srv_libs=
 USE_THREAD_DB=
 
 if test "$srv_linux_thread_db" = "yes"; then
-  srv_libs="-ldl"
-  old_LDFLAGS="$LDFLAGS"
-  LDFLAGS="$LDFLAGS -rdynamic"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  if test "$ac_cv_lib_dl_dlopen" = "yes"; then
+    srv_libs="-ldl"
+    old_LDFLAGS="$LDFLAGS"
+    LDFLAGS="$LDFLAGS -rdynamic"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -4313,7 +4362,10 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
-  LDFLAGS="$old_LDFLAGS"
+    LDFLAGS="$old_LDFLAGS"
+  else
+    srv_libs="-lthread_db"
+  fi
 
   srv_thread_depfiles="thread-db.o proc-service.o"
   USE_THREAD_DB="-DUSE_THREAD_DB"
@@ -4353,14 +4405,17 @@ fi
 # Check whether --with-libthread-db was given.
 if test "${with_libthread_db+set}" = set; then :
   withval=$with_libthread_db; srv_libthread_db_path="${withval}"
-
-$as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1" >>confdefs.h
-
   srv_libs="$srv_libthread_db_path"
 
 fi
 
 
+if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
+
+$as_echo "#define USE_LIBTHREAD_DB_DIRECTLY 1" >>confdefs.h
+
+fi
+
 if test "$srv_xmlfiles" != ""; then
   srv_xmlbuiltin="xml-builtin.o"
 
index 638c228..f862918 100644 (file)
@@ -175,17 +175,27 @@ if test "$ac_cv_header_sys_procfs_h" = yes; then
   BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
 fi
 
+dnl Check for libdl, but do not add it to LIBS as only gdbserver
+dnl needs it (and gdbreplay doesn't).
+old_LIBS="$LIBS"
+AC_CHECK_LIB(dl, dlopen)
+LIBS="$old_LIBS"
+
 srv_thread_depfiles=
 srv_libs=
 USE_THREAD_DB=
 
 if test "$srv_linux_thread_db" = "yes"; then
-  srv_libs="-ldl"
-  old_LDFLAGS="$LDFLAGS"
-  LDFLAGS="$LDFLAGS -rdynamic"
-  AC_TRY_LINK([], [], [RDYNAMIC=-rdynamic], [RDYNAMIC=])
-  AC_SUBST(RDYNAMIC)
-  LDFLAGS="$old_LDFLAGS"
+  if test "$ac_cv_lib_dl_dlopen" = "yes"; then
+    srv_libs="-ldl"
+    old_LDFLAGS="$LDFLAGS"
+    LDFLAGS="$LDFLAGS -rdynamic"
+    AC_TRY_LINK([], [], [RDYNAMIC=-rdynamic], [RDYNAMIC=])
+    AC_SUBST(RDYNAMIC)
+    LDFLAGS="$old_LDFLAGS"
+  else
+    srv_libs="-lthread_db"
+  fi
 
   srv_thread_depfiles="thread-db.o proc-service.o"
   USE_THREAD_DB="-DUSE_THREAD_DB"
@@ -201,10 +211,13 @@ fi
 AC_ARG_WITH(libthread-db,
 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
 [srv_libthread_db_path="${withval}"
-  AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
   srv_libs="$srv_libthread_db_path"
 ])
 
+if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
+  AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
+fi
+
 if test "$srv_xmlfiles" != ""; then
   srv_xmlbuiltin="xml-builtin.o"
   AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])