Skip to content

Commit

Permalink
Added OpenBSD support.
Browse files Browse the repository at this point in the history
  • Loading branch information
tx00100xt committed Nov 18, 2023
1 parent 7c16557 commit dbefdaf
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME MATCHES "GNU|kFreeBSD
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-reorder -Wno-unused-but-set-variable -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-unused-function -Wno-format")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder -Wno-unused-but-set-variable -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-unused-function -Wno-format")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
SET(FREEBSD TRUE)
endif()
if(APPLE)
Expand Down
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,49 @@ make -j4
make install
```

### OpenBSD

#### Install the required packages
```
sudo pkg_add bison cmake git sdl2 libogg libvorbis nasm
```
#### Setting up the repository

```
git clone https://github.com/tx00100xt/SeriousSamClassic.git
```

#### 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 for amd64 (for SS:TFE and SS:TSE)

Type this in your terminal:

```
cd SeriousSamClassic
mkdir build
cd build
cmake ..
make -j4
make install
```
#### Building for i386 (for SS:TFE and SS:TSE)

Type this in your terminal:

```
cd SeriousSamClassic
mkdir build
cd build
cmake .. -DCMAKE_C_FLAGS=-mmmx -DCMAKE_CXX_FLAGS=-mmmx -DCMAKE_SHARED_LINKER_FLAGS='-Wl,-znotext' -DUSE_I386_NASM_ASM=TRUE
make -j4
make install
```

### macOS

#### Install dependes
Expand Down Expand Up @@ -321,6 +364,7 @@ Supported OS
-----------
* `Linux`
* `FreeBSD`
* `OpenBSD`
* `Windows`
* `Raspberry PI OS`
* `macOS`
Expand Down
3 changes: 3 additions & 0 deletions SamTFE/Sources/Engine/Base/Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define PLATFORM_MACOSX 1
#elif (defined __FreeBSD__)
#define PLATFORM_FREEBSD 1
#elif (defined __OpenBSD__)
#define PLATFORM_OPENBSD 1
#define PLATFORM_FREEBSD 1
#else
#warning "UNKNOWN PLATFORM IDENTIFIED!!!!"
#define PLATFORM_UNKNOWN 1
Expand Down
6 changes: 6 additions & 0 deletions SamTFE/Sources/Engine/Base/ListIterator.inl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public:
iter##next=iter, iter##next.IsPastEnd() || (iter##next.MoveToNext(),1), !iter.IsPastEnd(); \
iter = iter##next)

#ifdef PLATFORM_OPENBSD
#ifdef LIST_HEAD
#undef LIST_HEAD
#endif
#endif

// get the pointer to the first element in the list
#define LIST_HEAD(listhead, baseclass, member) \
( (baseclass *) ( ((UBYTE *)(&(listhead).Head())) - _offsetof(baseclass, member) ) )
Expand Down
4 changes: 4 additions & 0 deletions SamTFE/Sources/Engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include <stdlib.h>
#if (!defined __INTEL_COMPILER) && (!defined PLATFORM_MACOSX)
#ifdef PLATFORM_OPENBSD
#include <sys/malloc.h>
#else
#include <malloc.h>
#endif
#endif
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
Expand Down
9 changes: 9 additions & 0 deletions SamTFE/Sources/Engine/Templates/LinearAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ inline void CLinearAllocator<Type>::Reset(void)
// do nothing
return;

#ifdef PLATFORM_OPENBSD
#ifdef LIST_HEAD
#undef LIST_HEAD
#endif
// get the pointer to the first element in the list
#define LIST_HEAD(listhead, baseclass, member) \
( (baseclass *) ( ((UBYTE *)(&(listhead).Head())) - _offsetof(baseclass, member) ) )
#endif

// if there is only one block allocated
} else if (&la_lhBlocks.Head()==&la_lhBlocks.Tail()) {
// just restart at the beginning
Expand Down
2 changes: 2 additions & 0 deletions SamTFE/Sources/GameMP/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include "StdAfx.h"
#include "GameMP/Game.h"
#ifndef PLATFORM_OPENBSD
#include <sys/timeb.h>
#endif
#include <time.h>
#include <locale.h>

Expand Down
2 changes: 2 additions & 0 deletions SamTFE/Sources/SeriousSam/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#include "SeriousSam/StdH.h"
#include <Engine/Build.h>
#ifndef PLATFORM_OPENBSD
#include <sys/timeb.h>
#endif
#include <time.h>

#ifdef PLATFORM_WIN32
Expand Down
3 changes: 3 additions & 0 deletions SamTSE/Sources/Engine/Base/Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define PLATFORM_MACOSX 1
#elif (defined __FreeBSD__)
#define PLATFORM_FREEBSD 1
#elif (defined __OpenBSD__)
#define PLATFORM_OPENBSD 1
#define PLATFORM_FREEBSD 1
#else
#warning "UNKNOWN PLATFORM IDENTIFIED!!!!"
#define PLATFORM_UNKNOWN 1
Expand Down
6 changes: 6 additions & 0 deletions SamTSE/Sources/Engine/Base/ListIterator.inl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public:
iter##next=iter, iter##next.IsPastEnd() || (iter##next.MoveToNext(),1), !iter.IsPastEnd(); \
iter = iter##next)

#ifdef PLATFORM_OPENBSD
#ifdef LIST_HEAD
#undef LIST_HEAD
#endif
#endif

// get the pointer to the first element in the list
#define LIST_HEAD(listhead, baseclass, member) \
( (baseclass *) ( ((UBYTE *)(&(listhead).Head())) - _offsetof(baseclass, member) ) )
Expand Down
4 changes: 4 additions & 0 deletions SamTSE/Sources/Engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include <stdlib.h>
#if (!defined __INTEL_COMPILER) && (!defined PLATFORM_MACOSX)
#ifdef PLATFORM_OPENBSD
#include <sys/malloc.h>
#else
#include <malloc.h>
#endif
#endif
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
Expand Down
9 changes: 9 additions & 0 deletions SamTSE/Sources/Engine/Templates/LinearAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ inline void CLinearAllocator<Type>::Reset(void)
// do nothing
return;

#ifdef PLATFORM_OPENBSD
#ifdef LIST_HEAD
#undef LIST_HEAD
#endif
// get the pointer to the first element in the list
#define LIST_HEAD(listhead, baseclass, member) \
( (baseclass *) ( ((UBYTE *)(&(listhead).Head())) - _offsetof(baseclass, member) ) )
#endif

// if there is only one block allocated
} else if (&la_lhBlocks.Head()==&la_lhBlocks.Tail()) {
// just restart at the beginning
Expand Down
2 changes: 2 additions & 0 deletions SamTSE/Sources/GameMP/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include "StdAfx.h"
#include "GameMP/Game.h"
#ifndef PLATFORM_OPENBSD
#include <sys/timeb.h>
#endif
#include <time.h>
#include <locale.h>

Expand Down
2 changes: 2 additions & 0 deletions SamTSE/Sources/SeriousSam/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#include "SeriousSam/StdH.h"
#include <Engine/Build.h>
#ifndef PLATFORM_OPENBSD
#include <sys/timeb.h>
#endif
#include <time.h>

#ifdef PLATFORM_WIN32
Expand Down

0 comments on commit dbefdaf

Please sign in to comment.