From 590a0fbbf6606619457fc23e4c979b45a15788ab Mon Sep 17 00:00:00 2001 From: tx00100xt Date: Tue, 20 Dec 2022 18:00:19 +0300 Subject: [PATCH] Added support FreeBSD. Update README.md --- CHANGELOG.md | 4 +- README.md | 84 ++++++++++++++++++++++++++- SamTFE/Sources/CMakeLists.txt | 28 +++++---- SamTFE/Sources/Engine/Base/Timer.cpp | 6 +- SamTFE/Sources/Engine/Base/Types.h | 2 +- SamTFE/Sources/cmake/FindVulkan.cmake | 73 +++++++++++++++++++++++ SamTSE/Sources/CMakeLists.txt | 28 +++++---- SamTSE/Sources/Engine/Base/Timer.cpp | 6 +- SamTSE/Sources/Engine/Base/Types.h | 2 +- SamTSE/Sources/cmake/FindVulkan.cmake | 73 +++++++++++++++++++++++ 10 files changed, 275 insertions(+), 31 deletions(-) create mode 100644 SamTFE/Sources/cmake/FindVulkan.cmake create mode 100644 SamTSE/Sources/cmake/FindVulkan.cmake diff --git a/CHANGELOG.md b/CHANGELOG.md index e8632e17..caa879f7 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -117,6 +117,6 @@ All notable changes to this project will be documented in this file. - Added hud_bShowScore console variable. - Fixed old scripts for AMD cards. -## 2022-11-30 - 2022-12-10 +## 2022-11-30 - 2022-12-20 - Added support Windows. - +- Added support FreeBSD. diff --git a/README.md b/README.md index 79737213..980b9ef4 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,52 @@ cd SeriousSamClassic/SamTSE/Sources ./build-linux64.sh -DRPI4=TRUE # use build-linux32.sh for 32-bits ``` +### FreeBSD + +#### Setting up the repository + +Type this in your terminal: + +``` +git clone https://github.com/tx00100xt/SeriousSamClassic-VK.git SeriousSamClassic-VK +``` + +#### Copy official game data (optional) + +If you have access to a copy of the game (either by CD or through Steam), +you can copy the *.gro files from the game directory to the repository. +(SeriousSamClassic/SamTFE is the directory of the game Serious Sam Classic The First Encounter, SeriousSamClassic/SamTSE is the directory of the game Serious Sam Classic The Second Encounter) + +#### Building (only for SS:TFE) + +Type this in your terminal: + +``` +cd SeriousSamClassic-VK/SamTFE/Sources +cp -vfr Entities/PlayerWeapons_old.es Entities/PlayerWeapons.es +mkdir cmake-build +cd cmake-build +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTFE=TRUE .. +make -j4 +cp -v SeriousSam DedicatedServer MakeFONT ecc ../../Bin +cp -v Debug/*.so ../../Bin +``` + +#### Building (only for SS:TSE) + +Type this in your terminal: + +``` +cd SeriousSamClassic-VK/SamTSE/Sources +cp -vfr EntitiesMP/PlayerWeapons_old.es EntitiesMP/PlayerWeapons.es +mkdir cmake-build +cd cmake-build +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. +make -j4 +cp -v SeriousSam DedicatedServer MakeFONT ecc ../../Bin +cp -v Debug/*.so ../../Bin +``` + Note that the CD version of SS:TSE used MP3 for music. You will need to build / get `libamp11lib.so` and copy it inside `Bin` with the other libs to have music. Steam version uses ogg and doesn't need this library. Running @@ -199,6 +245,8 @@ Remark: -JD- and VITEK is author this mod for windows. ![XPLUS Sacred Yards](https://raw.githubusercontent.com/tx00100xt/SeriousSamClassic-VK/main/Images/samxplus_3.png) +### Linux + #### Building XPLUS (only for SS:TFE) Type this in your terminal: @@ -207,10 +255,28 @@ Type this in your terminal: cd SeriousSamClassic-VK/SamTFE/Sources ./build-linux64xplus.sh -DTFE=TRUE # use build-linux32xplus.sh for 32-bits ``` + +### FreeBSD + +#### Building XPLUS (only for SS:TFE) + +Type this in your terminal: + +``` +cd SeriousSamClassic-VK/SamTFE/Sources +cp -vfr Entities/PlayerWeaponsHD.es Entities/PlayerWeapons.es +mkdir cmake-build +cd cmake-build +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DTFE=TRUE .. +make -j4 +cp -v Debug/*.so ../../Mods/XPLUS/Bin +``` Download: [Xplus TFE from Google Drive] or [Xplus TFE from pCloud], and unpack to SeriousSamClassic/SamTFE/Mods directory. To start the modification, use the game menu - item Modification. +### Linux + #### Building XPLUS (only for SS:TSE) Type this in your terminal: @@ -219,13 +285,28 @@ Type this in your terminal: cd SeriousSamClassic-VK/SamTSE/Sources ./build-linux64xplus.sh # use build-linux32xplus.sh for 32-bits ``` + +### FreeBSD + +#### Building XPLUS (only for SS:TSE) + +Type this in your terminal: + +``` +cd SeriousSamClassic-VK/SamTSE/Sources +cp -vfr EntitiesMP/PlayerWeaponsHD.es EntitiesMP/PlayerWeapons.es +mkdir cmake-build +cd cmake-build +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. +make -j4 +cp -v Debug/*.so ../../Mods/XPLUS/Bin +``` Download: [Xplus TSE from Google Drive] or [Xplus TSE from pCloud],, and unpack to SeriousSamClassic/SamTSE/Mods directory. To start the modification, use the game menu - item Modification. Building demo version of the game --------------------------------- - To build the demo version of the game, official demo files for Windows and official patches for the game from Croteam are used. These files are automatically downloaded and unpacked in demo build scripts. @@ -255,6 +336,7 @@ Supported Architectures Supported OS ----------- * `Linux` +* `FreeBSD` * `Windows` * `Raspberry PI OS` diff --git a/SamTFE/Sources/CMakeLists.txt b/SamTFE/Sources/CMakeLists.txt index 50737afb..77ebf2ff 100644 --- a/SamTFE/Sources/CMakeLists.txt +++ b/SamTFE/Sources/CMakeLists.txt @@ -7,6 +7,7 @@ project(SeriousEngine) # Use system SDL2 is on by default option(USE_SYSTEM_SDL2 "Use systems sdl2 development files" On) option(USE_SYSTEM_ZLIB "Use systems zlib development files" On) +option(USE_SYSTEM_VULKAN "Use systems vulkan development files" On) option(USE_CCACHE "Set to ON to use ccache if present in the system" ${USE_CCACHE}) @@ -60,6 +61,15 @@ if(USE_SYSTEM_ZLIB) endif() endif() +if(USE_SYSTEM_VULKAN) + find_package(Vulkan REQUIRED) + if(Vulkan_FOUND) + include_directories(${Vulkan_INCLUDE_DIRS}) + else() + message(FATAL_ERROR "Error! USE_SYSTEM_VULKAN is set but neccessary developer files are missing") + endif() +endif() + # RAKE! Where to install the binaries. if(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" OR CMAKE_INSTALL_PREFIX STREQUAL "") # Only works for linux since I don't # know what default is for windows/macos/freebsd. @@ -100,18 +110,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") SET(DEBUG TRUE) endif() -## Find Vulkan for MACOSX -if(MACOSX) - if(NOT USE_SYSTEM_Vulkan) - find_package(Vulkan REQUIRED) - if(Vulkan_FOUND) - include_directories(${Vulkan_INCLUDE_DIR}) - else() - message(FATAL_ERROR "Error USE_SYSTEM_Vulkan is set but neccessary developer files are missing") - endif() - endif() -endif() - ## ** RAKE! start compiler specific flags section ** ## ** RAKE! Borrowed from dhewm3 project, need to ** ## ** RAKE! clean up for SeriousEngine use. Also ** @@ -1012,6 +1010,7 @@ target_link_libraries(${ENGINELIB} engine_safemath) if(FREEBSD) target_link_libraries(${ENGINELIB} ${SDL2_LIBRARY}) target_link_libraries(${ENGINELIB} ${ZLIB_LIBRARIES}) +target_link_libraries(${ENGINELIB} ${Vulkan_LIBRARY}) endif() if(MACOSX) if(USE_SYSTEM_SDL2) # use sdl2 framework on system @@ -1029,8 +1028,13 @@ endif() if(RPI4) target_link_libraries(${ENGINELIB} "rt") endif() + +if(FREEBSD) +set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-rpath,$ORIGIN") +else() target_link_libraries(${ENGINELIB} vulkan) set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-lvulkan,-rpath,$ORIGIN") +endif() add_executable(SeriousSam #${ENGINE_SRCS} diff --git a/SamTFE/Sources/Engine/Base/Timer.cpp b/SamTFE/Sources/Engine/Base/Timer.cpp index c0167555..52db75da 100644 --- a/SamTFE/Sources/Engine/Base/Timer.cpp +++ b/SamTFE/Sources/Engine/Base/Timer.cpp @@ -621,7 +621,11 @@ CTimer::CTimer(BOOL bInterrupt /*=TRUE*/) if (SDL_Init(SDL_INIT_TIMER) == -1) FatalError(TRANS("Cannot initialize multimedia timer!")); tm_TimerID = SDL_AddTimer(ULONG(TickQuantum*1000.0f), CTimer_TimerFunc_SDL, NULL); - if( tm_TimerID==NULL) FatalError(TRANS("Cannot initialize multimedia timer!")); + #ifdef PLATFORM_FREEBSD + if( tm_TimerID==0x00) FatalError(TRANS("Cannot initialize multimedia timer!")); + #else + if( tm_TimerID==NULL) FatalError(TRANS("Cannot initialize multimedia timer!")); + #endif #endif // make sure that timer interrupt is ticking diff --git a/SamTFE/Sources/Engine/Base/Types.h b/SamTFE/Sources/Engine/Base/Types.h index 110e3617..22f703c1 100644 --- a/SamTFE/Sources/Engine/Base/Types.h +++ b/SamTFE/Sources/Engine/Base/Types.h @@ -283,7 +283,7 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*)); } typedef uint64_t __uint64; - #if (!defined __INTEL_COMPILER) + #if (!defined __INTEL_COMPILER) && (!defined PLATFORM_FREEBSD) typedef int64_t __int64; #endif diff --git a/SamTFE/Sources/cmake/FindVulkan.cmake b/SamTFE/Sources/cmake/FindVulkan.cmake new file mode 100644 index 00000000..54b0d6bf --- /dev/null +++ b/SamTFE/Sources/cmake/FindVulkan.cmake @@ -0,0 +1,73 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +#.rst: +# FindVulkan +# ---------- +# +# Try to find Vulkan +# +# IMPORTED Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if +# Vulkan has been found. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following variables:: +# +# Vulkan_FOUND - True if Vulkan was found +# Vulkan_INCLUDE_DIRS - include directories for Vulkan +# Vulkan_LIBRARIES - link against this library to use Vulkan +# +# The module will also define two cache variables:: +# +# Vulkan_INCLUDE_DIR - the Vulkan include directory +# Vulkan_LIBRARY - the path to the Vulkan library +# +if(WIN32) + find_path(Vulkan_INCLUDE_DIR + NAMES vulkan/vulkan.h + HINTS + "$ENV{VULKAN_SDK}/Include" + ) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + find_library(Vulkan_LIBRARY + NAMES vulkan-1 + HINTS + "$ENV{VULKAN_SDK}/Lib" + "$ENV{VULKAN_SDK}/Bin" + ) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + find_library(Vulkan_LIBRARY + NAMES vulkan-1 + HINTS + "$ENV{VULKAN_SDK}/Lib32" + "$ENV{VULKAN_SDK}/Bin32" + NO_SYSTEM_ENVIRONMENT_PATH + ) + endif() +else() + find_path(Vulkan_INCLUDE_DIR + NAMES vulkan/vulkan.h + HINTS + "$ENV{VULKAN_SDK}/include") + find_library(Vulkan_LIBRARY + NAMES vulkan + HINTS + "$ENV{VULKAN_SDK}/lib") +endif() +set(Vulkan_LIBRARIES ${Vulkan_LIBRARY}) +set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR}) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Vulkan + DEFAULT_MSG + Vulkan_LIBRARY Vulkan_INCLUDE_DIR) +mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY) +if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) + add_library(Vulkan::Vulkan UNKNOWN IMPORTED) + set_target_properties(Vulkan::Vulkan PROPERTIES + IMPORTED_LOCATION "${Vulkan_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") +endif() diff --git a/SamTSE/Sources/CMakeLists.txt b/SamTSE/Sources/CMakeLists.txt index 50737afb..77ebf2ff 100644 --- a/SamTSE/Sources/CMakeLists.txt +++ b/SamTSE/Sources/CMakeLists.txt @@ -7,6 +7,7 @@ project(SeriousEngine) # Use system SDL2 is on by default option(USE_SYSTEM_SDL2 "Use systems sdl2 development files" On) option(USE_SYSTEM_ZLIB "Use systems zlib development files" On) +option(USE_SYSTEM_VULKAN "Use systems vulkan development files" On) option(USE_CCACHE "Set to ON to use ccache if present in the system" ${USE_CCACHE}) @@ -60,6 +61,15 @@ if(USE_SYSTEM_ZLIB) endif() endif() +if(USE_SYSTEM_VULKAN) + find_package(Vulkan REQUIRED) + if(Vulkan_FOUND) + include_directories(${Vulkan_INCLUDE_DIRS}) + else() + message(FATAL_ERROR "Error! USE_SYSTEM_VULKAN is set but neccessary developer files are missing") + endif() +endif() + # RAKE! Where to install the binaries. if(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" OR CMAKE_INSTALL_PREFIX STREQUAL "") # Only works for linux since I don't # know what default is for windows/macos/freebsd. @@ -100,18 +110,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") SET(DEBUG TRUE) endif() -## Find Vulkan for MACOSX -if(MACOSX) - if(NOT USE_SYSTEM_Vulkan) - find_package(Vulkan REQUIRED) - if(Vulkan_FOUND) - include_directories(${Vulkan_INCLUDE_DIR}) - else() - message(FATAL_ERROR "Error USE_SYSTEM_Vulkan is set but neccessary developer files are missing") - endif() - endif() -endif() - ## ** RAKE! start compiler specific flags section ** ## ** RAKE! Borrowed from dhewm3 project, need to ** ## ** RAKE! clean up for SeriousEngine use. Also ** @@ -1012,6 +1010,7 @@ target_link_libraries(${ENGINELIB} engine_safemath) if(FREEBSD) target_link_libraries(${ENGINELIB} ${SDL2_LIBRARY}) target_link_libraries(${ENGINELIB} ${ZLIB_LIBRARIES}) +target_link_libraries(${ENGINELIB} ${Vulkan_LIBRARY}) endif() if(MACOSX) if(USE_SYSTEM_SDL2) # use sdl2 framework on system @@ -1029,8 +1028,13 @@ endif() if(RPI4) target_link_libraries(${ENGINELIB} "rt") endif() + +if(FREEBSD) +set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-rpath,$ORIGIN") +else() target_link_libraries(${ENGINELIB} vulkan) set_target_properties(${ENGINELIB} PROPERTIES ENABLE_EXPORTS ON LINK_FLAGS "-Wl,-lvulkan,-rpath,$ORIGIN") +endif() add_executable(SeriousSam #${ENGINE_SRCS} diff --git a/SamTSE/Sources/Engine/Base/Timer.cpp b/SamTSE/Sources/Engine/Base/Timer.cpp index c0167555..52db75da 100644 --- a/SamTSE/Sources/Engine/Base/Timer.cpp +++ b/SamTSE/Sources/Engine/Base/Timer.cpp @@ -621,7 +621,11 @@ CTimer::CTimer(BOOL bInterrupt /*=TRUE*/) if (SDL_Init(SDL_INIT_TIMER) == -1) FatalError(TRANS("Cannot initialize multimedia timer!")); tm_TimerID = SDL_AddTimer(ULONG(TickQuantum*1000.0f), CTimer_TimerFunc_SDL, NULL); - if( tm_TimerID==NULL) FatalError(TRANS("Cannot initialize multimedia timer!")); + #ifdef PLATFORM_FREEBSD + if( tm_TimerID==0x00) FatalError(TRANS("Cannot initialize multimedia timer!")); + #else + if( tm_TimerID==NULL) FatalError(TRANS("Cannot initialize multimedia timer!")); + #endif #endif // make sure that timer interrupt is ticking diff --git a/SamTSE/Sources/Engine/Base/Types.h b/SamTSE/Sources/Engine/Base/Types.h index 110e3617..22f703c1 100644 --- a/SamTSE/Sources/Engine/Base/Types.h +++ b/SamTSE/Sources/Engine/Base/Types.h @@ -283,7 +283,7 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*)); } typedef uint64_t __uint64; - #if (!defined __INTEL_COMPILER) + #if (!defined __INTEL_COMPILER) && (!defined PLATFORM_FREEBSD) typedef int64_t __int64; #endif diff --git a/SamTSE/Sources/cmake/FindVulkan.cmake b/SamTSE/Sources/cmake/FindVulkan.cmake new file mode 100644 index 00000000..54b0d6bf --- /dev/null +++ b/SamTSE/Sources/cmake/FindVulkan.cmake @@ -0,0 +1,73 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +#.rst: +# FindVulkan +# ---------- +# +# Try to find Vulkan +# +# IMPORTED Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if +# Vulkan has been found. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following variables:: +# +# Vulkan_FOUND - True if Vulkan was found +# Vulkan_INCLUDE_DIRS - include directories for Vulkan +# Vulkan_LIBRARIES - link against this library to use Vulkan +# +# The module will also define two cache variables:: +# +# Vulkan_INCLUDE_DIR - the Vulkan include directory +# Vulkan_LIBRARY - the path to the Vulkan library +# +if(WIN32) + find_path(Vulkan_INCLUDE_DIR + NAMES vulkan/vulkan.h + HINTS + "$ENV{VULKAN_SDK}/Include" + ) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + find_library(Vulkan_LIBRARY + NAMES vulkan-1 + HINTS + "$ENV{VULKAN_SDK}/Lib" + "$ENV{VULKAN_SDK}/Bin" + ) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + find_library(Vulkan_LIBRARY + NAMES vulkan-1 + HINTS + "$ENV{VULKAN_SDK}/Lib32" + "$ENV{VULKAN_SDK}/Bin32" + NO_SYSTEM_ENVIRONMENT_PATH + ) + endif() +else() + find_path(Vulkan_INCLUDE_DIR + NAMES vulkan/vulkan.h + HINTS + "$ENV{VULKAN_SDK}/include") + find_library(Vulkan_LIBRARY + NAMES vulkan + HINTS + "$ENV{VULKAN_SDK}/lib") +endif() +set(Vulkan_LIBRARIES ${Vulkan_LIBRARY}) +set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR}) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Vulkan + DEFAULT_MSG + Vulkan_LIBRARY Vulkan_INCLUDE_DIR) +mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY) +if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) + add_library(Vulkan::Vulkan UNKNOWN IMPORTED) + set_target_properties(Vulkan::Vulkan PROPERTIES + IMPORTED_LOCATION "${Vulkan_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") +endif()