summaryrefslogtreecommitdiffhomepage
path: root/tests/scripts/minimake.sh
blob: c573663f54f4499c832f8fc725a787c9aba5e385 (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
# Integration: a tiny make: rebuild targets whose inputs are newer.
printf 'a\n' >a.src; printf 'b\n' >b.src
build() { # target: deps...
    target=$1; shift
    need=0
    [ -e "$target" ] || need=1
    for d in "$@"; do
        [ "$d" -nt "$target" ] && need=1
    done
    if [ $need = 1 ]; then
        echo "building $target"
        cat "$@" >"$target"
    else
        echo "$target is up to date"
    fi
}
all() {
    build a.o a.src
    build b.o b.src
    build prog a.o b.o
}
all
sleep 1.1
all
sleep 1.1
printf 'b2\n' >b.src
all
cat prog