aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--acinclude.m436
-rw-r--r--configure.ac29
-rw-r--r--epan/filesystem.c8
3 files changed, 24 insertions, 49 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index e825dc1e93..687b25d3aa 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -638,42 +638,6 @@ AC_DEFUN([AC_WIRESHARK_PCAP_REMOTE_CHECK],
])
#
-# AC_WIRESHARK_CHECK_DLADDR
-#
-AC_DEFUN([AC_WIRESHARK_CHECK_DLADDR],
-[
- ac_save_CFLAGS="$CFLAGS"
- ac_save_LIBS="$LIBS"
- CFLAGS="$CFLAGS $GLIB_CFLAGS"
- LIBS="$GLIB_LIBS $LIBS $1"
- AC_TRY_RUN(
-[
-#define _GNU_SOURCE /* required on Linux, sigh */
-#include <dlfcn.h>
-
-int
-main(void)
-{
- Dl_info info;
-
- if (!dladdr((void *)main, &info))
- return 1; /* failure */
- return 0; /* assume success */
-}
-],
- ac_cv_dladdr_finds_executable_path=yes,
- ac_cv_dladdr_finds_executable_path=no,
- [echo $ac_n "cross compiling; assumed OK... $ac_c"
- ac_cv_dladdr_finds_executable_path=yes])
- CFLAGS="$ac_save_CFLAGS"
- LIBS="$ac_save_LIBS"
- if test x$ac_cv_dladdr_finds_executable_path = xyes
- then
- AC_DEFINE(DLADDR_FINDS_EXECUTABLE_PATH, 1, [Define if dladdr can be used to find the path of the executable])
- fi
-])
-
-#
# AC_WIRESHARK_ZLIB_CHECK
#
AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
diff --git a/configure.ac b/configure.ac
index 5d5676c36a..67731951bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1574,23 +1574,34 @@ else
fi
#
-# If we have <dlfcn.h>, check whether we can use dladdr to find a
-# filename (hopefully, a full pathname, but no guarantees) for
-# the executable.
+# If we have <dlfcn.h>, check whether we have dladdr.
#
if test "$ac_cv_header_dlfcn_h" = "yes"
then
- AC_MSG_CHECKING(whether dladdr can be used to find the pathname of an executable)
- AC_WIRESHARK_CHECK_DLADDR
- if test x$ac_cv_dladdr_finds_executable_path = xno
+ #
+ # Use GLib compiler flags and linker flags; GLib's gmodule
+ # stuff uses the dl APIs if available, so it might know
+ # what flags are needed.
+ #
+ ac_save_CFLAGS="$CFLAGS"
+ ac_save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $GLIB_CFLAGS"
+ LIBS="$GLIB_LIBS $LIBS"
+ AC_CHECK_FUNCS(dladdr)
+ if test x$ac_cv_func_dladdr = xno
then
#
# OK, try it with -ldl, in case you need that to get
- # dladdr().
+ # dladdr(). For some reason, on Linux, that's not
+ # part of the GLib flags; perhaps GLib itself is
+ # linked with libdl, so that you can link with
+ # Glib and it'll pull libdl in itself.
#
- AC_WIRESHARK_CHECK_DLADDR(-ldl)
+ LIBS="$LIBS -ldl"
+ AC_CHECK_FUNCS(dladdr)
fi
- AC_MSG_RESULT($ac_cv_dladdr_finds_executable_path)
+ CFLAGS="$ac_save_CFLAGS"
+ LIBS="$ac_save_LIBS"
fi
#
diff --git a/epan/filesystem.c b/epan/filesystem.c
index ef0970e4c4..3ff5ad1fc8 100644
--- a/epan/filesystem.c
+++ b/epan/filesystem.c
@@ -71,7 +71,7 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
-#ifdef DLADDR_FINDS_EXECUTABLE_PATH
+#ifdef HAVE_DLADDR
#include <dlfcn.h>
#endif
#include <pwd.h>
@@ -441,7 +441,7 @@ init_progfile_dir(const char *arg0
_U_
#endif
, int (*main_addr)(int, char **)
-#if defined(_WIN32) || !defined(DLADDR_FINDS_EXECUTABLE_PATH)
+#if defined(_WIN32) || !defined(HAVE_DLADDR)
_U_
#endif
)
@@ -507,7 +507,7 @@ init_progfile_dir(const char *arg0
msg, error);
}
#else
-#ifdef DLADDR_FINDS_EXECUTABLE_PATH
+#ifdef HAVE_DLADDR
Dl_info info;
#endif
const char *execname;
@@ -535,7 +535,7 @@ init_progfile_dir(const char *arg0
running_in_build_directory_flag = TRUE;
execname = get_executable_path();
-#ifdef DLADDR_FINDS_EXECUTABLE_PATH
+#ifdef HAVE_DLADDR
if (execname == NULL) {
/*
* Try to use dladdr() to find the pathname of the executable.