Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(openttd): Add openttd dedicated server #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions openttd-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# OpenTTD-Server

Build the openttd-server dedicated as a static PIE ELF running on Linux.

## Requirements
Make sure the following packages are installed:
- build-utils
- cmake
- git
- strip

## Building
The openttd and openttd_test static PIE files are located in the current directory.
If you want to rebuild, run:

```bash
$ ./build.sh
```

This script downloads, unpacks, patches, configures, and builds the openttd dedicated server PIE ELF file.
Make sure that you patch out any other libraries that you might have in your system.
If you want to add a library, add this type of line after the `sed` command:

```
set(ZLIB_USE_STATIC_LIBS "ON")
```
35 changes: 35 additions & 0 deletions openttd-server/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

APPNAME=openttd
DIRNAME=OpenTTD
URL=https://github.com/OpenTTD/OpenTTD.git

echo -n "Downloading ${APPNAME} sources ..."
git clone --depth 1 ${URL} --quiet
echo "DONE"

echo -n "Building ${APPNAME} ..."

pushd ${DIRNAME} > /dev/null 2>&1 || exit 1

mkdir build
pushd build > /dev/null 2>&1 || exit 1

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPTION_DEDICATED=ON -DOPTION_USE_ASSERTS=OFF -DOPTION_USE_THREADS=ON ..

echo "target_compile_options(openttd PUBLIC \"-static-pie\")" >> ../CMakeLists.txt
echo "target_compile_options(openttd_lib PUBLIC \"-static-pie\")" >> ../CMakeLists.txt
echo "target_link_options(openttd PUBLIC \"-static-pie\")" >> ../CMakeLists.txt
echo "target_link_options(openttd_lib PUBLIC \"-static-pie\")" >> ../CMakeLists.txt

sed -i 's/link_package/#link_package/g' ../CMakeLists.txt

make -j$(nproc)

strip openttd
strip openttd_test

popd > /dev/null 2>&1 || exit 1

popd > /dev/null 2>&1 || exit 1

Binary file added openttd-server/openttd
Binary file not shown.
Binary file added openttd-server/openttd_test
Binary file not shown.