diff --git a/direct/src/directbase/ppython.cxx b/direct/src/directbase/ppython.cxx index 9796c86c6f..af396692b2 100755 --- a/direct/src/directbase/ppython.cxx +++ b/direct/src/directbase/ppython.cxx @@ -125,14 +125,14 @@ int main(int argc, char **argv) /////////////////////////////////////////////////////////////////////// // -// Linux and OSX Version +// Linux and OSX and FreeBSD Version // // This would probably work on most unixes, with the possible // exception of the /proc/self/exe bit. // /////////////////////////////////////////////////////////////////////// -#if defined(__linux__) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) #ifdef BUILDING_GENPYCODE #define LINK_SOURCE "/bin/genpycode" @@ -156,9 +156,9 @@ int main(int argc, char **argv) #include #include #include -#ifdef __APPLE__ +#if defined( __APPLE__) #include -#else +#elif !defined(__FreeBSD__) #include #endif @@ -180,8 +180,12 @@ int main(int argc, char **argv) char *modargv[1024]; int fnlen,modargc; - // Ask linux for the file name of this executable. + // Ask the OS for the file name of this executable. +#ifdef __FreeBSD__ + int ok = readlink("/proc/curproc/file", fnbuf, PATH_MAX-1); +#else int ok = readlink("/proc/self/exe", fnbuf, PATH_MAX-1); +#endif if (ok<0) { if (argc>0) strcpy(fnbuf, argv[0]); else errorexit("Cannot read /proc/sys/exe");