portable way of getting EXEDIR

master
Alessandro Mauri 3 years ago
parent dda5abb8e9
commit 60d8105b8f
  1. 2
      makefile
  2. 6
      src/main.c

@ -5,7 +5,7 @@ MANPREFIX = ${PREFIX}/share/man
#CC ?= gcc #CC ?= gcc
SRCDIR = ./src SRCDIR = ./src
CFLAGS = -Wall -Werror -pedantic -O3 -std=c11 -fno-strict-aliasing \ 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 # remove this
LDFLAGS = -L${PREFIX}/lib -lSDL2 -lm -llua5.2 LDFLAGS = -L${PREFIX}/lib -lSDL2 -lm -llua5.2
FILES != find ${SRCDIR} -name '*.c' FILES != find ${SRCDIR} -name '*.c'

@ -26,10 +26,16 @@ static double get_scale(void)
static void get_exe_filename(char *buf, int sz) static void get_exe_filename(char *buf, int sz)
{ {
#ifdef __linux__
char path[512]; char path[512];
sprintf(path, "/proc/%d/exe", getpid()); sprintf(path, "/proc/%d/exe", getpid());
int len = readlink(path, buf, sz - 1); int len = readlink(path, buf, sz - 1);
buf[len] = '\0'; 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) static void init_window_icon(void)

Loading…
Cancel
Save