CMake stuff works now on linux and windows... and should be possible to make to work...
authorPerttu Ahola <celeron55@gmail.com>
Sat, 8 Jan 2011 15:34:25 +0000 (17:34 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Sat, 8 Jan 2011 15:34:25 +0000 (17:34 +0200)
CMakeLists.txt
cmake/Modules/FindIrrlicht.cmake
cmake/Modules/misc.cmake [new file with mode: 0644]
doc/README.txt
minetest.conf.example
src/CMakeLists.txt
src/main.cpp
src/porting.cpp
src/servermain.cpp

index 53999e02235acaf5d53fb876cf8ba36999782b7e..24cb78f392f52edf28d12eeecd95fdd72b74ac49 100644 (file)
@@ -4,12 +4,72 @@ if(${CMAKE_VERSION} STREQUAL "2.8.2")
   message( WARNING "CMake/CPack version 2.8.2 will not create working .deb packages!")
 endif(${CMAKE_VERSION} STREQUAL "2.8.2")
 
-set(CMAKE_BUILD_TYPE Debug)
+# This can be read from ${PROJECT_NAME} after project() is called
+project(minetest)
+
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
+include(${CMAKE_SOURCE_DIR}/cmake/Modules/misc.cmake)
+
+# Default to Release
+if(NOT CMAKE_BUILD_TYPE)
+       set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
+endif()
+
+# Configuration
+
+set(RUN_IN_PLACE 0 CACHE BOOL "Run directly in source directory structure")
 
-# This is done here so that IRRDIR is relative to the typical cmake call directory
+set(BUILD_CLIENT 1 CACHE BOOL "Build client")
+set(BUILD_SERVER 1 CACHE BOOL "Build server")
+
+# Get date and time
+GETDATETIME(BUILD_DATE)
+MESSAGE(STATUS "BUILD_DATE = ${BUILD_DATE}")
+
+# This is done here so that relative search paths are more reasnable
 find_package(Irrlicht)
 
 # This way the CMakeLists.txt file in src/ is processed
 add_subdirectory(src)
 
+install(FILES "doc/README.txt" DESTINATION "share/minetest/doc")
+
+# CPack
+
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An InfiniMiner/Minecraft inspired game")
+set(CPACK_PACKAGE_VERSION_MAJOR 0)
+set(CPACK_PACKAGE_VERSION_MINOR 0)
+set(CPACK_PACKAGE_VERSION_PATCH 0)
+set(CPACK_PACKAGE_VENDOR "celeron55")
+set(CPACK_PACKAGE_FILE_NAME "minetest-${BUILD_DATE}")
+
+if(WIN32)
+       # For some reason these aren't copied otherwise
+       if(BUILD_CLIENT)
+               install(FILES bin/minetest.exe DESTINATION bin)
+       endif()
+       if(BUILD_SERVER)
+               install(FILES bin/minetestserver.exe DESTINATION bin)
+       endif()
+
+       set(CPACK_GENERATOR ZIP)
+
+       # This might be needed for some installer
+       #set(CPACK_PACKAGE_EXECUTABLES bin/minetest.exe "Minetest" bin/minetestserver.exe "Minetest Server")
+elseif(APPLE)
+       # TODO
+       # see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29
+       set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME})
+       set(CPACK_PACKAGE_ICON "")
+       set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
+       set(CPACK_BUNDLE_ICON "")
+       set(CPACK_BUNDLE_PLIST "")
+       set(CPACK_BUNDLE_STARTUP_COMMAND "Contents/MacOS/minetest")
+       set(CPACK_GENERATOR BUNDLE)
+else()
+       set(CPACK_GENERATOR TGZ)
+       set(CPACK_SOURCE_GENERATOR TGZ)
+endif()
+
+include(CPack)
+
index c39a8cbfb222ea9a130326e7885e19890d6cf786..246e72cfb1c90e63d25ac0b550749361f9c71b7d 100644 (file)
@@ -1,28 +1,54 @@
-MESSAGE(STATUS "IRRDIR = $ENV{IRRDIR}")
+#FindIrrlicht.cmake
+
+set(IRRLICHT_SOURCE_DIR "" CACHE PATH "Path to irrlicht source directory (optional)")
+
+if( UNIX )
+       # Unix
+else( UNIX )
+       # Windows
+endif( UNIX )
+
+# Find include directory
 
 FIND_PATH(IRRLICHT_INCLUDE_DIR NAMES irrlicht.h
-   PATHS
-   $ENV{IRRDIR}/include
-   /usr/local/include/irrlicht
-   /usr/include/irrlicht
+       PATHS
+       /usr/local/include/irrlicht
+       /usr/include/irrlicht
+       "${IRRLICHT_SOURCE_DIR}/include"
 )
 
