Debian Codegraph @

tests/local.mk

raw
1 ## Make Autoconf tests.
2
3 # Copyright (C) 2000-2017, 2020-2026 Free Software Foundation, Inc.
4
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17
18 # We don't actually distribute the built testsuite or package.m4, since one
19 # only needs m4 to build them, and m4 is required to install Autoconf.
20 # But if you are borrowing from this file for setting up autotest in your
21 # project, remember to distribute both testsuite and package.m4.
22 EXTRA_DIST += \
23 tests/local.at \
24 tests/mktests.pl \
25 tests/atlocal.in \
26 tests/wrapper.as \
27 tests/statesave.m4
28
29 # Running the uninstalled scripts. Build them upon 'all', for the manpages.
30 noinst_SCRIPTS = $(wrappers)
31 DISTCLEANFILES += tests/atconfig tests/atlocal $(TESTSUITE)
32
33 # The ':;' works around a redirected compound command bash exit status bug.
34 tests/package.m4: Makefile
35 :;{ \
36 echo '# Signature of the current package.' && \
37 echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])' && \
38 echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])' && \
39 echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])' && \
40 echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])' && \
41 echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])' && \
42 echo 'm4_define([AT_PACKAGE_URL], [$(PACKAGE_URL)])'; \
43 } > $@-t
44 mv $@-t $@
45
46
47
48 ## ---------- ##
49 ## Wrappers. ##
50 ## ---------- ##
51
52 wrappers = \
53 tests/autoconf \
54 tests/autoheader \
55 tests/autom4te \
56 tests/autoreconf \
57 tests/autoscan \
58 tests/autoupdate \
59 tests/ifnames
60
61 CLEANFILES += \
62 tests/package.m4 \
63 tests/wrapper.in \
64 $(wrappers)
65
66 tests/wrapper.in: $(srcdir)/tests/wrapper.as lib/m4sugar/m4sh.m4f
67 $(MY_AUTOM4TE) --language=M4sh $(srcdir)/tests/wrapper.as -o $@
68
69 edit_wrapper = sed \
70 -e 's|@wrap_program[@]|$(@F)|g' \
71 -e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \
72 -e 's|@abs_top_builddir[@]|$(abs_top_builddir)|g' \
73 -e "s|@configure_input[@]|Generated from $$input.|g"
74
75 $(wrappers): tests/wrapper.in
76 rm -f $@ [email protected]
77 input=tests/wrapper.in \
78 && $(edit_wrapper) tests/wrapper.in >[email protected]
79 chmod +x [email protected]
80 chmod a-w [email protected]
81 mv -f [email protected] $@
82
83
84
85 ## ------------ ##
86 ## Test suite. ##
87 ## ------------ ##
88
89 TESTSUITE_GENERATED_AT = \
90 tests/aclang.at \
91 tests/acc.at \
92 tests/acerlang.at \
93 tests/acfortran.at \
94 tests/acgo.at \
95 tests/aca68.at \
96 tests/acgeneral.at \
97 tests/acstatus.at \
98 tests/acautoheader.at \
99 tests/acautoupdate.at \
100 tests/acspecific.at \
101 tests/acfunctions.at \
102 tests/acheaders.at \
103 tests/actypes.at \
104 tests/aclibs.at \
105 tests/acprograms.at
106
107 TESTSUITE_HAND_AT = \
108 tests/suite.at \
109 tests/m4sugar.at \
110 tests/m4sh.at \
111 tests/autotest.at \
112 tests/base.at \
113 tests/tools.at \
114 tests/torture.at \
115 tests/compile.at \
116 tests/c.at \
117 tests/erlang.at \
118 tests/fortran.at \
119 tests/go.at \
120 tests/a68.at \
121 tests/semantics.at \
122 tests/autoscan.at \
123 tests/foreign.at
124
125 TESTSUITE_EXTRA = \
126 tests/data/ax_prog_cc_for_build_v18.m4 \
127 tests/data/ax_prog_cxx_for_build_v3.m4 \
128 tests/data/gnulib_std_gnu11_2020_08_17.m4
129
130 CLEANFILES += $(TESTSUITE_GENERATED_AT)
131 EXTRA_DIST += $(TESTSUITE_HAND_AT) $(TESTSUITE_EXTRA)
132
133 TESTSUITE_AT = $(TESTSUITE_GENERATED_AT) $(TESTSUITE_HAND_AT)
134 TESTSUITE = tests/testsuite
135
136 # Run the non installed autom4te.
137 # Don't use AUTOM4TE since 'make alpha' makes it unavailable although
138 # we are allowed to use it (since we ship it).
139 AUTOTESTFLAGS = -I tests -I $(srcdir)/tests
140 AUTOTEST = $(MY_AUTOM4TE) --language=autotest
141 $(TESTSUITE): tests/package.m4 \
142 tests/local.at \
143 $(TESTSUITE_AT) \
144 lib/autotest/autotest.m4f
145 $(AUTOTEST) $(AUTOTESTFLAGS) suite.at -o [email protected]
146 mv [email protected] $@
147
148 # Factor out invocation of the testsuite script.
149 run_testsuite = $(SHELL) $(TESTSUITE) -C tests MAKE=$(MAKE)
150
151 # Avoid a race condition that would make parallel "distclean" fail.
152 # The rule in clean-local tests for existence of $(TESTSUITE), and
153 # if found, attempts to run it. But the distclean-generic rule may
154 # be running in parallel, and it removes $(DISTCLEANFILES) which
155 # includes $(TESTSUITE). This is the Automake rule, plus our
156 # dependency, and we silence the warning from 'automake -Wall' by
157 # hiding the dependency behind a variable.
158 # TODO - fix this if newer automake accommodates the dependency.
159 distclean_generic = distclean-generic
160 $(distclean_generic): clean-local
161
162 clean-local:
163 test ! -f $(TESTSUITE) || $(run_testsuite) --clean
164 rm -f *.tmp
165 rm -f -r autom4te.cache
166
167 check-local: tests/atconfig tests/atlocal $(TESTSUITE)
168 +$(run_testsuite) $(TESTSUITEFLAGS)
169
170 # Automake doesn't know how to regenerate this file because
171 # it's created via AC_CONFIG_COMMANDS.
172 tests/atconfig: $(top_builddir)/config.status
173 cd $(top_builddir) && $(SHELL) ./config.status $@
174
175 # Run the test suite on the *installed* tree.
176 installcheck-local: tests/atconfig tests/atlocal $(TESTSUITE)
177 +$(run_testsuite) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
178
179
180
181 ## ------------------ ##
182 ## Maintainer rules. ##
183 ## ------------------ ##
184
185 MAINTAINERCLEANFILES += $(TESTSUITE_GENERATED_AT)
186
187 ## Producing the test files.
188
189 # The files which contain macros we check for syntax. Use $(srcdir)
190 # for the benefit of non-GNU make.
191 autoconfdir = $(srcdir)/lib/autoconf
192 AUTOCONF_FILES = $(autoconfdir)/general.m4 \
193 $(autoconfdir)/status.m4 \
194 $(autoconfdir)/autoheader.m4 \
195 $(autoconfdir)/autoupdate.m4 \
196 $(autoconfdir)/specific.m4 \
197 $(autoconfdir)/functions.m4 \
198 $(autoconfdir)/lang.m4 \
199 $(autoconfdir)/c.m4 \
200 $(autoconfdir)/erlang.m4 \
201 $(autoconfdir)/fortran.m4 \
202 $(autoconfdir)/go.m4 \
203 $(autoconfdir)/a68.m4 \
204 $(autoconfdir)/headers.m4 \
205 $(autoconfdir)/libs.m4 \
206 $(autoconfdir)/types.m4 \
207 $(autoconfdir)/programs.m4
208
209 $(TESTSUITE_GENERATED_AT): tests/mktests.stamp
210 ## Recover from the removal of $@
211 @if test -f $@; then :; else \
212 rm -f tests/mktests.stamp; \
213 $(MAKE) $(AM_MAKEFLAGS) tests/mktests.stamp; \
214 fi
215
216 tests/mktests.stamp : tests/mktests.pl $(AUTOCONF_FILES)
217 @rm -f tests/mktests.tmp
218 @touch tests/mktests.tmp
219 $(PERL) $(srcdir)/tests/mktests.pl tests $(AUTOCONF_FILES)
220 @mv -f tests/mktests.tmp $@
221
222 CLEANFILES += tests/mktests.tmp tests/mktests.stamp
223
224 ## maintainer-check ##
225
226 # The test suite cannot be run in parallel with itself.
227 maintainer-check:
228 $(MAKE) $(AM_MAKEFLAGS) check
229 $(MAKE) $(AM_MAKEFLAGS) maintainer-check-posix
230
231 # The hairy heredoc is more robust than using echo.
232 CLEANFILES += expr
233 expr:
234 :;{ \
235 echo '#! $(SHELL)'; \
236 echo 'result=`$(EXPR) "$$@"`'; \
237 echo 'estatus=$$?'; \
238 echo 'cat <<EOF'; \
239 echo '$${result:-0}'; \
240 echo 'EOF'; \
241 echo 'exit $$estatus'; \
242 } > $@-t
243 chmod +x $@-t
244 mv $@-t $@
245
246 # Try the test suite with more severe environments.
247 maintainer-check-posix: expr
248 POSIXLY_CORRECT=yes $(MAKE) $(AM_MAKEFLAGS) check
249 rm expr