diff --git a/src/blupi.cxx b/src/blupi.cxx index 7445173..60776dd 100644 --- a/src/blupi.cxx +++ b/src/blupi.cxx @@ -1119,7 +1119,13 @@ main (int argc, char * argv[]) } _argv.push_back (nullptr); - std::string argv0 = getenv ("APPIMAGE") ? getenv ("APPIMAGE") : argv[0]; + std::string argv0; + + if (getenv ("APPIMAGE")) + argv0 = getenv ("APPIMAGE"); + else + argv0 = GetBinDir () + basename (argv[0]); + execv (argv0.c_str (), const_cast (&_argv[0])); } diff --git a/src/config.h.in b/src/config.h.in index e1630ef..e242b04 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -22,3 +22,4 @@ #define PB_VERSION_MINOR @PB_VERSION_MINOR@ #define PB_VERSION_PATCH @PB_VERSION_PATCH@ #define PB_VERSION_EXTRA "@PB_VERSION_EXTRA@" +#define PB_BINDIR "@CMAKE_INSTALL_BINDIR@" diff --git a/src/misc.cxx b/src/misc.cxx index 82bf220..7a814a6 100644 --- a/src/misc.cxx +++ b/src/misc.cxx @@ -34,6 +34,7 @@ #include #include "blupi.h" +#include "config.h" #include "def.h" #include "misc.h" @@ -105,8 +106,8 @@ GetBaseDir () return GetShareDir () + "planetblupi/"; } -std::string -GetShareDir () +static std::string +GetDataDir () { static std::string basePath; @@ -123,7 +124,21 @@ GetShareDir () SDL_free (sdlBasePath); } - return basePath + "share/"; + return basePath; +} + +std::string +GetShareDir () +{ + return GetDataDir () + "share/"; +} + +std::string +GetBinDir () +{ + std::string abs; + std::string bin = GetDataDir () + PB_BINDIR + "/"; + return bin; } // Ajoute le chemin permettant de lire un fichier diff --git a/src/misc.h b/src/misc.h index d1a5c98..7e6ba71 100644 --- a/src/misc.h +++ b/src/misc.h @@ -35,6 +35,7 @@ extern Sint32 Random (Sint32 min, Sint32 max); std::string GetBaseDir (); std::string GetShareDir (); +std::string GetBinDir (); std::string GetLocale (); extern void AddUserPath (std::string & pFilename);