Merge pull request #23 from Yamagi/freebsd

Add Freebsd support
This commit is contained in:
Ryan C. Gordon 2016-04-15 13:07:29 -04:00
commit d66559abfa
6 changed files with 42 additions and 4 deletions

View File

@ -28,6 +28,9 @@ endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME MATCHES "GNU|kFreeBSD") if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME MATCHES "GNU|kFreeBSD")
SET(LINUX TRUE) SET(LINUX TRUE)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
SET(FREEBSD TRUE)
endif()
if(APPLE) if(APPLE)
SET(MACOSX TRUE) SET(MACOSX TRUE)
endif() endif()
@ -71,6 +74,16 @@ if(LINUX)
add_definitions(-DPRAGMA_ONCE=1) add_definitions(-DPRAGMA_ONCE=1)
endif() endif()
if(FREEBSD)
set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
add_definitions(-DPLATFORM_UNIX=1)
add_definitions(-DPLATFORM_FREEBSD=1)
add_definitions(-D_FILE_OFFSET_BITS=64)
add_definitions(-D_LARGEFILE_SOURCE=1)
add_definitions(-DPRAGMA_ONCE=1)
include_directories("/usr/local/include")
endif()
if(MACOSX) if(MACOSX)
add_definitions(-DPLATFORM_UNIX=1) add_definitions(-DPLATFORM_UNIX=1)
add_definitions(-DPLATFORM_MACOSX=1) add_definitions(-DPLATFORM_MACOSX=1)
@ -830,6 +843,19 @@ if(LINUX)
endif() endif()
endif() endif()
if(FREEBSD)
set_target_properties(ssam PROPERTIES LINK_FLAGS "-Wl,-rpath,$ORIGIN")
target_link_libraries(ssam "m")
target_link_libraries(ssam "pthread")
target_link_libraries(ssam ${SDL2_LIBRARY})
if(BUILD_DEDICATED_SERVER)
set_target_properties(SeriousSamDedicated PROPERTIES LINK_FLAGS "-Wl,-rpath,$ORIGIN")
target_link_libraries(SeriousSamDedicated "m")
target_link_libraries(SeriousSamDedicated "pthread")
target_link_libraries(SeriousSamDedicated ${SDL2_LIBRARY})
endif()
endif()
if(TFE) if(TFE)
set_target_properties(ssam PROPERTIES OUTPUT_NAME "ssam-tfe") set_target_properties(ssam PROPERTIES OUTPUT_NAME "ssam-tfe")
endif() endif()

View File

@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <stdarg.h> #include <stdarg.h>
#include <math.h> #include <math.h>
#if !PLATFORM_MACOSX #if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD)
#include <malloc.h> #include <malloc.h>
#endif #endif

View File

@ -37,6 +37,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#if PLATFORM_FREEBSD
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
// Read the Pentium TimeStampCounter (or something like that). // Read the Pentium TimeStampCounter (or something like that).
static inline __int64 ReadTSC(void) static inline __int64 ReadTSC(void)
{ {
@ -340,6 +345,13 @@ CTimer::CTimer(BOOL bInterrupt /*=TRUE*/)
#elif PLATFORM_MACOSX #elif PLATFORM_MACOSX
tm_llPerformanceCounterFrequency = tm_llCPUSpeedHZ = ((__int64) GetCPUSpeed()) * 1000000; tm_llPerformanceCounterFrequency = tm_llCPUSpeedHZ = ((__int64) GetCPUSpeed()) * 1000000;
#elif PLATFORM_FREEBSD
__int64 mhz = 0;
size_t len = sizeof(mhz);
sysctlbyname("hw.clockrate", &mhz, &len, NULL, 0);
tm_llPerformanceCounterFrequency = tm_llCPUSpeedHZ = (__int64) (mhz * 1000000);
#else #else
// !!! FIXME : This is an ugly hack. // !!! FIXME : This is an ugly hack.
double mhz = 0.0; double mhz = 0.0;

View File

@ -38,7 +38,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <search.h> // for qsort #include <search.h> // for qsort
#include <float.h> // for FPU control #include <float.h> // for FPU control
#if !PLATFORM_MACOSX #if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD)
#include <malloc.h> #include <malloc.h>
#endif #endif

View File

@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <search.h> // for qsort #include <search.h> // for qsort
#include <float.h> // for FPU control #include <float.h> // for FPU control
#if !PLATFORM_MACOSX #if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD)
#include <malloc.h> #include <malloc.h>
#endif #endif

View File

@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// !!! FIXME: rcg01082002 Do something with these. // !!! FIXME: rcg01082002 Do something with these.
#ifdef PLATFORM_UNIX #ifdef PLATFORM_UNIX
#include <Engine/Base/SDL/SDLEvents.h> #include <Engine/Base/SDL/SDLEvents.h>
#if !PLATFORM_MACOSX #if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD)
#include <mntent.h> #include <mntent.h>
#endif #endif
#endif #endif