mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-08 21:00:05 +02:00
178 lines
6.9 KiB
Plaintext
178 lines
6.9 KiB
Plaintext
From 95165f77dfe95c072607600f2b5766ac88100f4c Mon Sep 17 00:00:00 2001
|
|
From: Gerasim Troeglazov <3dEyes@gmail.com>
|
|
Date: Mon, 9 Sep 2019 00:15:38 +1000
|
|
Subject: Fix build for Haiku
|
|
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 838afc5..6ea9a69 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -206,7 +206,11 @@ CHECK_INCLUDE_FILE_CXX(sys/timerfd.h HAVE_SYS_TIMERFD_H)
|
|
CHECK_INCLUDE_FILE_CXX(sys/socket.h HAVE_SYS_SOCKET_H)
|
|
CHECK_INCLUDE_FILE_CXX(sys/eventfd.h HAVE_SYS_EVENTFD_H)
|
|
CHECK_INCLUDE_FILE_CXX(sys/file.h HAVE_SYS_FILE_H)
|
|
+if(NOT HAIKU)
|
|
CHECK_INCLUDE_FILES_CXX("X11/Xlib.h;X11/extensions/Xrandr.h" HAVE_X11_EXTENSIONS_XRANDR_H)
|
|
+else()
|
|
+set(X11_LIBRARIES "")
|
|
+endif()
|
|
CHECK_CXX_SOURCE_COMPILES("#include <getopt.h>\nint main(int argc, char * argv[]) { getopt_long(argc, argv, \"\", 0, 0); }" HAVE_GETOPT_H)
|
|
|
|
############################################################################
|
|
@@ -1104,9 +1108,12 @@ endif()
|
|
if(HAVE_PTHREAD)
|
|
target_link_libraries(libmisc pthread)
|
|
endif()
|
|
-if(UNIX AND NOT APPLE)
|
|
+if(UNIX AND NOT APPLE AND NOT HAIKU)
|
|
target_link_libraries(libmisc rt)
|
|
endif()
|
|
+if(HAIKU)
|
|
+ target_link_libraries(libmisc network)
|
|
+endif()
|
|
|
|
add_library(libc4script STATIC
|
|
src/C4Include.cpp
|
|
diff --git a/config.h.cmake b/config.h.cmake
|
|
index 433f683..c91f81e 100644
|
|
--- a/config.h.cmake
|
|
+++ b/config.h.cmake
|
|
@@ -103,7 +103,11 @@
|
|
|
|
/* Path to data directory */
|
|
#ifdef WITH_APPDIR_INSTALLATION
|
|
+#ifdef __HAIKU__
|
|
+#define OC_SYSTEM_DATA_DIR "data"
|
|
+#else
|
|
#define OC_SYSTEM_DATA_DIR "../share/games/openclonk"
|
|
+#endif
|
|
#else
|
|
#define OC_SYSTEM_DATA_DIR "${CMAKE_INSTALL_PREFIX}/share/games/openclonk"
|
|
#endif
|
|
diff --git a/src/config/C4Config.cpp b/src/config/C4Config.cpp
|
|
index 05989ff..5bacae8 100644
|
|
--- a/src/config/C4Config.cpp
|
|
+++ b/src/config/C4Config.cpp
|
|
@@ -134,13 +134,13 @@ void C4ConfigGraphics::CompileFunc(StdCompiler *compiler)
|
|
compiler->Value(mkNamingAdapt(ShowClock, "ShowClock", 0 ,false, true));
|
|
compiler->Value(mkNamingAdapt(ShowCrewNames, "ShowCrewNames", 1 ,false, true));
|
|
compiler->Value(mkNamingAdapt(ShowCrewCNames, "ShowCrewCNames", 0 ,false, true));
|
|
- compiler->Value(mkNamingAdapt(Windowed, "Windowed", 0 ,false, true));
|
|
+ compiler->Value(mkNamingAdapt(Windowed, "Windowed", 1 ,false, true));
|
|
compiler->Value(mkNamingAdapt(PXSGfx, "PXSGfx" , 1 ));
|
|
compiler->Value(mkNamingAdapt(Gamma, "Gamma" , 100 ));
|
|
compiler->Value(mkNamingAdapt(Monitor, "Monitor", 0 )); // 0 = D3DADAPTER_DEFAULT
|
|
compiler->Value(mkNamingAdapt(MaxRefreshDelay, "MaxRefreshDelay", 30 ));
|
|
compiler->Value(mkNamingAdapt(NoOffscreenBlits, "NoOffscreenBlits", 1 ));
|
|
- compiler->Value(mkNamingAdapt(MultiSampling, "MultiSampling", 4 ));
|
|
+ compiler->Value(mkNamingAdapt(MultiSampling, "MultiSampling", 0 ));
|
|
compiler->Value(mkNamingAdapt(AutoFrameSkip, "AutoFrameSkip", 1 ));
|
|
compiler->Value(mkNamingAdapt(MouseCursorSize, "MouseCursorSize", 50 ));
|
|
}
|
|
@@ -223,6 +223,8 @@ void C4ConfigSecurity::CompileFunc(StdCompiler *compiler)
|
|
compiler->Value(mkNamingAdapt(s(KeyPath), "KeyPath", R"(%APPDATA%\)" C4ENGINENAME, false, true));
|
|
#elif defined(__linux__)
|
|
compiler->Value(mkNamingAdapt(s(KeyPath), "KeyPath", "$HOME/.clonk/" C4ENGINENICK, false, true));
|
|
+#elif defined(__HAIKU__)
|
|
+ compiler->Value(mkNamingAdapt(s(KeyPath), "KeyPath", "$HOME/config/settings/" C4ENGINENICK, false, true));
|
|
#elif defined(__APPLE__)
|
|
compiler->Value(mkNamingAdapt(s(KeyPath), "KeyPath", "$HOME/Library/Application Support/" C4ENGINENAME, false, true));
|
|
#endif
|
|
@@ -318,6 +320,8 @@ void C4Config::GetConfigFileName(StdStrBuf &filename, const char *config_file)
|
|
filename.Copy(home);
|
|
#ifdef __APPLE__
|
|
filename += "Library/Preferences/" C4ENGINEID ".config";
|
|
+#elif defined(__HAIKU__)
|
|
+ filename += "config/settings/" C4ENGINENICK "/config";
|
|
#else
|
|
filename += ".clonk/" C4ENGINENICK "/config";
|
|
#endif
|
|
@@ -360,6 +364,15 @@ bool C4Config::Load(const char *config_file)
|
|
filename += ".clonk/" C4ENGINENICK;
|
|
CreatePath(filename.getData());
|
|
}
|
|
+#endif
|
|
+#ifdef __HAIKU__
|
|
+ if (!config_file)
|
|
+ {
|
|
+ StdStrBuf filename(getenv("HOME"));
|
|
+ if (filename) { filename += "/"; }
|
|
+ filename += "config/settings/" C4ENGINENICK;
|
|
+ CreatePath(filename.getData());
|
|
+ }
|
|
#endif
|
|
// Buggy StdCompiler crashes when compiling a Null-StdStrBuf
|
|
buf.Ref(" ");
|
|
@@ -522,6 +535,8 @@ void C4ConfigGeneral::DeterminePaths()
|
|
SCopy(ExePath.getMData(),SystemDataPath);
|
|
#elif defined(__APPLE__)
|
|
SCopy(::Application.GetGameDataPath().c_str(), SystemDataPath);
|
|
+#elif defined(__HAIKU__)
|
|
+ SCopy("/boot/system/apps/OpenClonk/data", SystemDataPath);
|
|
#elif defined(WITH_AUTOMATIC_UPDATE) && defined(WITH_APPDIR_INSTALLATION)
|
|
// AppDir: layout like normal unix installation, but relative to executable.
|
|
auto str = FormatString("%s%s", ExePath.getMData(), OC_SYSTEM_DATA_DIR);
|
|
@@ -549,6 +564,8 @@ void C4ConfigGeneral::DeterminePaths()
|
|
SCopy(R"(%APPDATA%\)" C4ENGINENAME, UserDataPath);
|
|
#elif defined(__APPLE__)
|
|
SCopy("$HOME/Library/Application Support/" C4ENGINENAME, UserDataPath);
|
|
+#elif defined(__HAIKU__)
|
|
+ SCopy("$HOME/config/settings/" C4ENGINENICK, UserDataPath);
|
|
#else
|
|
SCopy("$HOME/.clonk/" C4ENGINENICK, UserDataPath);
|
|
#endif
|
|
diff --git a/src/game/ClonkMain.cpp b/src/game/ClonkMain.cpp
|
|
index a7c69dd..746cee6 100644
|
|
--- a/src/game/ClonkMain.cpp
|
|
+++ b/src/game/ClonkMain.cpp
|
|
@@ -206,11 +206,25 @@ static void restart(char * argv[])
|
|
|
|
int main (int argc, char * argv[])
|
|
{
|
|
+#ifdef __HAIKU__
|
|
+ char *binpath = realpath(argv[0], NULL);
|
|
+ if (binpath != NULL) {
|
|
+ char *appdir = strrchr(binpath, '/');
|
|
+ *appdir = '\0';
|
|
+ chdir(binpath);
|
|
+ free(binpath);
|
|
+ }
|
|
+
|
|
+ setenv("MESA_GL_VERSION_OVERRIDE", "3.3", 1);
|
|
+ setenv("MESA_GLSL_VERSION_OVERRIDE", "330", 1);
|
|
+#endif
|
|
+#ifndef __HAIKU__
|
|
if (!geteuid())
|
|
{
|
|
printf("Do not run %s as root!\n", argc ? argv[0] : "this program");
|
|
return C4XRV_Failure;
|
|
}
|
|
+#endif
|
|
#ifdef HAVE_BACKWARD
|
|
backward::SignalHandling sh;
|
|
#elif defined(HAVE_SIGNAL_H)
|
|
diff --git a/src/network/C4NetIO.cpp b/src/network/C4NetIO.cpp
|
|
index 24a5c6b..ab3ebde 100644
|
|
--- a/src/network/C4NetIO.cpp
|
|
+++ b/src/network/C4NetIO.cpp
|
|
@@ -697,6 +697,7 @@ std::vector<C4NetIO::HostAddress> C4NetIO::GetLocalAddresses()
|
|
}
|
|
#endif
|
|
|
|
+#ifndef __HAIKU__
|
|
struct ifaddrs* addrs;
|
|
if (getifaddrs(&addrs) < 0)
|
|
return result;
|
|
@@ -711,6 +712,7 @@ std::vector<C4NetIO::HostAddress> C4NetIO::GetLocalAddresses()
|
|
}
|
|
}
|
|
freeifaddrs(addrs);
|
|
+#endif
|
|
#endif
|
|
|
|
return result;
|
|
--
|
|
2.37.3
|
|
|