summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-08-12 09:09:32 +0000
committerGuy Harris <guy@alum.mit.edu>2013-08-12 09:09:32 +0000
commit70523b5014574f15b4edbd78243b6004525f3839 (patch)
tree8917ce63ab241bf8fb1c5af1ca940b05448555d3
parentf568d56df2d6a3ad912200b6f760aaed073b0deb (diff)
downloadwireshark-70523b5014574f15b4edbd78243b6004525f3839.tar.gz
On some platforms, to get dladdr() you need to link with -ldl. First
try it without -ldl (in case the OS doesn't have it - not a good idea, as it complicates the build process for cross-platform tools that might require it on other platforms, but "not a good idea" never stopped UN*X vendors in the past) and, if that fails, try it with -ldl. svn path=/trunk/; revision=51309
-rw-r--r--acinclude.m436
-rw-r--r--configure.ac31
2 files changed, 43 insertions, 24 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 687b25d3aa..e825dc1e93 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -638,6 +638,42 @@ 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 c4c47b384a..5d5676c36a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1581,31 +1581,14 @@ fi
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_save_CFLAGS="$CFLAGS"
- ac_save_LIBS="$LIBS"
- CFLAGS="$CFLAGS $GLIB_CFLAGS"
- LIBS="$GLIB_LIBS $LIBS"
- 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
+ AC_WIRESHARK_CHECK_DLADDR
+ if test x$ac_cv_dladdr_finds_executable_path = xno
then
- AC_DEFINE(DLADDR_FINDS_EXECUTABLE_PATH, 1, [Define if dladdr can be used to find the path of the executable])
+ #
+ # OK, try it with -ldl, in case you need that to get
+ # dladdr().
+ #
+ AC_WIRESHARK_CHECK_DLADDR(-ldl)
fi
AC_MSG_RESULT($ac_cv_dladdr_finds_executable_path)
fi