Index: code/branches/buildsystem3/src/CMakeLists.txt
===================================================================
--- code/branches/buildsystem3/src/CMakeLists.txt	(revision 2701)
+++ code/branches/buildsystem3/src/CMakeLists.txt	(revision 2702)
@@ -62,5 +62,5 @@
 CHECK_CXX_SOURCE_COMPILES("${_source}" HAVE_FORCEINLINE)
 
-# Check ciso646 include (operators in words)
+# Check ciso646 include (literal operators)
 INCLUDE(CheckIncludeFileCXX)
 CHECK_INCLUDE_FILE_CXX(iso646.h HAVE_ISO646_H)
@@ -78,4 +78,6 @@
 # Copy and configure OrxonoxConfig which gets included in every file
 CONFIGURE_FILE(OrxonoxConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/OrxonoxConfig.h)
+# This file only gets included by very few classes to avoid a large recompilation
+CONFIGURE_FILE(SpecialConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/SpecialConfig.h)
 
 
Index: code/branches/buildsystem3/src/OrxonoxConfig.h.in
===================================================================
--- code/branches/buildsystem3/src/OrxonoxConfig.h.in	(revision 2701)
+++ code/branches/buildsystem3/src/OrxonoxConfig.h.in	(revision 2702)
@@ -180,52 +180,14 @@
  * Various Settings
  *-------------------------------*/
-/* Set whether we must suffix "ceguilua/" for the CEGUILua.h include */
-#cmakedefine CEGUILUA_USE_INTERNAL_LIBRARY
-
-/* Defined if a precompiled depdency package was used. We then copy all libraries
-   too when installing. */
-#cmakedefine DEPENDENCY_PACKAGE_ENABLE
-
-/* Using MSVC or XCode IDE */
-#cmakedefine CMAKE_CONFIGURATION_TYPES
-
-/* Macros used in the next section */
-#define MACRO_CONCATENATE(str1, str2) str1##str2
-#define MACRO_QUOTEME_AUX(x) #x
-#define MACRO_QUOTEME(x) MACRO_QUOTEME_AUX(x)
-
-/* Handle default ConfigValues */
+/* Define a platform independent directory separator */
 namespace orxonox
 {
-    const char* const ORXONOX_MEDIA_INSTALL_PATH ("@ORXONOX_MEDIA_INSTALL_PATH_EXEC@/");
-    const char* const ORXONOX_CONFIG_INSTALL_PATH("@ORXONOX_CONFIG_INSTALL_PATH_EXEC@/");
-    const char* const ORXONOX_LOG_INSTALL_PATH   ("@ORXONOX_LOG_INSTALL_PATH_EXEC@/");
-
-    const char* const ORXONOX_MEDIA_DEV_PATH     ("@ORXONOX_MEDIA_DEV_PATH@/");
-#ifdef CMAKE_CONFIGURATION_TYPES
-    const char* const ORXONOX_CONFIG_DEV_PATH    ("@ORXONOX_CONFIG_DEV_PATH@/" MACRO_QUOTEME(CMAKE_BUILD_TYPE) "/");
-    const char* const ORXONOX_LOG_DEV_PATH       ("@ORXONOX_LOG_DEV_PATH@/"    MACRO_QUOTEME(CMAKE_BUILD_TYPE) "/");
+#ifdef ORXONOX_PLATFORM_WINDOWS
+    const char CP_SLASH('\\');
 #else
-    const char* const ORXONOX_CONFIG_DEV_PATH    ("@ORXONOX_CONFIG_DEV_PATH@/");
-    const char* const ORXONOX_LOG_DEV_PATH       ("@ORXONOX_LOG_DEV_PATH@/");
-#endif
-    
-    /* OGRE Plugins */
-#ifdef NDEBUG
-    const char* const ORXONOX_OGRE_PLUGINS("@OGRE_PLUGINS_RELEASE@");
-#  ifdef DEPENDENCY_PACKAGE_ENABLE
-    const char* const ORXONOX_OGRE_PLUGINS_FOLDER(".");
-#  else
-    const char* const ORXONOX_OGRE_PLUGINS_FOLDER("@OGRE_PLUGINS_FOLDER_RELEASE@");
-#  endif
-#else
-    const char* const ORXONOX_OGRE_PLUGINS("@OGRE_PLUGINS_DEBUG@");
-#  ifdef DEPENDENCY_PACKAGE_ENABLE
-    const char* const ORXONOX_OGRE_PLUGINS_FOLDER(".");
-#  else
-    const char* const ORXONOX_OGRE_PLUGINS_FOLDER("@OGRE_PLUGINS_FOLDER_DEBUG@");
-#  endif
+    const char CP_SLASH('/')
 #endif
 }
 