-MESSAGE(STATUS "IRRLICHT_INCLUDE_DIR = ${IRRLICHT_INCLUDE_DIR}")
+# Find library directory
 
 FIND_LIBRARY(IRRLICHT_LIBRARY NAMES libIrrlicht.a Irrlicht
-   PATHS
-   $ENV{IRRDIR}/lib
-   $ENV{IRRDIR}/lib/Linux
-   $ENV{IRRDIR}/lib/MacOSX
-   $ENV{IRRDIR}/lib/Win32-gcc
-   $ENV{IRRDIR}/lib/Win32-visualstudio
-   $ENV{IRRDIR}/lib/Win64-visualstudio
-   /usr/local/lib
-   /usr/lib
+       PATHS
+       /usr/local/lib
+       /usr/lib
+       #${IRRLICHT_PLATFORM_DIR}
+       "${IRRLICHT_SOURCE_DIR}/lib/Win32-visualstudio"
+       "${IRRLICHT_SOURCE_DIR}/lib/Win32-gcc"
 )
 
+MESSAGE(STATUS "IRRLICHT_INCLUDE_DIR = ${IRRLICHT_INCLUDE_DIR}")
 MESSAGE(STATUS "IRRLICHT_LIBRARY = ${IRRLICHT_LIBRARY}")
 
+# On windows, find the dll for installation
+if(WIN32)
+       if(MSVC)
+               FIND_FILE(IRRLICHT_DLL NAMES Irrlicht.dll
+                       PATHS
+                       "${IRRLICHT_SOURCE_DIR}/bin/Win32-VisualStudio"
+                       DOC "Path of the Irrlicht dll (for installation)"
+               )
+       else()
+               FIND_FILE(IRRLICHT_DLL NAMES Irrlicht.dll
+                       PATHS
+                       "${IRRLICHT_SOURCE_DIR}/bin/Win32-gcc"
+                       DOC "Path of the Irrlicht dll (for installation)"
+               )
+       endif()
+       MESSAGE(STATUS "IRRLICHT_DLL = ${IRRLICHT_DLL}")
+endif(WIN32)
+
 # handle the QUIETLY and REQUIRED arguments and set IRRLICHT_FOUND to TRUE if
 # all listed variables are TRUE
 INCLUDE(FindPackageHandleStandardArgs)
@@ -34,5 +60,5 @@ ELSE(IRRLICHT_FOUND)
   SET(IRRLICHT_LIBRARIES)
 ENDIF(IRRLICHT_FOUND)
 
