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