PIC Port Added support for subtraction
[fw/sdcc] / src / regression / Makefile
1 # Regression testing Makefile for Pic Port of SDCC
2 #
3 # GPL'd
4 #
5 # T. Scott Dattalo scott@dattalo.com
6 #
7 # This makefile provides a means by which the output
8 # of the SDCC Compiler can be tested. This version
9 # is unique to the PIC (as in Microchip PIC) port.
10 # As such it requires the following software:
11 #
12 #  gpasm version 0.8.10 (or greater)
13 #  gpsim version 0.20.7 (or greater)
14 #
15 # Usage:
16 #
17 # make
18 #  - without any options the whole regression test is
19 #    performed. The results are placed into a log file
20 #    (defined by $LOGFILE).
21 #
22 # make asm
23 #  - Creates .asm files by compiling the .c files
24 #
25 # make cod
26 #  - Creates .cod files by assembling the .asm files
27 #    (.cod files are symbolic files compatible with
28 #    MPASM, Microchip's assembler)
29 #
30 # make stc
31 #  - Creates .stc files which are script files for
32 #    gpsim.
33 #
34 # make clean
35 #  - removes all of the intermediate files created
36 #
37 # make cleancod
38 # make cleanasm
39 # make cleanstc
40 #  - removes either the .stc, .asm, or .cod files
41
42
43 CC = ../../bin/sdcc
44
45 .SUFFIXES: .asm .c .cod .stc
46
47 # Results of the test are placed here:
48 LOGFILE = test.log
49
50 # Script file for creating gpsim scripts
51 CREATESTC = create_stc
52
53 # Script file for invoking gpsim
54 SIMULATE = simulate
55
56 # List the C files to be test here:
57 SRC = b.c \
58         add.c \
59         bool1.c \
60         call1.c \
61         compare.c \
62         compare2.c \
63         for.c \
64         sub.c \
65         while.c
66
67 COD := $(patsubst %.c, %.cod, $(SRC))
68 ASM := $(patsubst %.c, %.asm, $(SRC))
69 STC := $(patsubst %.c, %.stc, $(SRC))
70
71 all:    test
72
73
74 # The asm files are generated by sdcc
75 .c.asm:
76         $(CC) -mpic14 -c $*.c
77
78 # The .cod files are generated by gpasm
79 # these get loaded by gpsim.
80 .asm.cod:
81         gpasm $*.asm
82
83 # The .stc files are script files for gpsim
84 .cod.stc:
85         ./$(CREATESTC) $*.cod $*.stc
86
87 # this will also make .stc files
88 #%.stc : %.cod
89 #       ./create_stc $^ $@
90
91 # now for the dependencies
92
93 cod : $(COD)
94
95
96 asm : $(ASM)
97
98 stc : $(STC)
99
100 test:   $(STC)
101         if [ -n "$(STC)" ]; then \
102         stcfiles="$(STC)" ; \
103         for f in $$stcfiles ; do \
104           ./$(SIMULATE) $$f $(LOGFILE); \
105         done ; \
106         fi
107         echo "Done - Results are in $(LOGFILE)"
108
109 cleancod:
110         files="$(COD)" ; \
111         for f in $$files ; do \
112           if [ -f $$f ]; then rm $$f; fi \
113         done ; \
114
115 cleanasm:
116         files="$(ASM)" ; \
117         for f in $$files ; do \
118           if [ -f $$f ]; then rm $$f; fi \
119         done ; \
120
121 cleanstc:
122         files="$(STC)" ; \
123         for f in $$files ; do \
124           if [ -f $$f ]; then rm $$f; fi \
125         done ; \
126
127 clean: cleancod cleanasm cleanstc
128         if [ -f "$(LOGFILE)" ]; then rm $(LOGFILE); fi