Restructure Makefile to add automated tests.
[jonesforth.git] / Makefile
1 # $Id: Makefile,v 1.6 2007-10-07 11:07:15 rich Exp $
2
3 SHELL   := /bin/bash
4
5 all:    jonesforth
6
7 jonesforth: jonesforth.S
8         gcc -m32 -nostdlib -static -Wl,-Ttext,0 -Wl,--build-id=none -o $@ $<
9
10 run:
11         cat jonesforth.f $(PROG) - | ./jonesforth
12
13 clean:
14         rm -f jonesforth *~ core .test_*
15
16 TESTS   := $(patsubst %.f,%.test,$(wildcard test_*.f))
17
18 test check: $(TESTS)
19
20 test_%.test: test_%.f jonesforth
21         @echo -n "$< ... "
22         @rm -f .$@
23         @cat <(echo ': TEST-MODE ;') jonesforth.f $< <(echo 'TEST') | \
24           ./jonesforth 2>&1 | \
25           sed 's/DSP=[0-9]*//g' > .$@
26         @diff -u .$@ $<.out
27         @rm -f .$@
28         @echo "ok"
29
30 .SUFFIXES: .f .test
31 .PHONY: test check
32
33 remote:
34         scp jonesforth.S jonesforth.f rjones@oirase:Desktop/
35         ssh rjones@oirase sh -c '"rm -f Desktop/jonesforth; \
36           gcc -m32 -nostdlib -static -Wl,-Ttext,0 -o Desktop/jonesforth Desktop/jonesforth.S; \
37           cat Desktop/jonesforth.f - | Desktop/jonesforth arg1 arg2 arg3"'