Don't include mcs51-stack-auto in target all
[fw/sdcc] / support / regression / Makefile
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 # All original tests live in TESTS_DIR and below
44 TESTS_DIR = tests
45 TESTS_NAME = $(TESTS_DIR)
46 # All suite results go in RESULTS_DIR
47 RESULTS_DIR = results
48 # All data relating to supported ports live in their own directory
49 # under PORTS_DIR.
50 PORTS_DIR = ports
51
52 # Itermediate data directories
53 # Directory that generated cases and the related object code go.
54 CASES_DIR = gen
55
56 # Script that takes a source test suite and generates the iterations
57 GENERATE_CASES = generate-cases.py
58
59 # Magically generate the list of configured ports to test.
60 # Each directory under ports/ is used as a port name.  Each port is tested.
61 # Each port must have a spec.mk which describes how to build the object
62 # files and how to run the emulator.
63 ALL_PORTS = $(filter-out CVS mcs51 mcs51-large mcs51-stack-auto ds390 gbz80,$(notdir $(wildcard $(PORTS_DIR)/*)))
64
65 # These  ports will be cleaned with 'make clean'
66 CLEAN_PORTS = $(filter-out CVS,$(notdir $(wildcard $(PORTS_DIR)/*)))
67
68 all: test-ports
69
70 # Test all of the ports
71 test-ports:
72         for i in $(ALL_PORTS); do $(MAKE) inter-port-clean test-port PORT=$$i; done
73
74 # Helper rule for testing the z80 port only
75 test-z80:
76         $(MAKE) inter-port-clean test-port PORT=z80
77
78 # Helper rule for testing the z80 port only
79 test-gbz80:
80         $(MAKE) inter-port-clean test-port PORT=gbz80
81
82 # Helper rule for testing the mcs51 port only
83 test-mcs51:
84         $(MAKE) inter-port-clean test-port PORT=mcs51
85 test-mcs51-large:
86         $(MAKE) inter-port-clean test-port PORT=mcs51-large
87 test-mcs51-stack-auto:
88         $(MAKE) inter-port-clean make-library test-port PORT=mcs51-stack-auto
89
90 # Helper rule for testing the ds390 port only
91 test-ds390:
92         $(MAKE) inter-port-clean test-port PORT=ds390
93
94 ### Helper rule for testing the host cc only
95 test-host:
96         $(MAKE) inter-port-clean test-port PORT=host
97
98 test-host2:
99         $(MAKE) test-port PORT=host
100
101 # Begin per-port rules
102 # List of all of the known source test suites.
103 ALL_TESTS = $(shell find $(TESTS_DIR) -name "*.c")
104
105 # Intermediate directory
106 PORT_CASES_DIR = $(CASES_DIR)/$(PORT)
107 PORT_RESULTS_DIR = $(RESULTS_DIR)/$(PORT)
108 # Each test generates a result log file
109 PORT_RESULTS = $(ALL_TESTS:$(TESTS_DIR)/%.c=$(PORT_RESULTS_DIR)/%.out)
110
111 SDCC_DIR = ../..
112 SDCC_EXTRA_DIR = ../../../sdcc-extra
113
114
115 # Defaults.  Override in spec.mk if required.
116 # Path to SDCC
117 SDCC = $(SDCC_DIR)/bin/sdcc
118 # Base flags.
119 SDCCFLAGS +=
120 # Extension of object intermediate files
121 OBJEXT = .o
122 # Extension of files that can be run in the emulator
123 EXEEXT = .bin
124 # Currently unused.  Extension to append to intermediate directories.
125 DIREXT =
126
127 # Only include if we're in a per-port call.
128 ifdef PORT
129 include $(PORTS_DIR)/$(PORT)/spec.mk
130 endif
131
132 SDCCFLAGS += -Ifwk/include -Itests
133
134 # List of intermediate files to keep.  Pretty much keep everything as
135 # disk space is free.
136 .PRECIOUS: $(PORT_CASES_DIR)/% %$(OBJEXT) %$(EXEEXT)
137
138 # Rule to generate the iterations of a test suite off the soure suite.
139 $(PORT_CASES_DIR)/%/iterations.stamp: $(TESTS_DIR)/%.c $(GENERATE_CASES)
140         echo Processing $<
141         rm -rf $(CASES_DIR)/$(TESTS_NAME)
142         mkdir -p $(CASES_DIR)/$(TESTS_NAME)
143         mkdir -p `dirname $@`
144         python $(GENERATE_CASES) $< > /dev/null
145         cp $(CASES_DIR)/$(TESTS_NAME)/*.c `dirname $@`
146         touch $@
147
148 # Rule linking the combined results log to all of the files in the
149 # iteration directory.
150 $(PORT_RESULTS_DIR)/%.out: $(PORT_CASES_DIR)/%/iterations.stamp
151         $(MAKE) iterations PORT=$(PORT) CASES=`dirname $<`
152
153 # Rule to summaries the results for one port after all of the tests
154 # have been run.
155 port-results: port-dirs $(PORT_RESULTS)
156         echo Summary for \'$(PORT)\': `cat $(PORT_RESULTS) | python collate-results.py`
157
158 port-dirs:
159         mkdir -p $(PORT_CASES_DIR) $(PORT_RESULTS_DIR)
160
161 test-port: port-results
162
163 # Begin rules that process each iteration generated from the source
164 # test
165
166 # List of all of the generated iteration source files.
167 SUB_CASES = $(sort $(wildcard $(CASES)/*.c))
168 # List of all the sub result logs generated from the iterations.
169 SUB_RESULTS = $(SUB_CASES:%.c=%.out)
170 # Overall target.  Concatenation of all of the sub results.
171 RESULTS = $(CASES:$(CASES_DIR)/%$(DIREXT)=$(RESULTS_DIR)/%.out)
172
173 iterations: $(RESULTS)
174
175 # Rule to generate the overall target from the sub results.
176 $(RESULTS): $(SUB_RESULTS)
177         cat $(SUB_RESULTS) > $@
178
179 # The remainder of the rules are in $PORT/spec.mak.  The port needs to
180 # be able to turn an iterated test suite into a sub result, normally
181 # by:
182 #    1. Compile the required library files
183 #    2. Compile this test suite.
184 #    3. Link 1, 2, and any required stdlib into an executable.
185 #    4. Run the executable inside an emulator, and capture the text
186 #    output into %.out.
187 #
188 # The emulator must exit when main() returns.
189
190 # BeginGeneric rules
191
192 clean: inter-port-clean
193         rm -rf $(CASES_DIR) $(RESULTS_DIR) *.pyc fwk/lib/timeout fwk/lib/timeout.exe
194         for i in $(CLEAN_PORTS); do $(MAKE) -f $(PORTS_DIR)/$$i/spec.mk _clean PORTS_DIR=$(PORTS_DIR) PORT=$$i; done
195
196 inter-port-clean:
197         rm -f  fwk/lib/*.o fwk/lib/*.asm fwk/lib/*.rst fwk/lib/*.lst fwk/lib/*.rel \
198                fwk/lib/*.ihx fwk/lib/*.map fwk/lib/*.sym