2020-11-06 16:42:44 +00:00
|
|
|
#!/bin/sh
|
2021-06-26 19:50:17 +00:00
|
|
|
. ./build.cfg
|
2021-08-07 21:14:51 +00:00
|
|
|
|
2022-11-26 00:54:36 +00:00
|
|
|
if ! [ -x "$(command -v git)" ]
|
2022-04-25 19:52:35 +00:00
|
|
|
then
|
2022-11-26 00:54:36 +00:00
|
|
|
printf "'git' is not installed.\n"
|
2021-08-07 21:14:51 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-11-06 16:42:44 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
FTE_MAKEFILE=./src/engine/engine/Makefile
|
2022-11-26 00:54:36 +00:00
|
|
|
FTE_SVNDIR=./src/engine/.svn
|
|
|
|
|
2021-01-16 18:29:27 +00:00
|
|
|
COMPILE_SYS=$(uname)
|
2022-05-13 15:50:06 +00:00
|
|
|
COMPILE_OS=$(uname -o)
|
2021-01-16 18:29:27 +00:00
|
|
|
|
|
|
|
# Check how many cores/processors we should use for building
|
2022-04-25 19:52:35 +00:00
|
|
|
if ! [ -x "$(command -v nproc)" ]
|
|
|
|
then
|
2021-05-09 20:01:13 +00:00
|
|
|
# check if we're on OpenBSD then
|
2022-04-25 19:52:35 +00:00
|
|
|
if ! [ -x "$(command -v sysctl)" ]
|
|
|
|
then
|
2021-05-09 20:01:13 +00:00
|
|
|
BUILD_PROC=1
|
|
|
|
else
|
|
|
|
BUILD_PROC=$(sysctl -n hw.ncpu)
|
|
|
|
fi
|
2021-01-16 18:29:27 +00:00
|
|
|
else
|
|
|
|
BUILD_PROC=$(nproc)
|
|
|
|
fi
|
2020-12-26 06:27:34 +00:00
|
|
|
|
2022-05-05 16:13:16 +00:00
|
|
|
# Compiler choice
|
|
|
|
if [ "$COMPILE_SYS" = "OpenBSD" ]
|
|
|
|
then
|
|
|
|
ENGINE_CC=cc
|
|
|
|
ENGINE_CXX=c++
|
|
|
|
else
|
|
|
|
if [ "$BUILD_CLANG" = "1" ]; then
|
|
|
|
ENGINE_CC=clang
|
|
|
|
ENGINE_CXX=clang++
|
|
|
|
else
|
|
|
|
ENGINE_CC=gcc
|
|
|
|
ENGINE_CXX=g++
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ "$BUILD_DEBUG" -eq 1 ]
|
|
|
|
then
|
2021-01-16 15:57:48 +00:00
|
|
|
MAKETARGET=gl-dbg
|
2020-12-26 06:27:34 +00:00
|
|
|
OUTPUT=./debug
|
|
|
|
else
|
2021-01-16 15:57:48 +00:00
|
|
|
MAKETARGET=gl-rel
|
2020-12-26 06:27:34 +00:00
|
|
|
OUTPUT=./release
|
|
|
|
fi
|
|
|
|
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ "$BUILD_SDL2" -eq 1 ]
|
|
|
|
then
|
2020-12-26 06:27:34 +00:00
|
|
|
PLATFORM=SDL2
|
2021-06-26 16:09:08 +00:00
|
|
|
OUTPUT=$OUTPUT/fteqw-glsdl2
|
2020-12-26 06:27:34 +00:00
|
|
|
else
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ "$COMPILE_SYS" = "OpenBSD" ]
|
|
|
|
then
|
2021-01-16 18:29:27 +00:00
|
|
|
PLATFORM=bsd
|
|
|
|
OUTPUT=$OUTPUT/fteqw-gl
|
2022-04-25 19:52:35 +00:00
|
|
|
elif [ "$COMPILE_SYS" = "FreeBSD" ]
|
|
|
|
then
|
2021-01-16 18:29:27 +00:00
|
|
|
PLATFORM=bsd
|
|
|
|
OUTPUT=$OUTPUT/fteqw-gl
|
2022-04-25 19:52:35 +00:00
|
|
|
elif [ "$COMPILE_SYS" = "NetBSD" ]
|
|
|
|
then
|
2021-01-16 18:29:27 +00:00
|
|
|
PLATFORM=bsd
|
|
|
|
OUTPUT=$OUTPUT/fteqw-gl
|
2022-04-25 19:52:35 +00:00
|
|
|
elif [ "$COMPILE_SYS" = "Linux" ]
|
|
|
|
then
|
2021-01-16 15:57:48 +00:00
|
|
|
PLATFORM=linux64
|
|
|
|
OUTPUT=$OUTPUT/fteqw-gl64
|
2022-04-25 19:52:35 +00:00
|
|
|
elif [ "$COMPILE_SYS" = "GNU/Linux" ]
|
|
|
|
then
|
2021-03-23 19:41:52 +00:00
|
|
|
PLATFORM=linux64
|
|
|
|
OUTPUT=$OUTPUT/fteqw-gl64
|
2021-01-16 18:29:27 +00:00
|
|
|
else
|
|
|
|
printf "Unsupported platform.\n"
|
|
|
|
exit
|
2021-01-16 15:57:48 +00:00
|
|
|
fi
|
2020-12-26 06:27:34 +00:00
|
|
|
fi
|
2020-11-06 16:42:44 +00:00
|
|
|
|
2022-05-13 15:50:06 +00:00
|
|
|
# GNU Make is _not_ make!...
|
|
|
|
if [ "$COMPILE_OS" = "Msys" ]; then
|
|
|
|
MAKE=make
|
|
|
|
PLATFORM=win64
|
|
|
|
else
|
2022-06-07 02:58:29 +00:00
|
|
|
if ! [ -x "$(command -v gmake)" ]
|
|
|
|
then
|
|
|
|
# only assume that Linux may not ship with a gmake... HACK!
|
|
|
|
if [ "$COMPILE_SYS" = "Linux" ]
|
|
|
|
then
|
|
|
|
MAKE=make
|
|
|
|
else
|
|
|
|
printf "You need to install GNU make.\n"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
MAKE=gmake
|
|
|
|
fi
|
2022-05-13 15:50:06 +00:00
|
|
|
fi
|
|
|
|
|
2020-11-06 16:42:44 +00:00
|
|
|
mkdir -p ./bin
|
|
|
|
|
2022-11-26 00:54:36 +00:00
|
|
|
# SVN is no more
|
|
|
|
if [ -d "$FTE_SVNDIR" ]
|
|
|
|
then
|
2022-11-30 23:37:13 +00:00
|
|
|
printf "Detected Subversion repo... Please remove ./src/engine before proceeding.\n"
|
2022-11-26 00:54:36 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ -f "$FTE_MAKEFILE" ]
|
|
|
|
then
|
|
|
|
if [ "$BUILD_UPDATE" -eq 1 ]
|
|
|
|
then
|
2021-08-07 10:27:19 +00:00
|
|
|
printf "Engine is present, updating...\n"
|
|
|
|
cd ./src/engine/
|
2021-08-27 10:31:07 +00:00
|
|
|
|
2022-11-26 00:54:36 +00:00
|
|
|
if [ -z "$(git status --untracked-files=no --porcelain)" ]
|
2022-04-25 19:52:35 +00:00
|
|
|
then
|
2022-11-26 00:54:36 +00:00
|
|
|
# TODO: let devs decide to fetch changes instead first
|
|
|
|
git pull --rebase
|
|
|
|
else
|
|
|
|
# Uncommitted changes
|
|
|
|
printf "You have uncommitted changes. Will not pull --rebase.\n"
|
2021-08-27 10:31:07 +00:00
|
|
|
fi
|
|
|
|
|
2021-08-07 10:27:19 +00:00
|
|
|
cd ./engine
|
|
|
|
else
|
|
|
|
cd ./src/engine/engine
|
|
|
|
fi
|
2020-11-06 16:42:44 +00:00
|
|
|
else
|
2020-11-07 09:40:36 +00:00
|
|
|
printf "Engine is NOT present, cloning...\n"
|
|
|
|
cd ./src/
|
2022-11-26 00:54:36 +00:00
|
|
|
git clone "https://github.com/VeraVisions/fteqw" engine
|
2020-11-06 16:42:44 +00:00
|
|
|
cd ./engine/engine
|
|
|
|
fi
|
|
|
|
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ "$BUILD_CLEAN" -eq 1 ]
|
|
|
|
then
|
2022-05-13 15:50:06 +00:00
|
|
|
$MAKE clean
|
2021-08-07 21:14:51 +00:00
|
|
|
printf "Cleaned the build directory.\n\n"
|
2021-05-17 16:19:30 +00:00
|
|
|
fi
|
|
|
|
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ "$BUILD_ENGINE_DEPENDENCIES" -eq 1 ]
|
|
|
|
then
|
2022-07-13 18:25:14 +00:00
|
|
|
$MAKE -j $BUILD_PROC makelibs
|
2021-08-07 21:14:51 +00:00
|
|
|
printf "Built the static dependencies successfully.\n\n"
|
2021-06-26 16:09:08 +00:00
|
|
|
fi
|
|
|
|
|
2022-07-07 16:10:14 +00:00
|
|
|
$MAKE -j $BUILD_PROC CC=$ENGINE_CC CXX=$ENGINE_CXX $MAKETARGET CFLAGS=-DMULTITHREAD FTE_TARGET=$PLATFORM
|
2020-12-26 06:27:34 +00:00
|
|
|
cp -v "$OUTPUT" ../../../bin/fteqw
|
2021-08-07 21:14:51 +00:00
|
|
|
printf "Built the client engine successfully.\n\n"
|
2020-12-22 00:56:44 +00:00
|
|
|
|
2022-05-13 15:50:06 +00:00
|
|
|
$MAKE -j $BUILD_PROC CC=$ENGINE_CC CXX=$ENGINE_CXX sv-dbg
|
2021-01-16 15:57:48 +00:00
|
|
|
cp -v ./debug/fteqw-sv ../../../bin/fteqw-sv
|
2021-08-07 21:14:51 +00:00
|
|
|
printf "Built the dedicated server successfully.\n\n"
|
|
|
|
|
2022-05-13 15:50:06 +00:00
|
|
|
$MAKE -j $BUILD_PROC CC=$ENGINE_CC CXX=$ENGINE_CXX qcc-rel
|
2020-11-06 16:42:44 +00:00
|
|
|
cp -v ./release/fteqcc ../../../bin/fteqcc
|
2021-08-07 21:14:51 +00:00
|
|
|
printf "Built the QuakeC compiler successfully.\n\n"
|
2020-11-06 17:50:44 +00:00
|
|
|
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ "$BUILD_IMGTOOL" -eq 1 ]
|
|
|
|
then
|
2022-05-05 16:13:16 +00:00
|
|
|
# Note: DOESN'T LIKE CLANG!
|
2022-05-13 15:50:06 +00:00
|
|
|
$MAKE -j $BUILD_PROC imgtool-rel
|
2021-06-26 16:09:08 +00:00
|
|
|
cp -v ./release/imgtool ../../../bin/imgtool
|
2021-08-07 21:14:51 +00:00
|
|
|
printf "Built the imgtool successfully.\n\n"
|
2021-06-26 16:09:08 +00:00
|
|
|
fi
|
|
|
|
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ "$BUILD_SOURCE" -eq 1 ]
|
|
|
|
then
|
2022-05-05 16:13:16 +00:00
|
|
|
# Note: DOESN'T LIKE CLANG!
|
2022-05-13 15:50:06 +00:00
|
|
|
$MAKE -j $BUILD_PROC plugins-rel CFLAGS=-DGLQUAKE NATIVE_PLUGINS="hl2"
|
2021-11-09 16:33:16 +00:00
|
|
|
find ./release/ -name 'fteplug_hl2_*.so' -exec cp -prv '{}' '../../../bin/' ';'
|
|
|
|
printf "Built the Source Engine plugin successfully.\n\n"
|
|
|
|
fi
|
|
|
|
|
2022-06-10 14:55:30 +00:00
|
|
|
if [ "$BUILD_QUAKE3" -eq 1 ]
|
|
|
|
then
|
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX $MAKE -j $BUILD_PROC plugins-rel NATIVE_PLUGINS="quake3"
|
|
|
|
find ./release/ -name 'fteplug_quake3_*.so' -exec cp -prv '{}' '../../../bin/' ';'
|
|
|
|
printf "Built the Quake III plugin successfully.\n\n"
|
|
|
|
fi
|
|
|
|
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ "$BUILD_BULLET" -eq 1 ]
|
|
|
|
then
|
2022-05-13 15:50:06 +00:00
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX $MAKE -j $BUILD_PROC plugins-rel NATIVE_PLUGINS="bullet"
|
2021-06-26 16:09:08 +00:00
|
|
|
find ./release/ -name 'fteplug_bullet_*.so' -exec cp -prv '{}' '../../../bin/' ';'
|
2021-08-07 21:14:51 +00:00
|
|
|
printf "Built the bullet plugin successfully.\n\n"
|
2021-06-26 16:09:08 +00:00
|
|
|
fi
|
|
|
|
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ "$BUILD_ODE" -eq 1 ]
|
|
|
|
then
|
2022-05-13 15:50:06 +00:00
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX $MAKE -j $BUILD_PROC plugins-rel NATIVE_PLUGINS="ode"
|
2021-11-20 16:27:52 +00:00
|
|
|
find ./release/ -name 'fteplug_ode_*.so' -exec cp -prv '{}' '../../../bin/' ';'
|
|
|
|
printf "Built the ode plugin successfully.\n\n"
|
|
|
|
fi
|
|
|
|
|
2022-04-25 19:52:35 +00:00
|
|
|
if [ "$BUILD_FFMPEG" -eq 1 ]
|
|
|
|
then
|
2022-05-13 15:50:06 +00:00
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX $MAKE -j $BUILD_PROC plugins-rel NATIVE_PLUGINS="ffmpeg"
|
2021-06-26 16:09:08 +00:00
|
|
|
find ./release/ -name 'fteplug_ffmpeg_*.so' -exec cp -prv '{}' '../../../bin/' ';'
|
2021-08-07 21:14:51 +00:00
|
|
|
printf "Built the ffmpeg plugin successfully.\n\n"
|
2021-06-26 16:09:08 +00:00
|
|
|
fi
|
2021-08-07 21:14:51 +00:00
|
|
|
|
|
|
|
printf "DONE. Built ALL components successfully.\n"
|