-MARK_AS_ADVANCED(IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR) 
+MARK_AS_ADVANCED(IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR IRRLICHT_DLL
 
diff --git a/cmake/Modules/misc.cmake b/cmake/Modules/misc.cmake
new file mode 100644 (file)
index 0000000..61a7d14
--- /dev/null
@@ -0,0 +1,16 @@
+MACRO (GETDATETIME RESULT)
+    IF (WIN32)
+               EXECUTE_PROCESS(COMMAND "cmd" /C echo %date% %time% OUTPUT_VARIABLE ${RESULT})
+               string(REGEX REPLACE "\n" "" ${RESULT} "${${RESULT}}")
+    ELSEIF(UNIX)
+        EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d_%H:%M:%S" OUTPUT_VARIABLE ${RESULT})
+               string(REGEX REPLACE "\n" "" ${RESULT} "${${RESULT}}")
+    ELSE (WIN32)
+        MESSAGE(SEND_ERROR "date not implemented")
+        SET(${RESULT} "Unknown")
+    ENDIF (WIN32)
+
+       string(REGEX REPLACE " " "_" ${RESULT} "${${RESULT}}")
+
+ENDMACRO (GETDATETIME)
+
index 8cfddb2b64de6de442ac6fdd40d555afdedb08d4..09e5fea0545658dcef1a30357356d6aacb0a137c 100644 (file)
@@ -5,67 +5,81 @@ Copyright (c) 2010 Perttu Ahola <celeron55@gmail.com>
 
 An InfiniMiner/Minecraft inspired game.
 
+NOTE: This file is somewhat outdated most of the time.
+
 This is a development version:
 - Don't expect it to work as well as a finished game will.
 - Please report any bugs to me. That way I can fix them to the next release.
-       - debug.txt is very useful when the game crashes.
+       - debug.txt is useful when the game crashes.
 
 Public servers:
-       kray.dy.fi :30000 (friend's server - recommended)
-       celeron.55.lt :30000 (my own server, kind of unused)
-- If you want to run a server, I can list you on my website and in here.
+       kray.dy.fi :30000 (friend's server)
+       celeron.55.lt :30000 (my own server)
 
 Controls:
-- WASD+mouse: Move
-- Mouse L: Dig
-- Mouse R: Place block
-- Mouse Wheel: Change item
-- F: Change item
-- R: Toggle full view range
+- See the in-game pause menu
 
 Configuration file:
 - An optional configuration file can be used. See minetest.conf.example.
 - Path to file can be passed as a parameter to the executable:
        --config <path-to-file>
-- If not given as a parameter, these are checked, in order:
-       ../minetest.conf
+- Defaults:
+       - If built with -DRUN_IN_PLACE:
+               ../minetest.conf
+               ../../minetest.conf
+       - Otherwise something like this:
+               Windows: C:\Documents and Settings\user\Application Data\minetest\minetest.conf
+               Linux: ~/.minetest/minetest.conf
+               OS X: ~/Library/Application Support/minetest.conf
 
 Command-line options:
 - Use --help
 
-Running on Windows:
-- The working directory should be ./bin
-
-Running on GNU/Linux:
-- fasttest is a linux binary compiled on a recent Arch Linux installation.
-  It should run on most recent GNU/Linux distributions.
-- Browse to the game ./bin directory and type:
-    LD_LIBRARY_PATH=. ./fasttest
-- If it doesn't work, use wine. I aim at 100% compatibility with wine.
-
 Compiling on GNU/Linux:
+
 - You need:
-* Irrlicht:
-       http://downloads.sourceforge.net/irrlicht/irrlicht-1.7.2.zip
-* JThread:
-       http://research.edm.uhasselt.be/~jori/page/index.php?n=CS.Jthread
-* zlib:
-       - Get the -dev package from your package manager.
-- Irrlicht and JThread are very likely not to be found from your distro's
-  repository.
-- Compiling each of them should be fairly unproblematic, though.
+       * CMake
+       * Irrlicht
+       * Zlib
+       - You can probably find these in your distro's package manager
+
+- Check possible options:
+       $ cd whatever/minetest
+       $ cmake . -LH
+
+- A system-wide install:
+       $ cd whatever/minetest
+       $ cmake . -DCMAKE_INSTALL_PREFIX=/usr/local
+       $ make -j2
+       $ sudo make install
+
+       $ minetest
+
+- For running in the source directory:
+       $ cd whatever/minetest
+       $ cmake . -DRUN_IN_PLACE
+       $ make -j2
+
+       $ ./bin/minetest
 
 Compiling on Windows:
-- You need Irrlicht, JThread and zlib, see above
-- Be sure to
-  #define JMUTEX_CRITICALSECTION
-  in jmutex.h before compiling it. Otherwise mutexes will be very slow.
+- You need CMake, Irrlicht, zlib and Visual Studio or MinGW
+- NOTE: Probably it will not work easily and you will need to fix some stuff.
+- Steps:
+       - Start up the CMake GUI
+       - Select your compiler
+       - Hit "Configure"
+       - Set up some options and paths
+       - Hit "Configure"
+       - Hit "Generate"
+       - VC: Open the generated .sln and build it
+       - MinGW: Browse to the build directory and run 'make'
 
 License of Minetest-c55
 -----------------------
 
 Minetest-c55
-Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
index 48754c57ffefd3e46cc821b9a85525c8391b8bd1..4ce3b81e2ff5654f09222027c8b6258ba8bb0135 100644 (file)
@@ -27,6 +27,8 @@
 
 # Server side stuff
 
+#map-dir = /home/palle/custom_map
+
 # - The possible generators are:
 # (Indeed you can do all of them with only "power" 8))
 # H=value:
index 72a159f161eb01956b19e051356eed328c5fc905..083395271ef6aec91d6caff07f8ca9a9c4cc2ef4 100644 (file)
@@ -1,19 +1,37 @@
 project(minetest)
 cmake_minimum_required( VERSION 2.6 )
-set ( CMAKE_BUILD_TYPE Debug )
-add_definitions ( -Wall -DRUN_IN_PLACE -O2)
-find_package(ZLIB REQUIRED)
-find_package(X11 REQUIRED)
-find_package(OpenGL REQUIRED)
-find_package(JPEG REQUIRED)
-find_package(BZip2 REQUIRED)
 
-if( UNIX )
-  #set( platform_SRCS some_necessary_linux_file.cpp )
-else( UNIX )
-  #windows
-  #set( platform_SRCS dllmain.cpp stdafx.cpp )
-endif( UNIX )
+if(RUN_IN_PLACE)
+       add_definitions ( -DRUN_IN_PLACE )
+endif(RUN_IN_PLACE)
+
+if(UNIX)
+       # Unix
+       if(BUILD_CLIENT)
+               find_package(X11 REQUIRED)
+               find_package(OpenGL REQUIRED)
+               find_package(JPEG REQUIRED)
+               find_package(BZip2 REQUIRED)
+       endif(BUILD_CLIENT)
+       find_package(ZLIB REQUIRED)
+       set(SERVER_PLATFORM_LIBS -lpthread)
+elseif(WIN32)
+       # Windows
+       # Surpress some warnings
+       add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
+       # Zlib stuff
+       set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
+                       CACHE PATH "Zlib include directory")
+       set(ZLIB_LIBRARIES "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.lib"
+                       CACHE PATH "Path to zlibwapi.lib")
+       set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll"
+                       CACHE PATH "Path to zlibwapi.dll (for installation)")
+endif()
+
+configure_file(
+       "${PROJECT_SOURCE_DIR}/config.h.in"
+       "${PROJECT_BINARY_DIR}/config.h"
+)
 
 set(minetest_SRCS
        porting.cpp
@@ -48,26 +66,135 @@ set(minetest_SRCS
        test.cpp
 )
 
+set(minetestserver_SRCS
+       porting.cpp
+       materials.cpp
+       defaultsettings.cpp
+       mapnode.cpp
+       voxel.cpp
+       mapblockobject.cpp
+       inventory.cpp
+       debug.cpp
+       serialization.cpp
+       light.cpp
+       filesys.cpp
+       connection.cpp
+       environment.cpp
+       server.cpp
+       socket.cpp
+       mapblock.cpp
+       mapsector.cpp
+       heightmap.cpp
+       map.cpp
+       player.cpp
+       utility.cpp
+       servermain.cpp
+       test.cpp
+)
+
 include_directories(
-       ${ZLIB_INCLUDE_DIR}
+       ${PROJECT_BINARY_DIR}
        ${IRRLICHT_INCLUDE_DIR}
+       ${ZLIB_INCLUDE_DIR}
+       ${CMAKE_BUILD_TYPE}
        "${PROJECT_SOURCE_DIR}/jthread"
 )
 
 set(EXECUTABLE_OUTPUT_PATH ../bin)
 
-add_executable(minetest ${minetest_SRCS})
+if(BUILD_CLIENT)
+       add_executable(minetest ${minetest_SRCS})
+       target_link_libraries(
+               minetest
+               ${ZLIB_LIBRARIES}
+               ${IRRLICHT_LIBRARY}
+               ${OPENGL_LIBRARIES}
+               ${JPEG_LIBRARIES}
+               ${BZIP2_LIBRARIES}
+               jthread
+       )
+endif(BUILD_CLIENT)
+if(BUILD_SERVER)
+       add_executable(minetestserver ${minetestserver_SRCS})
+       target_link_libraries(
+               minetestserver
+               ${ZLIB_LIBRARIES}
+               jthread
+               ${SERVER_PLATFORM_LIBS}
+       )
+endif(BUILD_SERVER)
 
-target_link_libraries(
-       minetest
-       ${ZLIB_LIBRARIES}
-       ${IRRLICHT_LIBRARY}
-       ${OPENGL_LIBRARIES}
-       ${JPEG_LIBRARIES}
-       ${BZIP2_LIBRARIES}
-       jthread
-)
+# Set some optimizations and tweaks
+if( UNIX )
+       # Unix
+       
+       set(UNIX_FLAGS "-Wall")
+
+       if(BUILD_CLIENT)
+               set_target_properties(minetest PROPERTIES COMPILE_FLAGS
+                               "${UNIX_FLAGS}")
+       endif(BUILD_CLIENT)
+
+       if(BUILD_SERVER)
+               set_target_properties(minetestserver PROPERTIES COMPILE_FLAGS
+                               "${UNIX_FLAGS} -DSERVER")
+       endif(BUILD_SERVER)
+
+else( UNIX )
+       # Windows
+       
+       if(BUILD_CLIENT)
+               # EHa enables SEH exceptions (used for catching segfaults)
+               set_target_properties(minetest PROPERTIES COMPILE_FLAGS
+                               "/O2 /Ob2 /Oi /Ot /Oy /GL /EHa")
+       endif(BUILD_CLIENT)
+
+       if(BUILD_SERVER)
+               # EHa enables SEH exceptions (used for catching segfaults)
+               set_target_properties(minetestserver PROPERTIES COMPILE_FLAGS
+                               "/O2 /Ob2 /Oi /Ot /Oy /GL /EHa /D SERVER")
+       endif(BUILD_SERVER)
+
+endif( UNIX )
+
+#
+# Installation
+#
+
+if(WIN32)
+       set(DATADIR "data")
+       set(BINDIR "bin")
+elseif(APPLE)
+       set(DATADIR "share/minetest")
+       set(BINDIR "bin")
+elseif(UNIX)
+       set(DATADIR "share/minetest")
+       set(BINDIR "bin")
+endif()
+
+if(BUILD_CLIENT)
+       install(TARGETS minetest DESTINATION ${BINDIR})
+
+       file(GLOB images "${CMAKE_CURRENT_SOURCE_DIR}/../data/*.png")
+
+       install(FILES ${images} DESTINATION ${DATADIR})
+
+       if(WIN32)
+               if(DEFINED IRRLICHT_DLL)
+                       install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR})
+               endif()
+               if(DEFINED ZLIB_DLL)
+                       install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
+               endif()
+       endif()
+endif(BUILD_CLIENT)
+
+if(BUILD_SERVER)
+       install(TARGETS minetestserver DESTINATION ${BINDIR})
+endif(BUILD_SERVER)
+
+# Subdirectories
 
 add_subdirectory(jthread)
 
