-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.RUNME
executable file
·440 lines (384 loc) · 11.9 KB
/
.RUNME
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
#!/bin/bash
#
# Copyright (C) 2014 Neil McGill
#
# This game is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This game is distributed in the hope that it will be fun,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this game; if not, write to the Free
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
. ./scripts/common.sh
for i in \
/opt/local/bin/sdl2-config \
/usr/local/bin/sdl2-config \
/usr/bin/sdl2-config \
/mingw/bin/sdl2-config \
/mingw64/bin/sdl2-config
do
if [ -x $i ]
then
SDL2_CONFIG=$i
break
fi
done
#
# Prefer SDL over SDL2 as it seems more common
#
for i in \
/opt/local/bin/sdl-config \
/usr/local/bin/sdl-config \
/usr/bin/sdl-config \
/mingw/bin/sdl-config \
/mingw64/bin/sdl-config
do
if [ -x $i ]
then
SDL1_CONFIG=$i
break
fi
done
sdl_help()
{
log_warn "Is SDL 1.2 or 1.3 installed? If not:"
log_warn " For ubuntu SDL2 do: "
log_warn " sudo apt-get install libsdl2.0-dev"
log_warn " sudo apt-get install libsdl-mixer2.0-dev"
log_warn " sudo apt-get install libsdl-net2.0-dev"
log_warn " For ubuntu SDL1.2 do: "
log_warn " sudo apt-get install libsdl1.2-dev"
log_warn " sudo apt-get install libsdl-mixer1.2-dev"
log_warn " sudo apt-get install libsdl-net1.2-dev"
log_warn " For macos, install Mac ports and then do: "
log_warn " sudo port install libsdl2"
log_warn " sudo port install libsdl2_image"
log_warn " sudo port install libsdl2_mixer"
log_warn " sudo port install libsdl2_net"
log_warn " sudo port install libsdl2_ttf"
}
SDL1_SCORE=0
SDL2_SCORE=0
if [ "$SDL1_CONFIG" != "" ]; then
SDL1_INC_PATH=`$SDL1_CONFIG --cflags | sed 's/.*-I\([a-zA-Z\/_0-9:\.]*\) .*/\1/g'`
find $SDL1_INC_PATH | grep -q SDL_mixer.h
if [ $? -eq 0 ]; then
SDL1_SCORE=`expr $SDL1_SCORE + 1`
SDL1_MIXER=`find $SDL1_INC_PATH -name SDL_mixer.h`
fi
find $SDL1_INC_PATH | grep -q SDL_net.h
if [ $? -eq 0 ]; then
SDL1_SCORE=`expr $SDL1_SCORE + 1`
SDL1_NET=`find $SDL1_INC_PATH -name SDL_net.h`
fi
fi
if [ "$SDL2_CONFIG" != "" ]; then
SDL2_INC_PATH=`$SDL2_CONFIG --cflags | sed 's/.*-I\([a-zA-Z\/_0-9:\.]*\) .*/\1/g'`
find $SDL2_INC_PATH | grep -q SDL_mixer.h
if [ $? -eq 0 ]; then
SDL2_SCORE=`expr $SDL2_SCORE + 1`
SDL2_MIXER=`find $SDL2_INC_PATH -name SDL_mixer.h`
fi
find $SDL2_INC_PATH | grep -q SDL_net.h
if [ $? -eq 0 ]; then
SDL2_SCORE=`expr $SDL2_SCORE + 1`
SDL2_NET=`find $SDL2_INC_PATH -name SDL_net.h`
fi
fi
log_info "SDL1 config : $SDL1_CONFIG"
log_info "SDL1 version : "`$SDL1_CONFIG --version`
log_info "SDL1 include path: $SDL1_INC_PATH"
log_info "SDL1 mixer.h : $SDL1_MIXER"
log_info "SDL1 net.h : $SDL1_NET"
log_info "SDL1 score : $SDL1_SCORE"
if [[ "$SDL2_CONFIG" != "" ]]; then
log_info "SDL2 config : $SDL2_CONFIG"
log_info "SDL2 version : "`$SDL2_CONFIG --version`
log_info "SDL2 include path: $SDL2_INC_PATH"
log_info "SDL2 mixer.h : $SDL2_MIXER"
log_info "SDL2 net.h : $SDL2_NET"
log_info "SDL2 score : $SDL2_SCORE"
fi
USE_SDL1=0
USE_SDL2=0
if [[ $SDL1_SCORE = "0" ]]; then
if [[ $SDL2_SCORE = "0" ]]; then
sdl_help
log_err "I need SDL1 or SDL2 and SDL net and SDL mixer"
exit 1
else
SDL_CONFIG=$SDL2_CONFIG
USE_SDL2=1
fi
elif [[ $SDL2_SCORE = "0" ]]; then
if [[ $SDL1_SCORE = "0" ]]; then
sdl_help
log_err "I need SDL1 or SDL2 and SDL net and SDL mixer"
exit 1
else
SDL_CONFIG=$SDL1_CONFIG
USE_SDL1=1
fi
else
if [[ $SDL2_SCORE -ge $SDL1_SCORE ]]; then
log_info "Prefer SDL2 as it has more headers"
SDL_CONFIG=$SDL2_CONFIG
USE_SDL2=1
else
log_info "Prefer SDL1 as it has more headers"
SDL_CONFIG=$SDL1_CONFIG
USE_SDL1=1
fi
fi
/bin/rm -f data/gorynlich-hiscore.txt data/gorynlich-config.txt
#
# Make the ramdisk
#
RAMDISK_FILES=.ramdisk_files
log_info "Creating ramdisk filelist"
find data -type f | grep -v Resources | grep -v DS_Store | grep -v "\.ttf$" | grep -v "xcf" | grep -v "mp3" | grep -v "\.session" | grep -v "^\." > $RAMDISK_FILES
if [ ! -s $ramdisk_files ]
then
cd src
log_die "Failed to build list of ramdisk files"
fi
mkdir -p src/asm
scripts/RUNME.ramdisk.pl $RAMDISK_FILES
if [ $? -ne 0 ]
then
log_die "Failed to make ramdisk files"
fi
/bin/rm -f $RAMDISK_FILES
#
# Make the makefile
#
cd src
rm -f Makefile
cat Makefile.base | sed '/DO NOT DELETE/,$d' > Makefile.tmp
mv Makefile.tmp Makefile
if [ -x ../makedepend ]
then
../makedepend *.c -p .o/ 2>/dev/null
else
makedepend *.c -p .o/ 2>/dev/null
fi
if [ $? -ne 0 ]
then
log_warn "Is makedepend installed? If not:"
log_warn " For ubuntu do: sudo apt-get install xutils-dev"
log_warn " For MAC do: sudo port install makedepend"
log_warn " For MingW do: look in third-party for Win32 binary"
echo
log_warn "If you still can't find it, I have the source in third-party"
log_warn " cd third-party"
log_warn " tar xvf makedepend-1.0.5.tar.gz"
log_warn " cd makedepend-1.0.5"
log_warn " ./configure"
log_warn "Hit enter to continue"
read dummy
cd src
makedepend *.c -p .o/ 2>/dev/null
fi
cd ..
#
# Gives warings at runtime on MACOS
#
SDL_LIBS=`$SDL_CONFIG --static-libs`
if [ $? -ne 0 ]
then
log_err "Please install SDL 1.2 or 1.3. $SDL_CONFIG failed."
log_err "SDL-1.2.14.tar.gz is in support/"
exit 1
fi
C_FLAGS=`$SDL_CONFIG --cflags`
if [ $? -ne 0 ]
then
log_err "Please install SDL 1.2 or 1.3. $SDL_CONFIG failed."
log_err "SDL-1.2.14.tar.gz is in support/"
exit 1
fi
log_info "SDL version:" `$SDL_CONFIG --version`
log_info " ($SDL_CONFIG)"
#
# -funwind-tables and -rdynamic for backtrace info on linux.
# But it seemed to help little.
#
LDLIBS="$SDL_LIBS"
if [ "$USE_SDL2" = "1" ]
then
# LDLIBS="$LDLIBS -lSDL2_ttf"
LDLIBS="$LDLIBS -lSDL2_mixer"
LDLIBS="$LDLIBS -lSDL2_net"
else
# LDLIBS="$LDLIBS -lSDL_ttf"
LDLIBS="$LDLIBS -lSDL_mixer"
LDLIBS="$LDLIBS -lSDL_net"
fi
#
# for backtraces, but it doesn't help much
#
case `uname` in
*MSYS*)
PATH=/mingw64/bin:$PATH
export PATH
EXE=".exe"
C_FLAGS="$C_FLAGS -mwin32"
C_FLAGS="$C_FLAGS -I/mingw64/x86_64-w64-mingw32/include"
LDLIBS="$LDLIBS -L/mingw64/x86_64-w64-mingw32/lib/"
LDLIBS=`echo $LDLIBS | sed -e 's/-lmingw32 //g'`
LDLIBS="$LDLIBS -lopengl32"
;;
*MINGW*)
EXE=".exe"
LDLIBS=`echo $LDLIBS | sed -e 's/-XCClinker//g'`
LDLIBS="$LDLIBS -funwind-tables"
#LDLIBS="$LDLIBS -lglew32"
LDLIBS="$LDLIBS -lopengl32"
#
# For __imp warnings in pthread
#
#C_FLAGS="$C_FLAGS -DPTW32_STATIC_LIB -DGLEW_STATIC"
C_FLAGS="$C_FLAGS -DPTW32_STATIC_LIB "
#
# As sdl2-config may be configured for /usr/local
#
C_FLAGS="$C_FLAGS -I/c/MinGW/include/SDL2"
WERROR=""
COMPILER_WARN=""
;;
*Darwin*)
EXE=""
LDLIBS="$LDLIBS -funwind-tables"
LDLIBS="$LDLIBS -rdynamic"
DSYM="dsymutil ../gorynlich"
WERROR="-Werror"
COMPILER_WARN="-Wmissing-prototypes"
;;
*)
EXE=""
LDLIBS="$LDLIBS -funwind-tables"
LDLIBS="$LDLIBS -rdynamic"
LDLIBS="$LDLIBS -lGL"
#
# Better to leave off for production
#
WERROR="-Werror"
COMPILER_WARN="-Wmissing-prototypes"
;;
esac
#
# Better to leave off for production
#
WERROR=""
LDLIBS="$LDLIBS -lpthread"
cd src
echo "COMPILER_FLAGS=$WERROR -g -ggdb3 -O0 $C_FLAGS # AUTOGEN" >> .Makefile
echo "COMPILER_FLAGS=$WERROR -g -ggdb3 -O2 $C_FLAGS # AUTOGEN" > .Makefile
echo " " >> .Makefile
echo "CLANG_COMPILER_WARNINGS=-Wall -fmessage-length=0 -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs $COMPILER_WARN -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-sign-conversion # AUTOGEN" >> .Makefile
echo "GCC_COMPILER_WARNINGS=-Wall -fmessage-length=0 -Wno-trigraphs $COMPILER_WARN -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value # AUTOGEN" >> .Makefile
echo "GXX_COMPILER_WARNINGS=-Wall -fmessage-length=0 -Wno-trigraphs -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value # AUTOGEN" >> .Makefile
`clang --version >/dev/null 2>/dev/null`
if [ $? -eq 0 ]
then
echo "COMPILER_WARNINGS=\$(GCC_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GXX_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(CLANG_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "CC=clang # AUTOGEN" >> .Makefile
echo "# CC=gcc # AUTOGEN" >> .Makefile
echo "# CC=cc # AUTOGEN" >> .Makefile
echo "# CC=g++ # AUTOGEN" >> .Makefile
else
`gcc --version >/dev/null 2>/dev/null`
if [ $? -eq 0 ]
then
echo "COMPILER_WARNINGS=\$(CLANG_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GXX_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GCC_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "# CC=clang # AUTOGEN" >> .Makefile
echo "CC=gcc # AUTOGEN" >> .Makefile
echo "# CC=cc # AUTOGEN" >> .Makefile
echo "# CC=g++ # AUTOGEN" >> .Makefile
else
`g++ --version >/dev/null 2>/dev/null`
if [ $? -eq 0 ]
then
echo "COMPILER_WARNINGS=\$(CLANG_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GCC_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GXX_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "# CC=clang # AUTOGEN" >> .Makefile
echo "# CC=gcc # AUTOGEN" >> .Makefile
echo "# CC=cc # AUTOGEN" >> .Makefile
echo "CC=g++ # AUTOGEN" >> .Makefile
else
echo "COMPILER_WARNINGS=\$(CLANG_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GXX_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GCC_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "# CC=clang # AUTOGEN" >> .Makefile
echo "# CC=gcc # AUTOGEN" >> .Makefile
echo "# CC=cc # AUTOGEN" >> .Makefile
echo "CC=g++ # AUTOGEN" >> .Makefile
fi
fi
fi
case `uname` in
*MSYS*)
echo "CC=/mingw64/bin/x86_64-w64-mingw32-gcc.exe # AUTOGEN" >> .Makefile
LDLIBS="$LDLIBS -lmingw32 -lSDL2main -lSDL2 -mwindows /mingw64/lib/libSDL2main.a -L/mingw64/lib -lSDL2main -lSDL2"
;;
esac
echo " " >> .Makefile
echo "EXE=$EXE # AUTOGEN" >> .Makefile
echo "DSYM=$DSYM # AUTOGEN" >> .Makefile
echo "LDLIBS=$LDLIBS # AUTOGEN" >> .Makefile
echo "CFLAGS=\$(COMPILER_FLAGS) \$(COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
cat Makefile | grep -v AUTOGEN | grep -v "^ $" >> .Makefile
if [ -s .Makefile ]
then
mv .Makefile Makefile
if [ ! -f Makefile ]
then
log_err "No makefile?!"
exit 1
fi
else
log_err "Makefile create fail?!"
exit 1
fi
log_info "Cleaning"
make clobber | sed 's/^/ /g'
CORES=""
case `uname` in
*Darwin*)
CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep Cores | sed 's/.*: //g'`
;;
*inux*)
CORES=`cat /proc/cpuinfo | grep "cpu cores" | head -1 | awk '{print $4}'`
;;
esac
if [ "$CORES" != "" ]
then
CORES="-j $CORES"
fi
log_info "Compiling"
make $CORES $* all
if [ $? -eq 0 ]
then
echo
log_info "Run gorynlich to start"
rm -f Makefile.bak
else
cd ..
log_die "Build failed"
sdl_help
exit 1
fi
cd ..
exit 0