-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·481 lines (410 loc) · 13.9 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
: # Detect if Windows batch, if so goto end section
:<<"::CMDLITERAL"
@ECHO OFF
GOTO :SCRIPTWIN
::CMDLITERAL
#!/usr/bin/env bash
# Check machine architecture
if [ "$(uname)" = "Darwin" ]; then
machine=OSX
echo "OSX is not supported!"
exit
elif [ "$(expr substr $(uname -s) 1 10)" = "MINGW32_NT" ]; then
machine=Win32
ext=.dll
elif [ "$(expr substr $(uname -s) 1 10)" = "MINGW64_NT" ]; then
machine=Win64
ext=.dll
elif [ "$(uname -sm)" = "Linux x86_64" ]; then
machine=Linux64
ext=.so
elif [ "$(uname -sm)" = "Linux i686" ]; then
machine=Linux32
ext=.so
elif [ "$(uname -sm)" = "Linux armv6l" ] || [ "$(uname -sm)" = "Linux armv7l" ]; then
# pi uses v6, even on pi2/3/4?
machine=LinuxArm
arch=_armv6hf
ext=.so
else
echo "Can't get machine identity, exiting!"
exit
fi
echo
echo "Running $machine"
# Linux: install packages and set paths
if [ "$(expr substr $machine 1 5)" = "Linux" ]; then
echo
read -p 'Install packages? [y/N] ' installpkg
if [ "$installpkg" = "y" ] || [ "$installpkg" = "Y" ]; then
echo
echo "Installing packages..."
if [ -n "$(command -v apt-get)" ]; then
sudo apt update
if [ "$machine" = "LinuxArm" ]; then
sudo apt install libfontconfig1-dev git build-essential cmake libsdl2-dev
elif [ "$machine" = "Linux32" ] || [ "$machine" = "Linux64" ]; then
sudo dpkg --add-architecture i386
sudo apt install libfontconfig1-dev git build-essential cmake libfreetype6-dev:i386 gcc-multilib g++-multilib libsdl2-dev:i386 libfontconfig-dev:i386
fi
elif [ -n "$(command -v yum)" ]; then
sudo yum check-update
sudo yum install epel-release
sudo yum config-manager --set-enabled powertools
sudo yum update
sudo yum install cmake gcc-c++ freetype-devel urw-fonts git python3 libgcc.{i686,x86_64} glibc-devel.{i686,x86_64} libstdc++-devel.{i686,x86_64} libxml2-devel.{i686,x86_64} fontconfig.{i686,x86_64} fontconfig-devel.{i686,x86_64} fontconfig-devel pkgconf.{i686,x86_64} freetype-devel.{i686,x86_64} SDL2-devel.{i686,x86_64} mesa-dri-drivers.{i686,x86_64}
# should query status first:
sudo alternatives --set python /usr/bin/python3
else
echo
echo "Neither apt nor yum found, please install packages by hand!"
exit
fi
fi
# Find where we are
basedir=$PWD
gamedir=$basedir/HL
mkdir -p $gamedir
sourcedir=$basedir/sources
mkdir -p $sourcedir
addondir=$basedir/buildfiles
echo
echo "Installing to $gamedir"
echo "Sources will be downloaded to $sourcedir"
echo
read -p 'Build Xash3D? [y/N] ' buildxash
if [ "$buildxash" = "y" ] || [ "$buildxash" = "Y" ]; then
cd $sourcedir
# ARM needs SDL
if [ "$machine" = "LinuxArm" ]; then
wget http://www.libsdl.org/release/SDL2-2.0.22.tar.gz
tar xvf SDL2-2.0.22.tar.gz
cd SDL2-2.0.22
mkdir -p build
cd build
cmake ..
make -j$(nproc)
sudo make install
fi
xash3ddir=$sourcedir/xash3d
# If the source already exists, delete
if [ -d "$xash3ddir" ]; then
rm -Rf $xash3ddir
fi
engineversion=new
# Engine version check
if [ "$engineversion" = "old" ]; then
git clone --recursive https://github.com/thomaseichhorn/xash3d.git $xash3ddir
cd $xash3ddir/engine
git clone https://github.com/thomaseichhorn/nanogl.git
cd ..
git clone https://github.com/thomaseichhorn/halflife.git hlsdk/
mkdir -p build
cd build
if [ "$machine" = "LinuxArm" ]; then
cmake -DXASH_VGUI=no -DXASH_NANOGL=yes -DXASH_GLES=yes ..
elif [ "$machine" = "Linux32" ]; then
cmake -DHL_SDK_DIR=../hlsdk -DXASH_SDL=yes -DXASH_VGUI=yes ..
elif [ "$machine" = "Linux64" ]; then
cmake -DHL_SDK_DIR=../hlsdk -DXASH_SDL=yes -DXASH_VGUI=yes -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32" -DCMAKE_EXE_LINKER_FLAGS="-m32" ..
fi
make -j$(nproc)
cp engine/libxash.so $gamedir
cp game_launch/xash3d $gamedir
cp mainui/libxashmenu.so $gamedir
# no specific library endings:
arch=
ext=.so
else
#git clone --recursive https://github.com/thomaseichhorn/xash3d-fwgs.git $xash3ddir
git clone --recursive https://github.com/FWGS/xash3d-fwgs.git $xash3ddir
cd $xash3ddir
git remote add upstream https://github.com/FWGS/xash3d-fwgs.git
if [ "$machine" = "LinuxArm" ] || [ "$machine" = "Linux32" ]; then
./waf configure -T release
# --enable-gles1 --disable-gl --disable-vgui
elif [ "$machine" = "Linux64" ]; then
./waf configure -T release
fi
./waf build
./waf install --destdir=$gamedir
fi
fi
echo
read -p 'Build HL SDK? [y/N] ' buildhlsdk
if [ "$buildhlsdk" = "y" ] || [ "$buildhlsdk" = "Y" ]; then
# First (default) valve
cd $sourcedir
hlsdkdir=$sourcedir/hlsdk-xash3d
# If the source already exists, delete
if [ -d "$hlsdkdir" ]; then
rm -Rf $hlsdkdir
fi
git clone --recursive https://github.com/thomaseichhorn/hlsdk-xash3d.git $hlsdkdir
cd $hlsdkdir
git fetch origin
git remote add upstream https://github.com/FWGS/hlsdk-xash3d.git
git submodule init
git submodule update
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=cc -S ..
cmake --build .
cp cl_dll/client$arch$ext $addondir/valve/cl_dlls/client$arch$ext
cp dlls/hl$arch$ext $addondir/valve/dlls/hl$arch$ext
# DMC
cd $hlsdkdir
git checkout --track origin/dmc
git submodule init
git submodule update
cd build
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=cc -S ..
cmake --build .
cp cl_dll/client$arch$ext $addondir/dmc/cl_dlls/client$arch$ext
cp dlls/hl$arch$ext $addondir/dmc/dlls/dmc$arch$ext
# OpFor
cd $hlsdkdir
git checkout --track origin/opfor
git submodule init
git submodule update
cd build
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=cc -S ..
cmake --build .
cp cl_dll/client$arch$ext $addondir/gearbox/cl_dlls/client$arch$ext
cp dlls/opfor$arch$ext $addondir/gearbox/dlls/opfor$arch$ext
# Bshift
cd $hlsdkdir
git checkout --track origin/bshift
git submodule init
git submodule update
cd build
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=cc -S ..
cmake --build .
cp cl_dll/client$arch$ext $addondir/bshift/cl_dlls/client$arch$ext
cp dlls/bshift$arch$ext $addondir/bshift/dlls/bshift$arch$ext
git checkout master
# Hack for vgui.so
cd $hlsdkdir
cp vgui_support/vgui-dev/lib/vgui.so $gamedir/.
fi
echo
read -p 'Build CS Client? [y/N] ' buildcs
if [ "$buildcs" = "y" ] || [ "$buildcs" = "Y" ]; then
cd $sourcedir
csdir=$sourcedir/cs16-client
# If the source already exists, delete
if [ -d "$csdir" ]; then
rm -Rf $csdir
fi
git clone https://github.com/thomaseichhorn/cs16-client.git $csdir
cd $csdir/cl_dll
mkdir build
cd build
cmake ..
make -j$(nproc)
cp libclient.so $addondir/cstrike/cl_dlls/client$arch$ext
fi
echo
read -p 'Build Parabot? [y/N] ' buildbot
if [ "$buildbot" = "y" ] || [ "$buildbot" = "Y" ]; then
cd $sourcedir
botdir=$sourcedir/Parabot
# If the source already exists, delete
if [ -d "$botdir" ]; then
rm -Rf $botdir
fi
git clone https://github.com/thomaseichhorn/Parabot.git $botdir
cd $botdir/dlls
if [ "$(make -j$(nproc))" ]; then
# Replace liblist.gam entries
sed -i '13s/.*/gamedll_linux "addons\/parabot\/dlls\/parabot.so"/' $addondir/dmc/liblist.gam
sed -i '11s/.*/gamedll_linux "addons\/parabot\/dlls\/parabot.so"/' $addondir/gearbox/liblist.gam
sed -i '9s/.*/gamedll_linux "addons\/parabot\/dlls\/parabot.so"/' $addondir/valve/liblist.gam
cp parabot.so ../addons/parabot/dlls/parabot$arch$ext
cp -R ../addons/ $addondir/dmc/.
cp -R ../addons/ $addondir/gearbox/.
cp -R ../addons/ $addondir/valve/.
else
echo "Couldn't build Parabot!"
fi
fi
echo "#!/bin/bash" > $gamedir/run.sh
echo "cd $gamedir" >> $gamedir/run.sh
echo "export LIBGL_FB=1" >> $gamedir/run.sh
echo "export LIBGL_BATCH=1" >> $gamedir/run.sh
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$gamedir" >> $gamedir/run.sh
echo "./xash3d -console -debug" >> $gamedir/run.sh
echo "#!/bin/bash" > $gamedir/server.sh
echo "cd $gamedir" >> $gamedir/server.sh
echo "export LIBGL_FB=1" >> $gamedir/server.sh
echo "export LIBGL_BATCH=1" >> $gamedir/server.sh
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$gamedir" >> $gamedir/server.sh
echo "./xash3d -console -dev 5 -dedicated +exec server.cfg +maxplayers 32" >> $gamedir/server.sh
echo
echo "Finished build!"
echo
echo "Now copy your valve (optional: and bshift, cstrike, dmc, gearbox) folder to $gamedir."
echo "Then copy the contents of the folder $addondir to $gamedir, overwriting all files."
exit $?
fi
if [ "$machine" = "Win32" ]; then
# Default environment:
export PATH="$PATH:/C/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin"
# Find where we are
basedir="$PWD"
gamedir="$basedir/HL"
mkdir -p "$gamedir"
sourcedir="$basedir/sources"
mkdir -p "$sourcedir"
addondir="$basedir/buildfiles"
echo
echo "Installing to $gamedir"
echo "Sources will be downloaded to $sourcedir"
echo
read -p 'Build Xash3D? [y/N] ' buildxash
if [ "$buildxash" = "y" ] || [ "$buildxash" = "Y" ]; then
cd "$sourcedir"
xash3ddir="$sourcedir/xash3d"
# If the source already exists, delete
if [ -d "$xash3ddir" ]; then
rm -Rf "$xash3ddir"
fi
git clone --recursive https://github.com/thomaseichhorn/xash3d.git "$xash3ddir"
cd "$xash3ddir/engine"
git clone https://github.com/thomaseichhorn/nanogl.git
cd ..
git clone https://github.com/thomaseichhorn/halflife.git hlsdk/
mkdir -p build
cd build
cmake .. -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
mingw32-make -j$(nproc)
cp engine/xash_sdl.dll "$gamedir"
cp game_launch/xash.exe "$gamedir"
cp mainui/menu.dll "$gamedir"
cp SDL2/SDL2-2.0.7/i686-w64-mingw32/bin/SDL2.dll "$gamedir"
cp VGUI/vgui-dev-master/lib/win32_vc6/vgui.dll "$gamedir"
cp vgui_support_prebuilt/vgui_support_bin-master/vgui_support.dll "$gamedir"
fi
echo
read -p 'Build HL SDK? [y/N] ' buildhlsdk
if [ "$buildhlsdk" = "y" ] || [ "$buildhlsdk" = "Y" ]; then
# First (default) valve
cd "$sourcedir"
hlsdkdir="$sourcedir/hlsdk-xash3d"
# If the source already exists, delete
if [ -d "$hlsdkdir" ]; then
rm -Rf "$hlsdkdir"
fi
git clone --recursive https://github.com/thomaseichhorn/hlsdk-xash3d.git "$hlsdkdir"
cd "$hlsdkdir"
git fetch origin
git remote add upstream https://github.com/FWGS/hlsdk-xash3d.git
git submodule init
git submodule update
mkdir -p build
cd build
cmake .. -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
mingw32-make -j$(nproc)
cp cl_dll/client.dll "$gamedir"
cp dlls/hl.dll "$gamedir"
cp cl_dll/client.dll "$addondir/valve/cl_dlls/client.dll"
cp dlls/hl.dll "$addondir/valve/dlls/hl.dll"
# DMC
cd "$hlsdkdir"
git checkout --track origin/dmc
git submodule init
git submodule update
cd build
rm -rf *
cmake .. -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
mingw32-make -j$(nproc)
cp cl_dll/client.dll "$addondir/dmc/cl_dlls/client.dll"
cp dlls/hl.dll "$addondir/dmc/dlls/dmc.dll"
# OpFor
cd "$hlsdkdir"
git checkout --track origin/opfor
git submodule init
git submodule update
cd build
rm -rf *
cmake .. -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
mingw32-make -j$(nproc)
cp cl_dll/client.dll "$addondir/gearbox/cl_dlls/client.dll"
cp dlls/opfor.dll "$addondir/gearbox/dlls/opfor.dll"
# Bshift
cd "$hlsdkdir"
git checkout --track origin/bshift
git submodule init
git submodule update
cd build
rm -rf *
cmake .. -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
mingw32-make -j$(nproc)
cp cl_dll/client.dll "$addondir/bshift/cl_dlls/client.dll"
cp dlls/bshift.dll "$addondir/bshift/dlls/bshift.dll"
git checkout master
fi
echo
read -p 'Build CS Client? [y/N] ' buildcs
if [ "$buildcs" = "y" ] || [ "$buildcs" = "Y" ]; then
cd "$sourcedir"
csdir="$sourcedir/cs16-client"
# If the source already exists, delete
if [ -d "$csdir" ]; then
rm -Rf "$csdir"
fi
git clone https://github.com/thomaseichhorn/cs16-client.git "$csdir"
cd "$csdir/cl_dll"
mkdir build
cd build
cmake .. -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
mingw32-make -j$(nproc)
cp libclient.dll $addondir/cstrike/cl_dlls/client.dll
fi
echo
read -p 'Build Parabot? [y/N] ' buildbot
if [ "$buildbot" = "y" ] || [ "$buildbot" = "Y" ]; then
cd "$sourcedir"
botdir="$sourcedir/Parabot"
# If the source already exists, delete
if [ -d "$botdir" ]; then
rm -Rf "$botdir"
fi
git clone https://github.com/thomaseichhorn/Parabot.git "$botdir"
cd "$botdir/dlls"
mingw32-make -j$(nproc)
cp parabot.dll ../addons/parabot/dlls/.
cp -R ../addons/ $addondir/dmc/.
cp -R ../addons/ $addondir/gearbox/.
cp -R ../addons/ $addondir/valve/.
# Replace liblist.gam entries
sed -i '12s/.*/gamedll "addons\\parabot\\dlls\\parabot.dll"/' $addondir/dmc/liblist.gam
sed -i '10s/.*/gamedll "addons\\parabot\\dlls\\parabot.dll"/' $addondir/gearbox/liblist.gam
sed -i '8s/.*/gamedll "addons\\parabot\\dlls\\parabot.dll"/' $addondir/valve/liblist.gam
fi
echo "#!/bin/bash" > $gamedir/run.sh
echo "cd $gamedir" >> $gamedir/run.sh
echo "export LIBGL_FB=1" >> $gamedir/run.sh
echo "export LIBGL_BATCH=1" >> $gamedir/run.sh
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$gamedir" >> $gamedir/run.sh
echo "./xash.exe -console -debug" >> $gamedir/run.sh
echo "#!/bin/bash" > $gamedir/server.sh
echo "cd $gamedir" >> $gamedir/server.sh
echo "export LIBGL_FB=1" >> $gamedir/server.sh
echo "export LIBGL_BATCH=1" >> $gamedir/server.sh
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$gamedir" >> $gamedir/server.sh
echo "./xash.exe -console -dev 5 -dedicated +exec server.cfg +maxplayers 32" >> $gamedir/server.sh
echo
echo "Finished build!"
echo
echo "Now copy your valve (optional: and bshift, cstrike, dmc, gearbox) folder to $gamedir."
echo "Then copy the contents of the folder $addondir to $gamedir, overwriting all files."
exit $?
fi
# Windows with no compiler and/or tools
:SCRIPTWIN
ECHO Running %COMSPEC%! You need to install mingw64, cmake and git!
PAUSE