Browse Source

portable way of getting EXEDIR

master
Alessandro Mauri 5 months ago
parent
commit
0973f957c2
2 changed files with 7 additions and 1 deletions
  1. +1
    -1
      makefile
  2. +6
    -0
      src/main.c

+ 1
- 1
makefile View File

@ -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'


+ 6
- 0
src/main.c View File

@ -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)


Loading…
Cancel
Save