-
Notifications
You must be signed in to change notification settings - Fork 1
/
compile
executable file
·51 lines (40 loc) · 1.25 KB
/
compile
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
#!/bin/sh
set -e # halt on first error
link=all # link all binaries by default
linked=no # track whether we linked
DATA_GEN=-DDATA_GEN
case $1 in
-nolink) link=none ; shift ;; # don't link
-link) link="$2" ; shift ; shift ;; # link only one binary
-nodata_gen) DATA_GEN= ; shift ;;
esac
# these flags max out warnings and debug info
FLAGS="-g -Wall -Wextra -Werror -Wfatal-errors -pedantic"
case $# in
0) set *.c ;; # if no args are given, compile all .c files
esac
# compile each argument to a .o file
for cfile
do
gcc $DATA_GEN $FLAGS -c $cfile
done
case $link in
all|trst) gcc $FLAGS -o trst main.o input.o navigate.o polar.o helper.o
linked=yes ;;
esac
case $link in
all|waypoint_expansion) gcc $FLAGS -o wpexpand waypoint_expansion.o waypoint_expand_main.o
linked=yes ;;
esac
case $link in
all|gen_data) gcc $FLAGS -o gen_data env_data_gen.o
linked=yes ;;
esac
rm -rf *.o # make sure no object files are left hanging around
# error if asked to link something we didn't recognize
if [ $linked = no ]; then
case $link in # if the -link option makes no sense, complain
none) ;; # OK, do nothing
*) echo "`basename $0`: don't know how to link $link" 1>&2 ; exit 1 ;;
esac
fi