1
0
Fork 0

Various fixes for building on OpenBSD.

This commit is contained in:
Julian Smith 2019-08-12 17:52:53 +01:00
parent 5615c39175
commit f3d1135320
7 changed files with 51 additions and 5 deletions

View file

@ -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;

View file

@ -22,6 +22,10 @@
#include "js.h"
#ifdef __OpenBSD__
#define TRUE JS_TRUE
#endif
struct os_specific_s ;

View file

@ -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

View file

@ -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()

View file

@ -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();
}

View file

@ -93,6 +93,10 @@ extern bool global_crashRptEnabled;
#include <GUI/QtLauncher.hxx>
#endif
#ifdef __OpenBSD__
#include <sys/resource.h>
#endif
using namespace flightgear;
using std::cerr;
@ -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();

View file

@ -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