Hi, According to the GNU Coding Standards https://www.gnu.org/prep/standards/html_node/Standard-Targets.html "The dist target should explicitly depend on all non-source files that are in the distribution, to make sure they are up to date in the distribution."
An easy way to test whether the 'dist' target has this property is to run $ ./configure $ make dist or (in a VPATH build) $ ../configure $ make dist without doing "make" before "make dist". Distributed non-source files that make this difficult are the man pages for programs, that are generated from the '--help' output using help2man. While packages that only have a top-level Makefile.am (such as GNU sed or GNU coreutils) get this right, it is a little bit more complicated in packages with a Makefile.am per directory (such as GNU m4 and GNU gettext). Originally reported for GNU gettext at <https://lists.gnu.org/archive/html/bug-gettext/2024-07/msg00010.html>. In GNU m4 $ ./configure; make dist fails like this: $ make dist ... (cd doc && make top_distdir=../m4-2024-05-13 distdir=../m4-2024-05-13/doc \ am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir) make[3]: Entering directory '/M4/m4/doc' make distdir-am make[4]: Entering directory '/M4/m4/doc' WARNING: The `man' page `m4.1' cannot be updated yet. Retry once the program executable is ready. cp: cannot stat './m4.1': No such file or directory make[4]: *** [Makefile:2242: distdir-am] Error 1 make[4]: Leaving directory '/M4/m4/doc' make[3]: *** [Makefile:2239: distdir] Error 2 make[3]: Leaving directory '/M4/m4/doc' make[2]: *** [Makefile:2172: distdir-am] Error 1 make[2]: Leaving directory '/M4/m4' make[1]: *** [Makefile:2166: distdir] Error 2 make[1]: Leaving directory '/M4/m4' make: *** [Makefile:2273: dist] Error 2 And when this is fixed, it fails in a different place: $ make dist ... (cd checks && make top_distdir=../m4-2024-05-13 distdir=../m4-2024-05-13/checks \ am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir) make[3]: Entering directory '/M4/m4/checks' make distdir-am make[4]: Entering directory '/M4/m4/checks' rm -f ./*[0-9][0-9][0-9].* cd . && AWK=gawk ./get-them ../doc/m4.texi Node: Top Node: Preliminaries - truncated Node: Intro Node: History Node: Bugs Node: Manual Node: Invoking m4 - truncated Node: Operation modes - truncated Node: Preprocessor features - truncated -- 1 file Node: Limits control - truncated Node: Frozen state - truncated Node: Debugging options - truncated -- 1 file Node: Command line files - truncated -- 5 files Node: Syntax Node: Names Node: Quoted strings - truncated Node: Comments -- 2 files Node: Other tokens - truncated Node: Input processing - truncated -- 2 files Node: Macros Node: Invocation Node: Inhibiting Invocation - truncated -- 8 files Node: Macro Arguments - truncated -- 5 files Node: Quoting Arguments - truncated -- 1 file Node: Macro expansion - truncated -- 2 files Node: Definitions - truncated Node: Define -- 3 files Node: Arguments -- 6 files Node: Pseudo Arguments - truncated -- 9 files Node: Undefine -- 3 files Node: Defn -- 7 files Node: Pushdef -- 2 files Node: Indir -- 3 files Node: Builtin -- 5 files Node: Conditionals - truncated Node: Ifdef -- 1 file Node: Ifelse -- 5 files Node: Shift -- 8 files Node: Forloop -- 3 files Node: Foreach -- 6 files Node: Stacks -- 2 files Node: Composition - truncated -- 4 files Node: Debugging Node: Dumpdef -- 2 files Node: Trace -- 5 files Node: Debug Levels - truncated -- 3 files Node: Debug Output - truncated -- 1 file Node: Input Control - truncated Node: Dnl -- 3 files Node: Changequote - truncated -- 11 files Node: Changecom -- 6 files Node: Changeword -- 6 files Node: M4wrap -- 6 files Node: File Inclusion - truncated Node: Include -- 6 files Node: Search Path - truncated Node: Diversions -- 4 files Node: Divert -- 5 files Node: Undivert -- 6 files Node: Divnum -- 1 file Node: Cleardivert - truncated -- 2 files Node: Text handling - truncated Node: Len -- 1 file Node: Index macro - truncated -- 4 files Node: Regexp -- 3 files Node: Substr -- 2 files Node: Translit -- 4 files Node: Patsubst -- 5 files Node: Format -- 4 files Node: Arithmetic Node: Incr -- 1 file Node: Eval -- 6 files Node: Shell commands - truncated Node: Platform macros - truncated -- 3 files Node: Syscmd -- 2 files Node: Esyscmd -- 1 file Node: Sysval -- 2 files Node: Mkstemp -- 3 files Node: Miscellaneous - truncated Node: Errprint -- 1 file Node: Location -- 3 files Node: M4exit -- 2 files Node: Frozen files - truncated Node: Using frozen files - truncated -- 3 files Node: Frozen file format - truncated Node: Compatibility - truncated Node: Extensions -- 1 file Node: Incompatibilities - truncated Node: Other Incompatibilities - truncated -- 2 files Node: Answers Node: Improved exch - truncated -- 1 file Node: Improved forloop - truncated -- 3 files Node: Improved foreach - truncated -- 11 files Node: Improved copy - truncated -- 2 files Node: Improved m4wrap - truncated -- 2 files Node: Improved cleardivert - truncated -- 1 file Node: Improved capitalize - truncated -- 2 files Node: Improved fatal_error - truncated -- 1 file Node: Copying This Package - truncated Node: GNU General Public License - truncated Node: Copying This Manual - truncated Node: GNU Free Documentation License - truncated Node: Indices Node: Macro index - truncated Node: Concept index - truncated echo stamp >stamp-checks make[4]: *** No rule to make target '*[0-9][0-9][0-9].*', needed by 'distdir-am'. Stop. make[4]: Leaving directory '/M4/m4/checks' make[3]: *** [Makefile:1957: distdir] Error 2 make[3]: Leaving directory '/M4/m4/checks' make[2]: *** [Makefile:2174: distdir-am] Error 1 make[2]: Leaving directory '/M4/m4' make[1]: *** [Makefile:2168: distdir] Error 2 make[1]: Leaving directory '/M4/m4' make: *** [Makefile:2275: dist] Error 2 The attached patch fixes both issues. Note that it has the side-effect that a plain "make all" will build the artifacts in a different order: First the $(BUILT_SOURCES), then the rest. But this is harmless.
>From 847e0bdc2f8e23514faef42e9317160fd24605c3 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Mon, 22 Jul 2024 03:09:32 +0200 Subject: [PATCH] build: Fix failure of "./configure; make dist". * Makefile.am (BUILT_SOURCES): Add doc/m4.1, checks-files. (doc/m4.1): New target. (checks-files): New phony target. --- Makefile.am | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index fbc32911..99a3c8cb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ## Makefile.am - template for generating Makefile via Automake ## -## Copyright (C) 2000-2001, 2003-2014, 2016-2017, 2020-2023 Free +## Copyright (C) 2000-2001, 2003-2014, 2016-2017, 2020-2024 Free ## Software Foundation, Inc. ## ## This file is part of GNU M4. @@ -64,6 +64,19 @@ BUILT_SOURCES = $(top_srcdir)/.version $(top_srcdir)/.version: echo $(VERSION) > $@-t && mv $@-t $@ +# Ensure that the manual page is up-to-date when "make dist" runs. +BUILT_SOURCES += doc/m4.1 +doc/m4.1: $(top_srcdir)/src/m4.c + $(AM_V_GEN)(cd lib && $(MAKE) $(AM_MAKEFLAGS)) \ + && (cd src && $(MAKE) $(AM_MAKEFLAGS) m4$(EXEEXT)) \ + && (cd doc && $(MAKE) $(AM_MAKEFLAGS) m4.1) + +# Ensure that the checks/*[0-9][0-9][0-9].* files exist when "make dist" runs. +BUILT_SOURCES += checks-files +.PHONY: checks-files +checks-files: + cd checks && $(MAKE) $(AM_MAKEFLAGS) + # Arrange so that .tarball-version appears only in the distribution # tarball, and never in a checked-out repository. dist-hook: gen-ChangeLog -- 2.34.1