+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