From 3e3301dfb84117edeacc5da2ad6be3a20d8c3a75 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 2 Aug 2008 09:30:29 +0000 Subject: [PATCH] Added support for OSX --- direct/src/directbase/ppython.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/direct/src/directbase/ppython.cxx b/direct/src/directbase/ppython.cxx index 483752d9a9..7e93e4bf72 100755 --- a/direct/src/directbase/ppython.cxx +++ b/direct/src/directbase/ppython.cxx @@ -117,14 +117,14 @@ int main(int argc, char **argv) /////////////////////////////////////////////////////////////////////// // -// Linux Version +// Linux and OSX Version // // This would probably work on most unixes, with the possible // exception of the /proc/self/exe bit. // /////////////////////////////////////////////////////////////////////// -#ifdef __linux__ +#if defined(__linux__) || defined(__APPLE__) #ifdef BUILDING_GENPYCODE #define LINK_SOURCE "/bin/genpycode" @@ -139,12 +139,16 @@ int main(int argc, char **argv) #endif #include -#include #include #include #include #include #include +#ifdef __APPLE__ + #include +#else + #include +#endif void errorexit(char *s) { @@ -165,9 +169,9 @@ int main(int argc, char **argv) int fnlen,modargc; // Ask linux for the file name of this executable. - int ok = readlink("/proc/self/exe", fnbuf, PATH_MAX-1); - if (ok<0) errorexit("Cannot read /proc/sys/exe"); + if (ok<0 && argc > 0) strcpy(fnbuf, argv[0]); + else errorexit("Cannot read /proc/sys/exe"); fnbuf[PATH_MAX-1] = 0; fnlen = strlen(fnbuf);