2020-11-06 08:42:44 -08:00
|
|
|
#!/bin/sh
|
2021-06-26 12:50:17 -07:00
|
|
|
. ./build.cfg
|
2021-08-07 14:14:51 -07:00
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if ! [ -x "$(command -v svn)" ]
|
|
|
|
then
|
2021-08-07 14:14:51 -07:00
|
|
|
printf "'svn' is not installed.\n"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-11-06 08:42:44 -08:00
|
|
|
set -e
|
|
|
|
|
|
|
|
FTE_MAKEFILE=./src/engine/engine/Makefile
|
2021-01-16 10:29:27 -08:00
|
|
|
COMPILE_SYS=$(uname)
|
|
|
|
|
|
|
|
# Check how many cores/processors we should use for building
|
2022-04-25 12:52:35 -07:00
|
|
|
if ! [ -x "$(command -v nproc)" ]
|
|
|
|
then
|
2021-05-09 13:01:13 -07:00
|
|
|
# check if we're on OpenBSD then
|
2022-04-25 12:52:35 -07:00
|
|
|
if ! [ -x "$(command -v sysctl)" ]
|
|
|
|
then
|
2021-05-09 13:01:13 -07:00
|
|
|
BUILD_PROC=1
|
|
|
|
else
|
|
|
|
BUILD_PROC=$(sysctl -n hw.ncpu)
|
|
|
|
fi
|
2021-01-16 10:29:27 -08:00
|
|
|
else
|
|
|
|
BUILD_PROC=$(nproc)
|
|
|
|
fi
|
2020-12-25 22:27:34 -08:00
|
|
|
|
2022-05-05 09:13:16 -07: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 12:52:35 -07:00
|
|
|
if [ "$BUILD_DEBUG" -eq 1 ]
|
|
|
|
then
|
2021-01-16 07:57:48 -08:00
|
|
|
MAKETARGET=gl-dbg
|
2020-12-25 22:27:34 -08:00
|
|
|
OUTPUT=./debug
|
|
|
|
else
|
2021-01-16 07:57:48 -08:00
|
|
|
MAKETARGET=gl-rel
|
2020-12-25 22:27:34 -08:00
|
|
|
OUTPUT=./release
|
|
|
|
fi
|
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$BUILD_SDL2" -eq 1 ]
|
|
|
|
then
|
2020-12-25 22:27:34 -08:00
|
|
|
PLATFORM=SDL2
|
2021-06-26 09:09:08 -07:00
|
|
|
OUTPUT=$OUTPUT/fteqw-glsdl2
|
2020-12-25 22:27:34 -08:00
|
|
|
else
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$COMPILE_SYS" = "OpenBSD" ]
|
|
|
|
then
|
2021-01-16 10:29:27 -08:00
|
|
|
PLATFORM=bsd
|
|
|
|
OUTPUT=$OUTPUT/fteqw-gl
|
2022-04-25 12:52:35 -07:00
|
|
|
elif [ "$COMPILE_SYS" = "FreeBSD" ]
|
|
|
|
then
|
2021-01-16 10:29:27 -08:00
|
|
|
PLATFORM=bsd
|
|
|
|
OUTPUT=$OUTPUT/fteqw-gl
|
2022-04-25 12:52:35 -07:00
|
|
|
elif [ "$COMPILE_SYS" = "NetBSD" ]
|
|
|
|
then
|
2021-01-16 10:29:27 -08:00
|
|
|
PLATFORM=bsd
|
|
|
|
OUTPUT=$OUTPUT/fteqw-gl
|
2022-04-25 12:52:35 -07:00
|
|
|
elif [ "$COMPILE_SYS" = "Linux" ]
|
|
|
|
then
|
2021-01-16 07:57:48 -08:00
|
|
|
PLATFORM=linux64
|
|
|
|
OUTPUT=$OUTPUT/fteqw-gl64
|
2022-04-25 12:52:35 -07:00
|
|
|
elif [ "$COMPILE_SYS" = "GNU/Linux" ]
|
|
|
|
then
|
2021-03-23 12:41:52 -07:00
|
|
|
PLATFORM=linux64
|
|
|
|
OUTPUT=$OUTPUT/fteqw-gl64
|
2021-01-16 10:29:27 -08:00
|
|
|
else
|
|
|
|
printf "Unsupported platform.\n"
|
|
|
|
exit
|
2021-01-16 07:57:48 -08:00
|
|
|
fi
|
2020-12-25 22:27:34 -08:00
|
|
|
fi
|
2020-11-06 08:42:44 -08:00
|
|
|
|
|
|
|
mkdir -p ./bin
|
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ -f "$FTE_MAKEFILE" ]
|
|
|
|
then
|
|
|
|
if [ "$BUILD_UPDATE" -eq 1 ]
|
|
|
|
then
|
2021-08-07 03:27:19 -07:00
|
|
|
printf "Engine is present, updating...\n"
|
|
|
|
cd ./src/engine/
|
2021-08-27 03:31:07 -07:00
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$BUILD_ENGINEREVISION" -eq 0 ]
|
|
|
|
then
|
2021-08-27 03:31:07 -07:00
|
|
|
svn up
|
|
|
|
else
|
|
|
|
svn -r $BUILD_ENGINEREVISION up
|
|
|
|
fi
|
|
|
|
|
2021-08-07 03:27:19 -07:00
|
|
|
cd ./engine
|
|
|
|
else
|
|
|
|
cd ./src/engine/engine
|
|
|
|
fi
|
2020-11-06 08:42:44 -08:00
|
|
|
else
|
2020-11-07 01:40:36 -08:00
|
|
|
printf "Engine is NOT present, cloning...\n"
|
|
|
|
cd ./src/
|
2021-08-27 03:31:07 -07:00
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$BUILD_ENGINEREVISION" -eq 0 ]
|
|
|
|
then
|
2021-08-27 03:31:07 -07:00
|
|
|
svn checkout https://svn.code.sf.net/p/fteqw/code/trunk engine
|
|
|
|
else
|
|
|
|
svn -r $BUILD_ENGINEREVISION checkout https://svn.code.sf.net/p/fteqw/code/trunk engine
|
|
|
|
fi
|
2020-11-06 08:42:44 -08:00
|
|
|
cd ./engine/engine
|
|
|
|
fi
|
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$BUILD_CLEAN" -eq 1 ]
|
|
|
|
then
|
2021-05-17 09:19:30 -07:00
|
|
|
gmake clean
|
2021-08-07 14:14:51 -07:00
|
|
|
printf "Cleaned the build directory.\n\n"
|
2021-05-17 09:19:30 -07:00
|
|
|
fi
|
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$BUILD_ENGINE_DEPENDENCIES" -eq 1 ]
|
|
|
|
then
|
2022-05-05 09:13:16 -07:00
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX gmake -j $BUILD_PROC makelibs FTE_TARGET=$PLATFORM
|
2021-08-07 14:14:51 -07:00
|
|
|
printf "Built the static dependencies successfully.\n\n"
|
2021-06-26 09:09:08 -07:00
|
|
|
fi
|
|
|
|
|
2022-05-05 09:13:16 -07:00
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX gmake -j $BUILD_PROC $MAKETARGET CFLAGS=-DMULTITHREAD FTE_TARGET=$PLATFORM
|
2020-12-25 22:27:34 -08:00
|
|
|
cp -v "$OUTPUT" ../../../bin/fteqw
|
2021-08-07 14:14:51 -07:00
|
|
|
printf "Built the client engine successfully.\n\n"
|
2020-12-21 16:56:44 -08:00
|
|
|
|
2022-05-05 09:13:16 -07:00
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX gmake -j $BUILD_PROC sv-dbg
|
2021-01-16 07:57:48 -08:00
|
|
|
cp -v ./debug/fteqw-sv ../../../bin/fteqw-sv
|
2021-08-07 14:14:51 -07:00
|
|
|
printf "Built the dedicated server successfully.\n\n"
|
|
|
|
|
2022-05-05 09:13:16 -07:00
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX gmake -j $BUILD_PROC qcc-rel
|
2020-11-06 08:42:44 -08:00
|
|
|
cp -v ./release/fteqcc ../../../bin/fteqcc
|
2021-08-07 14:14:51 -07:00
|
|
|
printf "Built the QuakeC compiler successfully.\n\n"
|
2020-11-06 09:50:44 -08:00
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$BUILD_IMGTOOL" -eq 1 ]
|
|
|
|
then
|
2022-05-05 09:13:16 -07:00
|
|
|
# Note: DOESN'T LIKE CLANG!
|
2021-06-26 09:09:08 -07:00
|
|
|
gmake -j $BUILD_PROC imgtool-rel
|
|
|
|
cp -v ./release/imgtool ../../../bin/imgtool
|
2021-08-07 14:14:51 -07:00
|
|
|
printf "Built the imgtool successfully.\n\n"
|
2021-06-26 09:09:08 -07:00
|
|
|
fi
|
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$BUILD_SOURCE" -eq 1 ]
|
|
|
|
then
|
2022-05-05 09:13:16 -07:00
|
|
|
# Note: DOESN'T LIKE CLANG!
|
2021-11-09 08:33:16 -08:00
|
|
|
gmake -j $BUILD_PROC plugins-rel CFLAGS=-DGLQUAKE NATIVE_PLUGINS="hl2"
|
|
|
|
find ./release/ -name 'fteplug_hl2_*.so' -exec cp -prv '{}' '../../../bin/' ';'
|
|
|
|
printf "Built the Source Engine plugin successfully.\n\n"
|
|
|
|
fi
|
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$BUILD_BULLET" -eq 1 ]
|
|
|
|
then
|
2022-05-05 09:13:16 -07:00
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX gmake -j $BUILD_PROC plugins-rel NATIVE_PLUGINS="bullet"
|
2021-06-26 09:09:08 -07:00
|
|
|
find ./release/ -name 'fteplug_bullet_*.so' -exec cp -prv '{}' '../../../bin/' ';'
|
2021-08-07 14:14:51 -07:00
|
|
|
printf "Built the bullet plugin successfully.\n\n"
|
2021-06-26 09:09:08 -07:00
|
|
|
fi
|
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$BUILD_ODE" -eq 1 ]
|
|
|
|
then
|
2022-05-05 09:13:16 -07:00
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX gmake -j $BUILD_PROC plugins-rel NATIVE_PLUGINS="ode"
|
2021-11-20 08:27:52 -08:00
|
|
|
find ./release/ -name 'fteplug_ode_*.so' -exec cp -prv '{}' '../../../bin/' ';'
|
|
|
|
printf "Built the ode plugin successfully.\n\n"
|
|
|
|
fi
|
|
|
|
|
2022-04-25 12:52:35 -07:00
|
|
|
if [ "$BUILD_FFMPEG" -eq 1 ]
|
|
|
|
then
|
2022-05-05 09:13:16 -07:00
|
|
|
CC=$ENGINE_CC CXX=$ENGINE_CXX gmake -j $BUILD_PROC plugins-rel NATIVE_PLUGINS="ffmpeg"
|
2021-06-26 09:09:08 -07:00
|
|
|
find ./release/ -name 'fteplug_ffmpeg_*.so' -exec cp -prv '{}' '../../../bin/' ';'
|
2021-08-07 14:14:51 -07:00
|
|
|
printf "Built the ffmpeg plugin successfully.\n\n"
|
2021-06-26 09:09:08 -07:00
|
|
|
fi
|
2021-08-07 14:14:51 -07:00
|
|
|
|
|
|
|
printf "DONE. Built ALL components successfully.\n"
|