mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-20 21:43:06 +01:00
Add FreeBSD support
At the moment the platform specific code supports only FreeBSD as OpenBSD and NetBSD does not support the full path retrieval for an executable, we intentionally stop the compilation for those platforms.
This commit is contained in:
committed by
Michał Janiszewski
parent
d645e53428
commit
1d17725592
@@ -326,7 +326,7 @@ endif (NOT DISABLE_HTTP_TWITCH)
|
||||
|
||||
PKG_CHECK_MODULES(SPEEX REQUIRED speexdsp)
|
||||
|
||||
if (UNIX)
|
||||
if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD")
|
||||
# Include libdl for dlopen
|
||||
set(DLLIB dl)
|
||||
endif (UNIX)
|
||||
@@ -384,7 +384,7 @@ TARGET_LINK_LIBRARIES(${PROJECT} ${GLLIBS})
|
||||
# if creating a static binary, precede libraries with -static, then name all the libs
|
||||
TARGET_LINK_LIBRARIES(${PROJECT} ${STATIC_START} ${SDL2LIBS} ${HTTPLIBS} ${NETWORKLIBS} ${SPEEX_LIBRARIES} ${DLLIB} ${REQUIREDLIBS} ${BREAKPAD_LIBS})
|
||||
|
||||
if (APPLE OR STATIC)
|
||||
if (APPLE OR STATIC OR ${CMAKE_SYSTEM_NAME} MATCHES "BSD")
|
||||
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
|
||||
TARGET_LINK_LIBRARIES(${PROJECT} ${ICONV_LIBRARIES})
|
||||
endif (APPLE OR STATIC)
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
typedef int SOCKET;
|
||||
|
||||
@@ -16,7 +16,13 @@
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#ifdef __LINUX__
|
||||
// Despite the name, this file contains support for more OSs besides Linux, provided the necessary ifdefs remain small.
|
||||
// Otherwise, they should be spun off into their own files.
|
||||
#if defined(__LINUX__) || defined(__FREEBSD__)
|
||||
|
||||
#ifdef __FREEBSD__
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dlfcn.h>
|
||||
@@ -49,12 +55,23 @@ typedef enum { DT_NONE, DT_KDIALOG, DT_ZENITY } dialog_type;
|
||||
void platform_get_exe_path(utf8 *outPath, size_t outSize)
|
||||
{
|
||||
char exePath[MAX_PATH];
|
||||
#ifdef __LINUX__
|
||||
ssize_t bytesRead;
|
||||
bytesRead = readlink("/proc/self/exe", exePath, MAX_PATH);
|
||||
if (bytesRead == -1) {
|
||||
log_fatal("failed to read /proc/self/exe");
|
||||
}
|
||||
exePath[bytesRead - 1] = '\0';
|
||||
#elif __FREEBSD__
|
||||
size_t exeLen = sizeof(exePath);
|
||||
const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
|
||||
if (sysctl(mib, 4, exePath, &exeLen, NULL, 0) == -1) {
|
||||
log_fatal("failed to get process path");
|
||||
|
||||
}
|
||||
#else
|
||||
#error "Platform does not support full path exe retrieval"
|
||||
#endif
|
||||
char *exeDelimiter = strrchr(exePath, *PATH_SEPARATOR);
|
||||
if (exeDelimiter == NULL)
|
||||
{
|
||||
|
||||
@@ -229,7 +229,7 @@ void core_init();
|
||||
__declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
|
||||
#endif // __WINDOWS__
|
||||
|
||||
#if defined(__LINUX__) || defined(__MACOSX__)
|
||||
#if defined(__LINUX__) || defined(__MACOSX__) || defined(__FREEBSD__)
|
||||
void platform_posix_sub_user_data_path(char *buffer, size_t size, const char *homedir);
|
||||
void platform_posix_sub_resolve_openrct_data_path(utf8 *out, size_t size);
|
||||
#endif
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__)
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
#ifdef __MACOSX__
|
||||
#define OPENRCT2_PLATFORM "macOS"
|
||||
#endif
|
||||
#ifdef __FREEBSD__
|
||||
#define OPENRCT2_PLATFORM "FreeBSD"
|
||||
#endif
|
||||
#ifndef OPENRCT2_PLATFORM
|
||||
#error Unknown platform!
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user