this repo has no description
1#!/bin/sh -e
2
3# Originally written by akkartik. Modified by tekknolagi.
4
5test "$CC" || export CC=cc
6export CFLAGS="$CFLAGS -O0 -g -Wall -Wextra -pedantic -fno-strict-aliasing"
7
8# return 1 if $1 is older than _any_ of the remaining args
9older_than() {
10 local target=$1
11 shift
12 if [ ! -e $target ]
13 then
14 echo "updating $target" >&2
15 return 0 # success
16 fi
17 local f
18 for f in $*
19 do
20 if [ $f -nt $target ]
21 then
22 echo "updating $target" >&2
23 return 0 # success
24 fi
25 done
26 return 1 # failure
27}
28
29update_if_necessary() {
30 older_than ./bin/$1 $1.c greatest.h build && {
31 $CC $CFLAGS $1.c -o ./bin/$1
32 }
33 return 0 # success
34}
35
36update_if_necessary mmap-demo
37update_if_necessary compiling-integers
38update_if_necessary compiling-immediates
39update_if_necessary compiling-unary
40update_if_necessary compiling-binary
41update_if_necessary compiling-reader
42update_if_necessary compiling-let
43update_if_necessary compiling-if
44update_if_necessary compiling-heap
45update_if_necessary compiling-procedures
46update_if_necessary compiling-closures
47update_if_necessary compiling-elf
48
49exit 0