-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0build.sh
222 lines (197 loc) · 4.74 KB
/
0build.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
#!/bin/sh
# WARNING! SHITTY CODE!
defines="-DWIZARD -DLOCAL_SAVES"
cflags="-Wno-narrowing -Isrc/felib -m32"
lflags="-lm"
objects=""
have_package=""
BUILD_DIR="_build"
shitdoze="ona"
FORCE="ona"
linkflags=""
while [ $# -gt 0 ]; do
if [ "z$1" = "zshitdoze" ]; then
shitdoze="tan"
elif [ "z$1" = "zforce" ]; then
FORCE="tan"
else
echo "FATAL: unknown arg: $1"
exit 1
fi
shift
done
if [ $shitdoze = tan ]; then
ARCH="i686-w64-mingw32.static-"
BINSUFF=".exe"
defines="${defines} -DSHITDOZE"
BUILD_DIR="${BUILD_DIR}_shitdoze"
linkflags="-Wl,-subsystem,windows"
else
ARCH=""
BINSUFF=""
cflags="${cflags} -Wno-misleading-indentation"
fi
GCC="${ARCH}gcc"
GPP="${ARCH}g++"
PKGCONFIG="${ARCH}pkg-config"
find_package() {
if [ "z$2" != "z" ]; then
$PKGCONFIG --silence-errors $1 --atleast-version=$2
else
$PKGCONFIG --silence-errors $1
fi
if [ "$?" = "0" ]; then
cflags="${cflags} `$PKGCONFIG $1 --cflags`"
lflags="${lflags} `$PKGCONFIG $1 --libs`"
#echo "MSG: package '$1' found"
have_package="tan"
else
#echo "MSG: no package '$1'"
have_package="ona"
fi
}
# $1: srcdir
# $2: srcfile
# $3: use gcc if not empty
compile() {
local obj
local xname
local gppopt
local fstime
local fotime
#
obj=`basename $2 .cpp`
obj=`basename $obj .c`
obj="${obj}.o"
obj="${BUILD_DIR}/${obj}"
objects="${objects} ${obj}"
xname=`basename -s .c "$2"`
if [ "z$xname" = "z$2" ]; then
echo "C++ $2"
gppopt="-std=gnu++14"
else
echo "CC $2"
gppopt=""
fi
if [ $FORCE != tan ]; then
if [ -e ${obj} ]; then
fstime=`stat '--format=%Y' "$1/$2"`
fotime=`stat '--format=%Y' ${obj}`
if [ $fotime -ge $fstime ]; then
return
fi
fi
fi
$GCC -pipe -c -O2 -Wall -Isrc/game ${gppopt} ${defines} ${cflags} -o ${obj} "$1/$2"
if [ "$?" != "0" ]; then
echo "FATAL: compilation failed!"
exit 1
fi
}
link() {
echo "LINK ivan${BINSUFF}"
#echo "============="
#echo "${objects}"
#echo "============="
#echo "${lflags}"
#echo "============="
$GPP -pipe -s -o ivan${BINSUFF} ${objects} ${lflags} ${linkflags}
if [ "$?" != "0" ]; then
echo "FATAL: linking failed!"
exit 1
fi
${ARCH}strip -s ivan${BINSUFF}
}
find_package sdl 1.2
if [ "$have_package" != "tan" ]; then
echo "FATAL: you need SDL development package installed, version 1.2 or above!"
exit 1
fi
find_package SDL_mixer 1.2
if [ "$have_package" != "tan" ]; then
echo "MSG: no SDL_mixer package found, sound disabled"
defines="${defines} -DDISABLE_SOUND"
else
echo "MSG: sound support enabled"
fi
find_package libpng 1.6
if [ "$have_package" = "tan" ]; then
defines="${defines} -DHAVE_LIBPNG"
echo "MSG: libpng found"
else
find_package libpng16 1.6
if [ "$have_package" = "tan" ]; then
defines="${defines} -DHAVE_LIBPNG"
echo "MSG: libpng found"
else
#find_package imlib2 1.4
#if [ "$have_package" = "tan" ]; then
# defines="${defines} -DHAVE_IMLIB2"
# echo "MSG: imlib2 found"
#fi
echo "FATAL: libpng v1.6 not found!"
exit 1
fi
fi
find_package zlib 1.2
if [ "$have_package" = "tan" ]; then
defines="${defines} -DUSE_ZLIB"
echo "MSG: compressed saves enabled"
fi
find_package gl
if [ "$have_package" = "tan" ]; then
echo "MSG: OpenGL renderer enabled"
else
echo "MSG: OpenGL renderer disabled"
defines="${defines} -DDISABLE_OPENGL"
fi
find_package alsa
if [ "$have_package" = "tan" ]; then
echo "MSG: ALSA silencing enabled"
defines="${defines} -DENABLE_ALSA"
fi
#echo "CFLAGS: ${cflags}"
#echo "DEFINES: ${defines}"
mkdir ${BUILD_DIR} 2>/dev/null
compile src/felib bitmap.cpp
compile src/felib config.cpp
compile src/felib feerror.cpp
compile src/felib feio.cpp
compile src/felib felist.cpp
compile src/felib femain.cpp
compile src/felib femath.cpp
compile src/felib festring.cpp
compile src/felib fetime.cpp
compile src/felib graphics.cpp
compile src/felib hscore.cpp
compile src/felib rawbit.cpp
compile src/felib fesave.cpp
compile src/felib feparse.cpp
compile src/felib whandler.cpp
compile src/felib regex.c
compile src/game ivancommon.cpp
compile src/game actset.cpp
compile src/game areaset.cpp
compile src/game charset.cpp
compile src/game command.cpp
compile src/game coreset.cpp
compile src/game dataset.cpp
compile src/game dungeon.cpp
compile src/game game.cpp
compile src/game godset.cpp
compile src/game iconf.cpp
compile src/game id.cpp
compile src/game igraph.cpp
compile src/game itemset.cpp
compile src/game levelset.cpp
compile src/game main.cpp
compile src/game materset.cpp
compile src/game message.cpp
compile src/game object.cpp
compile src/game roomset.cpp
compile src/game script.cpp
compile src/game slotset.cpp
compile src/game trapset.cpp
compile src/game wmapset.cpp
compile src/game wskill.cpp
link