+2006-04-30 Bruno Haible <bruno@clisp.org>
+
+ * progreloc.c: Include <mach-o/dyld.h> if available.
+ (find_executable): Use _NSGetExecutablePath when possible.
+
2006-05-12 Bruno Haible <bruno@clisp.org>
* mkdtemp.c [MINGW]: Include <io.h>.
#endif
#include <sys/stat.h>
+/* Get declaration of _NSGetExecutablePath on MacOS X 10.2 or newer. */
+#if HAVE_MACH_O_DYLD_H
+# include <mach-o/dyld.h>
+#endif
+
#if defined _WIN32 || defined __WIN32__
# undef WIN32 /* avoid warning on mingw32 */
# define WIN32
executable_fd = open (buf, O_RDONLY, 0);
}
}
+#endif
+#if HAVE_MACH_O_DYLD_H && HAVE__NSGETEXECUTABLEPATH
+ /* On MacOS X 10.2 or newer, the function
+ int _NSGetExecutablePath (char *buf, unsigned long *bufsize);
+ can be used to retrieve the executable's full path. */
+ char location[4096];
+ unsigned long length = sizeof (location);
+ if (_NSGetExecutablePath (location, &length) == 0
+ && location[0] == '/')
+ return canonicalize_file_name (location);
#endif
/* Guess the executable's full path. We assume the executable has been
called via execlp() or execvp() with properly set up argv[0]. The
+2006-04-30 Bruno Haible <bruno@clisp.org>
+
+ * relocatable.m4 (AC_RELOCATABLE): Also test for availability of
+ <unistd.h>, <mach-o/dyld.h>. _NSGetExecutablePath.
+
2006-05-09 Bruno Haible <bruno@clisp.org>
* javaexec.m4 (gt_JAVAEXEC): On Cygwin, set CLASSPATH_SEPARATOR to a
-# relocatable.m4 serial 4 (gettext-0.15)
-dnl Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+# relocatable.m4 serial 5 (gettext-0.15)
+dnl Copyright (C) 2003, 2005-2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_LIBOBJ([relocatable])
AC_DEFINE([ENABLE_RELOCATABLE], 1,
[Define to 1 if the package shall run at any location in the filesystem.])
+ AC_CHECK_HEADERS([unistd.h mach-o/dyld.h])
+ AC_CHECK_FUNCS([_NSGetExecutablePath])
case "$host_os" in
mingw*) is_noop=yes ;;
linux*) use_elf_origin_trick=yes ;;