aboutsummaryrefslogtreecommitdiffstats
path: root/configure.in
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2009-03-22 18:06:06 +0000
committerGuy Harris <guy@alum.mit.edu>2009-03-22 18:06:06 +0000
commit2f6fe511f3638c25630f4d00ea54e86edf91170b (patch)
tree3efe61316066e61a159d49ce8fcf9acf34d36ef8 /configure.in
parent4993cb95cd24e6e5fa231512ca72ca8e404228f0 (diff)
Sigh.
dladdr() in GNU libc isn't available (<dlfcn.h> 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
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in38
1 files changed, 20 insertions, 18 deletions
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 <dlfcn.h>, 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 <stdio.h>
+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
@@ -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)