From 1a5dfba4efc892d5e8659bc51fb9f57ed28eaa16 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Thu, 30 May 2024 14:41:48 +0100 Subject: gdb/doc: allow for version.subst in the source tree In a git checkout of the source code we don't have a version.subst file in the gdb/doc directory. When building the GDB docs the version.subst file is generated on demand (we have a recipe for that). However, in a release tar file we do include a copy of the version.subst file in the source tree, as a result the version.subst recipe will not be run. If, in a release build, we force the running of any recipe that depends on version.subst then we run into a problem. For example, slightly confusingly, if we 'touch gdb/doc/version.subst' within the unpacked source tree of a release, then 'make -C gdb/doc GDBvn.texi' in the build tree, we'll see: make: Entering directory '/tmp/build/build/gdb/doc' GEN GDBvn.texi sed: can't read version.subst: No such file or directory make: Leaving directory '/tmp/build/build/gdb/doc' The problem is that every reference to version.subst in GDB's Makefile assumes that the version.subst file will always be in the build directory. Handily version.subst is always the first dependency in every recipe that uses that file. As such we can replace references to version.subst with $<, make will expand this to the location where the dependency was found. In the case of the man page generation, the reference to version.subst is hidden inside POD2MAN. It seemed a little confusing adding a use of $< within POD2MAN, so I've moved the use into the recipe, which I think is clearer. I've also added comments for the two rules that I've modified to explain our use of $<. After this change it is possible to rebuild the man pages even when version.subst is located in the source tree. Approved-By: Tom Tromey --- gdb/doc/Makefile.in | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in index 70d65d5..effd0f4 100644 --- a/gdb/doc/Makefile.in +++ b/gdb/doc/Makefile.in @@ -178,8 +178,8 @@ MANCONF = -Dman TEXI2POD = perl $(srcdir)/../../etc/texi2pod.pl \ $(MAKEINFOFLAGS) $(MAKEINFO_EXTRA_FLAGS) -POD2MAN = pod2man --center="GNU Development Tools" \ - --release="gdb-`sed q version.subst`" + +POD2MAN = pod2man --center="GNU Development Tools" # List of man pages generated from gdb.texi MAN1S = gdb.1 gdbserver.1 gcore.1 gdb-add-index.1 @@ -435,9 +435,14 @@ refcard.pdf : refcard.tex $(REFEDITS) $(SILENCE) rm -f sedref.log sedref.tex tmp.sed # File to record current GDB version number. +# +# It is important that version.subst be the first dependency so that +# $< can be used in the recipe, this allows us to find version.subst +# in either the source tree or the build tree as this file is +# included, pre-built, as part of a release. GDBvn.texi : version.subst $(ECHO_GEN) - $(SILENCE) echo "@set GDBVN `sed q version.subst`" > ./GDBvn.new + $(SILENCE) echo "@set GDBVN `sed q $<`" > ./GDBvn.new $(SILENCE) if [ -n "$(PKGVERSION)" ]; then \ echo "@set VERSION_PACKAGE $(PKGVERSION)" >> ./GDBvn.new; \ fi @@ -652,11 +657,16 @@ annotate/index.html: $(ANNOTATE_DOC_FILES) # pages, then the .pod files must become a dependency, this will # trigger an attempt to rebuild these files while building and # installing a release of GDB, which is something we don't want. +# +# It is important that version.subst be the first dependency so that +# $< can be used in the recipe, this allows us to find version.subst +# in either the source tree or the build tree as this file is +# included, pre-built, as part of a release. $(MAN1S) $(MAN5S) : version.subst $(GDB_DOC_FILES) $(ECHO_TEXI2POD) $(TEXI2POD) $(MANCONF) -D$(basename $@) \ < $(srcdir)/gdb.texinfo > $(basename $@).pod $(ECHO_TEXI2MAN) ($(POD2MAN) --section=$(subst .,,$(suffix $@)) \ - $(basename $@).pod | \ + --release="gdb-`sed q $<`" $(basename $@).pod | \ sed -e '/^.if n .na/d' > $@.T$$$$ && \ mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1) $(SILENCE) rm -f $(basename $@).pod -- cgit v1.1