1 # Copyright © 2015,2019-2022 Nick Bowler
3 # Automake fragment to hook up a basic Autotest test suite into the
4 # build. It is expected that a testsuite.at file exists in $(srcdir).
5 # The testsuite will be output to $(builddir)/testsuite.
7 # The DX_AUTOMAKE_COMPAT macro must be expanded by configure.ac to
8 # provide necessary substitutions. If DX_PROG_AUTOTEST is used, this
9 # will be included automatically.
11 # You must define the AUTOTEST variable to the Autotest program (normally,
12 # this is autom4te -l autotest). The DX_PROG_AUTOTEST macro can be used
13 # to set this automatically. You must also define the HAVE_AUTOTEST Automake
14 # conditional which controls whether the testsuite-generating rules are
15 # enabled. If DX_PROG_AUTOTEST is used, this may be set like:
18 # AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"])
20 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
21 # This is free software: you are free to do what the fuck you want to.
22 # There is NO WARRANTY, to the extent permitted by law.
24 check-local: check-autotest
25 check-autotest: testsuite
26 $(SHELL) $? $(TESTSUITEFLAGS)
27 .PHONY: check-autotest
29 clean-local: clean-autotest
31 for f in testsuite "$(srcdir)/testsuite"; do \
32 test ! -f "$$f" || { $(SHELL) "$$f" --clean; break; }; \
34 .PHONY: clean-autotest
36 maintainer-clean-local: maintainer-clean-autotest
37 maintainer-clean-autotest:
38 rm -f testsuite testsuite.deps package.m4
39 .PHONY: maintainerclean-autotest
41 package.m4: $(top_srcdir)/configure.ac
43 printf 'm4_define([%s], [%s])\n' \
44 AT_PACKAGE_NAME '$(PACKAGE_NAME)' \
45 AT_PACKAGE_TARNAME '$(PACKAGE_TARNAME)' \
46 AT_PACKAGE_VERSION '$(PACKAGE_VERSION)' \
47 AT_PACKAGE_STRING '$(PACKAGE_STRING)' \
48 AT_PACKAGE_BUGREPORT '$(PACKAGE_BUGREPORT)' \
49 AT_PACKAGE_URL '$(PACKAGE_URL)' \
51 $(AM_V_at) mv -f $@.tmp $@
53 DX_AUTOTEST_ERROR = @:; { \
54 printf 'ERROR: Autotest was not available at configure time.\n'; \
55 printf 'You should only need it if you modified the test suite.\n'; \
56 printf 'Autotest is part of autom4te, included in the GNU\n'; \
57 printf 'Autoconf package: <https://gnu.org/s/autoconf/>\n'; \
60 DX_AUTOTEST = $(AUTOTEST) -I$(srcdir) $(ATFLAGS)
62 testsuite: testsuite.at package.m4
66 $(AM_V_GEN) $(DX_AUTOTEST) -p m4_include -o $@.tmp testsuite.at
67 $(AM_V_at) $(DX_AUTOTEST) -t m4_include:'$$1' -o $@.deps.tmp \
70 $(AM_V_at) exec 3<$@.deps.tmp 4>$(DEPDIR)/$(@F).P; \
71 while read f <&3; do printf '$@: %s\n%s:\n' "$$f" "$$f" >&4; done
73 $(AM_V_at) mv -f $@.deps.tmp $@.deps
74 $(AM_V_at) mv -f $@.tmp $@
75 testsuite.deps: testsuite
77 dist-hook: dist-autotest-deps
78 dist-autotest-deps: testsuite.deps
79 exec 3<$?; while read f <&3; do \
80 dir=`expr "$$f" : '\(.*\)/'`; \
81 $(MKDIR_P) "$(distdir)/$$dir" && \
82 chmod u+w "$(distdir)/$$dir" && \
83 cp -p "$(srcdir)/$$f" "$(distdir)/$$f" || exit; \
85 .PHONY: dist-autotest-deps
87 EXTRA_DIST += testsuite testsuite.at testsuite.deps package.m4
88 DISTCLEANFILES += atconfig $(DEPDIR)/testsuite.P
90 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/testsuite.P@am__quote@@dx_include_marker@
92 # Automake 1.16 and newer use make rules to generate the dependency stubs.
93 # Use this opportunity to generate accurate prerequisites from distributed
94 # testsuite dependencies, needed so that make knows to rebuild the testsuite
95 # when source files are modified in a distribution tarball, or after a make
98 # With older Automake the stubs are generated directly in config.status.
99 # Since this rule is ignored things should still work but the build may
100 # miss modifications to the testsuite on the first build from a tarball.
101 @dx_depfiles_target@: ./$(DEPDIR)/testsuite.P
102 ./$(DEPDIR)/testsuite.P:
104 @if test -f $(builddir)/testsuite.deps; then \
105 exec 3<$(builddir)/testsuite.deps; \
106 elif test -f $(srcdir)/testsuite.deps; then \
107 exec 3<$(srcdir)/testsuite.deps; \
109 echo '# dummy' >$@-t && exit; \
110 fi; exec 4>$@-t; while read f <&3; do \
111 printf 'testsuite: %s\n%s:\n' "$$f" "$$f" >&4; \