1## Makefile for the testsuite subdirectory of the D Standard library.
2## Copyright (C) 2016-2021 Free Software Foundation, Inc.
3##
4## GCC is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 3, or (at your option)
7## any later version.
8##
9## GCC is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with GCC; see the file COPYING3.  If not see
16## <http://www.gnu.org/licenses/>.
17
18# Process this file with automake to produce Makefile.in.
19
20AUTOMAKE_OPTIONS = foreign
21
22# Setup the testing framework, if you have one
23EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
24	   echo $(top_builddir)/../expect/expect; else echo expect; fi)
25
26_RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
27	     echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
28RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
29
30PWD_COMMAND = $${PWDCMD-pwd}
31
32check_p_subno=$(word 2,$(subst _, ,$*))
33check_p_numbers0:=1 2 3 4 5 6 7 8 9
34check_p_numbers1:=0 $(check_p_numbers0)
35check_p_numbers2:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers1)))
36check_p_numbers3:=$(addprefix 0,$(check_p_numbers1)) $(check_p_numbers2)
37check_p_numbers4:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers3)))
38check_p_numbers5:=$(addprefix 0,$(check_p_numbers3)) $(check_p_numbers4)
39check_p_numbers6:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers5)))
40check_p_numbers:=$(check_p_numbers0) $(check_p_numbers2) $(check_p_numbers4) $(check_p_numbers6)
41check_p_subdirs=$(wordlist 1,$(if $(GCC_TEST_PARALLEL_SLOTS),$(GCC_TEST_PARALLEL_SLOTS),10),$(check_p_numbers))
42check_DEJAGNU_libphobos_targets = $(addprefix check-DEJAGNUlibphobos,$(check_p_subdirs))
43$(check_DEJAGNU_libphobos_targets): check-DEJAGNUlibphobos%: libphobos%/site.exp
44
45site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
46	@echo 'Making a new site.exp file ...'
47	@echo '## these variables are automatically generated by make ##' >site.tmp
48	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
49	@echo '# edit the last section' >>site.tmp
50	@echo 'set srcdir "$(srcdir)"' >>site.tmp
51	@echo "set objdir `pwd`" >>site.tmp
52	@echo 'set build_alias "$(build_alias)"' >>site.tmp
53	@echo 'set build_triplet $(build_triplet)' >>site.tmp
54	@echo 'set host_alias "$(host_alias)"' >>site.tmp
55	@echo 'set host_triplet $(host_triplet)' >>site.tmp
56	@echo 'set target_alias "$(target_alias)"' >>site.tmp
57	@echo 'set target_triplet $(target_triplet)' >>site.tmp
58	@list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \
59	  echo "## Begin content included from file $$f.  Do not modify. ##" \
60	   && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \
61	   && echo "## End content included from file $$f. ##" \
62	   || exit 1; \
63	 done >> site.tmp
64	@echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp
65	@if test -f site.exp; then \
66	   sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \
67	fi
68	@-rm -f site.bak
69	@test ! -f site.exp || mv site.exp site.bak
70	@mv site.tmp site.exp
71
72%/site.exp: site.exp
73	-@test -d $* || mkdir $*
74	@srcdir=`cd $(srcdir); ${PWD_COMMAND}`;
75	@objdir=`${PWD_COMMAND}`/$*; \
76	sed -e "s|^set srcdir .*$$|set srcdir $$srcdir|" \
77	    -e "s|^set objdir .*$$|set objdir $$objdir|" \
78	    site.exp > $*/site.exp.tmp
79	@-rm -f $*/site.bak
80	@test ! -f $*/site.exp || mv $*/site.exp $*/site.bak
81	@mv $*/site.exp.tmp $*/site.exp
82
83# Run the testsuite in normal mode.
84check-DEJAGNU $(check_DEJAGNU_libphobos_targets): check-DEJAGNU%: site.exp
85	$(if $*,@)AR="$(AR)"; export AR; \
86	RANLIB="$(RANLIB)"; export RANLIB; \
87	if [ -z "$*" ] && [ -n "$(filter -j%, $(MFLAGS))" ]; then \
88	  rm -rf libphobos-parallel || true; \
89	  mkdir libphobos-parallel; \
90	  $(MAKE) $(AM_MAKEFLAGS) $(check_DEJAGNU_libphobos_targets); \
91	  rm -rf libphobos-parallel || true; \
92	  for idx in $(check_p_subdirs); do \
93	    if [ -d libphobos$$idx ]; then \
94	      mv -f libphobos$$idx/libphobos.sum libphobos$$idx/libphobos.sum.sep; \
95	      mv -f libphobos$$idx/libphobos.log libphobos$$idx/libphobos.log.sep; \
96	    fi; \
97	  done; \
98	  $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \
99	    libphobos[0-9]*/libphobos.sum.sep > libphobos.sum; \
100	  $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \
101	    libphobos[0-9]*/libphobos.log.sep > libphobos.log; \
102	  exit 0; \
103	fi; \
104	srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
105	EXPECT=$(EXPECT); export EXPECT; \
106	runtest=$(_RUNTEST); \
107	if [ -z "$$runtest" ]; then runtest=runtest; fi; \
108	tool=libphobos; \
109	if [ -n "$*" ]; then \
110	  if [ -f libphobos-parallel/finished ]; then rm -rf "$*"; exit 0; fi; \
111	  GCC_RUNTEST_PARALLELIZE_DIR=`${PWD_COMMAND}`/libphobos-parallel; \
112	  export GCC_RUNTEST_PARALLELIZE_DIR; \
113	  cd "$*"; \
114	fi; \
115	if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
116	  $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \
117		    $(RUNTESTFLAGS); \
118	  if [ -n "$*" ]; then \
119	    touch $$GCC_RUNTEST_PARALLELIZE_DIR/finished; \
120	  fi; \
121	else \
122	  echo "WARNING: could not find \`runtest'" 1>&2; :;\
123	fi
124
125check-am:
126	$(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
127
128.PHONY: check-DEJAGNU
129
130AM_MAKEFLAGS = "EXEEXT=$(EXEEXT)"
131
132CLEANFILES = *.exe *.log *.o *.sum site.exp
133
134# To remove runtest-parallel directories.
135clean-local:
136	rm -rf libphobos*
137