diff --git a/makefile b/makefile index 9ea09e4..327c0cb 100644 --- a/makefile +++ b/makefile @@ -5,7 +5,7 @@ MANPREFIX = ${PREFIX}/share/man #CC ?= gcc SRCDIR = ./src CFLAGS = -Wall -Werror -pedantic -O3 -std=c11 -fno-strict-aliasing \ - -I${SRCDIR} -I${PREFIX}/include/ -DLUA_USE_POSIX + -I${SRCDIR} -I${PREFIX}/include/ -DLUA_USE_POSIX -D_PREFIX="${PREFIX}" # remove this LDFLAGS = -L${PREFIX}/lib -lSDL2 -lm -llua5.2 FILES != find ${SRCDIR} -name '*.c' diff --git a/src/main.c b/src/main.c index c76b097..88b879e 100644 --- a/src/main.c +++ b/src/main.c @@ -26,10 +26,16 @@ static double get_scale(void) static void get_exe_filename(char *buf, int sz) { +#ifdef __linux__ char path[512]; sprintf(path, "/proc/%d/exe", getpid()); int len = readlink(path, buf, sz - 1); buf[len] = '\0'; +#elif defined(_PREFIX) + strncpy(buf, _PREFIX, sz); +#else + strncpy(buf, "/usr/local/share/lite/", sz); +#endif } static void init_window_icon(void)