make fetch
[autoconf.git] / tests / local.mk
blobc100f0c12c2c57e8c7b0b6362ebe997ce8c4eef0
1 ## Make Autoconf tests.
3 # Copyright (C) 2000-2017, 2020-2023 Free Software Foundation, Inc.
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.
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.
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/>.
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
29 # Running the uninstalled scripts. Build them upon 'all', for the manpages.
30 noinst_SCRIPTS = $(wrappers)
31 DISTCLEANFILES += tests/atconfig tests/atlocal $(TESTSUITE)
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 $@
48 ## ---------- ##
49 ## Wrappers. ##
50 ## ---------- ##
52 wrappers = \
53 tests/autoconf \
54 tests/autoheader \
55 tests/autom4te \
56 tests/autoreconf \
57 tests/autoscan \
58 tests/autoupdate \
59 tests/ifnames
61 CLEANFILES += \
62 tests/package.m4 \
63 tests/wrapper.in \
64 $(wrappers)
66 tests/wrapper.in: $(srcdir)/tests/wrapper.as $(m4sh_m4f_dependencies)
67 $(MY_AUTOM4TE) --language=M4sh $(srcdir)/tests/wrapper.as -o $@
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"
75 $(wrappers): tests/wrapper.in
76 rm -f $@ $@.tmp
77 input=tests/wrapper.in \
78 && $(edit_wrapper) tests/wrapper.in >$@.tmp
79 chmod +x $@.tmp
80 chmod a-w $@.tmp
81 mv -f $@.tmp $@
85 ## ------------ ##
86 ## Test suite. ##
87 ## ------------ ##
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/acgeneral.at \
96 tests/acstatus.at \
97 tests/acautoheader.at \
98 tests/acautoupdate.at \
99 tests/acspecific.at \
100 tests/acfunctions.at \
101 tests/acheaders.at \
102 tests/actypes.at \
103 tests/aclibs.at \
104 tests/acprograms.at
106 TESTSUITE_HAND_AT = \
107 tests/suite.at \
108 tests/m4sugar.at \
109 tests/m4sh.at \
110 tests/autotest.at \
111 tests/base.at \
112 tests/tools.at \
113 tests/torture.at \
114 tests/compile.at \
115 tests/c.at \
116 tests/erlang.at \
117 tests/fortran.at \
118 tests/go.at \
119 tests/semantics.at \
120 tests/autoscan.at \
121 tests/foreign.at
123 TESTSUITE_EXTRA = \
124 tests/data/ax_prog_cc_for_build_v18.m4 \
125 tests/data/ax_prog_cxx_for_build_v3.m4 \
126 tests/data/gnulib_std_gnu11_2020_08_17.m4
128 CLEANFILES += $(TESTSUITE_GENERATED_AT)
129 EXTRA_DIST += $(TESTSUITE_HAND_AT) $(TESTSUITE_EXTRA)
131 TESTSUITE_AT = $(TESTSUITE_GENERATED_AT) $(TESTSUITE_HAND_AT)
132 TESTSUITE = tests/testsuite
134 # Run the non installed autom4te.
135 # Don't use AUTOM4TE since 'make alpha' makes it unavailable although
136 # we are allowed to use it (since we ship it).
137 AUTOTESTFLAGS = -I tests -I $(srcdir)/tests
138 AUTOTEST = $(MY_AUTOM4TE) --language=autotest
139 $(TESTSUITE): tests/package.m4 \
140 tests/local.at \
141 $(TESTSUITE_AT) \
142 lib/autotest/autotest.m4f
143 $(AUTOTEST) $(AUTOTESTFLAGS) suite.at -o $@.tmp
144 mv $@.tmp $@
146 # Factor out invocation of the testsuite script.
147 run_testsuite = $(SHELL) $(TESTSUITE) -C tests MAKE=$(MAKE)
149 # Avoid a race condition that would make parallel "distclean" fail.
150 # The rule in clean-local tests for existence of $(TESTSUITE), and
151 # if found, attempts to run it. But the distclean-generic rule may
152 # be running in parallel, and it removes $(DISTCLEANFILES) which
153 # includes $(TESTSUITE). This is the Automake rule, plus our
154 # dependency, and we silence the warning from 'automake -Wall' by
155 # hiding the dependency behind a variable.
156 # TODO - fix this if newer automake accommodates the dependency.
157 distclean_generic = distclean-generic
158 $(distclean_generic): clean-local
160 clean-local:
161 test ! -f $(TESTSUITE) || $(run_testsuite) --clean
162 rm -f *.tmp
163 rm -f -r autom4te.cache
165 check-local: tests/atconfig tests/atlocal $(TESTSUITE)
166 +$(run_testsuite) $(TESTSUITEFLAGS)
168 # Automake doesn't know how to regenerate this file because
169 # it's created via AC_CONFIG_COMMANDS.
170 tests/atconfig: $(top_builddir)/config.status
171 cd $(top_builddir) && $(SHELL) ./config.status $@
173 # Run the test suite on the *installed* tree.
174 installcheck-local: tests/atconfig tests/atlocal $(TESTSUITE)
175 +$(run_testsuite) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
179 ## ------------------ ##
180 ## Maintainer rules. ##
181 ## ------------------ ##
183 MAINTAINERCLEANFILES += $(TESTSUITE_GENERATED_AT)
185 ## Producing the test files.
187 # The files which contain macros we check for syntax. Use $(srcdir)
188 # for the benefit of non-GNU make.
189 autoconfdir = $(srcdir)/lib/autoconf
190 AUTOCONF_FILES = $(autoconfdir)/general.m4 \
191 $(autoconfdir)/status.m4 \
192 $(autoconfdir)/autoheader.m4 \
193 $(autoconfdir)/autoupdate.m4 \
194 $(autoconfdir)/specific.m4 \
195 $(autoconfdir)/functions.m4 \
196 $(autoconfdir)/lang.m4 \
197 $(autoconfdir)/c.m4 \
198 $(autoconfdir)/erlang.m4 \
199 $(autoconfdir)/fortran.m4 \
200 $(autoconfdir)/go.m4 \
201 $(autoconfdir)/headers.m4 \
202 $(autoconfdir)/libs.m4 \
203 $(autoconfdir)/types.m4 \
204 $(autoconfdir)/programs.m4
206 $(TESTSUITE_GENERATED_AT): tests/mktests.stamp
207 ## Recover from the removal of $@
208 @if test -f $@; then :; else \
209 rm -f tests/mktests.stamp; \
210 $(MAKE) $(AM_MAKEFLAGS) tests/mktests.stamp; \
213 tests/mktests.stamp : tests/mktests.pl $(AUTOCONF_FILES)
214 @rm -f tests/mktests.tmp
215 @touch tests/mktests.tmp
216 $(PERL) $(srcdir)/tests/mktests.pl tests $(AUTOCONF_FILES)
217 @mv -f tests/mktests.tmp $@
219 CLEANFILES += tests/mktests.tmp tests/mktests.stamp
221 ## maintainer-check ##
223 # The test suite cannot be run in parallel with itself.
224 maintainer-check:
225 $(MAKE) $(AM_MAKEFLAGS) check
226 $(MAKE) $(AM_MAKEFLAGS) maintainer-check-posix
228 # The hairy heredoc is more robust than using echo.
229 CLEANFILES += expr
230 expr:
231 :;{ \
232 echo '#! $(SHELL)'; \
233 echo 'result=`$(EXPR) "$$@"`'; \
234 echo 'estatus=$$?'; \
235 echo 'cat <<EOF'; \
236 echo '$${result:-0}'; \
237 echo 'EOF'; \
238 echo 'exit $$estatus'; \
239 } > $@-t
240 chmod +x $@-t
241 mv $@-t $@
243 # Try the test suite with more severe environments.
244 maintainer-check-posix: expr
245 POSIXLY_CORRECT=yes $(MAKE) $(AM_MAKEFLAGS) check
246 rm expr