summaryrefslogtreecommitdiff
path: root/src/regression/Makefile
blob: 26a7ff3557cd28021c47fda4a791e3360776acfb (plain) (blame)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Regression testing Makefile for Pic Port of SDCC
#
# note that this regression suite was started before
# the one in sdcc/regression. The regression suite in
# sdcc/regression is better suited for testing mature
# ports.
#
# GPL'd
#
# T. Scott Dattalo scott@dattalo.com
#
# This makefile provides a means by which the output
# of the SDCC Compiler can be tested. This version
# is unique to the PIC (as in Microchip PIC) port.
# As such it requires the following software:
#
#  gpasm version 0.11.1 (or greater)
#  gpsim version 0.20.7 (or greater)
#
# Usage:
#
# make
#  - without any options the whole regression test is
#    performed. The results are placed into a log file
#    (defined by $LOGFILE).
#
# make asm
#  - Creates .asm files by compiling the .c files
#
# make cod
#  - Creates .cod files by assembling the .asm files
#    (.cod files are symbolic files compatible with
#    MPASM, Microchip's assembler)
#
# make stc
#  - Creates .stc files which are script files for
#    gpsim.
#
# make clean
#  - removes all of the intermediate files created
#
# make cleancod
# make cleanasm
# make cleanstc
# make cleano
#  - removes either the .stc, .asm, .cod or .o files

# verboseness
#Q ?= # be verbose
Q ?= @ # be quiet

SDCC_SRC=../..
SDCC_BIN=../..

CC = $(SDCC_BIN)/bin/sdcc
LINKER = gplink
USE_PIC16 ?= 0
ifeq ($(strip $(filter 1 yes,$(USE_PIC16))),)
TARGETPIC = 16f877
#TARGETPIC = 16f84
CFLAGS = -mpic14 -p$(TARGETPIC)
DIR = pic14
else
TARGETPIC = 18f452
CFLAGS	= -mpic16 -p$(TARGETPIC)
DIR = pic16
endif
CFLAGS += -Wl,-q --no-warn-non-free
CFLAGS += -Wl,--map
CFLAGS += -I $(SDCC_SRC)/device/include/$(DIR) -I $(SDCC_SRC)/device/non-free/include/$(DIR)
CFLAGS += -L $(SDCC_BIN)/device/lib/build/$(DIR) -L $(SDCC_BIN)/device/non-free/lib/build/$(DIR)
#CFLAGS += --no-pcode-opt
#CFLAGS += -V

.SUFFIXES: .asm .c .cod .stc
.NOTPARALLEL:

# Results of the test are placed here:
LOGFILE = test.log

# Script file for creating gpsim scripts
CREATESTC = create_stc

# Script file for invoking gpsim
SIMULATE = simulate

# List the C files to be test here:
SRC = add.c \
      add2.c \
      add3.c \
      add4.c \
      and1.c \
      and2.c \
      arrays.c \
      b.c \
      bank1.c \
      bool1.c \
      bool2.c \
      bool3.c \
      call1.c \
      compare.c \
      compare10.c \
      compare2.c \
      compare3.c \
      compare4.c \
      compare5.c \
      compare6.c \
      compare7.c \
      compare8.c \
      compare9.c \
      configword.c \
      empty.c \
      for.c \
      init0.c \
      inline.c \
      mult1.c \
      nestfor.c \
      or1.c \
      pcodeopt.c \
      pointer1.c \
      ptrarg.c \
      ptrfunc.c \
      rotate1.c \
      rotate2.c \
      rotate3.c \
      rotate4.c \
      rotate5.c \
      rotate6.c \
      rotate7.c \
      string1.c \
      struct1.c \
      sub.c \
      sub2.c \
      switch1.c \
      while.c \
      xor.c

COD := $(patsubst %.c, %.cod, $(SRC))
ASM := $(patsubst %.c, %.asm, $(SRC))
O   := $(patsubst %.c, %.o,   $(SRC))
P   := $(patsubst %.c, %.p,   $(SRC))
STC := $(patsubst %.c, %.stc, $(SRC))
HEX := $(patsubst %.c, %.hex, $(SRC))
LST := $(patsubst %.c, %.lst, $(SRC))
MAP := $(patsubst %.c, %.map, $(SRC))

all:	test


# The cod files are generated by sdcc
.c.cod:
	$(Q)-$(CC) $(CFLAGS) $*.c

# The .stc files are script files for gpsim
.cod.stc:
	$(Q)-./$(CREATESTC) $*.cod $*.stc
	$(Q)-./$(SIMULATE) $*.stc $(LOGFILE)

# this will also make .stc files
#%.stc : %.cod
#	./create_stc $^ $@

# now for the dependencies

cod : $(COD)

o : $(O)

asm : $(ASM)

stc : $(STC)
	echo $(STC)

test:	$(STC)
	$(Q)echo "Done - Results are in $(LOGFILE)"

cleancod:
	files="$(COD)" ; \
	for f in $$files ; do \
	  if [ -f $$f ]; then rm $$f; fi \
	done ; \

cleano:
	files="$(O)" ; \
	for f in $$files ; do \
	  if [ -f $$f ]; then rm $$f; fi \
	done ; \

cleanp:
	files="$(P)" ; \
	for f in $$files ; do \
	  if [ -f $$f ]; then rm $$f; fi \
	done ; \

cleanasm:
	files="$(ASM)" ; \
	for f in $$files ; do \
	  if [ -f $$f ]; then rm $$f; fi \
	done ; \

cleanstc:
	files="$(STC)" ; \
	for f in $$files ; do \
	  if [ -f $$f ]; then rm $$f; fi \
	done ; \

cleanhex:
	files="$(HEX)" ; \
	for f in $$files ; do \
	  if [ -f $$f ]; then rm $$f; fi \
	done ; \

cleanlst:
	files="$(LST)" ; \
	for f in $$files ; do \
	  if [ -f $$f ]; then rm $$f; fi \
	done ; \

cleanmap:
	files="$(MAP)" ; \
	for f in $$files ; do \
	  if [ -f $$f ]; then rm $$f; fi \
	done ; \

clean: cleancod cleanasm cleanstc cleano cleanp cleanhex cleanlst cleanmap
	if [ -f "$(LOGFILE)" ]; then rm $(LOGFILE); fi