アセンブラファイルとテストの整理
[YACASL2.git] / test / unit / Test.mk
1 LOGFILE = ../test.log
2 INCLUDE = ../../../include
3 CC = gcc
4 CFLAGS = -g -Wall -I $(INCLUDE)
5 COMMONSRC = ../../../src/struct.c ../../../src/cmd.c ../../../src/cerr.c
6 ASSRC = ../../../src/assemble.c ../../../src/token.c ../../../src/label.c ../../../src/macro.c
7 EXECSRC = ../../../exec.c ../../../dump.c
8 ifeq "$(UCLASS)" "AS"
9   SRC = $(COMMONSRC) $(ASSRC)
10 endif
11 ifeq "$(UCLASS)" "EXEC"
12   SRC = $(COMMONSRC) $(EXECSRC)
13 endif
14 ifeq "$(UCLASS)" "COMMON"
15   SRC = $(COMMONSRC)
16 endif
17 define report
18   @echo -n "$(UNITNAME): Test " >$@
19   @if test ! -s $^; then \
20     echo -n "Success " >>$@; \
21   else \
22     echo -n "Failure " >>$@; \
23   fi
24   @echo `date +"%F %T"` >>$@
25 endef
26
27 .PHPNY: all prepare clean
28 all: check
29 prepare: orgclean testclean 0.txt
30 check: testclean logadd
31 orgclean:
32         @rm -f 0.txt
33 testclean:
34         @rm -f 1.txt diff.txt report.txt
35 $(UNITNAME): $(COMMONSRC) $(ASSRC) $(UNITNAME).c
36         gcc $(CFLAGS) -o $(UNITNAME) $(SRC) $(UNITNAME).c
37 0.txt 1.txt: $(UNITNAME)
38         ./$(UNITNAME) >$@ 2>&1
39 diff.txt: 1.txt
40         @-diff 0.txt 1.txt >$@ 2>&1
41 report.txt: diff.txt
42         $(report)
43 logadd: report.txt
44         @cat $^ >>$(LOGFILE)