-
Notifications
You must be signed in to change notification settings - Fork 4
/
linux_build.sh
executable file
·66 lines (59 loc) · 1.51 KB
/
linux_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
#!/bin/sh
cc="clang++"
warn="-Werror -Wall -Wno-char-subscripts -Wno-unused-function -Wno-switch -Wno-sign-compare -Wno-unknown-pragmas"
if [ $cc = "g++" ] ; then
diag="-fno-diagnostics-show-caret"
warn="$warn -Wno-write-strings -Wno-class-memaccess"
else
diag="-fno-caret-diagnostics"
warn="$warn -Wno-writable-strings"
fi
serverdef="-Dm_server -Dm_app"
clientdef="-Dm_client -Dm_app"
opt_debug="-std=c++17 -Isrc/ -g -Dm_debug"
opt_release="-std=c++17 -O2 -DNDEBUG"
libs="-lm -lGL -lX11 -lenet"
compile_client=0
compile_server=0
debug=1
if [ $# -gt 0 ] ; then
case $1 in
"tags" )
ctags src/*.cpp src/*.h
;;
"client" )
compile_client=1
;;
"server" )
compile_server=1
;;
"clean" )
rm -f client server client.so server.so
;;
"release" )
compile_client=1
compile_server=1
debug=0
;;
esac
else
# compile both client and server by defaultif no other args given
compile_client=1
compile_server=1
fi
if [ $debug = 1 ] ; then
opt=$opt_debug
else
opt=$opt_release
fi
if [ $compile_client = 1 ] ; then
$cc -shared -fPIC $warn $diag $opt $clientdef src/client.cpp -o client.so $libs &
$cc -fPIC $warn $diag $opt $clientdef src/linux_platform_client.cpp src/client.cpp -o client $libs &
fi
if [ $compile_server = 1 ] ; then
$cc -shared -fPIC $warn $diag $opt $serverdef src/server.cpp -o server.so $libs &
$cc -fPIC $warn $diag $opt $serverdef src/linux_platform_server.cpp src/server.cpp -o server $libs &
fi
if [ $compile_server = 1 ] || [ $compile_client = 1 ] ; then
wait $(jobs -p)
fi