diff util.c @ 762:206c449eaa81

Get "portable" builds working on Linux and add a build time check for whether /proc exists
author Michael Pavone <pavone@retrodev.com>
date Sun, 28 Jun 2015 18:44:11 -0700
parents fc68992cf18d
children 2a25ea5d94f7 2f48a3c187c6
line wrap: on
line diff
--- a/util.c	Sun Jun 28 17:16:24 2015 -0700
+++ b/util.c	Sun Jun 28 18:44:11 2015 -0700
@@ -138,11 +138,12 @@
 {
 	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 @@
 		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 @@
 					break;
 				}
 			}
+#ifndef HAS_PROC
 		} else {
 			exe_dir = linktext;
 		}
+#endif
 	}
 	return exe_dir;
 }