+
 #endif /* _OrxonoxConfig_H__ */
Index: code/branches/buildsystem3/src/SpecialConfig.h.in
===================================================================
--- code/branches/buildsystem3/src/SpecialConfig.h.in	(revision 2702)
+++ code/branches/buildsystem3/src/SpecialConfig.h.in	(revision 2702)
@@ -0,0 +1,97 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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 the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief
+    Various constants and options that only affect very little code.
+ @note
+    This is merely to avoid recompiling everything when only a path changes.
+
+    @GENERATED_FILE_COMMENT@
+ */
+
+#ifndef _SpecialConfig_H__
+#define _SpecialConfig_H__
+
+/* Set whether we must suffix "ceguilua/" for the CEGUILua.h include */
+#cmakedefine CEGUILUA_USE_INTERNAL_LIBRARY
+
+/* Defined if a precompiled depdency package was used. We then copy all libraries
+   too when installing. */
+#cmakedefine DEPENDENCY_PACKAGE_ENABLE
+
+/* Orxonox either gets installed to the system or just into a folder.
+   The latter uses relative paths. */
+#cmakedefine INSTALL_COPYABLE
+
+/* Using MSVC or XCode IDE */
+#cmakedefine CMAKE_CONFIGURATION_TYPES
+
+/* Macros used in the next section */
+#define MACRO_CONCATENATE(str1, str2) str1##str2
+#define MACRO_QUOTEME_AUX(x) #x
+#define MACRO_QUOTEME(x) MACRO_QUOTEME_AUX(x)
+
+/* Handle default ConfigValues */
+namespace orxonox
+{
+    const char* const ORXONOX_RUNTIME_INSTALL_PATH("@ORXONOX_RUNTIME_INSTALL_PATH@");
+    const char* const ORXONOX_MEDIA_INSTALL_PATH  ("@ORXONOX_MEDIA_INSTALL_PATH@");
+    /* Config and Log path might be relative because they could be user and therefore runtime dependent */
+    const char* const ORXONOX_CONFIG_INSTALL_PATH ("@ORXONOX_CONFIG_INSTALL_PATH@");
+    const char* const ORXONOX_LOG_INSTALL_PATH    ("@ORXONOX_LOG_INSTALL_PATH@");
+
+    const char* const ORXONOX_MEDIA_DEV_PATH      ("@CMAKE_MEDIA_OUTPUT_DIRECTORY@");
+#ifdef CMAKE_CONFIGURATION_TYPES
+    const char* const ORXONOX_CONFIG_DEV_PATH     ("@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" MACRO_QUOTEME(CMAKE_BUILD_TYPE));
+    const char* const ORXONOX_LOG_DEV_PATH        ("@CMAKE_LOG_OUTPUT_DIRECTORY@/"    MACRO_QUOTEME(CMAKE_BUILD_TYPE));
+#else
+    const char* const ORXONOX_CONFIG_DEV_PATH     ("@CMAKE_CONFIG_OUTPUT_DIRECTORY@");
+    const char* const ORXONOX_LOG_DEV_PATH        ("@CMAKE_LOG_OUTPUT_DIRECTORY@");
+#endif
+    
+    /* OGRE Plugins */
+#ifdef NDEBUG
+    const char* const ORXONOX_OGRE_PLUGINS("@OGRE_PLUGINS_RELEASE@");
+#  ifdef DEPENDENCY_PACKAGE_ENABLE
+    const char* const ORXONOX_OGRE_PLUGINS_FOLDER(".");
+#  else
+    const char* const ORXONOX_OGRE_PLUGINS_FOLDER("@OGRE_PLUGINS_FOLDER_RELEASE@");
+#  endif
+#else
+    const char* const ORXONOX_OGRE_PLUGINS("@OGRE_PLUGINS_DEBUG@");
+#  ifdef DEPENDENCY_PACKAGE_ENABLE
+    const char* const ORXONOX_OGRE_PLUGINS_FOLDER(".");
+#  else
+    const char* const ORXONOX_OGRE_PLUGINS_FOLDER("@OGRE_PLUGINS_FOLDER_DEBUG@");
+#  endif
+#endif
+}
+
+#endif /* _SpecialConfig_H__ */
Index: code/branches/buildsystem3/src/core/ArgumentCompletionFunctions.cc
===================================================================
--- code/branches/buildsystem3/src/core/ArgumentCompletionFunctions.cc	(revision 2701)
+++ code/branches/buildsystem3/src/core/ArgumentCompletionFunctions.cc	(revision 2702)
@@ -27,10 +27,10 @@
  */
 
