diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-06-28 18:44:11 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-06-28 18:44:11 -0700 |
commit | 983959f838575b6af3e64be442a63647312fcc61 (patch) | |
tree | 0fe8f3d105504051f1631575b52dc8bea79860a0 /util.c | |
parent | 834477c2a7f882752fc6ab272f8e01865db33720 (diff) |
Get "portable" builds working on Linux and add a build time check for whether /proc exists
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -138,11 +138,12 @@ char * get_exe_dir() { static char * exe_dir; if (!exe_dir) { + char * cur; +#ifndef HAS_PROC char * linktext = readlink_alloc("/proc/self/exe"); if (!linktext) { goto fallback; } - char * cur; int linksize = strlen(linktext); for(cur = linktext + linksize - 1; cur != linktext; cur--) { @@ -154,6 +155,7 @@ char * get_exe_dir() if (cur == linktext) { free(linktext); fallback: +#endif if (!exe_str) { fputs("/proc/self/exe is not available and set_exe_str was not called!", stderr); } @@ -167,9 +169,11 @@ fallback: break; } } +#ifndef HAS_PROC } else { exe_dir = linktext; } +#endif } return exe_dir; } |