]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/Makefile.in
Document new hard requirement on GNU make
[thirdparty/binutils-gdb.git] / gdb / testsuite / Makefile.in
CommitLineData
c906108c 1# Makefile for regression testing the GNU debugger.
618f726f 2# Copyright 1992-2016 Free Software Foundation, Inc.
c906108c
SS
3
4# This file is part of GDB.
5
d53a7b30 6# This program is free software; you can redistribute it and/or modify
c906108c 7# it under the terms of the GNU General Public License as published by
d53a7b30
JB
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
c906108c
SS
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
d53a7b30 15#
c906108c 16# You should have received a copy of the GNU General Public License
d53a7b30 17# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c
SS
18
19VPATH = @srcdir@
20srcdir = @srcdir@
21prefix = @prefix@
22exec_prefix = @exec_prefix@
b8b4e42b 23abs_builddir = @abs_builddir@
437277d4 24abs_srcdir = @abs_srcdir@
c906108c 25
be2a5f71 26target_alias = @target_noncanonical@
c906108c
SS
27program_transform_name = @program_transform_name@
28build_canonical = @build@
29host_canonical = @host@
30target_canonical = @target@
c906108c
SS
31
32SHELL = @SHELL@
93076499 33EXEEXT = @EXEEXT@
c906108c
SS
34SUBDIRS = @subdirs@
35RPATH_ENVVAR = @RPATH_ENVVAR@
36
2a31c623
PA
37EXTRA_RULES = @EXTRA_RULES@
38
39CC=@CC@
40
41EXPECT = `if [ "$${READ1}" != "" ] ; then \
42 echo $${rootme}/expect-read1; \
43 elif [ -f $${rootme}/../../expect/expect ] ; then \
44 echo $${rootme}/../../expect/expect ; \
45 else \
46 echo expect ; \
47 fi`
c906108c
SS
48
49RUNTEST = $(RUNTEST_FOR_TARGET)
50
51RUNTESTFLAGS =
52
6bc80edc
TT
53FORCE_PARALLEL =
54
fb6a751f
SDJ
55# Default number of iterations that we will use to run the testsuite
56# if the user does not specify the RACY_ITER environment variable
57# (e.g., when the user calls the make rule directly from the command
58# line).
59DEFAULT_RACY_ITER = 3
60
c906108c
SS
61RUNTEST_FOR_TARGET = `\
62 if [ -f $${srcdir}/../../dejagnu/runtest ]; then \
63 echo $${srcdir}/../../dejagnu/runtest; \
64 else \
65 if [ "$(host_canonical)" = "$(target_canonical)" ]; then \
66 echo runtest; \
67 else \
dcfff61f 68 t='$(program_transform_name)'; echo runtest | sed -e $$t; \
c906108c
SS
69 fi; \
70 fi`
71
72#### host, target, and site specific Makefile frags come in here.
73
74# The use of $$(x_FOR_TARGET) reduces the command line length by not
75# duplicating the lengthy definition.
76
77TARGET_FLAGS_TO_PASS = \
78 "prefix=$(prefix)" \
79 "exec_prefix=$(exec_prefix)" \
80 "against=$(against)" \
81 'CC=$$(CC_FOR_TARGET)' \
82 "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
83 "CFLAGS=$(TESTSUITE_CFLAGS)" \
c906108c
SS
84 'CXX=$$(CXX_FOR_TARGET)' \
85 "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
86 "CXXFLAGS=$(CXXFLAGS)" \
87 "MAKEINFO=$(MAKEINFO)" \
88 "INSTALL=$(INSTALL)" \
89 "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
90 "INSTALL_DATA=$(INSTALL_DATA)" \
91 "LDFLAGS=$(LDFLAGS)" \
92 "LIBS=$(LIBS)" \
93 "RUNTEST=$(RUNTEST)" \
94 "RUNTESTFLAGS=$(RUNTESTFLAGS)"
95
2a31c623 96all: $(EXTRA_RULES)
c906108c
SS
97 @echo "Nothing to be done for all..."
98
99.NOEXPORT:
100INFODIRS=doc
101info:
102install-info:
103dvi:
9453113a
DJ
104pdf:
105install-pdf:
085dd6e6
JM
106html:
107install-html:
c906108c
SS
108
109install:
110
111uninstall: force
112
b8b4e42b
JK
113# Use absolute `site.exp' path everywhere to suppress VPATH lookups for it.
114# Bare `site.exp' is used as a target here if user requests it explicitly.
115# $(RUNTEST) is looking up `site.exp' only in the current directory.
116
117$(abs_builddir)/site.exp site.exp: ./config.status Makefile
c906108c
SS
118 @echo "Making a new config file..."
119 -@rm -f ./tmp?
120 @touch site.exp
121 -@mv site.exp site.bak
122 @echo "## these variables are automatically generated by make ##" > ./tmp0
123 @echo "# Do not edit here. If you wish to override these values" >> ./tmp0
124 @echo "# add them to the last section" >> ./tmp0
c906108c
SS
125 @echo "set host_triplet ${host_canonical}" >> ./tmp0
126 @echo "set target_alias $(target_alias)" >> ./tmp0
127 @echo "set target_triplet ${target_canonical}" >> ./tmp0
128 @echo "set build_triplet ${build_canonical}" >> ./tmp0
437277d4 129 @echo "set srcdir ${abs_srcdir}" >> ./tmp0
c906108c 130 @echo "set tool gdb" >> ./tmp0
f3525b70 131 @echo 'source $${srcdir}/lib/append_gdb_boards_dir.exp' >> ./tmp0
c906108c
SS
132 @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
133 @cat ./tmp0 > site.exp
134 @cat site.bak | sed \
135 -e '1,/^## All variables above are.*##/ d' >> site.exp
136 -@rm -f ./tmp?
137
138installcheck:
139
81208388
TT
140# See whether -j was given to make. Either it was given with no
141# arguments, and appears as "j" in the first word, or it was given an
142# argument and appears as "-j" in a separate word.
143@GMAKE_TRUE@saw_dash_j = $(or $(findstring j,$(firstword $(MAKEFLAGS))),$(filter -j,$(MAKEFLAGS)))
144
145# For GNU make, try to run the tests in parallel if any -j option is
146# given. If RUNTESTFLAGS is not empty, then by default the tests will
147# be serialized. This can be overridden by setting FORCE_PARALLEL to
148# any non-empty value. For a non-GNU make, do not parallelize.
fb6a751f
SDJ
149@GMAKE_TRUE@CHECK_TARGET_TMP = $(if $(FORCE_PARALLEL),check-parallel,$(if $(RUNTESTFLAGS),check-single,$(if $(saw_dash_j),check-parallel,check-single)))
150@GMAKE_TRUE@CHECK_TARGET = $(if $(RACY_ITER),$(addsuffix -racy,$(CHECK_TARGET_TMP)),$(CHECK_TARGET_TMP))
6bc80edc
TT
151@GMAKE_FALSE@CHECK_TARGET = check-single
152
81208388
TT
153# Note that we must resort to a recursive make invocation here,
154# because GNU make 3.82 has a bug preventing MAKEFLAGS from being used
155# in conditions.
156check: all $(abs_builddir)/site.exp
157 $(MAKE) $(CHECK_TARGET)
6bc80edc 158
2a31c623
PA
159check-read1:
160 $(MAKE) READ1="1" check
161
6bc80edc
TT
162# All the hair to invoke dejagnu. A given invocation can just append
163# $(RUNTESTFLAGS)
164DO_RUNTEST = \
c906108c
SS
165 rootme=`pwd`; export rootme; \
166 srcdir=${srcdir} ; export srcdir ; \
167 EXPECT=${EXPECT} ; export EXPECT ; \
93076499 168 EXEEXT=${EXEEXT} ; export EXEEXT ; \
c906108c
SS
169 $(RPATH_ENVVAR)=$$rootme/../../expect:$$rootme/../../libstdc++:$$rootme/../../tk/unix:$$rootme/../../tcl/unix:$$rootme/../../bfd:$$rootme/../../opcodes:$$$(RPATH_ENVVAR); \
170 export $(RPATH_ENVVAR); \
171 if [ -f $${rootme}/../../expect/expect ] ; then \
172 TCL_LIBRARY=$${srcdir}/../../tcl/library ; \
173 export TCL_LIBRARY ; fi ; \
41d1845e 174 $(RUNTEST) --status
6bc80edc 175
c17ef0d5
DE
176# TESTS exists for the user to pass on the command line to easily
177# say "Only run these tests." With check-single it's not necessary, but
178# with check-parallel there's no other way to (easily) specify a subset
179# of tests. For consistency we support it for check-single as well.
180# To specify all tests in a subdirectory, use TESTS=gdb.subdir/*.exp.
181# E.g., make check TESTS="gdb.server/*.exp gdb.threads/*.exp".
182@GMAKE_TRUE@TESTS :=
183@GMAKE_FALSE@TESTS =
184
185@GMAKE_TRUE@ifeq ($(strip $(TESTS)),)
186@GMAKE_TRUE@expanded_tests_or_none :=
187@GMAKE_TRUE@else
188@GMAKE_TRUE@expanded_tests := $(patsubst $(srcdir)/%,%,$(wildcard $(addprefix $(srcdir)/,$(TESTS))))
189@GMAKE_TRUE@expanded_tests_or_none := $(or $(expanded_tests),no-matching-tests-found)
190@GMAKE_TRUE@endif
191@GMAKE_FALSE@expanded_tests_or_none = $(TESTS)
192
4992aa20
JM
193# Shorthand for running all the tests in a single directory.
194@GMAKE_TRUE@check-gdb.%:
195@GMAKE_TRUE@ $(MAKE) check TESTS="gdb.$*/*.exp"
196
81208388 197check-single:
41d1845e 198 $(DO_RUNTEST) $(RUNTESTFLAGS) $(expanded_tests_or_none)
6bc80edc 199
fb6a751f
SDJ
200check-single-racy:
201 -rm -rf cache racy_outputs temp
202 mkdir -p racy_outputs; \
203 racyiter="$(RACY_ITER)"; \
204 test "x$$racyiter" == "x" && \
205 racyiter=$(DEFAULT_RACY_ITER); \
206 if test $$racyiter -lt 2 ; then \
207 echo "RACY_ITER must be at least 2."; \
208 exit 1; \
209 fi; \
210 trap "exit" INT; \
211 for n in `seq $$racyiter` ; do \
212 mkdir -p racy_outputs/$$n; \
213 $(DO_RUNTEST) --outdir=racy_outputs/$$n $(RUNTESTFLAGS) \
214 $(expanded_tests_or_none); \
215 done; \
216 $(srcdir)/analyze-racy-logs.py \
217 `ls racy_outputs/*/gdb.sum` > racy.sum; \
218 sed -n '/=== gdb Summary ===/,$$ p' racy.sum
219
6bc80edc 220check-parallel:
5dd3176f 221 -rm -rf cache outputs temp
81208388 222 $(MAKE) -k do-check-parallel; \
bef95aac 223 result=$$?; \
6bc80edc 224 $(SHELL) $(srcdir)/dg-extract-results.sh \
81208388 225 `find outputs -name gdb.sum -print` > gdb.sum; \
6bc80edc 226 $(SHELL) $(srcdir)/dg-extract-results.sh -L \
bef95aac
SM
227 `find outputs -name gdb.log -print` > gdb.log; \
228 sed -n '/=== gdb Summary ===/,$$ p' gdb.sum; \
229 exit $$result
81208388 230
fb6a751f
SDJ
231check-parallel-racy:
232 -rm -rf cache racy_outputs temp
233 racyiter="$(RACY_ITER)"; \
234 test "x$$racyiter" == "x" && \
235 racyiter=$(DEFAULT_RACY_ITER); \
236 if test $$racyiter -lt 2 ; then \
237 echo "RACY_ITER must be at least 2."; \
238 exit 1; \
239 fi; \
240 trap "exit" INT; \
241 for n in `seq $$racyiter` ; do \
242 $(MAKE) -k do-check-parallel-racy \
243 RACY_OUTPUT_N=$$n; \
244 $(SHELL) $(srcdir)/dg-extract-results.sh \
245 `find racy_outputs/$$n -name gdb.sum -print` > \
246 racy_outputs/$$n/gdb.sum; \
247 $(SHELL) $(srcdir)/dg-extract-results.sh -L \
248 `find racy_outputs/$$n -name gdb.log -print` > \
249 racy_outputs/$$n/gdb.log; \
250 sed -n '/=== gdb Summary ===/,$$ p' racy_outputs/$$n/gdb.sum; \
251 done; \
252 $(srcdir)/analyze-racy-logs.py \
253 `ls racy_outputs/*/gdb.sum` > racy.sum; \
254 sed -n '/=== gdb Summary ===/,$$ p' racy.sum
255
81208388
TT
256# Turn a list of .exp files into "check/" targets. Only examine .exp
257# files appearing in a gdb.* directory -- we don't want to pick up
258# lib/ by mistake. For example, gdb.linespec/linespec.exp becomes
259# check/gdb.linespec/linespec.exp. The list is generally sorted
260# alphabetically, but we take a few tests known to be slow and push
261# them to the front of the list to try to lessen the overall time
262# taken by the test suite -- if one of these tests happens to be run
263# late, it will cause the overall time to increase.
c17ef0d5 264@GMAKE_TRUE@ifeq ($(strip $(TESTS)),)
81208388
TT
265slow_tests = gdb.base/break-interp.exp gdb.base/interp.exp \
266 gdb.base/multi-forks.exp
267@GMAKE_TRUE@all_tests := $(shell cd $(srcdir) && find gdb.* -name '*.exp' -print)
268@GMAKE_TRUE@reordered_tests := $(slow_tests) $(filter-out $(slow_tests),$(all_tests))
fb6a751f 269@GMAKE_TRUE@TEST_TARGETS := $(addprefix $(if $(RACY_ITER),check-racy,check)/,$(reordered_tests))
c17ef0d5 270@GMAKE_TRUE@else
fb6a751f 271@GMAKE_TRUE@TEST_TARGETS := $(addprefix $(if $(RACY_ITER),check-racy,check)/,$(expanded_tests_or_none))
c17ef0d5 272@GMAKE_TRUE@endif
81208388
TT
273
274do-check-parallel: $(TEST_TARGETS)
275 @:
276
277@GMAKE_TRUE@check/%.exp:
278@GMAKE_TRUE@ -mkdir -p outputs/$*
41d1845e 279@GMAKE_TRUE@ @$(DO_RUNTEST) GDB_PARALLEL=yes --outdir=outputs/$* $*.exp $(RUNTESTFLAGS)
c906108c 280
fb6a751f
SDJ
281do-check-parallel-racy: $(TEST_TARGETS)
282 @:
283
284@GMAKE_TRUE@check-racy/%.exp:
285@GMAKE_TRUE@ -mkdir -p racy_outputs/$(RACY_OUTPUT_N)/$*
286@GMAKE_TRUE@ $(DO_RUNTEST) GDB_PARALLEL=yes \
287@GMAKE_TRUE@ --outdir=racy_outputs/$(RACY_OUTPUT_N)/$* $*.exp \
288@GMAKE_TRUE@ $(RUNTESTFLAGS)
289
c17ef0d5
DE
290check/no-matching-tests-found:
291 @echo ""
292 @echo "No matching tests found."
293 @echo ""
294
3d338901
DE
295# Utility rule invoked by step 2 of the build-perf rule.
296@GMAKE_TRUE@workers/%.worker:
297@GMAKE_TRUE@ mkdir -p gdb.perf/outputs/$*
41d1845e 298@GMAKE_TRUE@ $(DO_RUNTEST) --outdir=gdb.perf/outputs/$* lib/build-piece.exp WORKER=$* GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=build-pieces
3d338901
DE
299
300# Utility rule to build tests that support it in parallel.
301# The build is broken into 3 steps distinguished by GDB_PERFTEST_SUBMODE:
302# gen-workers, build-pieces, final.
303#
304# GDB_PERFTEST_MODE appears *after* RUNTESTFLAGS here because we don't want
305# anything in RUNTESTFLAGS to override it.
306#
307# We don't delete the outputs directory here as these programs can take
308# awhile to build, and perftest.exp has support for deciding whether to
309# recompile them. If you want to remove these directories, make clean.
310#
311# The point of step 1 is to construct the set of worker tasks for step 2.
312# All of the information needed by build-piece.exp is contained in the name
313# of the generated .worker file.
314@GMAKE_TRUE@build-perf: $(abs_builddir)/site.exp
315@GMAKE_TRUE@ rm -rf gdb.perf/workers
316@GMAKE_TRUE@ mkdir -p gdb.perf/workers
317@GMAKE_TRUE@ @: Step 1: Generate the build .worker files.
41d1845e 318@GMAKE_TRUE@ $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf/workers GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=gen-workers
3d338901
DE
319@GMAKE_TRUE@ @: Step 2: Compile the pieces. Here is the build parallelism.
320@GMAKE_TRUE@ $(MAKE) $$(cd gdb.perf && echo workers/*/*.worker)
321@GMAKE_TRUE@ @: Step 3: Do the final link.
41d1845e 322@GMAKE_TRUE@ $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=final
3d338901
DE
323
324# The default is to both compile and run the tests.
325GDB_PERFTEST_MODE = both
326
7636ccf9
YQ
327check-perf: all $(abs_builddir)/site.exp
328 @if test ! -d gdb.perf; then mkdir gdb.perf; fi
3d338901 329 $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PERFTEST_MODE=$(GDB_PERFTEST_MODE) $(RUNTESTFLAGS)
7636ccf9 330
c906108c
SS
331force:;
332
c906108c 333clean mostlyclean:
1d41d745 334 -rm -f *~ core *.o a.out xgdb *.x *.grt bigcore.corefile .gdb_history
576fd14c 335 -rm -f core.* *.tf *.cl tracecommandsscript copy1.txt zzz-gdbscript
957df313 336 -rm -f *.dwo *.dwp
81208388 337 -rm -rf outputs temp cache
3d338901 338 -rm -rf gdb.perf/workers gdb.perf/outputs gdb.perf/temp gdb.perf/cache
2a31c623 339 -rm -f read1.so expect-read1
c906108c
SS
340
341distclean maintainer-clean realclean: clean
342 -rm -f *~ core
343 -rm -f Makefile config.status *-init.exp
344 -rm -fr *.log summary detail *.plog *.sum *.psum site.*
c906108c 345
a4ce5b0d 346Makefile : Makefile.in config.status $(host_makefile_frag)
c906108c
SS
347 $(SHELL) config.status
348
349config.status: configure
350 $(SHELL) config.status --recheck
6bf58e63
TT
351
352TAGS: force
967d1f9b
TT
353 find $(srcdir) -name '*.exp' -print | \
354 etags --regex='/proc[ \t]+\([^ \t]+\)/\1/' -
2a31c623
PA
355
356# Build the expect wrapper script that preloads the read1.so library.
357expect-read1:
358 @echo Making expect-read1
359 @rm -f expect-read1-tmp
360 @touch expect-read1-tmp
361 @echo "# THIS FILE IS GENERATED -*- buffer-read-only: t -*- \n" >>expect-read1-tmp
362 @echo "# vi:set ro: */\n\n" >>expect-read1-tmp
363 @echo "# To regenerate this file, run:\n" >>expect-read1-tmp
364 @echo "# make clean; make/\n" >>expect-read1-tmp
365 @echo "export LD_PRELOAD=`pwd`/read1.so" >>expect-read1-tmp
366 @echo 'exec expect "$$@"' >>expect-read1-tmp
367 @chmod +x expect-read1-tmp
368 @mv expect-read1-tmp expect-read1
369
370# Build the read1.so preload library. This overrides the `read'
371# function, making it read one byte at a time. Running the testsuite
372# with this catches racy tests.
373read1.so: lib/read1.c
374 $(CC) -o $@ ${srcdir}/lib/read1.c -Wall -g -shared -fPIC $(CFLAGS)
375
376# Build the read1 machinery.
377.PHONY: read1
378read1: read1.so expect-read1