+#include "ArgumentCompletionFunctions.h"
+
 #include <iostream>
 #include <map>
-
 #include <boost/filesystem.hpp>
 
-#include "ArgumentCompletionFunctions.h"
 #include "CoreIncludes.h"
 #include "Identifier.h"
@@ -68,5 +68,5 @@
                     std::string dir = startdirectory.string();
                     if (dir.size() > 0 && dir[dir.size() - 1] == ':')
-                        startdirectory = dir + "/";
+                        startdirectory = dir + CP_SLASH;
                 }
 #endif
@@ -78,5 +78,5 @@
                 {
                     if (boost::filesystem::is_directory(*file))
-                        dirlist.push_back(ArgumentCompletionListElement((*file).string() + "/", getLowercase((*file).string()) + "/", (*file).leaf() + "/"));
+                        dirlist.push_back(ArgumentCompletionListElement((*file).string() + CP_SLASH, getLowercase((*file).string()) + "/", (*file).leaf() + "/"));
                     else
                         filelist.push_back(ArgumentCompletionListElement((*file).string(), getLowercase((*file).string()), (*file).leaf()));
Index: code/branches/buildsystem3/src/core/CommandLine.cc
===================================================================
--- code/branches/buildsystem3/src/core/CommandLine.cc	(revision 2701)
+++ code/branches/buildsystem3/src/core/CommandLine.cc	(revision 2702)
@@ -302,6 +302,5 @@
 
         std::string filename = CommandLine::getValue("optionsFile").getString();
-        boost::filesystem::path folder(Core::getConfigPath());
-        boost::filesystem::path filepath(folder/filename);
+        boost::filesystem::path filepath(Core::getConfigPath() / filename);
 
         // look for additional arguments in given file or start.ini as default
Index: code/branches/buildsystem3/src/core/ConfigFileManager.cc
===================================================================
--- code/branches/buildsystem3/src/core/ConfigFileManager.cc	(revision 2701)
+++ code/branches/buildsystem3/src/core/ConfigFileManager.cc	(revision 2702)
@@ -227,11 +227,9 @@
 
         // Get default file if necessary and available
-        boost::filesystem::path filepath(Core::getConfigPath());
-        filepath /= this->filename_;
+        boost::filesystem::path filepath(Core::getConfigPath() / this->filename_);
         if (!boost::filesystem::exists(filepath))
         {
             // Try to get default one from the media folder
-            boost::filesystem::path defaultFilepath(Core::getMediaPath());
-            defaultFilepath = defaultFilepath / "defaultConfig" / this->filename_;
+            boost::filesystem::path defaultFilepath(Core::getMediaPath() / "defaultConfig" / this->filename_);
             if (boost::filesystem::exists(defaultFilepath))
             {
@@ -345,6 +343,5 @@
     void ConfigFile::save() const
     {
-        boost::filesystem::path filepath(Core::getConfigPath());
-        filepath /= this->filename_;
+        boost::filesystem::path filepath(Core::getConfigPath() / this->filename_);
 
         std::ofstream file;
Index: code/branches/buildsystem3/src/core/Core.cc
===================================================================
--- code/branches/buildsystem3/src/core/Core.cc	(revision 2701)
+++ code/branches/buildsystem3/src/core/Core.cc	(revision 2702)
@@ -33,8 +33,22 @@
 
 #include "Core.h"
+
 #include <cassert>
 #include <fstream>
+#include <cstdlib>
+#include <cstdio>
 #include <boost/filesystem.hpp>
 
+#ifdef ORXONOX_PLATFORM_WINDOWS
+#  include <windows.h>
+#elif defined(ORXONOX_PLATFORM_APPLE)
+#  include <sys/param.h>
+#  include <mach-o/dyld.h>
+#else /* Linux */
+#  include <sys/types.h>
+#  include <unistd.h>
+#endif
+
+#include "SpecialConfig.h"
 #include "util/Exception.h"
 #include "Language.h"
@@ -46,4 +60,11 @@
 namespace orxonox
 {
+    //! Path to the parent directory of the ones above if program was installed with relativ pahts
+    static boost::filesystem::path rootPath_g;
+    static boost::filesystem::path executablePath_g;            //!< Path to the executable
+    static boost::filesystem::path mediaPath_g;                 //!< Path to the media file folder
+    static boost::filesystem::path configPath_g;                //!< Path to the config file folder
+    static boost::filesystem::path logPath_g;                   //!< Path to the log file folder
+
     bool Core::bShowsGraphics_s = false;
     bool Core::bHasServer_s     = false;
@@ -53,9 +74,5 @@
 
     bool Core::isDevBuild_s     = false;
-    std::string Core::configPath_s(ORXONOX_CONFIG_INSTALL_PATH); // from OrxonoxConfig.h
-    std::string Core::logPath_s   (ORXONOX_LOG_INSTALL_PATH);    // from OrxonoxConfig.h
-    std::string Core::mediaPath_s (ORXONOX_MEDIA_INSTALL_PATH);  // from OrxonoxConfig.h
-
-    Core* Core::singletonRef_s = 0;
+    Core* Core::singletonRef_s  = 0;
 
     SetCommandLineArgument(mediaPath, "").information("PATH");
@@ -76,11 +93,11 @@
 
         // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
-        OutputHandler::getOutStream().setLogPath(Core::logPath_s);
+        OutputHandler::getOutStream().setLogPath(Core::getLogPathString());
 
         // Possible media path override by the command line
         if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
         {
-            std::string mediaPath = CommandLine::getValue("mediaPath");
-            Core::tsetMediaPath(mediaPath);
+            //std::string mediaPath = CommandLine::getValue("mediaPath");
+            Core::tsetMediaPath(CommandLine::getValue("mediaPath"));
         }
     }
@@ -119,12 +136,6 @@
         SetConfigValue(bInitializeRandomNumberGenerator_, true).description("If true, all random actions are different each time you start the game").callback(this, &Core::initializeRandomNumberGenerator);
 
-        // Media path (towards config and log path) is ini-configurable
-        const char* defaultMediaPath = ORXONOX_MEDIA_INSTALL_PATH;
-        if (Core::isDevBuild())
-            defaultMediaPath = ORXONOX_MEDIA_DEV_PATH;
-
-        SetConfigValue(mediaPath_s, defaultMediaPath)
+        SetConfigValue(mediaPathString_, Core::getMediaPathPOSIXString())
             .description("Relative path to the game data.").callback(this, &Core::mediaPathChanged);
-
     }
 
@@ -162,14 +173,5 @@
     void Core::mediaPathChanged()
     {
-        if (mediaPath_s != "" && mediaPath_s[mediaPath_s.size() - 1] != '/')
-        {
-            ModifyConfigValue(mediaPath_s, set, mediaPath_s + "/");
-        }
-
-        if (mediaPath_s == "")
-        {
-            ModifyConfigValue(mediaPath_s, set, "/");
-            COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
-        }
+        mediaPath_g = boost::filesystem::path(this->mediaPathString_);
     }
 
@@ -248,12 +250,45 @@
     void Core::_tsetMediaPath(const std::string& path)
     {
-        if (*path.end() != '/' && *path.end() != '\\')
-        {
-            ModifyConfigValue(mediaPath_s, tset, path + "/");
-        }
-        else
-        {
-            ModifyConfigValue(mediaPath_s, tset, path);
-        }
+        ModifyConfigValue(mediaPathString_, tset, path);
+    }
+
+    /*static*/ const boost::filesystem::path& Core::getMediaPath()
+    {
+        return mediaPath_g;
+    }
+    /*static*/ std::string Core::getMediaPathString()
+    {
+        return mediaPath_g.directory_string() + CP_SLASH;
+    }
+    /*static*/ std::string Core::getMediaPathPOSIXString()
+    {
+        return mediaPath_g.string() + '/';
+        
+    }
+
+    /*static*/ const boost::filesystem::path& Core::getConfigPath()
+    {
+        return configPath_g;
+    }
+    /*static*/ std::string Core::getConfigPathString()
+    {
+        return configPath_g.directory_string() + CP_SLASH;
+    }
+    /*static*/ std::string Core::getConfigPathPOSIXString()
+    {
+        return configPath_g.string() + '/';
+    }
+
+    /*static*/ const boost::filesystem::path& Core::getLogPath()
+    {
+        return logPath_g;
+    }
+    /*static*/ std::string Core::getLogPathString()
+    {
+        return logPath_g.directory_string() + CP_SLASH;
+    }
+    /*static*/ std::string Core::getLogPathPOSIXString()
+    {
+        return logPath_g.string() + '/';
     }
 
@@ -271,5 +306,76 @@
     /**
     @brief
-        Checks for "orxonox_dev_build.keep_me" in the working diretory.
+        Performs the rather lower level operations just after
+        int main() has been called.
+    @remarks
+        This gets called AFTER pre-main stuff like AddFactory,
+        SetConsoleCommand, etc.
+    */
+    /*static*/ void Core::postMainInitialisation()
+    {
+        // set location of the executable
+        Core::setExecutablePath();
+
+        // Determine whether we have an installed or a binary dir run
+        // The latter occurs when simply running from the build directory
+        Core::checkDevBuild();
+
+        // Make sure the directories we write in exist or else make them
+        Core::createDirectories();
+    }
+
+    /**
+    @brief
+        Compares the executable path with the working directory
+    */
+    /*static*/ void Core::setExecutablePath()
+    {
+#ifdef ORXONOX_PLATFORM_WINDOWS
+        // get executable module
+        TCHAR buffer[1024];
+        if (GetModuleFileName(NULL, buffer, 1024) == 0)
+            ThrowException(General, "Could not retrieve executable path.");
+
+#elif defined(ORXONOX_PLATFORM_APPLE)
+        char buffer[1024];
+        unsigned long path_len = 1023;
+        if (_NSGetExecutablePath(buffer, &path_len))
+            ThrowException(General, "Could not retrieve executable path.");
+
+#else /* Linux */
+        /* written by Nicolai Haehnle <prefect_@gmx.net> */
+
+        /* Get our PID and build the name of the link in /proc */
+        char linkname[64]; /* /proc/<pid>/exe */
+        if (snprintf(linkname, sizeof(linkname), "/proc/%i/exe", getpid()) < 0)
+        {
+            /* This should only happen on large word systems. I'm not sure
+               what the proper response is here.
+               Since it really is an assert-like condition, aborting the
+               program seems to be in order. */
+            assert(false);
+        }
+
+        /* Now read the symbolic link */
+        char buffer[1024];
+        int ret;
+        ret = readlink(linkname, buffer, 1024);
+        /* In case of an error, leave the handling up to the caller */
+        if (ret == -1)
+            ThrowException(General, "Could not retrieve executable path.");
+
+        /* Ensure proper NUL termination */
+        buf[ret] = 0;
+#endif
+
+        executablePath_g = boost::filesystem::path(buffer);
+#ifndef ORXONOX_PLATFORM_APPLE
+        executablePath_g = executablePath_g.branch_path(); // remove executable name
+#endif
+    }
+
+    /**
+    @brief
+        Checks for "orxonox_dev_build.keep_me" in the executable diretory.
         If found it means that this is not an installed run, hence we
         don't write the logs and config files to ~/.orxonox
@@ -277,14 +383,46 @@
     /*static*/ void Core::checkDevBuild()
     {
-        std::ifstream probe;
-        probe.open("orxonox_dev_build.keep_me");
-        if (probe)
-        {
+        if (boost::filesystem::exists(executablePath_g / "orxonox_dev_build.keep_me"))
+        {
+            COUT(1) << "Running from the build tree." << std::endl;
             Core::isDevBuild_s = true;
-            // Constants are taken from OrxonoxConfig.h
-            Core::configPath_s = ORXONOX_CONFIG_DEV_PATH;
-            Core::logPath_s    = ORXONOX_LOG_DEV_PATH;
-            Core::mediaPath_s  = ORXONOX_MEDIA_DEV_PATH;
-            probe.close();
+            mediaPath_g  = ORXONOX_MEDIA_DEV_PATH;
+            configPath_g = ORXONOX_CONFIG_DEV_PATH;
+            logPath_g    = ORXONOX_LOG_DEV_PATH;
+        }
+        else
+        {
+#ifdef INSTALL_COPYABLE // --> relative paths
+            // Also set the root path
+            boost::filesystem::path relativeExecutablePath(ORXONOX_RUNTIME_INSTALL_PATH);
+            rootPath_g = executablePath_g;
+            while (!boost::filesystem::equivalent(rootPath_g / relativeExecutablePath, executablePath_g) || rootPath_g.empty())
+                rootPath_g = rootPath_g.branch_path();
+            if (rootPath_g.empty())
+                ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
+
+            // Using paths relative to the install prefix, complete them
+            mediaPath_g  = rootPath_g / ORXONOX_MEDIA_INSTALL_PATH;
+            configPath_g = rootPath_g / ORXONOX_CONFIG_INSTALL_PATH;
+            logPath_g    = rootPath_g / ORXONOX_LOG_INSTALL_PATH;
+#else
+            // There is no root path, so don't set it at all
+
+            mediaPath_g  = ORXONOX_MEDIA_INSTALL_PATH;
+
+            // Get user directory
+#  ifdef ORXONOX_PLATFORM_UNIX /* Apple? */
+            char* userDataPathPtr(getenv("HOME"));
+#  else
+            char* userDataPathPtr(getenv("APPDATA"));
+#  endif
+            if (userDataPathPtr == NULL)
+                ThrowException(General, "Could not retrieve user data path.");
+            boost::filesystem::path userDataPath(userDataPathPtr);
+            userDataPath /= ".orxonox";
+
+            configPath_g = userDataPath / ORXONOX_CONFIG_INSTALL_PATH;
+            logPath_g    = userDataPath / ORXONOX_LOG_INSTALL_PATH;
+#endif
         }
     }
@@ -299,7 +437,7 @@
         std::vector<std::pair<boost::filesystem::path, std::string> > directories;
         directories.push_back(std::pair<boost::filesystem::path, std::string>
-            (boost::filesystem::path(Core::configPath_s), "config"));
+            (boost::filesystem::path(configPath_g), "config"));
         directories.push_back(std::pair<boost::filesystem::path, std::string>
-            (boost::filesystem::path(Core::logPath_s),    "log"));
+            (boost::filesystem::path(logPath_g),    "log"));
 
         for (std::vector<std::pair<boost::filesystem::path, std::string> >::iterator it = directories.begin();
Index: code/branches/buildsystem3/src/core/Core.h
===================================================================
--- code/branches/buildsystem3/src/core/Core.h	(revision 2701)
+++ code/branches/buildsystem3/src/core/Core.h	(revision 2702)
@@ -44,6 +44,13 @@
 #include "util/OutputHandler.h"
 
-// Only allow main to access setDevBuild, so we need a forward declaration
+// Only allow main to access postMainInitialisation, so we need a forward declaration
 int main(int, char**);
+// boost::filesystem header has quite a large tail, use forward declaration
+namespace boost { namespace filesystem
+{
+    struct path_traits;
+    template<class String, class Traits> class basic_path;
+    typedef basic_path< std::string, path_traits> path;
+} }
 
 namespace orxonox
@@ -70,7 +77,13 @@
             static void tsetMediaPath(const std::string& path)
             { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); }
-            static const std::string& getMediaPath()  { return mediaPath_s; }
-            static const std::string& getConfigPath() { return configPath_s; }
-            static const std::string& getLogPath()    { return logPath_s; }
+            static const boost::filesystem::path& getMediaPath();
+            static const boost::filesystem::path& getConfigPath();
+            static const boost::filesystem::path& getLogPath();
+            static std::string getMediaPathString();
+            static std::string getConfigPathString();
+            static std::string getLogPathString();
+            static std::string getMediaPathPOSIXString();
+            static std::string getConfigPathPOSIXString();
+            static std::string getLogPathPOSIXString();
 
             // fast access global variables.
@@ -95,6 +108,8 @@
             void _tsetMediaPath(const std::string& path);
 
+            static void postMainInitialisation();
+            static void checkDevBuild();
+            static void setExecutablePath();
             static void createDirectories();
-            static void checkDevBuild();
 
             int softDebugLevel_;                            //!< The debug level
@@ -104,4 +119,5 @@
             std::string language_;                          //!< The language
             bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
+            std::string mediaPathString_;                   //!< Path to the data/media file folder as string
 
             static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
@@ -112,7 +128,4 @@
 
             static bool isDevBuild_s;                       //!< True for builds in the build directory (not installed)
-            static std::string configPath_s;                //!< Path to the config file folder
-            static std::string logPath_s;                   //!< Path to the log file folder
-            static std::string mediaPath_s;                 //!< Path to the data/media file folder
 
             static Core* singletonRef_s;
Index: code/branches/buildsystem3/src/core/Language.cc
===================================================================
--- code/branches/buildsystem3/src/core/Language.cc	(revision 2701)
+++ code/branches/buildsystem3/src/core/Language.cc	(revision 2702)
@@ -206,6 +206,5 @@
         COUT(4) << "Read default language file." << std::endl;
 
-        boost::filesystem::path folder(Core::getConfigPath());
-        boost::filesystem::path filepath(folder/getFilename(this->defaultLanguage_));
+        boost::filesystem::path filepath(Core::getConfigPath() / getFilename(this->defaultLanguage_));
 
         // This creates the file if it's not existing
@@ -258,6 +257,5 @@
         COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl;
 
-        boost::filesystem::path folder(Core::getConfigPath());
-        boost::filesystem::path filepath(folder/getFilename(Core::getLanguage()));
+        boost::filesystem::path filepath(Core::getConfigPath() / getFilename(Core::getLanguage()));
 
         // Open the file
@@ -315,6 +313,5 @@
         COUT(4) << "Language: Write default language file." << std::endl;
 
-        boost::filesystem::path folder(Core::getConfigPath());
-        boost::filesystem::path filepath(folder/getFilename(this->defaultLanguage_));
+        boost::filesystem::path filepath(Core::getConfigPath() / getFilename(this->defaultLanguage_));
 
         // Open the file
Index: code/branches/buildsystem3/src/core/LuaBind.cc
===================================================================
--- code/branches/buildsystem3/src/core/LuaBind.cc	(revision 2701)
+++ code/branches/buildsystem3/src/core/LuaBind.cc	(revision 2702)
@@ -53,5 +53,5 @@
     LuaBind::singletonRef_s = this;
 
-    this->includePath_ = Core::getMediaPath();
+    this->includePath_ = Core::getMediaPathPOSIXString();
 
     luaState_ = lua_open();
Index: code/branches/buildsystem3/src/core/TclBind.cc
===================================================================
--- code/branches/buildsystem3/src/core/TclBind.cc	(revision 2701)
+++ code/branches/buildsystem3/src/core/TclBind.cc	(revision 2702)
@@ -62,5 +62,6 @@
     void TclBind::setDataPath(const std::string& datapath)
     {
-        this->tclLibPath_ = datapath + "/tcl" + TCL_VERSION + "/";
+        // String has POSIX slashes
+        this->tclLibPath_ = datapath + "tcl" + TCL_VERSION + '/';
         this->bSetTclLibPath_ = true;
 
Index: code/branches/buildsystem3/src/orxonox/Main.cc
===================================================================
--- code/branches/buildsystem3/src/orxonox/Main.cc	(revision 2701)
+++ code/branches/buildsystem3/src/orxonox/Main.cc	(revision 2702)
@@ -92,14 +92,9 @@
     using namespace orxonox;
 
-    // First, determine whether we have an installed or a binary dir run
-    // The latter occurs when simply running from the build directory
-    Core::checkDevBuild();
-
-    // Make sure the directories we write in exist or else make them
-    Core::createDirectories();
+    Core::postMainInitialisation();
 
     // create a signal handler (only active for linux)
     SignalHandler signalHandler;
-    signalHandler.doCatch(argv[0], Core::getLogPath() + "orxonox_crash.log");
+    signalHandler.doCatch(argv[0], Core::getLogPathString() + "orxonox_crash.log");
 
     // Parse command line arguments
Index: code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.cc	(revision 2701)
+++ code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.cc	(revision 2702)
@@ -45,4 +45,5 @@
 #include <OgreWindowEventUtilities.h>
 
+#include "SpecialConfig.h"
 #include "util/Debug.h"
 #include "util/Exception.h"
@@ -135,5 +136,5 @@
         // load debug overlay
         COUT(3) << "Loading Debug Overlay..." << std::endl;
-        this->debugOverlay_ = new XMLFile(Core::getMediaPath() + "overlay/debug.oxo");
+        this->debugOverlay_ = new XMLFile((Core::getMediaPath() / "overlay" / "debug.oxo").file_string());
         Loader::open(debugOverlay_);
 
@@ -293,8 +294,6 @@
         }
 
-        boost::filesystem::path ogreConfigFilepath(Core::getConfigPath());
-        ogreConfigFilepath /= this->ogreConfigFile_;
-        boost::filesystem::path ogreLogFilepath(Core::getLogPath());
-        ogreLogFilepath /= this->ogreLogFile_;
+        boost::filesystem::path ogreConfigFilepath(Core::getConfigPath() / this->ogreConfigFile_);
+        boost::filesystem::path ogreLogFilepath(Core::getLogPath() / this->ogreLogFile_);
 
         // create a new logManager
@@ -357,5 +356,5 @@
         try
         {
-            cf.load(Core::getMediaPath() + resourceFile_);
+            cf.load((Core::getMediaPath() / resourceFile_).file_string());
         }
         catch (...)
@@ -383,5 +382,5 @@
 
                     Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
-                        std::string(Core::getMediaPath() + archName), typeName, secName);
+                        (Core::getMediaPath() / archName).directory_string(), typeName, secName);
                 }
             }
