forked from 0ad/0ad
Add bindir/datadir/libdir options, to find files when the game is installed in standard FHS locations
This was SVN commit r7758.
This commit is contained in:
parent
1ea8ab60ee
commit
2375c7cb95
@ -6,6 +6,9 @@ addoption("icc", "Use Intel C++ Compiler (Linux only; should use either \"--cc i
|
||||
addoption("outpath", "Location for generated project files")
|
||||
addoption("without-tests", "Disable generation of test projects")
|
||||
addoption("without-pch", "Disable generation and usage of precompiled headers")
|
||||
addoption("bindir", "Directory for executables (typically '/usr/games/bin'); default is to be relocatable")
|
||||
addoption("datadir", "Directory for data files (typically '/usr/share/games/0ad'); default is ../data/ relative to executable")
|
||||
addoption("libdir", "Directory for libraries (typically '/usr/games/lib'); default is ./ relative to executable")
|
||||
|
||||
dofile("functions.lua")
|
||||
dofile("extern_libs.lua")
|
||||
@ -206,13 +209,6 @@ function package_set_build_flags()
|
||||
end
|
||||
end
|
||||
|
||||
if OS == "linux" then
|
||||
-- To use our local SpiderMonkey library, it needs to be part of the runtime dynamic linker
|
||||
-- path. So add the executable path with -rpath:
|
||||
-- (TODO: is this a sane way to do it?)
|
||||
tinsert(package.linkoptions, {"-Wl,-rpath='$$ORIGIN'"}) -- use Makefile escaping of '$'
|
||||
end
|
||||
|
||||
tinsert(package.buildoptions, {
|
||||
-- Hide symbols in dynamic shared objects by default, for efficiency and for equivalence with
|
||||
-- Windows - they should be exported explicitly with __attribute__ ((visibility ("default")))
|
||||
@ -234,9 +230,27 @@ function package_set_build_flags()
|
||||
tinsert(package.libpaths, "/usr/i686-pc-linux-gnu/lib") -- needed for ICC to find libbfd
|
||||
end
|
||||
|
||||
package.defines = {
|
||||
-- "CONFIG_USE_MMGR",
|
||||
}
|
||||
if options["bindir"] then
|
||||
tinsert(package.defines, "INSTALLED_BINDIR=" .. options["bindir"])
|
||||
end
|
||||
if options["datadir"] then
|
||||
tinsert(package.defines, "INSTALLED_DATADIR=" .. options["datadir"])
|
||||
end
|
||||
if options["libdir"] then
|
||||
tinsert(package.defines, "INSTALLED_LIBDIR=" .. options["libdir"])
|
||||
end
|
||||
|
||||
if OS == "linux" then
|
||||
-- To use our local SpiderMonkey library, it needs to be part of the
|
||||
-- runtime dynamic linker path. Add it with -rpath to make sure it gets found.
|
||||
if options["libdir"] then
|
||||
tinsert(package.linkoptions, {"-Wl,-rpath=" .. options["libdir"]})
|
||||
else
|
||||
-- Add the executable path:
|
||||
tinsert(package.linkoptions, {"-Wl,-rpath='$$ORIGIN'"}) -- use Makefile escaping of '$'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "DllLoader.h"
|
||||
|
||||
#include "lib/timer.h"
|
||||
#include "lib/posix/posix_dlfcn.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "ps/CLogger.h"
|
||||
@ -30,10 +31,15 @@ void* const HANDLE_UNAVAILABLE = (void*)-1;
|
||||
// the library name.
|
||||
|
||||
// note: on Linux, lib is prepended to the SO file name;
|
||||
// we don't use a path with '/' so the linker will look in DT_RUNPATH
|
||||
// if we don't have an explicit libdir then we don't use
|
||||
// a path with '/' so the linker will look in DT_RUNPATH
|
||||
// (which we set to $ORIGIN) to find it in the executable's directory
|
||||
#if OS_UNIX
|
||||
#ifdef INSTALLED_LIBDIR
|
||||
static const char* prefix = STRINGIZE(INSTALLED_LIBDIR) "/lib";
|
||||
#else
|
||||
static const char* prefix = "lib";
|
||||
#endif
|
||||
#else
|
||||
static const char* prefix = "";
|
||||
#endif
|
||||
@ -72,6 +78,8 @@ bool DllLoader::LoadDLL()
|
||||
// postcondition: m_Handle valid or == HANDLE_UNAVAILABLE.
|
||||
if (m_Handle == 0)
|
||||
{
|
||||
TIMER(L"LoadDLL");
|
||||
|
||||
CStr filename = CStr(prefix) + m_Name + suffix;
|
||||
|
||||
// we don't really care when relocations take place, but one of
|
||||
|
@ -30,7 +30,13 @@
|
||||
Paths::Paths(const CmdLineArgs& args)
|
||||
{
|
||||
m_root = Root(wstring_from_utf8(args.GetArg0()));
|
||||
|
||||
#ifdef INSTALLED_DATADIR
|
||||
m_rdata = WIDEN(STRINGIZE(INSTALLED_DATADIR)) L"/";
|
||||
#else
|
||||
m_rdata = m_root/L"data/";
|
||||
#endif
|
||||
|
||||
const wchar_t* subdirectoryName = args.Has("writableRoot")? 0 : L"0ad";
|
||||
|
||||
// everything is a subdirectory of the root
|
||||
|
Loading…
Reference in New Issue
Block a user