Imported Upstream version 2.9.0
[debian/cc1111] / src / regression / Makefile
1 # Regression testing Makefile for Pic Port of SDCC
2 #
3 # note that this regression suite was started before
4 # the one in sdcc/regression. The regression suite in
5 # sdcc/regression is better suited for testing mature
6 # ports.
7 #
8 # GPL'd
9 #
10 # T. Scott Dattalo scott@dattalo.com
11 #
12 # This makefile provides a means by which the output
13 # of the SDCC Compiler can be tested. This version
14 # is unique to the PIC (as in Microchip PIC) port.
15 # As such it requires the following software:
16 #
17 #  gpasm version 0.11.1 (or greater)
18 #  gpsim version 0.20.7 (or greater)
19 #
20 # Usage:
21 #
22 # make
23 #  - without any options the whole regression test is
24 #    performed. The results are placed into a log file
25 #    (defined by $LOGFILE).
26 #
27 # make asm
28 #  - Creates .asm files by compiling the .c files
29 #
30 # make cod
31 #  - Creates .cod files by assembling the .asm files
32 #    (.cod files are symbolic files compatible with
33 #    MPASM, Microchip's assembler)
34 #
35 # make stc
36 #  - Creates .stc files which are script files for
37 #    gpsim.
38 #
39 # make clean
40 #  - removes all of the intermediate files created
41 #
42 # make cleancod
43 # make cleanasm
44 # make cleanstc
45 # make cleano
46 #  - removes either the .stc, .asm, .cod or .o files
47
48 # verboseness
49 #Q ?= # be verbose
50 Q ?= @ # be quiet
51
52 SDCC_SRC=../..
53 SDCC_BIN=../..
54
55 CC = $(SDCC_BIN)/bin/sdcc
56 LINKER = gplink
57 USE_PIC16 ?= 0
58 ifeq ($(strip $(filter 1 yes,$(USE_PIC16))),)
59 TARGETPIC = 16f877
60 #TARGETPIC = 16f84
61 CFLAGS = -mpic14 -p$(TARGETPIC)
62 DIR = pic
63 else
64 TARGETPIC = 18f452
65 CFLAGS  = -mpic16 -p$(TARGETPIC)
66 DIR = pic16
67 endif
68 CFLAGS += -Wl,-q
69 CFLAGS += -Wl,--map
70 CFLAGS += -I $(SDCC_SRC)/device/include/$(DIR)
71 CFLAGS += -L $(SDCC_BIN)/device/lib/$(DIR)/bin
72 #CFLAGS += --no-pcode-opt
73 #CFLAGS += -V
74
75 .SUFFIXES: .asm .c .cod .stc
76 .NOTPARALLEL:
77
78 # Results of the test are placed here:
79 LOGFILE = test.log
80
81 # Script file for creating gpsim scripts
82 CREATESTC = create_stc
83
84 # Script file for invoking gpsim
85 SIMULATE = simulate
86
87 # List the C files to be test here:
88 SRC = add.c \
89       add2.c \
90       add3.c \
91       add4.c \
92       and1.c \
93       and2.c \
94       arrays.c \
95       b.c \
96       bank1.c \
97       bool1.c \
98       bool2.c \
99       bool3.c \
100       call1.c \
101       compare.c \
102       compare10.c \
103       compare2.c \
104       compare3.c \
105       compare4.c \
106       compare5.c \
107       compare6.c \
108       compare7.c \
109       compare8.c \
110       compare9.c \
111       configword.c \
112       empty.c \
113       for.c \
114       init0.c \
115       inline.c \
116       mult1.c \
117       nestfor.c \
118       or1.c \
119       pcodeopt.c \
120       pointer1.c \
121       ptrarg.c \
122       ptrfunc.c \
123       rotate1.c \
124       rotate2.c \
125       rotate3.c \
126       rotate4.c \
127       rotate5.c \
128       rotate6.c \
129       rotate7.c \
130       string1.c \
131       struct1.c \
132       sub.c \
133       sub2.c \
134       switch1.c \
135       while.c \
136       xor.c
137
138 COD := $(patsubst %.c, %.cod, $(SRC))
139 ASM := $(patsubst %.c, %.asm, $(SRC))
140 O   := $(patsubst %.c, %.o,   $(SRC))
141 P   := $(patsubst %.c, %.p,   $(SRC))
142 STC := $(patsubst %.c, %.stc, $(SRC))
143 HEX := $(patsubst %.c, %.hex, $(SRC))
144 LST := $(patsubst %.c, %.lst, $(SRC))
145 MAP := $(patsubst %.c, %.map, $(SRC))
146
147 all:    test
148
149
150 # The cod files are generated by sdcc
151 .c.cod:
152         $(Q)-$(CC) $(CFLAGS) $*.c
153
154 # The .stc files are script files for gpsim
155 .cod.stc:
156         $(Q)-./$(CREATESTC) $*.cod $*.stc
157         $(Q)-./$(SIMULATE) $*.stc $(LOGFILE)
158
159 # this will also make .stc files
160 #%.stc : %.cod
161 #       ./create_stc $^ $@
162
163 # now for the dependencies
164
165 cod : $(COD)
166
167 o : $(O)
168
169 asm : $(ASM)
170
171 stc : $(STC)
172         echo $(STC)
173
174 test:   $(STC)
175         $(Q)echo "Done - Results are in $(LOGFILE)"
176
177 cleancod:
178         files="$(COD)" ; \
179         for f in $$files ; do \
180           if [ -f $$f ]; then rm $$f; fi \
181         done ; \
182
183 cleano:
184         files="$(O)" ; \
185         for f in $$files ; do \
186           if [ -f $$f ]; then rm $$f; fi \
187         done ; \
188
189 cleanp:
190         files="$(P)" ; \
191         for f in $$files ; do \
192           if [ -f $$f ]; then rm $$f; fi \
193         done ; \
194
195 cleanasm:
196         files="$(ASM)" ; \
197         for f in $$files ; do \
198           if [ -f $$f ]; then rm $$f; fi \
199         done ; \
200
201 cleanstc:
202         files="$(STC)" ; \
203         for f in $$files ; do \
204           if [ -f $$f ]; then rm $$f; fi \
205         done ; \
206
207 cleanhex:
208         files="$(HEX)" ; \
209         for f in $$files ; do \
210           if [ -f $$f ]; then rm $$f; fi \
211         done ; \
212
213 cleanlst:
214         files="$(LST)" ; \
215         for f in $$files ; do \
216           if [ -f $$f ]; then rm $$f; fi \
217         done ; \
218
219 cleanmap:
220         files="$(MAP)" ; \
221         for f in $$files ; do \
222           if [ -f $$f ]; then rm $$f; fi \
223         done ; \
224
225 clean: cleancod cleanasm cleanstc cleano cleanp cleanhex cleanlst cleanmap
226         if [ -f "$(LOGFILE)" ]; then rm $(LOGFILE); fi