4 misc/tools/xonotic-map-compiler-autobuild download
8 msg "Usage: ./all compile-map mapname1 mapname2 mapname3"
9 msg "For example: ./all compile-map dance xoylent"
11 if ! [ -f "netradiant/install/q3map2" ] ; then
12 msg "q3map2 needed! Building netradiant..."
13 make -C netradiant BUILD=native install/q3map2
15 for mapfile in "$@"; do
16 mapfile="data/xonotic-maps.pk3dir/maps/$mapfile.map"
17 if [ ! -f "$mapfile" ] ; then
18 msg "ERROR, $mapfile not found!"
20 verbose measure_time misc/tools/xonotic-map-compiler-optionsfile "$mapfile"
30 debug=release # when changing this default, change the description in the zsh autocompletion script
34 export CC="$CC -DSUPPORTIPV6"
69 case "`$CC -dumpversion`" in
70 [5-9]*|[1-9][0-9]*|4.[3-9]*|4.[1-9][0-9]*)
72 # -march=native is broken < 4.3
73 if $CC -mtune=native -march=native misc/tools/conftest.c -o conftest >/dev/null 2>&1; then
74 export CC="$CC -mtune=native -march=native"
78 if [ -n "$WE_HATE_OUR_USERS" ]; then
79 export CC="$CC -fno-common"
89 if [ x"`uname`" = x"Darwin" ]; then
90 TARGETS="sv-$debug sdl-$debug"
91 export CC="$CC -fno-reorder-blocks"
92 elif [ -n "$WE_HATE_OUR_USERS" ]; then
93 TARGETS="sv-$debug sdl-$debug"
95 TARGETS="sv-$debug cl-$debug sdl-$debug"
98 if [ $# -gt 0 ] && [ x"$1" = x"" ]; then
99 # if we give the command make the arg "", it will surely fail (invalid filename),
100 # so better handle it as an empty client option
103 elif [ -n "$1" ]; then
105 TARGETS_SAVE=$TARGETS
110 TARGETS="$TARGETS sdl-$debug"
113 TARGETS="$TARGETS cl-$debug"
116 TARGETS="$TARGETS sv-$debug"
119 BAD_TARGETS="$BAD_TARGETS $X"
123 if [ -n "$TARGETS" ]; then # at least a valid client
125 else # no valid client, let's assume this option is not meant to be a client then
126 TARGETS=$TARGETS_SAVE
131 if [ -z "$MAKE" ]; then
135 if [ -z "$MAKEFLAGS" ]; then
136 ncpus=`getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1`
137 if [ $ncpus -gt 1 ]; then
140 if [ -n "$WE_HATE_OUR_USERS" ]; then
141 MAKEFLAGS="$MAKEFLAGS DP_MAKE_TARGET=mingw"
145 if [ -n "$WE_HATE_OUR_USERS" ]; then
149 MAKEFLAGS="$MAKEFLAGS SDL_CONFIG=$d0/misc/builddeps/win64/sdl/bin/sdl2-config"
152 MAKEFLAGS="$MAKEFLAGS SDL_CONFIG=$d0/misc/builddeps/win32/sdl/bin/sdl2-config"
156 # win32: don't rely on jpeg includes
157 MAKEFLAGS="$MAKEFLAGS LIB_JPEG= CFLAGS_LIBJPEG="
160 if [ x"`uname`" = x"Darwin" ]; then
162 f=$d0/misc/buildfiles/osx/Xonotic.app/Contents/Frameworks
163 MAKEFLAGS="$MAKEFLAGS SDLCONFIG_MACOSXCFLAGS=-I$f/SDL2.framework/Headers SDLCONFIG_MACOSXLIBS=-F$f SDLCONFIG_MACOSXLIBS+=-framework SDLCONFIG_MACOSXLIBS+=SDL2 SDLCONFIG_MACOSXLIBS+=-framework SDLCONFIG_MACOSXLIBS+=Cocoa SDLCONFIG_MACOSXLIBS+=-I$f/SDL2.framework/Headers SDLCONFIG_MACOSXSTATICLIBS=-F$f SDLCONFIG_MACOSXSTATICLIBS+=-framework SDLCONFIG_MACOSXSTATICLIBS+=SDL2 SDLCONFIG_MACOSXSTATICLIBS+=-framework SDLCONFIG_MACOSXSTATICLIBS+=Cocoa SDLCONFIG_MACOSXSTATICLIBS+=-I$f/SDL2.framework/Headers"
166 # workaround ARM issue in DP's makefile.inc
171 MAKEFLAGS="$MAKEFLAGS CFLAGS_SSE= CFLAGS_SSE2="
175 if ! verbose $CC misc/tools/conftest.c -o conftest; then
177 msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
178 msg "~~~~~~~~~~ COMPILER ~~~~~~~~~~"
179 msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
180 msg "~~~~~~~~~~~~~~_...._~~~~~~~~~~"
181 msg "~~~~~~~~~~~,-' \\\`-._~~~~~~"
182 msg "~~~~~~~~~~/ --. >< \\~~~~~"
183 msg "~~~~~~~~~/ (*)> -<: \\~~~~"
184 msg "~~~~~~~~~( ^~-' (*) )~~~~"
185 msg "~~~~~~~~~\\ ^+-_/ |~~~~"
186 msg "~~~~~~~~~~\\ {vvv} |~~~~"
187 msg "~~~~~~~~~~,\\ , {^^^},/~~~~~"
188 msg "~~~~~~~~,/ \`---.....-'~~W~~~~"
189 msg "~~~~~~,/ \\_____/_\\_W~~/~~~~~"
190 msg "~~~~~/ /~~~\\__/~~~~~~"
191 msg "~~~~/ /~~~~~~~~~~~~~~"
192 msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
193 msg "~~~~~~~ Y U NO COMPILE ~~~~~~~"
194 msg "~~~~~~~~~~~~ CODE ~~~~~~~~~~~~"
195 msg "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
201 verbose cd "$d0/d0_blind_id"
202 if [ -z "$compiled0" ]; then
206 # compilation of crypto library failed
207 # use binaries then, if we can...
209 if [ -n "$WE_HATE_OUR_USERS" ]; then
212 verbose cp "$d0/misc/buildfiles/win64/libd0_blind_id"-* .libs/
213 verbose cp "$d0/misc/buildfiles/win64/libd0_rijndael"-* .libs/
214 verbose cp "$d0/misc/buildfiles/win64/libgmp"-* .libs/
218 verbose cp "$d0/misc/buildfiles/win32/libd0_blind_id"-* .libs/
219 verbose cp "$d0/misc/buildfiles/win32/libd0_rijndael"-* .libs/
220 verbose cp "$d0/misc/buildfiles/win32/libgmp"-* .libs/
229 # No cp commands, we want to use static linking instead.
230 export CC="$CC -I../../../../misc/builddeps/linux32/d0_blind_id/include"
231 export CC="$CC -L../../../../misc/builddeps/linux32/d0_blind_id/lib"
232 export CC="$CC -Wl,-rpath,../../../../misc/builddeps/linux32/d0_blind_id/lib"
233 export CC="$CC -I../../../../misc/builddeps/linux32/gmp/include"
234 export CC="$CC -L../../../../misc/builddeps/linux32/gmp/lib"
235 export CC="$CC -Wl,-rpath,../../../../misc/builddeps/linux32/gmp/lib"
236 MAKEFLAGS="$MAKEFLAGS DP_LINK_CRYPTO=shared DP_LINK_CRYPTO_RIJNDAEL=shared LIB_CRYPTO=../../../../misc/builddeps/linux32/d0_blind_id/lib/libd0_blind_id.a LIB_CRYPTO+=../../../../misc/builddeps/linux32/gmp/lib/libgmp.a LIB_CRYPTO_RIJNDAEL=../../../../misc/builddeps/linux32/d0_blind_id/lib/libd0_rijndael.a"
240 msg "Always need to compile libd0_blind_id on Linux `uname -m`."
245 verbose cp "$d0/misc/buildfiles/osx/Xonotic.app/Contents/MacOS/libd0_blind_id".* .libs/
246 verbose cp "$d0/misc/buildfiles/osx/Xonotic.app/Contents/MacOS/libd0_rijndael".* .libs/
250 msg "Always need to compile libd0_blind_id on `uname`."
257 if [ -f Makefile ]; then
258 verbose $MAKE $MAKEFLAGS distclean
261 if ! [ -f Makefile ]; then
262 verbose sh autogen.sh
265 verbose $MAKE $MAKEFLAGS
268 verbose cd "$d0/gmqcc"
270 verbose $MAKE $MAKEFLAGS clean
272 if [ -n "$WE_HATE_OUR_USERS" ]; then
273 verbose $MAKE $MAKEFLAGS gmqcc.exe
275 verbose $MAKE $MAKEFLAGS gmqcc
278 if [ -n "$MSYSTEM" ]; then
279 DATAMAKE=mingw32-make
283 verbose cd "$d0/data/xonotic-data.pk3dir"
285 verbose ${DATAMAKE} QCC="../../../../gmqcc/gmqcc" "$@" $MAKEFLAGS clean
287 verbose ${DATAMAKE} QCC="../../../../gmqcc/gmqcc" "$@" $MAKEFLAGS
288 # 4 levels up: data, xonotic-data, qcsrc, server
290 verbose cd "$d0/darkplaces"
291 if [ x"$BAD_TARGETS" = x" " ]; then
292 $ECHO "Warning: invalid empty client, default clients will be used."
295 verbose $MAKE $MAKEFLAGS clean
297 for T in $TARGETS; do
298 verbose $MAKE $MAKEFLAGS STRIP=: "$@" "$T"
300 for T in $BAD_TARGETS; do
301 $ECHO "Warning: discarded invalid client $T."
304 verbose "$SELF" update-maps
307 if [ -n "$WE_HATE_OUR_USERS" ]; then
310 export PATH="$d0/misc/buildfiles/win64:$d0/d0_blind_id/.libs:$PATH"
313 export PATH="$d0/misc/buildfiles/win32:$d0/d0_blind_id/.libs:$PATH"
316 elif [ x"`uname`" = x"Darwin" ]; then
317 export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Xonotic.app/Contents/MacOS:$d0/d0_blind_id/.libs"
318 export DYLD_FRAMEWORK_PATH="$d0/misc/buildfiles/osx/Xonotic.app/Contents/Frameworks"
320 export LD_LIBRARY_PATH="$d0/d0_blind_id/.libs${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
340 if ! [ -x "darkplaces/darkplaces$client" ]; then
341 if [ -x "darkplaces/darkplaces$client.exe" ]; then
344 $ECHO "Client darkplaces/darkplaces$client not found, aborting"
348 set -- "darkplaces/darkplaces$client" -xonotic "$@"
350 # if pulseaudio is running: USE IT
351 if [ -z "$SDL_AUDIODRIVER" ] && ! [ -n "$WE_HATE_OUR_USERS" ] && ! [ x"`uname`" = x"Darwin" ]; then
352 if ps -C pulseaudio >/dev/null; then
353 if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
354 export SDL_AUDIODRIVER=pulse
361 if [ x"$USE_GDB" = x"yes" ]; then
362 set -- gdb --args "$@"
364 elif [ x"$USE_GDB" = x"core" ]; then
365 set -- gdb --batch -x savecore.gdb --args "$@"
367 elif which catchsegv >/dev/null 2>&1; then
368 set -- catchsegv "$@"
370 if [ x"$USE_RLWRAP" != x"no" ] && which rlwrap >/dev/null 2>&1; then
371 set -- rlwrap -A -g '^quit' -q "\"" -s 10000 -S ']' -w 100 "$@"
374 verbose measure_time "$@" || true
375 if [ -f xonotic.core ]; then
376 if yesno "The program has CRASHED. Do you want to examine the core dump?"; then
377 gdb "$binary" xonotic.core
378 #elif yesno "You did not want to examine the core dump. Do you want to provide it - including your DarkPlaces checkout - to the Xonotic developers?"; then
379 # tar cvzf xonotic.core.tar.gz xonotic.core darkplaces/*.c darkplaces/*.h
381 # rm -f xonotic.core.tar.gz
383 $ECHO "The core dump can be examined later by"
384 $ECHO " gdb $binary xonotic.core"
390 $ECHO " $SELF compile [-c] [-qc] [-d|-p|-r] [-0] [-1] [sdl|glx|dedicated]"
391 $ECHO " $SELF update-maps"
392 $ECHO " $SELF run [sdl|glx|dedicated] options..."
393 $ECHO " $SELF compile-map mapname1 mapname2... (e.g. \"./all compile-map dance drain fuse\")"
397 # TODO(rpolzer): Why does :anticheat: output differ? Total game time differs? Why?
398 mkdir -p SERVERBENCH_TEMP
399 verbose "$SELF" run dedicated -noconfig -userdir SERVERBENCH_TEMP +exec serverbench.cfg |\
402 grep -v '^:gamestart:' |\
403 grep -v '^:anticheat:' |\
405 rm -rf SERVERBENCH_TEMP