Index: code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.cc	(revision 2701)
+++ code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.cc	(revision 2702)
@@ -202,5 +202,5 @@
         std::string levelName;
         CommandLine::getValue("level", &levelName);
-        startFile_ = new XMLFile(Core::getMediaPath() + std::string("levels/") + levelName);
+        startFile_ = new XMLFile(Core::getMediaPathString() + "levels" + CP_SLASH + levelName);
         Loader::open(startFile_);
     }
Index: code/branches/buildsystem3/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/branches/buildsystem3/src/orxonox/gamestates/GSRoot.cc	(revision 2701)
+++ code/branches/buildsystem3/src/orxonox/gamestates/GSRoot.cc	(revision 2702)
@@ -111,5 +111,5 @@
 
         // initialise TCL
-        this->tclBind_ = new TclBind(Core::getMediaPath());
+        this->tclBind_ = new TclBind(Core::getMediaPathPOSIXString());
         this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
 
Index: code/branches/buildsystem3/src/orxonox/gui/GUIManager.cc
===================================================================
--- code/branches/buildsystem3/src/orxonox/gui/GUIManager.cc	(revision 2701)
+++ code/branches/buildsystem3/src/orxonox/gui/GUIManager.cc	(revision 2702)
@@ -42,4 +42,5 @@
 #include <CEGUIDefaultLogger.h>
 #include <ogreceguirenderer/OgreCEGUIRenderer.h>
