diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 80f518e..7f823cb 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -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() diff --git a/Sources/Ecc/StdH.h b/Sources/Ecc/StdH.h index 8c19296..1b048a0 100644 --- a/Sources/Ecc/StdH.h +++ b/Sources/Ecc/StdH.h @@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include -#if !PLATFORM_MACOSX +#if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD) #include #endif diff --git a/Sources/Engine/Base/Timer.cpp b/Sources/Engine/Base/Timer.cpp index 43be607..8922297 100644 --- a/Sources/Engine/Base/Timer.cpp +++ b/Sources/Engine/Base/Timer.cpp @@ -37,6 +37,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #endif +#if PLATFORM_FREEBSD +#include +#include +#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; diff --git a/Sources/Engine/Engine.h b/Sources/Engine/Engine.h index eb17bdf..d63fae4 100644 --- a/Sources/Engine/Engine.h +++ b/Sources/Engine/Engine.h @@ -38,7 +38,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include // for qsort #include // for FPU control -#if !PLATFORM_MACOSX +#if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD) #include #endif diff --git a/Sources/Engine/StdH.h b/Sources/Engine/StdH.h index 61fae43..d889b87 100644 --- a/Sources/Engine/StdH.h +++ b/Sources/Engine/StdH.h @@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include // for qsort #include // for FPU control -#if !PLATFORM_MACOSX +#if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD) #include #endif diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp index fa487d3..9b76471 100644 --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -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 - #if !PLATFORM_MACOSX + #if !defined(PLATFORM_MACOSX) && !defined(PLATFORM_FREEBSD) #include #endif #endif