* device/lib/medium/Makefile: added for new memory model medium
[fw/sdcc] / support / regression / Makefile.in
1 # Test suite Makefile
2 # Part of SDCC - http://sdcc.sourceforge.net/
3 # Michael Hope <michaelh@juju.net.nz> 2001
4 #
5 # This Makefile builds and runs the test suites under tests/ for each
6 # one of the supported ports located under ports/.  The test suite
7 # results are summarised and individual test failures are logged.  The
8 # expected result is a single line per port summarising the number of
9 # failures, test points, and test cases.  The philosophy is that
10 # checked in code should always pass the suite with no failures, as
11 # then if there are failures then it is in the current developers code.
12 #
13 # Only the required suites are run.  Changing sdcc causes all to be
14 # re-run.  Changing one suite causes just that to be run.  Changing
15 # one of the library files should cause all to re-run
16
17 # Dependancies:
18 #   * The sdcc-extra package, available from CVS.
19 #       o cvs -d cvs.sdcc.sourceforge.net:/cvsroot/sdcc co sdcc-extra
20 #       o Provides the emulators
21 #   * The gbdk-lib package from gbdk.
22 #       o cvs -d cvs.gbdk.sourceforge.net:/cvsroot/gbdk co gbdk-lib
23 #       o Proviles mul, div, and include files for the z80 tests.
24 #   * python 1.5 or above
25 #   * uCsim for the mcs51 port
26 #
27 # The paths below assume that sdcc, sdcc-extra, and gbdk-lib all reside in
28 # the same directory.
29
30 # Old notes:
31 # Starting at the bottom
32 # Set of source test suites
33 # Each source suite is processesd producing multiple device specific test suites.
34 # Each device specific test suite is compiled.
35 # Each device specific test suite is run, and the output recorded.
36 # The output from each device specific test suite derrived from a source
37 # test suite are collated.
38
39 # Uncomment this to show only errors and the summary.
40 # Comment this out for debugging.
41 .SILENT:
42
43 CC = @CC@
44
45 # All original tests live in TESTS_DIR and below
46 TESTS_DIR = tests
47 TESTS_NAME = $(TESTS_DIR)
48 # All suite results go in RESULTS_DIR
49 RESULTS_DIR = results
50 # All data relating to supported ports live in their own directory
51 # under PORTS_DIR.
52 PORTS_DIR = ports
53
54 # Itermediate data directories
55 # Directory that generated cases and the related object code go.
56 CASES_DIR = gen
57
58 # Script that takes a source test suite and generates the iterations
59 GENERATE_CASES = generate-cases.py
60
61 # Magically generate the list of configured ports to test.
62 # Each directory under ports/ is used as a port name.  Each port is tested.
63 # Each port must have a spec.mk which describes how to build the object
64 # files and how to run the emulator.
65 ALL_PORTS = $(filter-out CVS xa51 ucz80 gbz80,$(notdir $(wildcard $(PORTS_DIR)/*)))
66
67 # These  ports will be cleaned with 'make clean'
68 CLEAN_PORTS = $(filter-out CVS,$(notdir $(wildcard $(PORTS_DIR)/*)))
69
70 MAKE_LIBRARY =
71
72 all: test-ports
73
74 # Test all of the ports
75 test-ports:
76         for i in $(ALL_PORTS); do $(MAKE) make_library test-port PORT=$$i; done
77
78 # Helper rule for testing the z80 port only
79 test-z80:
80         $(MAKE) test-port PORT=z80
81
82 # Helper rule for testing the z80 port only
83 test-gbz80:
84         $(MAKE) test-port PORT=gbz80
85
86 # Helper rule for testing the mcs51 port only
87 test-mcs51:
88         $(MAKE) test-port PORT=mcs51
89
90 test-mcs51-medium:
91         $(MAKE) test-port PORT=mcs51-medium
92
93 test-mcs51-large:
94         $(MAKE) test-port PORT=mcs51-large
95
96 test-mcs51-stack-auto:
97         $(MAKE) make_library test-port PORT=mcs51-stack-auto
98
99 test-mcs51-xstack-auto:
100         $(MAKE) make_library test-port PORT=mcs51-xstack-auto
101
102 # Helper rule for testing the ds390 port only
103 test-ds390:
104         $(MAKE) test-port PORT=ds390
105
106 # Helper rule for testing the z80 port only(use ucSim simulator)
107 test-ucz80:
108         $(MAKE) test-port PORT=ucz80
109
110 # Helper rule for testing the hc08 port only(use ucSim simulator)
111 test-hc08:
112         $(MAKE) test-port PORT=hc08
113
114 # Helper rule for testing the xa51 port only(use ucSim simulator)
115 test-xa51:
116         $(MAKE) test-port PORT=xa51
117
118 ### Helper rule for testing the host cc only
119 test-host:
120         $(MAKE) test-port PORT=host
121
122 test-host2:
123         $(MAKE) test-port PORT=host
124
125 # Begin per-port rules
126 # List of all of the known source test suites.
127 ALL_TESTS = $(shell find $(TESTS_DIR) -name "*.c")
128
129 # Intermediate directory
130 PORT_CASES_DIR = $(CASES_DIR)/$(PORT)
131 PORT_RESULTS_DIR = $(RESULTS_DIR)/$(PORT)
132 # Each test generates a result log file
133 PORT_RESULTS = $(ALL_TESTS:$(TESTS_DIR)/%.c=$(PORT_RESULTS_DIR)/%.out)
134
135 SDCC_DIR = ../..
136 SDCC_EXTRA_DIR = ../../../sdcc-extra
137 INC_DIR = $(SDCC_DIR)/device/include
138
139 # Defaults.  Override in spec.mk if required.
140 # Path to SDCC
141 SDCC = $(SDCC_DIR)/bin/sdcc
142 # Base flags.
143 SDCCFLAGS +=
144 # Extension of object intermediate files
145 OBJEXT = .o
146 # Extension of files that can be run in the emulator
147 EXEEXT = .bin
148 # Currently unused.  Extension to append to intermediate directories.
149 DIREXT =
150
151 # Only include if we're in a per-port call.
152 ifdef PORT
153 include $(PORTS_DIR)/$(PORT)/spec.mk
154 endif
155
156 make_library: $(MAKE_LIBRARY)
157
158 SDCCFLAGS += -Ifwk/include -Itests -I$(INC_DIR)
159
160 # List of intermediate files to keep.  Pretty much keep everything as
161 # disk space is free.
162 .PRECIOUS: $(PORT_CASES_DIR)/% %$(OBJEXT) %$(EXEEXT)
163
164 # Rule to generate the iterations of a test suite off the soure suite.
165 $(PORT_CASES_DIR)/%/iterations.stamp: $(TESTS_DIR)/%.c $(GENERATE_CASES)
166         echo Processing $<
167         rm -rf `dirname $@`
168         mkdir -p `dirname $@`
169         python $(GENERATE_CASES) $< `dirname $@` > /dev/null
170         touch $@
171
172 # Rule linking the combined results log to all of the files in the
173 # iteration directory.
174 $(PORT_RESULTS_DIR)/%.out: $(PORT_CASES_DIR)/%/iterations.stamp
175         $(MAKE) iterations PORT=$(PORT) CASES=`dirname $<`
176
177 # Rule to summaries the results for one port after all of the tests
178 # have been run.
179 port-results: port-dirs $(PORT_RESULTS)
180         echo Summary for \'$(PORT)\': `cat $(PORT_RESULTS) | python collate-results.py`
181
182 port-dirs:
183         mkdir -p $(PORT_CASES_DIR) $(PORT_RESULTS_DIR)
184
185 test-port: port-results
186
187 # Begin rules that process each iteration generated from the source
188 # test
189
190 # List of all of the generated iteration source files.
191 SUB_CASES = $(sort $(wildcard $(CASES)/*.c))
192 # List of all the sub result logs generated from the iterations.
193 SUB_RESULTS = $(SUB_CASES:%.c=%.out)
194 # Overall target.  Concatenation of all of the sub results.
195 RESULTS = $(CASES:$(CASES_DIR)/%$(DIREXT)=$(RESULTS_DIR)/%.out)
196
197 iterations: $(RESULTS)
198
199 # Rule to generate the overall target from the sub results.
200 $(RESULTS): $(SUB_RESULTS)
201         cat $(SUB_RESULTS) > $@
202
203 # The remainder of the rules are in $PORT/spec.mak.  The port needs to
204 # be able to turn an iterated test suite into a sub result, normally
205 # by:
206 #    1. Compile the required library files
207 #    2. Compile this test suite.
208 #    3. Link 1, 2, and any required stdlib into an executable.
209 #    4. Run the executable inside an emulator, and capture the text
210 #    output into %.out.
211 #
212 # The emulator must exit when main() returns.
213
214 # BeginGeneric rules
215
216 clean:
217         rm -rf $(CASES_DIR) $(RESULTS_DIR) *.pyc fwk/lib/timeout fwk/lib/timeout.exe
218         for i in $(CLEAN_PORTS); do $(MAKE) -f $(PORTS_DIR)/$$i/spec.mk _clean PORTS_DIR=$(PORTS_DIR) PORT=$$i; done