+#include "SpecialConfig.h" // Configures the macro below
 #ifdef CEGUILUA_USE_INTERNAL_LIBRARY
 #   include <ceguilua/CEGUILua.h>
@@ -151,5 +152,5 @@
 
                 // Create our own logger to specify the filepath
-                boost::filesystem::path ceguiLogFilepath(Core::getLogPath() + "cegui.log");
+                boost::filesystem::path ceguiLogFilepath(Core::getLogPath() / "cegui.log");
                 this->ceguiLogger_ = new DefaultLogger();
                 this->ceguiLogger_->setLogFilename(ceguiLogFilepath.file_string());
Index: code/branches/buildsystem3/src/orxonox/objects/Level.cc
===================================================================
--- code/branches/buildsystem3/src/orxonox/objects/Level.cc	(revision 2701)
+++ code/branches/buildsystem3/src/orxonox/objects/Level.cc	(revision 2702)
@@ -55,6 +55,6 @@
         this->xmlfilename_ = this->getFilename();
 
-        if (this->xmlfilename_.length() >= Core::getMediaPath().length())
-            this->xmlfilename_ = this->xmlfilename_.substr(Core::getMediaPath().length());
+        if (this->xmlfilename_.length() >= Core::getMediaPathString().length())
+            this->xmlfilename_ = this->xmlfilename_.substr(Core::getMediaPathString().length());
     }
 
