blob: 9d8730bc3a0e20f9dc231cb8fdf9b839e4d40a2a (
plain)
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
|
#!/bin/bash
cc=tcc
cflags=(-Wall -Wextra -O2)
ldflags=(-lm)
platform=gl
debug=
run=
clean=
tags=
if [ -z "$RUN_CMD" ]; then
RUN_CMD=./
fi
for flag in $@; do
case "$flag" in
'-run') run=true ;;
'-debug') debug=true ;;
'-clean') clean=true ;;
'-use-x11') platform=x11 ;;
'-use-gl') platform=gl ;;
esac
done
if [ ! -z "$clean" ]; then
rm demonchime
rm libteensy.so
exit
fi
[ ! -z "$debug" ] && cflags+=(-g -ggdb -rdynamic)
teensy_cflags=(${cflags[@]} -Iteensy -Iplatform/$platform)
[ ! -z "$debug" ] && teensy_cflags+=(-DTEENSY_DEBUG)
teensy_ldflags=(${ldflags[@]})
case "$platform" in
'x11')
teensy_ldflags+=(-lX11)
;;
'gl')
teensy_ldflags+=(-lglfw)
;;
esac
dc_cflags=(${cflags[@]} -Iteensy -Idc)
[ ! -z "$debug" ] && teensy_cflags+=(-DDC_DEBUG)
dc_ldflags=(${ldflags[@]} -L. -lteensy)
dc_src=$(find dc -name '*.c')
teensy_src=$(find teensy -name '*.c')
platform_src=$(find platform/$platform -name '*.c')
echo -e "dc:\t\t$(tr '\n' ' ' <<< "$dc_src")"
echo -e "teensy:\t\t$(tr '\n' ' ' <<< "$teensy_src")"
echo -e "platform:\t$(tr '\n' ' ' <<< "$platform_src")"
echo -e "building libteensy\t: ${teensy_ldflags[@]} ${teensy_cflags[@]}"
$cc -shared -o libteensy.so \
${teensy_ldflags[@]} \
${teensy_cflags[@]} \
${teensy_src[@]} ${platform_src[@]} || exit 1
echo -e "building demonchime\t: ${dc_ldflags[@]} ${dc_cflags[@]}"
$cc -o demonchime \
${dc_ldflags[@]} \
${dc_cflags[@]} \
${dc_src[@]} || exit 1
[ $? -eq 0 ] && [ ! -z "$run" ] && LD_LIBRARY_PATH=. ${RUN_CMD}demonchime
|