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")
SET(LINUX TRUE)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
SET(FREEBSD TRUE)
endif()
if(APPLE)
SET(MACOSX TRUE)
endif()
@ -71,6 +74,16 @@ if(LINUX)
add_definitions(-DPRAGMA_ONCE=1)
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)
add_definitions(-DPLATFORM_UNIX=1)
add_definitions(-DPLATFORM_MACOSX=1)
@ -830,6 +843,19 @@ if(LINUX)
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)
set_target_properties(ssam PROPERTIES OUTPUT_NAME "ssam-tfe")
endif()

View File

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

View File

@ -37,6 +37,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <sys/time.h>
#endif
#if PLATFORM_FREEBSD
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
// Read the Pentium TimeStampCounter (or something like that).
static inline __int64 ReadTSC(void)
{
@ -340,6 +345,13 @@ CTimer::CTimer(BOOL bInterrupt /*=TRUE*/)
#elif PLATFORM_MACOSX
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
// !!! FIXME : This is an ugly hack.
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 <float.h> // for FPU control
#if !PLATFORM_MACOSX
#if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD)
#include <malloc.h>
#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 <float.h> // for FPU control
#if !PLATFORM_MACOSX
#if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD)
#include <malloc.h>
#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.
#ifdef PLATFORM_UNIX
#include <Engine/Base/SDL/SDLEvents.h>
#if !PLATFORM_MACOSX
#if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD)
#include <mntent.h>
#endif
#endif