From 983959f838575b6af3e64be442a63647312fcc61 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 28 Jun 2015 18:44:11 -0700 Subject: Get "portable" builds working on Linux and add a build time check for whether /proc exists --- util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'util.c') diff --git a/util.c b/util.c index fc95011..20aa2ee 100644 --- a/util.c +++ b/util.c @@ -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; } -- cgit v1.2.3