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