Imported Upstream version 2.9.0
[debian/cc1111] / 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 svn.
19 #       o svn co https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/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 CFLAGS = @CFLAGS@
45 CPPFLAGS = @CPPFLAGS@ -DNO_VARARGS
46
47 # support VPATH:
48 VPATH        = @srcdir@
49 srcdir       = @srcdir@
50 top_srcdir   = @top_srcdir@
51 top_builddir = @top_builddir@
52
53 # All original tests live in TESTS_DIR and below
54 TESTS_DIR = $(srcdir)/tests
55 TESTS_NAME = $(TESTS_DIR)
56 # All suite results go in RESULTS_DIR
57 RESULTS_DIR = results
58 # All data relating to supported ports live in their own directory
59 # under PORTS_DIR.
60 PORTS_DIR = $(srcdir)/ports
61
62 # Itermediate data directories
63 # Directory that generated cases and the related object code go.
64 CASES_DIR = gen
65
66 # Script that takes a source test suite and generates the iterations
67 GENERATE_CASES = $(srcdir)/generate-cases.py
68
69 # Magically generate the list of configured ports to test.
70 # Each directory under ports/ is used as a port name.  Each port is tested.
71 # Each port must have a spec.mk which describes how to build the object
72 # files and how to run the emulator.
73 ALL_PORTS = $(filter-out .svn xa51 z80 gbz80 pic16 pic14 mcs51-common,$(notdir $(wildcard $(PORTS_DIR)/*)))
74
75 # These  ports will be cleaned with 'make clean'
76 CLEAN_PORTS = $(filter-out .svn mcs51-common,$(notdir $(wildcard $(PORTS_DIR)/*)))
77
78 MAKE_LIBRARY =
79
80 all: test-ports
81
82 # Test all of the ports
83 test-ports:
84         for i in $(ALL_PORTS); do $(MAKE) make_library test-port PORT=$$i; done
85
86 # Helper rule for testing the z80 port only
87 test-z80:
88         $(MAKE) test-port PORT=z80
89
90 # Helper rule for testing the z80 port only
91 test-gbz80:
92         $(MAKE) test-port PORT=gbz80
93
94 # Helper rule for testing the mcs51 port only
95 test-mcs51: test-mcs51-small test-mcs51-medium test-mcs51-large test-mcs51-stack-auto test-mcs51-xstack-auto
96
97 test-mcs51-small:
98         $(MAKE) test-port PORT=mcs51-small
99
100 test-mcs51-medium:
101         $(MAKE) test-port PORT=mcs51-medium
102
103 test-mcs51-large:
104         $(MAKE) test-port PORT=mcs51-large
105
106 test-mcs51-stack-auto:
107         $(MAKE) test-port PORT=mcs51-stack-auto
108
109 test-mcs51-xstack-auto:
110         $(MAKE) make_library test-port PORT=mcs51-xstack-auto
111
112 # Helper rule for testing the ds390 port only
113 test-ds390:
114         $(MAKE) test-port PORT=ds390
115
116 # Helper rule for testing the z80 port only(use ucSim simulator)
117 test-ucz80:
118         $(MAKE) test-port PORT=ucz80
119
120 # Helper rule for testing the hc08 port only(use ucSim simulator)
121 test-hc08:
122         $(MAKE) test-port PORT=hc08
123
124 # Helper rule for testing the xa51 port only(use ucSim simulator)
125 test-xa51:
126         $(MAKE) test-port PORT=xa51
127
128 # Helper rule for testing the pic16 port only(use gpsim simulator)
129 test-pic16:
130         $(MAKE) test-port PORT=pic16
131
132 # Helper rule for testing the pic14 port only(use gpsim simulator)
133 test-pic14:
134         $(MAKE) test-port PORT=pic14
135
136 ### Helper rule for testing the host cc only
137 test-host:
138         $(MAKE) test-port PORT=host
139
140 test-host2:
141         $(MAKE) test-port PORT=host
142
143 # Begin per-port rules
144 # List of all of the known source test suites.
145 ALL_TESTS = $(shell find $(TESTS_DIR) -name "*.c" | sort)
146
147 # Intermediate directory
148 PORT_CASES_DIR = $(CASES_DIR)/$(PORT)
149 PORT_RESULTS_DIR = $(RESULTS_DIR)/$(PORT)
150 # Each test generates a result log file
151 PORT_RESULTS = $(ALL_TESTS:$(TESTS_DIR)/%.c=$(PORT_RESULTS_DIR)/%.out)
152
153 SDCC_EXTRA_DIR = $(top_builddir)/../sdcc-extra
154
155 # Defaults.  Override in spec.mk if required.
156 # Path to SDCC
157 ifdef SDCC_BIN_PATH
158   SDCC = $(SDCC_BIN_PATH)/sdcc
159 else
160   SDCC = $(top_builddir)/bin/sdcc
161   INC_DIR ?= $(top_srcdir)/device/include
162 endif
163 # Base flags.
164 SDCCFLAGS += --fverbose-asm -DNO_VARARGS
165 # Extension of object intermediate files
166 OBJEXT = .o
167 # Extension of files that can be run in the emulator
168 EXEEXT = .bin
169 # Currently unused.  Extension to append to intermediate directories.
170 DIREXT =
171
172 # Only include if we're in a per-port call.
173 ifdef PORT
174 include $(PORTS_DIR)/$(PORT)/spec.mk
175 endif
176
177 make_library: $(MAKE_LIBRARY)
178
179 SDCCFLAGS += -I$(srcdir)/fwk/include -I$(srcdir)/tests
180 ifdef INC_DIR
181   SDCCFLAGS += -I$(INC_DIR)
182 endif
183
184 # List of intermediate files to keep.  Pretty much keep everything as
185 # disk space is free.
186 .PRECIOUS: $(PORT_CASES_DIR)/% %$(OBJEXT) %$(EXEEXT)
187
188 # Rule to generate the iterations of a test suite off the soure suite.
189 $(PORT_CASES_DIR)/%/iterations.stamp: $(TESTS_DIR)/%.c $(GENERATE_CASES)
190         echo Processing $(notdir $<)
191         rm -rf $(dir $@)
192         mkdir -p $(dir $@)
193         python $(GENERATE_CASES) $< $(dir $@) > /dev/null
194         touch $@
195
196 # Rule linking the combined results log to all of the files in the
197 # iteration directory.
198 $(PORT_RESULTS_DIR)/%.out: $(PORT_CASES_DIR)/%/iterations.stamp
199         $(MAKE) iterations PORT=$(PORT) CASES=$(dir $<)
200
201 # Rule to summaries the results for one port after all of the tests
202 # have been run.
203 port-results: port-dirs $(PORT_RESULTS)
204         echo Summary for \'$(PORT)\': `cat $(PORT_RESULTS) | python $(srcdir)/collate-results.py`
205         echo
206
207 port-dirs:
208         mkdir -p $(PORT_CASES_DIR) $(PORT_RESULTS_DIR)
209         echo Running $(PORT) regression tests
210
211 test-port: port-results
212
213 # Begin rules that process each iteration generated from the source
214 # test
215
216 # List of all of the generated iteration source files.
217 SUB_CASES = $(sort $(wildcard $(CASES)*.c))
218 # List of all the sub result logs generated from the iterations.
219 SUB_RESULTS = $(SUB_CASES:%.c=%.out)
220 # Overall target.  Concatenation of all of the sub results.
221 RESULTS = $(CASES:$(CASES_DIR)/%/$(DIREXT)=$(RESULTS_DIR)/%.out)
222
223 iterations: $(RESULTS)
224
225 # Rule to generate the overall target from the sub results.
226 $(RESULTS): $(SUB_RESULTS)
227         cat $(SUB_RESULTS) > $@
228
229 # The remainder of the rules are in $PORT/spec.mk.  The port needs to
230 # be able to turn an iterated test suite into a sub result, normally
231 # by:
232 #    1. Compile the required library files
233 #    2. Compile this test suite.
234 #    3. Link 1, 2, and any required stdlib into an executable.
235 #    4. Run the executable inside an emulator, and capture the text
236 #    output into %.out.
237 #
238 # The emulator must exit when main() returns.
239
240 # BeginGeneric rules
241
242 clean:
243         rm -rf $(CASES_DIR) $(RESULTS_DIR) *.pyc
244         for i in $(CLEAN_PORTS); do $(MAKE) -f $(PORTS_DIR)/$$i/spec.mk _clean PORTS_DIR=$(PORTS_DIR) PORT=$$i; done
245
246 distclean: clean
247         rm -f Makefile