-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
build.sh
executable file
·269 lines (207 loc) · 6.25 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
#!/bin/bash
#!/bin/sh
set -e
# Check for wmake
if [[ $(which wmake) ]]; then
echo "wmake found"
else
echo "wmake not found, is it installed and did you source fdenv.sh?"
exit 1
fi
# Check for nasm
if [[ $(which nasm) ]] ; then
echo "nasm found"
else
echo "nasm not found, is it installed?"
exit 1
fi
USE_GNU_MAKE=0
# Check for gnu make
if [[ $(which make) ]]; then
# Check that it's actually gnu
if [[ $(make --version | grep "GNU Make") ]]; then
USE_GNU_MAKE=1
echo "GNU make found"
else
echo "Not GNU Make? What platform are you on?"
fi
else
echo "GNU make not found, builds will be much slower"
fi
if [ $# -lt 1 ]; then
echo "Usage: $0 target.exe [buildopts]"
echo "Check the README for possible targets."
exit 1
fi
target=$1
shift 1
if [ "$target" = "fdoom.exe" ]; then
buildopts="-dMODE_Y"
elif [ "$target" = "fdoomh.exe" ]; then
buildopts="-dMODE_Y_HALF -dSCREENWIDTH=320 -dSCREENHEIGHT=100"
elif [ "$target" = "fdoomx.exe" ]; then
buildopts="-dMODE_X -dSCREENWIDTH=320 -dSCREENHEIGHT=240"
elif [ "$target" = "fdoomcga.exe" ]; then
buildopts="-dMODE_CGA"
elif [ "$target" = "fdoomega.exe" ]; then
buildopts="-dMODE_EGA"
elif [ "$target" = "fdoombwc.exe" ]; then
buildopts="-dMODE_CGA_BW"
elif [ "$target" = "fdoomhgc.exe" ]; then
buildopts="-dMODE_HERC"
elif [ "$target" = "fdoominc.exe" ]; then
buildopts="-dMODE_INCOLOR"
elif [ "$target" = "fdoomt1.exe" ]; then
buildopts="-dMODE_T4025"
elif [ "$target" = "fdoomt12.exe" ]; then
buildopts="-dMODE_T4050"
elif [ "$target" = "fdoomt25.exe" ]; then
buildopts="-dMODE_T8025"
elif [ "$target" = "fdoomt43.exe" ]; then
buildopts="-dMODE_T8043"
elif [ "$target" = "fdoomt50.exe" ]; then
buildopts="-dMODE_T8050"
elif [ "$target" = "fdoomvbr.exe" ]; then
buildopts="-dMODE_VBE2"
elif [ "$target" = "fdoomvbd.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT"
elif [ "$target" = "fdm240r.exe" ]; then
buildopts="-dMODE_VBE2 -dSCREENWIDTH=320 -dSCREENHEIGHT=240"
elif [ "$target" = "fdm300r.exe" ]; then
buildopts="-dMODE_VBE2 -dSCREENWIDTH=400 -dSCREENHEIGHT=300"
elif [ "$target" = "fdm384r.exe" ]; then
buildopts="-dMODE_VBE2 -dSCREENWIDTH=512 -dSCREENHEIGHT=384"
elif [ "$target" = "fdm400r.exe" ]; then
buildopts="-dMODE_VBE2 -dSCREENWIDTH=640 -dSCREENHEIGHT=400"
elif [ "$target" = "fdm480r.exe" ]; then
buildopts="-dMODE_VBE2 -dSCREENWIDTH=640 -dSCREENHEIGHT=480"
elif [ "$target" = "fdm600r.exe" ]; then
buildopts="-dMODE_VBE2 -dSCREENWIDTH=800 -dSCREENHEIGHT=600"
elif [ "$target" = "fdm768r.exe" ]; then
buildopts="-dMODE_VBE2 -dSCREENWIDTH=1024 -dSCREENHEIGHT=768"
elif [ "$target" = "fdm800r.exe" ]; then
buildopts="-dMODE_VBE2 -dSCREENWIDTH=1280 -dSCREENHEIGHT=800"
elif [ "$target" = "fdm1024r.exe" ]; then
buildopts="-dMODE_VBE2 -dSCREENWIDTH=1280 -dSCREENHEIGHT=1024"
elif [ "$target" = "fdoomvbd.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT"
elif [ "$target" = "fdm240d.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT -dSCREENWIDTH=320 -dSCREENHEIGHT=240"
elif [ "$target" = "fdm300d.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT -dSCREENWIDTH=400 -dSCREENHEIGHT=300"
elif [ "$target" = "fdm384d.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT -dSCREENWIDTH=512 -dSCREENHEIGHT=384"
elif [ "$target" = "fdm400d.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT -dSCREENWIDTH=640 -dSCREENHEIGHT=400"
elif [ "$target" = "fdm480d.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT -dSCREENWIDTH=640 -dSCREENHEIGHT=480"
elif [ "$target" = "fdm600d.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT -dSCREENWIDTH=800 -dSCREENHEIGHT=600"
elif [ "$target" = "fdm768d.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT -dSCREENWIDTH=1024 -dSCREENHEIGHT=768"
elif [ "$target" = "fdm800d.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT -dSCREENWIDTH=1280 -dSCREENHEIGHT=800"
elif [ "$target" = "fdm1024d.exe" ]; then
buildopts="-dMODE_VBE2_DIRECT -dSCREENWIDTH=1280 -dSCREENHEIGHT=1024"
elif [ "$target" = "fdoompcp.exe" ]; then
buildopts="-dMODE_PCP"
elif [ "$target" = "fdoom400.exe" ]; then
buildopts="-dMODE_SIGMA"
elif [ "$target" = "fdoomcvb.exe" ]; then
buildopts="-dMODE_CVB"
elif [ "$target" = "fdoomc16.exe" ]; then
buildopts="-dMODE_CGA16"
elif [ "$target" = "fdoom512.exe" ]; then
buildopts="-dMODE_CGA512"
elif [ "$target" = "fdoomcah.exe" ]; then
buildopts="-dMODE_CGA_AFH"
elif [ "$target" = "fdoom13h.exe" ]; then
buildopts="-dMODE_13H"
elif [ "$target" = "fdoommda.exe" ]; then
buildopts="-dMODE_MDA"
elif [ "$target" = "clean" ]; then
cd FASTDOOM
wmake clean
cd ..
exit 0
else
echo "Unknown target executable '$target' specified."
exit 1
fi
doclean=false
for param in "$@"; do
if [ "$param" = "-clean" ]; then
doclean=true
break
fi
done
if [ "$doclean" = "true" ]; then
cd FASTDOOM
wmake clean
cd ..
fi
dodebug=false
for param in "$@"; do
if [ "$param" = "-debug" ]; then
dodebug=true
break
fi
done
if [ "$dodebug" = "true" ]; then
echo "Enabling debug symbols, traceable stack frames, and debug logging/checks"
wccbuildopts="$buildopts -d2 -of+ -dDEBUG_ENABLED=1"
nasmbuildopts="-g -dDEBUG_ENABLED=1"
fi
make_gnu() {
make -j $(nproc) -f Makefile.gnu fdoom.exe EXTERNOPT="$buildopts $@" NASMOPT="$nasmbuildopts" WCCOPTS="$wccbuildopts"
}
make_watcom() {
wmake fdoom.exe EXTERNOPT="$buildopts $@" NASMOPT="$nasmbuildopts" WCCOPTS="$wccbuildopts"
}
cd FASTDOOM
set +e
if [ "$USE_GNU_MAKE" -eq 1 ]; then
make_gnu
if [ $? -ne 0 ]; then
echo "GNU make build failed, trying Watcom for more readable output..."
sleep 1
make_watcom
if [ $? -ne 0 ]; then
echo "Build failed."
exit 1
else
echo "wmake build succeeded but GNU make didnt. Check GNU output?"
fi
fi
else
make_watcom
if [ $? -ne 0 ]; then
echo "Build failed"
exit 1
fi
fi
yes | cp -rf fdoom.exe "../${target^^}"
# Copy corresponding .map file if it exists and debug enabled
if [ "$dodebug" = "true" ]; then
echo "Copying map file"
mapfile="fdoom.map"
echo $mapfile
targetmap="${target%.*}.map"
echo $targetmap
if [ -f "$mapfile" ]; then
yes | cp -rf "$mapfile" "../${targetmap^^}"
fi
fi
cd ..
dostub=false
for param in "$@"; do
if [ "$param" = "-stub" ]; then
dostub=true
break
fi
done
if [ "$dostub" = "true" ]; then
./stub.sh $target
fi
echo "RIP AND TEAR"
exit 0