A fresh distribution tarball includes a generated testsuite, but
does not have the benefit of rules from automatic dependency tracking.
This means if a file included by the testsuite is modified in the
tarball, the build will not detect that testsuite is out of date
and will not try to rebuild it.
A similar scenario occurs if 'make distclean' is run after building
the test suite.
Since modern Automake uses make rules to generate the dependency stubs,
we can use the distributed testsuite dependencies record to produce
an accurate initial list of prerequisites. And by ensuring that this
file is updated whenever the testsuite is built, we can handle the
'make distclean' case too.
maintainer-clean-local: maintainer-clean-autotest
maintainer-clean-autotest:
maintainer-clean-local: maintainer-clean-autotest
maintainer-clean-autotest:
- rm -f testsuite package.m4
+ rm -f testsuite testsuite.deps package.m4
.PHONY: maintainerclean-autotest
package.m4: $(top_srcdir)/configure.ac
.PHONY: maintainerclean-autotest
package.m4: $(top_srcdir)/configure.ac
printf 'Autoconf package: <https://gnu.org/s/autoconf/>\n'; \
} 1>&2; false
printf 'Autoconf package: <https://gnu.org/s/autoconf/>\n'; \
} 1>&2; false
-DX_ATFLAGS = -I$(srcdir) $(ATFLAGS)
+DX_AUTOTEST = $(AUTOTEST) -I$(srcdir) $(ATFLAGS)
testsuite: testsuite.at package.m4
if !HAVE_AUTOTEST
$(DX_AUTOTEST_ERROR)
endif
testsuite: testsuite.at package.m4
if !HAVE_AUTOTEST
$(DX_AUTOTEST_ERROR)
endif
- $(AM_V_GEN) $(AUTOTEST) $(DX_ATFLAGS) -p m4_include -o $@.tmp \
+ $(AM_V_GEN) $(DX_AUTOTEST) -p m4_include -o $@.tmp testsuite.at
+ $(AM_V_at) $(DX_AUTOTEST) -t m4_include:'$$1' -o $@.deps.tmp \
- $(AM_V_at) :; { \
- $(AUTOTEST) $(DX_ATFLAGS) -t m4_include:'$@: $$1' testsuite.at; \
- $(AUTOTEST) $(DX_ATFLAGS) -t m4_include:'$$1:' testsuite.at; \
- } >$(DEPDIR)/$(@F).P
+ $(AM_V_at) exec 3<$@.deps.tmp 4>$(DEPDIR)/$(@F).P; \
+ while read f <&3; do printf '$@: %s\n%s:\n' "$$f" "$$f" >&4; done
+ $(AM_V_at) mv -f $@.deps.tmp $@.deps
$(AM_V_at) mv -f $@.tmp $@
$(AM_V_at) mv -f $@.tmp $@
testsuite.deps: testsuite
testsuite.deps: testsuite
-if !HAVE_AUTOTEST
- $(DX_AUTOTEST_ERROR)
-endif
- $(AM_V_GEN) $(AUTOTEST) $(DX_ATFLAGS) -t m4_include:'$$1' -o $@.tmp \
- testsuite.at
- $(AM_V_at) mv -f $@.tmp $@
dist-hook: dist-autotest-deps
dist-autotest-deps: testsuite.deps
dist-hook: dist-autotest-deps
dist-autotest-deps: testsuite.deps
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/testsuite.P@am__quote@
# Automake 1.16 and newer use make rules to generate the dependency stubs.
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/testsuite.P@am__quote@
# Automake 1.16 and newer use make rules to generate the dependency stubs.
-# we must hook those which is kind of annoying to do. This should be harmless
-# on previous versions which generate the stubs directly in config.status.
+# Use this opportunity to generate accurate prerequisites from distributed
+# testsuite dependencies, needed so that make knows to rebuild the testsuite
+# when source files are modified in a distribution tarball, or after a make
+# distclean.
+#
+# With older Automake the stubs are generated directly in config.status.
+# Since this rule is ignored things should still work but the build may
+# miss modifications to the testsuite on the first build from a tarball.
_dx_autotest_depfiles = am--depfiles
$(_dx_autotest_depfiles): $(DEPDIR)/testsuite.P
$(DEPDIR)/testsuite.P:
@$(MKDIR_P) $(@D)
_dx_autotest_depfiles = am--depfiles
$(_dx_autotest_depfiles): $(DEPDIR)/testsuite.P
$(DEPDIR)/testsuite.P:
@$(MKDIR_P) $(@D)
- @echo '# dummy' >$@-t && mv -f $@-t $@
+ @if test -f $(builddir)/testsuite.deps; then \
+ exec 3<$(builddir)/testsuite.deps; \
+ elif test -f $(srcdir)/testsuite.deps; then \
+ exec 3<$(srcdir)/testsuite.deps; \
+ else \
+ echo '# dummy' >$@-t && exit; \
+ fi; exec 4>$@-t; while read f <&3; do \
+ printf 'testsuite: %s\n%s:\n' "$$f" "$$f" >&4; \
+ done
+ @mv -f $@-t $@