From 2f6fe511f3638c25630f4d00ea54e86edf91170b Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 22 Mar 2009 18:06:06 +0000 Subject: Sigh. dladdr() in GNU libc isn't available ( doesn't define Dl_info) unless _GNU_SOURCE is defined. In addition, it's not guaranteed to return anything more useful than argv[0]; just in case that changes at some point in the future, however, we still use it, we just run it through the same machinery that we run argv[0] through. (On Mac OS X, for example, the path of the executable is handed to the run-time linker by the kernel, so it *is* useful there.) svn path=/trunk/; revision=27821 --- configure.in | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index d110126399..f31aa0ee50 100644 --- a/configure.in +++ b/configure.in @@ -677,15 +677,19 @@ else fi # -# Check whether we can use dladdr to find the pathname of an executable. +# If we have , check whether we can use dladdr to find a +# filename (hopefully, a full pathname, but no guarantees) for +# the executable. # -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([ -#include +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 int @@ -693,23 +697,21 @@ main(void) { Dl_info info; - if (!dladdr((const void *)main, &info)) + if (!dladdr((void *)main, &info)) return 1; /* failure */ - if (info.dli_fname[0] != '/') - return 1; /* not an absolute path - 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]) + 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_MSG_RESULT($ac_cv_dladdr_finds_executable_path) fi -AC_MSG_RESULT($ac_cv_dladdr_finds_executable_path) - dnl IGE Mac integration check AC_MSG_CHECKING(whether to use IGE Mac integration functions) -- cgit v1.2.3