-dnl Copyright © 2012 Nick Bowler
+dnl Copyright © 2012, 2021 Nick Bowler
dnl
-dnl Definitions to help maintain compatibility with older versions of Automake.
+dnl Definitions to help maintain compatibility with multiple Automake versions.
dnl
dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
dnl This is free software: you are free to do what the fuck you want to.
p
}
EOF
-if sed -nf conftest.sed Makefile.in >conftest.out 2>/dev/null; then
+if sed -nf conftest.sed "$srcdir/Makefile.in" >conftest.out 2>/dev/null; then
read dx_genline <conftest.out
dx_cv_align_v=`expr "$dx_genline" : '.*'`
test $dx_cv_align_v -eq 0 && dx_cv_align_v=unknown
])
AS_IF([test x"$dx_cv_align_v" != x"unknown"],
- [AC_SUBST([DX_ALIGN_V], [-$dx_cv_align_v.$dx_cv_align_v])])
+ [AC_SUBST([DX_ALIGN_V], [-$dx_cv_align_v.$dx_cv_align_v])])
+
+AC_CACHE_CHECK([for depfiles generation method], [dx_cv_am_depfiles],
+ [AS_IF([grep '^am--depfiles:' "$srcdir/Makefile.in" >/dev/null ||
+ grep '[[$]](am__maybe_remake_depfiles)' "$srcdir/Makefile.in" >/dev/null],
+ [dx_cv_am_depfiles='make am--depfiles'],
+ [dx_cv_am_depfiles='config.status'])])
+AS_CASE([$dx_cv_am_depfiles],
+ ['make am--depfiles'], [dx_include_marker=' @%:@ am--include-marker'],
+ [dx_include_marker=''])
+AC_SUBST([dx_depfiles_target], [am--depfiles])
+AC_SUBST([dx_include_marker])
+AM_SUBST_NOTMAKE([dx_depfiles_target])
+AM_SUBST_NOTMAKE([dx_include_marker])
+
])
[AUTOTEST=$dx_cv_autotest_cmd])])
AC_DEFUN([DX_PROG_AUTOTEST],
- [m4_do([AC_REQUIRE([AC_PROG_FGREP])],
+ [m4_do([AC_REQUIRE([AC_PROG_FGREP])AC_REQUIRE([DX_AUTOMAKE_COMPAT])],
[AC_ARG_VAR([AUTOTEST], [command to compile autotest programs])],
[DX_DO([_DX_PROG_AUTOTEST_SRC],
[_DX_PROG_AUTOTEST_SET_VAR],
-# Copyright © 2015,2019-2020 Nick Bowler
+# Copyright © 2015,2019-2021 Nick Bowler
#
-# Automake fragment to hook up a basic Autotest test suite into the build.
-# It is expected that a testsuite.at file exists in $(srcdir). The
-# testsuite will be output to $(builddir)/testsuite.
+# Automake fragment to hook up a basic Autotest test suite into the
+# build. It is expected that a testsuite.at file exists in $(srcdir).
+# The testsuite will be output to $(builddir)/testsuite.
+#
+# The DX_AUTOMAKE_COMPAT macro must be expanded by configure.ac to
+# provide necessary substitutions. If DX_PROG_AUTOTEST is used, this
+# will be included automatically.
#
# You must define the AUTOTEST variable to the Autotest program (normally,
# this is autom4te -l autotest). The DX_PROG_AUTOTEST macro can be used
EXTRA_DIST += testsuite testsuite.at testsuite.deps package.m4
DISTCLEANFILES += atconfig $(DEPDIR)/testsuite.P
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/testsuite.P@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/testsuite.P@am__quote@@dx_include_marker@
# Automake 1.16 and newer use make rules to generate the dependency stubs.
# Use this opportunity to generate accurate prerequisites from distributed
# 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:
+@dx_depfiles_target@: ./$(DEPDIR)/testsuite.P
+./$(DEPDIR)/testsuite.P:
@$(MKDIR_P) $(@D)
@if test -f $(builddir)/testsuite.deps; then \
exec 3<$(builddir)/testsuite.deps; \
--- /dev/null
+dnl Copyright © 2021 Nick Bowler
+dnl
+dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+dnl This is free software: you are free to do what the fuck you want to.
+dnl There is NO WARRANTY, to the extent permitted by law.
+
+AT_BANNER([Automake snippet tests])
+
+m4_define([TEST_DEPFILES_INIT],
+[TEST_CONFIGURE_AC(
+[[AM_INIT_AUTOMAKE([foreign])
+
+DX_PROG_AUTOTEST
+AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"])
+
+AM_SET_DEPDIR
+AM_OUTPUT_DEPENDENCY_COMMANDS
+AM_MAKE_INCLUDE
+AM_DEP_TRACK
+
+AC_CONFIG_FILES([Makefile])
+]])
+
+cp "$srcdir/snippet/autotest.mk" .
+AT_DATA([Makefile.am],
+[[EXTRA_DIST =
+DISTCLEANFILES =
+include $(top_srcdir)/autotest.mk
+]])
+
+TEST_AUTORECONF])
+
+AT_SETUP([autotest.mk depfiles (MAKE=gmake)])
+
+TEST_DEPFILES_INIT
+
+# gmake sanity check
+AT_CHECK([{ echo 'rule:; @: $(info works)' |
+ gmake --no-print-directory -f - >out 2>/dev/null &&
+ read s <out && test x"$s" = x"works"; } || exit 77])
+
+mkdir build
+AT_CHECK([cd build && ../configure MAKE=gmake && test -f .deps/testsuite.P],
+ [0], [ignore])
+AT_CHECK([gmake --no-print-directory -sC build distclean &&
+ find build -type f])
+
+AT_CLEANUP
+
+AT_SETUP([autotest.mk depfiles (MAKE=dmake)])
+
+TEST_DEPFILES_INIT
+
+# dmake sanity check
+AT_CHECK([{ echo 'rule:; @echo works' | dmake -f - >out 2>/dev/null &&
+ read s <out && test x"$s" = x"works"; } || exit 77])
+
+AT_CHECK([./configure MAKE=dmake && test -f .deps/testsuite.P], [0], [ignore])
+
+AT_CLEANUP
AT_TESTED([prove])
+m4_divert_push([PREPARE_TESTS])dnl
+# Reduce influence from the toplevel "make" invocation on test cases.
+AS_UNSET([MAKEFLAGS])
+AS_UNSET([MAKELEVEL])
+AS_UNSET([MFLAGS])
+m4_divert_pop([PREPARE_TESTS])
+
m4_define([TEST_CONFIGURE_AC], [AT_KEYWORDS([autoconf m4])dnl
AT_DATA([configure.ac],
[[AC_INIT([test], [0])
AC_OUTPUT
]])
cp "$srcdir/install-sh" \
+ "$srcdir/depcomp" \
+ "$srcdir/missing" \
"$srcdir/config.guess" \
"$srcdir/config.sub" \
.
AT_CHECK([export CC; ./configure $1], [0], [ignore])])
m4_include([tests/macros.at])
+m4_include([tests/snippets.at])
m4_include([tests/functions.at])
m4_include([tests/programs.at])
m4_include([tests/libs.at])