From f14190dbcda7e9cf94e1691163081b98ecd2f3b1 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 6 Mar 2021 16:22:50 -0500 Subject: [PATCH] Fix Autotest depfiles generation with non-GNU makes. Depfiles generation uses the $MAKE value set at configure time, and apparently I never actually tried this with non-GNU makes. So of course it does not work. Let's try to improve the situation. --- m4/am-compat.m4 | 22 ++++++++++++++--- m4/autotest.m4 | 2 +- snippet/autotest.mk | 19 ++++++++------ tests/snippets.at | 60 +++++++++++++++++++++++++++++++++++++++++++++ testsuite.at | 10 ++++++++ 5 files changed, 100 insertions(+), 13 deletions(-) create mode 100644 tests/snippets.at diff --git a/m4/am-compat.m4 b/m4/am-compat.m4 index 46b2edf..ec14819 100644 --- a/m4/am-compat.m4 +++ b/m4/am-compat.m4 @@ -1,6 +1,6 @@ -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. @@ -50,7 +50,7 @@ cat >conftest.sed <<'EOF' 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 /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]) + ]) diff --git a/m4/autotest.m4 b/m4/autotest.m4 index f9e1eea..063144a 100644 --- a/m4/autotest.m4 +++ b/m4/autotest.m4 @@ -36,7 +36,7 @@ m4_define([_DX_PROG_AUTOTEST_SET_VAR], [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], diff --git a/snippet/autotest.mk b/snippet/autotest.mk index badfc9f..10acd71 100644 --- a/snippet/autotest.mk +++ b/snippet/autotest.mk @@ -1,8 +1,12 @@ -# 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 @@ -81,7 +85,7 @@ dist-autotest-deps: testsuite.deps 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 @@ -92,9 +96,8 @@ DISTCLEANFILES += atconfig $(DEPDIR)/testsuite.P # 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; \ diff --git a/tests/snippets.at b/tests/snippets.at new file mode 100644 index 0000000..32c1f70 --- /dev/null +++ b/tests/snippets.at @@ -0,0 +1,60 @@ +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 2>/dev/null && + read s