# HG changeset patch # User David Demelier # Date 1635085954 -7200 # Node ID 74f9cb70fc5d971fba28a9e8a556eb513378da5f # Parent 19782ea1cf4a2786fc33b76806c4b89606bbfed3 core: no longer care about in-source data diff -r 19782ea1cf4a -r 74f9cb70fc5d src/config.h.in --- a/src/config.h.in Sun Oct 24 15:57:42 2021 +0200 +++ b/src/config.h.in Sun Oct 24 16:32:34 2021 +0200 @@ -25,6 +25,7 @@ #define MLK_PREFIX "@CMAKE_INSTALL_PREFIX@" #define MLK_BINDIR "@CMAKE_INSTALL_BINDIR@" -#define MLK_DATADIR "@CMAKE_INSTaLL_DATADIR@" +#define MLK_DATADIR "@CMAKE_INSTALL_DATADIR@" +#define MLK_LOCALEDIR "@CMAKE_INSTALL_LOCALEDIR@" #endif /* !MLK_CONFIG_H */ diff -r 19782ea1cf4a -r 74f9cb70fc5d src/libmlk-core/core/sys.c --- a/src/libmlk-core/core/sys.c Sun Oct 24 15:57:42 2021 +0200 +++ b/src/libmlk-core/core/sys.c Sun Oct 24 16:32:34 2021 +0200 @@ -27,10 +27,6 @@ #if defined(_WIN32) # include # include - -# if !defined(S_ISDIR) -# define S_ISDIR(m) (m & _S_IFDIR) -# endif #else # include # include @@ -98,12 +94,21 @@ * instead unless is already absolute. */ - /* Component (e.g. MLK_BINDIR is set to /bin), return immediately. */ + /* + * If requested directory is absolute return immediately. + * + * e.g. whichdir == /usr/share -> return immediately + * whichdir == bin -> will be computed + */ if (absolute(whichdir)) return whichdir; - /* Determine base executable path. */ - if (!(base = SDL_GetBasePath())) + /* + * If MLK_BINDIR is absolute then we're unable to compute whichdir which + * now is mandatory relative. In that case return its whole path to the + * prefix. + */ + if (absolute(MLK_BINDIR) || !(base = SDL_GetBasePath())) snprintf(ret, sizeof (ret), "%s/%s", MLK_PREFIX, whichdir); else { /* @@ -126,6 +131,7 @@ * from: /usr/local/bin * to: /usr/local */ + printf("base=%s\n", base); port_strlcpy(path, base, sizeof (path)); SDL_free(base); @@ -172,46 +178,6 @@ return 0; } -static inline void -set_bindir(void) -{ - port_strlcpy(paths.bindir, system_directory(MLK_BINDIR), sizeof (paths.bindir)); -} - -static void -set_datadir(void) -{ - char *base, test[PATH_MAX]; - struct stat st; - - /* - * For convenient purposes, if we're running executables directly from - * source tree, check for libmlk-data presence and use it. Otherwise - * use standard system directory with the project named concatenated. - */ - if ((base = SDL_GetBasePath())) { - snprintf(test, sizeof (test), "%ssrc/libmlk-data", base); - - if (stat(test, &st) == 0 && S_ISDIR(st.st_mode)) { - port_strlcpy(paths.datadir, test, sizeof (paths.datadir)); - normalize(paths.datadir); - } - - SDL_free(base); - } - - /* Not found, use standard. */ - if (!paths.datadir[0]) - snprintf(paths.datadir, sizeof (paths.datadir), "%s/%s", - system_directory(MLK_DATADIR), info.name); -} - -static inline void -set_localedir(void) -{ - port_strlcpy(paths.localedir, system_directory(MLK_BINDIR), sizeof (paths.localedir)); -} - int sys_init(const char *organization, const char *name) { @@ -220,9 +186,9 @@ setbuf(stderr, NULL); setbuf(stdout, NULL); #endif - set_bindir(); - set_datadir(); - set_localedir(); + port_strlcpy(paths.bindir, system_directory(MLK_BINDIR), sizeof (paths.bindir)); + port_strlcpy(paths.datadir, system_directory(MLK_DATADIR), sizeof (paths.datadir)); + port_strlcpy(paths.localedir, system_directory(MLK_LOCALEDIR), sizeof (paths.localedir)); port_strlcpy(info.organization, organization, sizeof (info.organization)); port_strlcpy(info.name, name, sizeof (info.name));