diff --git a/3rdparty/hts_engine_API/lib/HTS_misc.c b/3rdparty/hts_engine_API/lib/HTS_misc.c index b0d112d32..290ef16e1 100644 --- a/3rdparty/hts_engine_API/lib/HTS_misc.c +++ b/3rdparty/hts_engine_API/lib/HTS_misc.c @@ -245,7 +245,7 @@ size_t HTS_ftell(HTS_File * fp) } else if (fp->type == HTS_FILE) { fpos_t pos; fgetpos((FILE *) fp->pointer, &pos); -#if defined(_WIN32) || defined(__CYGWIN__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__ANDROID__) +#if defined(_WIN32) || defined(__CYGWIN__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__OpenBSD__) return (size_t) pos; #else return (size_t) pos.__pos; diff --git a/3rdparty/joystick/jsNone.cxx b/3rdparty/joystick/jsNone.cxx index e5de5c2e0..f4f1d8c72 100644 --- a/3rdparty/joystick/jsNone.cxx +++ b/3rdparty/joystick/jsNone.cxx @@ -22,6 +22,10 @@ #include "js.h" +#ifdef __OpenBSD__ + #define TRUE JS_TRUE +#endif + struct os_specific_s ; diff --git a/CMakeLists.txt b/CMakeLists.txt index f1fb2f1ed..dee83e92b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,7 +136,8 @@ elseif(WIN32) MESSAGE("Installing: ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR - ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR + ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") find_package(Threads REQUIRED) find_package(X11 REQUIRED) @@ -233,6 +234,10 @@ if(SP_FDMS) set(ENABLE_SP_FDM 1) endif() +if(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") + include_directories(${PROJECT_SOURCE_DIR}/3rdparty/iaxclient/lib/libspeex/include) +endif() + if(ENABLE_FGCOM) set(ENABLE_IAX 1) include_directories(${PROJECT_SOURCE_DIR}/3rdparty/iaxclient/lib ) # for iaxclient.h @@ -246,7 +251,7 @@ if(EVENT_INPUT) add_definitions(-DWITH_EVENTINPUT) find_library(IOKIT_FRAMEWORK IOKit) list(APPEND EVENT_INPUT_LIBRARIES ${IOKIT_FRAMEWORK}) - elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD") + elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD") if(NOT UDEV_FOUND) message(WARNING "UDev not found, event input is disabled!") set(EVENT_INPUT 0) @@ -321,6 +326,10 @@ if (MSVC) endif() endif() +#if(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") +# include_directories("${CMAKE_SOURCE_DIR}/3rdparty/iaxclient/lib/libspeex/include") +#endif() + ############################################################################## ## Sqlite3 setup diff --git a/CMakeModules/SetupFGFSLibraries.cmake b/CMakeModules/SetupFGFSLibraries.cmake index 0e7546855..f73df77dd 100644 --- a/CMakeModules/SetupFGFSLibraries.cmake +++ b/CMakeModules/SetupFGFSLibraries.cmake @@ -84,4 +84,8 @@ function(setup_fgfs_libraries target) if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") target_link_libraries(${target} execinfo) endif() + + if(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") + target_link_libraries(${target} execinfo) + endif() endfunction() diff --git a/src/Main/bootstrap.cxx b/src/Main/bootstrap.cxx index 99affbec2..09f3c7618 100644 --- a/src/Main/bootstrap.cxx +++ b/src/Main/bootstrap.cxx @@ -163,6 +163,7 @@ void segfault_handler(int signo) { fprintf(stderr, "Error: caught signal %d:\n", signo); + #ifndef __OpenBSD__ size = backtrace(array, 128); if (size) { char** list = backtrace_symbols(array, size); @@ -199,6 +200,7 @@ void segfault_handler(int signo) { free(fname); free(list); } + #endif std::abort(); } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 5fd7feabd..c856b4c33 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -93,6 +93,10 @@ extern bool global_crashRptEnabled; #include #endif +#ifdef __OpenBSD__ +#include +#endif + using namespace flightgear; using std::cerr; @@ -532,7 +536,7 @@ int fgMainInit( int argc, char **argv ) // level once startup is done. sglog().setLogLevels( SG_ALL, SG_INFO ); sglog().setStartupLoggingEnabled(true); - + globals = new FGGlobals; if (!fgInitHome()) { return EXIT_FAILURE; @@ -555,6 +559,29 @@ int fgMainInit( int argc, char **argv ) SG_LOG(SG_GENERAL, SG_ALERT, "Minimum supported OpenScenegraph is V3.4.1 - currently using " << osgGetVersion() << " This can cause fatal OSG 'final reference count' errors at runtime"); #endif +#ifdef __OpenBSD__ + { + /* OpenBSD defaults to a small maximum data segment, which can cause + flightgear to crash with SIGBUS, so output a warning if this is likely. + */ + struct rlimit rlimit; + int e = getrlimit(RLIMIT_DATA, &rlimit); + if (e) { + SG_LOG( SG_GENERAL, SG_INFO, "This is OpenBSD; getrlimit() failed: " << strerror(errno)); + } + else { + long long required = 4LL * (1LL<<30); + if (rlimit.rlim_cur < required) { + SG_LOG( SG_GENERAL, SG_POPUP, "" + << "Max data segment (" << rlimit.rlim_cur << "bytes) too small.\n" + << "This can cause Flightgear to crash due to SIGBUS.\n" + << "E.g. increase with 'ulimit -d " << required/1024 << "'." + ); + } + } + } +#endif + // seed the random number generator sg_srandom_time(); diff --git a/src/Main/metar_main.cxx b/src/Main/metar_main.cxx index dd84514a2..349a305ed 100644 --- a/src/Main/metar_main.cxx +++ b/src/Main/metar_main.cxx @@ -42,7 +42,7 @@ using namespace std; using namespace simgear; // text color -#if defined(__linux__) || defined(__sun) || defined(__CYGWIN__) || defined( __FreeBSD__ ) || defined ( sgi ) +#if defined(__linux__) || defined(__sun) || defined(__CYGWIN__) || defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined ( sgi ) # define R "\033[31;1m" // red # define G "\033[32;1m" // green # define Y "\033[33;1m" // yellow