-#END
+#end
index 9ec49feb3eddab8a41287743ecfb5e58d2c23a76..a0da103c94aa06974495ea867aa1b80f99b188bb 100644 (file)
@@ -212,7 +212,7 @@ Doing now:
 */\r
 #define FIELD_OF_VIEW_TEST 0\r
 \r
-#ifdef UNITTEST_DISABLE\r
+#ifdef NDEBUG\r
        #ifdef _WIN32\r
                #pragma message ("Disabling unit tests")\r
        #else\r
@@ -259,6 +259,7 @@ Doing now:
 #include "materials.h"\r
 #include "guiMessageMenu.h"\r
 #include "filesys.h"\r
+#include "config.h"\r
 \r
 IrrlichtWrapper *g_irrlicht;\r
 \r
@@ -1110,6 +1111,12 @@ int main(int argc, char *argv[])
 \r
        BEGIN_DEBUG_EXCEPTION_HANDLER\r
 \r
+       // Print startup message\r
+       dstream<<DTIME<<"minetest-c55"\r
+                       " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST\r
+                       <<", "<<BUILD_INFO\r
+                       <<std::endl;\r
+       \r
        try\r
        {\r
        \r
@@ -1170,12 +1177,6 @@ int main(int argc, char *argv[])
        // Initialize default settings\r
        set_default_settings();\r
        \r
-       // Print startup message\r
-       dstream<<DTIME<<"minetest-c55"\r
-                       " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST\r
-                       <<", ENABLE_TESTS="<<ENABLE_TESTS\r
-                       <<std::endl;\r
-       \r
        // Set locale. This is for forcing '.' as the decimal point.\r
        std::locale::global(std::locale("C"));\r
        // This enables printing all characters in bitmap font\r
@@ -1211,6 +1212,9 @@ int main(int argc, char *argv[])
        {\r
                core::array<std::string> filenames;\r
                filenames.push_back(porting::path_userdata + "/minetest.conf");\r
+#ifdef RUN_IN_PLACE\r
+               filenames.push_back(porting::path_userdata + "/../minetest.conf");\r
+#endif\r
 \r
                for(u32 i=0; i<filenames.size(); i++)\r
                {\r
@@ -1282,6 +1286,8 @@ int main(int argc, char *argv[])
        std::string map_dir = porting::path_userdata+"/map";\r
        if(cmd_args.exists("map-dir"))\r
                map_dir = cmd_args.get("map-dir");\r
+       else if(g_settings.exists("map-dir"))\r
+               map_dir = g_settings.get("map-dir");\r
        \r
        if(cmd_args.getFlag("server"))\r
        {\r
index bff865c53f3bbcdcfde8389ef17f824a295dee6f..6686a657e180baa440ce0d24e419e60547f32340 100644 (file)
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 #include "porting.h"
+#include "config.h"
 
 namespace porting
 {
@@ -103,7 +104,9 @@ void initializePaths()
        path_userdata = std::string("../");
 
        #endif
-#else
+
+#else // RUN_IN_PLACE
+
        /*
                Use platform-specific paths otherwise
        */
@@ -127,6 +130,7 @@ void initializePaths()
        
        // Use "./bin/../data"
        path_data = std::string(buf) + "/../data";
+       //path_data = std::string(buf) + "/../share/" + APPNAME;
                
        // Use "C:\Documents and Settings\user\Application Data\<APPNAME>"
        len = GetEnvironmentVariable("APPDATA", buf, buflen);
@@ -137,20 +141,23 @@ void initializePaths()
                Linux
        */
        #elif defined(linux)
+               #include <unistd.h>
        
-       path_userdata = std::string("~/.") + APPNAME;
-       path_data = std::string("/usr/share/") + APPNAME;
+       path_userdata = std::string(getenv("HOME")) + "/." + APPNAME;
+       path_data = std::string(INSTALL_PREFIX) + "/share/" + APPNAME;
        
        /*
                OS X
        */
        #elif defined(__APPLE__)
+               #include <unistd.h>
 
-       path_userdata = std::string("~/Library/Application Support/") + APPNAME;
+       path_userdata = std::string(getenv("HOME")) + "/Library/Application Support/" + APPNAME;
        path_data = std::string("minetest-mac.app/Contents/Resources/data/");
 
        #endif
-#endif
+
+#endif // RUN_IN_PLACE
 
        dstream<<"path_data = "<<path_data<<std::endl;
        dstream<<"path_userdata = "<<path_userdata<<std::endl;
index d9b8af40239576a9fe0e576f3007b44b5f2a7737..8fcefaae7cfc7982fcdbefd943ffba36a502c09f 100644 (file)
@@ -25,12 +25,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #ifndef SERVER
        #ifdef _WIN32
+               #pragma error ("For a server build, SERVER must be defined globally")
        #else
                #error "For a server build, SERVER must be defined globally"
        #endif
 #endif
 
-#ifdef UNITTEST_DISABLE
+#ifdef NDEBUG
        #ifdef _WIN32
                #pragma message ("Disabling unit tests")
        #else
@@ -66,6 +67,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "strfnd.h"
 #include "porting.h"
 #include "materials.h"
+#include "config.h"
 
 /*
        Settings.
@@ -129,6 +131,12 @@ int main(int argc, char *argv[])
 
        BEGIN_DEBUG_EXCEPTION_HANDLER
 
+       // Print startup message
+       dstream<<DTIME<<"minetest-c55"
+                       " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
+                       <<", "<<BUILD_INFO
+                       <<std::endl;
+       
        try
        {
        
@@ -185,12 +193,6 @@ int main(int argc, char *argv[])
        // Initialize default settings
        set_default_settings();
        
-       // Print startup message
-       dstream<<DTIME<<"minetest-c55 server"
-                       " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
-                       <<", ENABLE_TESTS="<<ENABLE_TESTS
-                       <<std::endl;
-       
        // Set locale. This is for forcing '.' as the decimal point.
        std::locale::global(std::locale("C"));
        // This enables printing all characters in bitmap font
@@ -226,6 +228,9 @@ int main(int argc, char *argv[])
        {
                core::array<std::string> filenames;
                filenames.push_back(porting::path_userdata + "/minetest.conf");
+#ifdef RUN_IN_PLACE
+               filenames.push_back(porting::path_userdata + "/../minetest.conf");
+#endif
 
                for(u32 i=0; i<filenames.size(); i++)
                {
@@ -308,6 +313,8 @@ int main(int argc, char *argv[])
        std::string map_dir = porting::path_userdata+"/map";
        if(cmd_args.exists("map-dir"))
                map_dir = cmd_args.get("map-dir");
+       else if(g_settings.exists("map-dir"))
+               map_dir = g_settings.get("map-dir");
        
        Server server(map_dir.c_str(), hm_params, map_params);
        server.start(port);