@@ -97,5 +97,5 @@
         mask.include(Class(OverlayGroup)); // HACK to include the ChatOverlay
 
-        this->xmlfile_ = new XMLFile(Core::getMediaPath() + this->xmlfilename_, mask);
+        this->xmlfile_ = new XMLFile(Core::getMediaPathString() + this->xmlfilename_, mask);
 
         Loader::open(this->xmlfile_);
Index: code/branches/buildsystem3/src/util/CMakeLists.txt
===================================================================
--- code/branches/buildsystem3/src/util/CMakeLists.txt	(revision 2701)
+++ code/branches/buildsystem3/src/util/CMakeLists.txt	(revision 2702)
@@ -57,8 +57,12 @@
   ${CMAKE_BINARY_DIR}/src/OrxonoxConfig.h
   ${CMAKE_SOURCE_DIR}/src/OrxonoxConfig.h.in
+  ${CMAKE_BINARY_DIR}/src/SpecialConfig.h
+  ${CMAKE_SOURCE_DIR}/src/SpecialConfig.h.in
 )
 SOURCE_GROUP("" FILES
   ${CMAKE_BINARY_DIR}/src/OrxonoxConfig.h
   ${CMAKE_SOURCE_DIR}/src/OrxonoxConfig.h.in
+  ${CMAKE_BINARY_DIR}/src/SpecialConfig.h
+  ${CMAKE_SOURCE_DIR}/src/SpecialConfig.h.in
 )
 
