From: Brendan Shanks bshanks@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57874 --- tools/tools.h | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/tools/tools.h b/tools/tools.h index 319aff77da7..f017bab0e93 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -39,6 +39,9 @@ #ifdef HAVE_SYS_SYSCTL_H # include <sys/sysctl.h> #endif +#ifdef __APPLE__ +# include <mach-o/dyld.h> +#endif
#ifdef _WIN32 # include <direct.h> @@ -705,6 +708,12 @@ static inline char *get_bindir( const char *argv0 ) if (!sysctl( pathname, ARRAY_SIZE(pathname), path, &path_size, NULL, 0 )) dir = realpath( path, NULL ); free( path ); +#elif defined(__APPLE__) + uint32_t path_size = PATH_MAX; + char *path = xmalloc( path_size ); + if (!_NSGetExecutablePath( path, &path_size )) + dir = realpath( path, NULL ); + free( path ); #endif if (!dir && !(dir = realpath( argv0, NULL ))) return NULL; return get_dirname( dir );