-
Notifications
You must be signed in to change notification settings - Fork 5
/
build
executable file
·49 lines (43 loc) · 1.08 KB
/
build
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
#!/bin/sh -e
# Originally written by akkartik. Modified by tekknolagi.
test "$CC" || export CC=cc
export CFLAGS="$CFLAGS -O0 -g -Wall -Wextra -pedantic -fno-strict-aliasing"
# return 1 if $1 is older than _any_ of the remaining args
older_than() {
local target=$1
shift
if [ ! -e $target ]
then
echo "updating $target" >&2
return 0 # success
fi
local f
for f in $*
do
if [ $f -nt $target ]
then
echo "updating $target" >&2
return 0 # success
fi
done
return 1 # failure
}
update_if_necessary() {
older_than ./bin/$1 $1.c greatest.h build && {
$CC $CFLAGS $1.c -o ./bin/$1
}
return 0 # success
}
update_if_necessary mmap-demo
update_if_necessary compiling-integers
update_if_necessary compiling-immediates
update_if_necessary compiling-unary
update_if_necessary compiling-binary
update_if_necessary compiling-reader
update_if_necessary compiling-let
update_if_necessary compiling-if
update_if_necessary compiling-heap
update_if_necessary compiling-procedures
update_if_necessary compiling-closures
update_if_necessary compiling-elf
exit 0