1## Make Autoconf tests.
2
3# Copyright (C) 2000-2012 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 <http://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.
22EXTRA_DIST = $(TESTSUITE_AT) local.at mktests.sh \
23	     atlocal.in wrapper.as statesave.m4
24
25# Running the uninstalled scripts.  Build them upon `all', for the manpages.
26noinst_SCRIPTS = $(wrappers)
27DISTCLEANFILES = atconfig atlocal $(TESTSUITE)
28MAINTAINERCLEANFILES = Makefile.in
29
30# Import the dependencies on Autotest and M4sh.
31include ../lib/freeze.mk
32
33
34## ------------ ##
35## package.m4.  ##
36## ------------ ##
37
38# The `:;' works around a redirected compound command bash exit status bug.
39package.m4: Makefile
40	:;{ \
41	  echo '# Signature of the current package.' && \
42	  echo 'm4_define([AT_PACKAGE_NAME],      [$(PACKAGE_NAME)])' && \
43	  echo 'm4_define([AT_PACKAGE_TARNAME],   [$(PACKAGE_TARNAME)])' && \
44	  echo 'm4_define([AT_PACKAGE_VERSION],   [$(PACKAGE_VERSION)])' && \
45	  echo 'm4_define([AT_PACKAGE_STRING],    [$(PACKAGE_STRING)])' && \
46	  echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])' && \
47	  echo 'm4_define([AT_PACKAGE_URL],       [$(PACKAGE_URL)])'; \
48	} > $@-t
49	mv $@-t $@
50
51
52
53## ---------- ##
54## Wrappers.  ##
55## ---------- ##
56
57wrappers = autoconf autoheader autom4te autoreconf autoscan autoupdate ifnames
58CLEANFILES = wrapper.in $(wrappers) package.m4
59
60wrapper.in: $(srcdir)/wrapper.as $(m4sh_m4f_dependencies)
61	$(MY_AUTOM4TE) --language=M4sh $(srcdir)/wrapper.as -o $@
62
63edit = sed \
64	-e 's|@wrap_program[@]|$@|g' \
65	-e 's|@abs_top_srcdir[@]|@abs_top_srcdir@|g' \
66	-e 's|@abs_top_builddir[@]|@abs_top_builddir@|g' \
67	-e "s|@configure_input[@]|Generated from $$input.|g"
68
69$(wrappers): wrapper.in
70	rm -f $@ $@.tmp
71	input=wrapper.in; \
72	$(edit) wrapper.in >$@.tmp
73	chmod +x $@.tmp
74	chmod a-w $@.tmp
75	mv -f $@.tmp $@
76
77
78
79## ------------ ##
80## Test suite.  ##
81## ------------ ##
82
83TESTSUITE_GENERATED_AT = \
84	$(srcdir)/aclang.at \
85	$(srcdir)/acc.at \
86	$(srcdir)/acfortran.at \
87	$(srcdir)/acgo.at \
88	$(srcdir)/acgeneral.at \
89	$(srcdir)/acstatus.at \
90	$(srcdir)/acautoheader.at \
91	$(srcdir)/acautoupdate.at \
92	$(srcdir)/acspecific.at \
93	$(srcdir)/acfunctions.at \
94	$(srcdir)/acheaders.at \
95	$(srcdir)/actypes.at \
96	$(srcdir)/aclibs.at \
97	$(srcdir)/acprograms.at
98
99TESTSUITE_HAND_AT = \
100	suite.at \
101	m4sugar.at m4sh.at autotest.at \
102	base.at tools.at torture.at \
103	compile.at c.at erlang.at fortran.at go.at \
104	semantics.at \
105	autoscan.at \
106	foreign.at
107
108TESTSUITE_AT = $(TESTSUITE_GENERATED_AT) $(TESTSUITE_HAND_AT)
109TESTSUITE = ./testsuite
110
111# Run the non installed autom4te.
112# Don't use AUTOM4TE since `make alpha' makes it unavailable although
113# we are allowed to use it (since we ship it).
114AUTOTEST = $(MY_AUTOM4TE) --language=autotest
115$(TESTSUITE): package.m4 \
116	      local.at \
117	      $(TESTSUITE_AT) \
118	      $(autotest_m4f_dependencies)
119	cd $(top_builddir)/lib/autotest && $(MAKE) $(AM_MAKEFLAGS) autotest.m4f
120	$(AUTOTEST) -I . -I $(srcdir) suite.at -o $@.tmp
121	mv $@.tmp $@
122
123atconfig: $(top_builddir)/config.status
124	cd $(top_builddir) && ./config.status tests/$@
125
126# Avoid a race condition that would make parallel "distclean" fail.
127# The rule in clean-local tests for existence of $(TESTSUITE), and
128# if found, attempts to run it.  But the distclean-generic rule may
129# be running in parallel, and it removes $(DISTCLEANFILES) which
130# includes $(TESTSUITE).  This is the Automake rule, plus our
131# dependency, and we silence the warning from 'automake -Wall' by
132# hiding the dependency behind a variable.
133# TODO - fix this if newer automake accommodates the dependency.
134distclean_generic = distclean-generic
135$(distclean_generic): clean-local
136
137clean-local:
138	test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
139	rm -f *.tmp
140	rm -f -r autom4te.cache
141
142check-local: atconfig atlocal $(TESTSUITE)
143	$(SHELL) $(TESTSUITE) $(TESTSUITEFLAGS)
144
145# Run the test suite on the *installed* tree.
146installcheck-local: atconfig atlocal $(TESTSUITE)
147	$(SHELL) $(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
148
149
150
151## ------------------ ##
152## Maintainer rules.  ##
153## ------------------ ##
154
155MAINTAINERCLEANFILES += $(TESTSUITE_GENERATED_AT)
156
157## Producing the test files.
158
159# The files which contain macros we check for syntax.  Use $(top_srcdir)
160# for the benefit of non-GNU make.  Fix the names in the rule below
161# where we `cd' to $srcdir.
162autoconfdir = $(top_srcdir)/lib/autoconf
163AUTOCONF_FILES = $(autoconfdir)/general.m4 \
164		 $(autoconfdir)/status.m4 \
165		 $(autoconfdir)/autoheader.m4 \
166		 $(autoconfdir)/autoupdate.m4 \
167		 $(autoconfdir)/specific.m4 \
168		 $(autoconfdir)/functions.m4 \
169		 $(autoconfdir)/lang.m4 \
170		 $(autoconfdir)/c.m4 \
171		 $(autoconfdir)/erlang.m4 \
172		 $(autoconfdir)/fortran.m4 \
173		 $(autoconfdir)/go.m4 \
174		 $(autoconfdir)/headers.m4 \
175		 $(autoconfdir)/libs.m4 \
176		 $(autoconfdir)/types.m4 \
177		 $(autoconfdir)/programs.m4
178
179$(TESTSUITE_GENERATED_AT): mktests.stamp
180## Recover from the removal of $@
181	@if test -f $@; then :; else \
182	  rm -f mktests.stamp; \
183	  $(MAKE) $(AM_MAKEFLAGS) mktests.stamp; \
184	fi
185
186mktests.stamp : mktests.sh $(AUTOCONF_FILES)
187	@rm -f mktests.tmp
188	@touch mktests.tmp
189	cd $(srcdir) && ./mktests.sh \
190	  `echo " "$(AUTOCONF_FILES) | sed 's, [^ ]*/, ../lib/autoconf/,g'`
191	@mv -f mktests.tmp $@
192
193## Distribute the stamp file, since we distribute the generated files.
194EXTRA_DIST += mktests.stamp
195CLEANFILES += mktests.tmp
196MAINTAINERCLEANFILES += mktests.stamp
197
198## maintainer-check ##
199
200# These cannot be run in parallel.
201maintainer-check:
202	$(MAKE) $(AM_MAKEFLAGS) maintainer-check-posix
203	$(MAKE) $(AM_MAKEFLAGS) maintainer-check-c++
204
205# The hairy heredoc is more robust than using echo.
206CLEANFILES += expr
207expr:
208	:;{					\
209	  echo '#! $(SHELL)';			\
210	  echo 'result=`$(EXPR) "$$@"`';	\
211	  echo 'estatus=$$?';			\
212	  echo 'cat <<EOF';			\
213	  echo '$${result:-0}';			\
214	  echo 'EOF';				\
215	  echo 'exit $$estatus';		\
216	} > $@-t
217	chmod +x $@-t
218	mv $@-t $@
219
220# Try the test suite with more severe environments.
221maintainer-check-posix: expr
222	POSIXLY_CORRECT=yes $(MAKE) $(AM_MAKEFLAGS) check
223	rm expr
224
225# Try using G++ as a C compiler.
226maintainer-check-c++:
227	CC=g++ $(MAKE) $(AM_MAKEFLAGS) check
228