#!/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