]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Use _NSGetExecutablePath on MacOS X >= 10.2.
authorBruno Haible <bruno@clisp.org>
Mon, 15 May 2006 11:58:23 +0000 (11:58 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:13:19 +0000 (12:13 +0200)
gettext-tools/lib/ChangeLog
gettext-tools/lib/progreloc.c
gettext-tools/m4/ChangeLog
gettext-tools/m4/relocatable.m4

index a06d422a4d63e6bdf2fbcfa1994b6816417e38c8..f8489f46b46ac5d8865d141c1775ce8d78edc8d0 100644 (file)
@@ -1,3 +1,8 @@
+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>.
index be64bf0e9253403ad1a06ad207d95ed17147caed..45c8826379d3377a62f218ba151a905473503231 100644 (file)
 #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
@@ -184,6 +189,16 @@ find_executable (const char *argv0)
        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
index 94a294006d8457f0346b8c641aca99695d933048..453273fc61b7e0b3a92e7508086f2d9b37f06fab 100644 (file)
@@ -1,3 +1,8 @@
+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
index 40910a16b98b9c71dc960fee7b7fa932835bc6ca..caee4c439d32495bf5ec30584213a33945f807e0 100644 (file)
@@ -1,5 +1,5 @@
-# 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.
@@ -22,6 +22,8 @@ AC_DEFUN([AC_RELOCATABLE],
     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 ;;