aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt8
-rw-r--r--src/cmake_config.h.in10
-rw-r--r--src/config.h9
-rw-r--r--src/lua/CMakeLists.txt2
-rw-r--r--src/main.cpp4
-rw-r--r--src/porting.cpp49
6 files changed, 55 insertions, 27 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a0276cfaa..e369b9623 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,10 +1,6 @@
project(minetest)
cmake_minimum_required( VERSION 2.6 )
-if(RUN_IN_PLACE)
- add_definitions ( -DRUN_IN_PLACE )
-endif(RUN_IN_PLACE)
-
# Set some random things default to not being visible in the GUI
mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
mark_as_advanced(JTHREAD_INCLUDE_DIR JTHREAD_LIBRARY)
@@ -139,13 +135,15 @@ else()
#set(CLIENT_PLATFORM_LIBS -lXxf86vm)
# This way Xxf86vm is found on OpenBSD too
find_library(XXF86VM_LIBRARY Xxf86vm)
+ mark_as_advanced(XXF86VM_LIBRARY)
set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY})
endif()
find_package(Jthread REQUIRED)
find_package(Sqlite3 REQUIRED)
-# TODO: Create proper find script for Lua
+# Do not use system-wide installation of Lua, because it'll likely be a
+# different version and/or has different build options.
set(LUA_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lua/src")
set(LUA_LIBRARY "lua")
diff --git a/src/cmake_config.h.in b/src/cmake_config.h.in
index 054cca165..c2bdc9670 100644
--- a/src/cmake_config.h.in
+++ b/src/cmake_config.h.in
@@ -4,16 +4,18 @@
#define CMAKE_CONFIG_H
#define CMAKE_PROJECT_NAME "@PROJECT_NAME@"
-#define CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
#define CMAKE_VERSION_STRING "@VERSION_STRING@"
+#define CMAKE_RUN_IN_PLACE @RUN_IN_PLACE@
+#define CMAKE_USE_GETTEXT @USE_GETTEXT@
+#define CMAKE_USE_SOUND @USE_SOUND@
+#define CMAKE_STATIC_SHAREDIR "@SHAREDIR@"
+
#ifdef NDEBUG
#define CMAKE_BUILD_TYPE "Release"
#else
#define CMAKE_BUILD_TYPE "Debug"
#endif
-#define CMAKE_USE_GETTEXT @USE_GETTEXT@
-#define CMAKE_USE_SOUND @USE_SOUND@
-#define CMAKE_BUILD_INFO "VER=@VERSION_STRING@ BUILD_TYPE="CMAKE_BUILD_TYPE" RUN_IN_PLACE=@RUN_IN_PLACE@ USE_GETTEXT=@USE_GETTEXT@ USE_SOUND=@USE_SOUND@ INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@"
+#define CMAKE_BUILD_INFO "VER=@VERSION_STRING@ BUILD_TYPE="CMAKE_BUILD_TYPE" RUN_IN_PLACE=@RUN_IN_PLACE@ USE_GETTEXT=@USE_GETTEXT@ USE_SOUND=@USE_SOUND@ STATIC_SHAREDIR=@SHAREDIR@"
#endif
diff --git a/src/config.h b/src/config.h
index 233d74717..aedca8b20 100644
--- a/src/config.h
+++ b/src/config.h
@@ -8,9 +8,10 @@
#define PROJECT_NAME "Minetest"
#define VERSION_STRING "unknown"
-#define BUILD_TYPE "unknown"
+#define RUN_IN_PLACE 0
#define USE_GETTEXT 0
#define USE_SOUND 0
+#define STATIC_SHAREDIR ""
#define BUILD_INFO "non-cmake"
#ifdef USE_CMAKE_CONFIG_H
@@ -19,12 +20,14 @@
#define PROJECT_NAME CMAKE_PROJECT_NAME
#undef VERSION_STRING
#define VERSION_STRING CMAKE_VERSION_STRING
- #undef BUILD_INFO
- #define BUILD_INFO CMAKE_BUILD_INFO
+ #undef RUN_IN_PLACE
+ #define RUN_IN_PLACE CMAKE_RUN_IN_PLACE
#undef USE_GETTEXT
#define USE_GETTEXT CMAKE_USE_GETTEXT
#undef USE_SOUND
#define USE_SOUND CMAKE_USE_SOUND
+ #undef STATIC_SHAREDIR
+ #define STATIC_SHAREDIR CMAKE_STATIC_SHAREDIR
#undef BUILD_INFO
#define BUILD_INFO CMAKE_BUILD_INFO
#endif
diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt
index f2f8b9768..36e271889 100644
--- a/src/lua/CMakeLists.txt
+++ b/src/lua/CMakeLists.txt
@@ -45,6 +45,7 @@ if(DEFAULT_DLOPEN)
else()
option(LUA_USE_DLOPEN "Enable dlopen support." OFF)
endif()
+mark_as_advanced(LUA_USE_DLOPEN)
if(DEFAULT_POSIX)
else()
@@ -55,6 +56,7 @@ if(DEFAULT_ANSI)
else()
option(LUA_ANSI "Disable non-ansi features." OFF)
endif()
+mark_as_advanced(LUA_ANSI)
#
# Lua version
diff --git a/src/main.cpp b/src/main.cpp
index 092a7b03f..6075e9d10 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -878,7 +878,7 @@ int main(int argc, char *argv[])
// Initialize debug streams
#define DEBUGFILE "debug.txt"
-#ifdef RUN_IN_PLACE
+#if RUN_IN_PLACE
std::string logfile = DEBUGFILE;
#else
std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE;
@@ -962,7 +962,7 @@ int main(int argc, char *argv[])
// Legacy configuration file location
filenames.push_back(porting::path_user +
DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");
-#ifdef RUN_IN_PLACE
+#if RUN_IN_PLACE
// Try also from a lower level (to aid having the same configuration
// for many RUN_IN_PLACE installs)
filenames.push_back(porting::path_user +
diff --git a/src/porting.cpp b/src/porting.cpp
index fb999abf9..945aea6eb 100644
--- a/src/porting.cpp
+++ b/src/porting.cpp
@@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "log.h"
#include "util/string.h"
+#include <list>
#ifdef __APPLE__
#include "CoreFoundation/CoreFoundation.h"
@@ -154,7 +155,7 @@ bool detectMSVCBuildDir(char *c_path)
void initializePaths()
{
-#ifdef RUN_IN_PLACE
+#if RUN_IN_PLACE
/*
Use relative paths if RUN_IN_PLACE
*/
@@ -252,19 +253,41 @@ void initializePaths()
#elif defined(linux)
#include <unistd.h>
- char buf[BUFSIZ];
- memset(buf, 0, BUFSIZ);
// Get path to executable
- assert(readlink("/proc/self/exe", buf, BUFSIZ-1) != -1);
-
- pathRemoveFile(buf, '/');
+ std::string bindir = "";
+ {
+ char buf[BUFSIZ];
+ memset(buf, 0, BUFSIZ);
+ assert(readlink("/proc/self/exe", buf, BUFSIZ-1) != -1);
+ pathRemoveFile(buf, '/');
+ bindir = buf;
+ }
- path_share = std::string(buf) + "/../share/" + PROJECT_NAME;
- //path_share = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME;
- if (!fs::PathExists(path_share)) {
- dstream<<"WARNING: system-wide share not found at \""<<path_share<<"\"";
- path_share = std::string(buf) + "/..";
- dstream<<"WARNING: Using \""<<path_share<<"\" instead."<<std::endl;
+ // Find share directory from these.
+ // It is identified by containing the subdirectory "builtin".
+ std::list<std::string> trylist;
+ std::string static_sharedir = STATIC_SHAREDIR;
+ if(static_sharedir != "" && static_sharedir != ".")
+ trylist.push_back(static_sharedir);
+ trylist.push_back(bindir + "/../share/" + PROJECT_NAME);
+ trylist.push_back(bindir + "/..");
+
+ for(std::list<std::string>::const_iterator i = trylist.begin();
+ i != trylist.end(); i++)
+ {
+ const std::string &trypath = *i;
+ if(!fs::PathExists(trypath) || !fs::PathExists(trypath + "/builtin")){
+ dstream<<"WARNING: system-wide share not found at \""
+ <<trypath<<"\""<<std::endl;
+ continue;
+ }
+ // Warn if was not the first alternative
+ if(i != trylist.begin()){
+ dstream<<"WARNING: system-wide share found at \""
+ <<trypath<<"\""<<std::endl;
+ }
+ path_share = trypath;
+ break;
}
path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;
@@ -297,7 +320,7 @@ void initializePaths()
#elif defined(__FreeBSD__)
- path_share = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME;
+ path_share = STATIC_SHAREDIR;
path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;
#endif