public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCHv2 2/5] gdb/doc: allow for version.subst in the source tree
Date: Fri, 31 May 2024 09:18:39 +0100	[thread overview]
Message-ID: <7d24d630fb96976deb225f1098df2b32e72643bd.1717142725.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1717142725.git.aburgess@redhat.com>

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.

In this commit I replace direct references to version.subst with a
small shell snippet which returns the path to the version.subst file
to use.  If there is a version.subst file in the build directory then
that file is selected, otherwise we return the path to a version.subst
file in the source directory.

As the POD2MAN1 and POD2MAN5 commands both depend on version.subst I
have added version.subst as a dependency to the two recipes that use
this variable.
---
 gdb/doc/Makefile.in | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in
index 3a179e9799a..e5f8a11008e 100644
--- a/gdb/doc/Makefile.in
+++ b/gdb/doc/Makefile.in
@@ -178,10 +178,21 @@ MANCONF = -Dman
 TEXI2POD = perl $(srcdir)/../../etc/texi2pod.pl \
 		$(MAKEINFOFLAGS) $(MAKEINFO_EXTRA_FLAGS)
 
+# Shell snippet which will provide the full filename of the
+# version.subst file to use.  If there is a copy in the build
+# directory then that is preferred, otherwise we assume there is a
+# copy in the source tree.
+VERSION_SUBST = $$(if [ -r version.subst ]; \
+                   then \
+                      (echo $$PWD/version.subst); \
+                   else \
+                      (builtin cd $(srcdir) && echo $$PWD/version.subst); \
+                   fi)
+
 POD2MAN1 = pod2man --center="GNU Development Tools" \
-		   --release="gdb-`sed q version.subst`" --section=1
+		   --release="gdb-`sed q $(VERSION_SUBST)`" --section=1
 POD2MAN5 = pod2man --center="GNU Development Tools" \
-		   --release="gdb-`sed q version.subst`" --section=5
+		   --release="gdb-`sed q $(VERSION_SUBST)`" --section=5
 
 # List of man pages generated from gdb.texi
 MAN1S = gdb.1 gdbserver.1 gcore.1 gdb-add-index.1
@@ -439,7 +450,7 @@ refcard.pdf : refcard.tex $(REFEDITS)
 # File to record current GDB version number.
 GDBvn.texi : version.subst
 	$(ECHO_GEN)
-	$(SILENCE) echo "@set GDBVN `sed q version.subst`" > ./GDBvn.new
+	$(SILENCE) echo "@set GDBVN `sed q $(VERSION_SUBST)`" > ./GDBvn.new
 	$(SILENCE) if [ -n "$(PKGVERSION)" ]; then \
 	  echo "@set VERSION_PACKAGE $(PKGVERSION)" >> ./GDBvn.new; \
 	fi
@@ -654,13 +665,13 @@ 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.
-$(MAN1S) : %.1 : $(GDB_DOC_FILES)
+$(MAN1S) : %.1 : $(GDB_DOC_FILES) version.subst
 	$(ECHO_TEXI2POD) $(TEXI2POD) $(MANCONF) -D$* < $(srcdir)/gdb.texinfo > $*.pod
 	$(ECHO_TEXI2MAN) ($(POD2MAN1) $*.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
 	$(SILENCE) rm -f $*.pod
 
-$(MAN5S) : %.5 : $(GDB_DOC_FILES)
+$(MAN5S) : %.5 : $(GDB_DOC_FILES) version.subst
 	$(ECHO_TEXI2POD) $(TEXI2POD) $(MANCONF) -D$* < $(srcdir)/gdb.texinfo > $*.pod
 	$(ECHO_TEXI2MAN) ($(POD2MAN1) $*.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
-- 
2.25.4


  parent reply	other threads:[~2024-05-31  8:18 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-11  9:37 [PATCH 0/4] gdb/doc: build fixes and improvements Andrew Burgess
2024-05-11  9:37 ` [PATCH 1/4] gdb/doc: don't delete *.pod files too early Andrew Burgess
2024-05-13 16:13   ` Tom Tromey
2024-05-14 15:53     ` Andrew Burgess
2024-05-11  9:37 ` [PATCH 2/4] gdb/doc: don't try to copy GDBvn.texi from the source tree Andrew Burgess
2024-05-13 16:12   ` Tom Tromey
2024-05-13 17:33     ` Eli Zaretskii
2024-05-14 13:32       ` Andrew Burgess
2024-06-14 19:06     ` Pedro Alves
2024-05-11  9:37 ` [PATCH 3/4] gdb/doc: fix parallel build of refcard related targets Andrew Burgess
2024-05-13 16:13   ` Tom Tromey
2024-05-11  9:37 ` [PATCH 4/4] gdb/doc: fix parallel build of pdf and dvi files Andrew Burgess
2024-05-13 16:18   ` Tom Tromey
2024-05-14 13:40     ` Andrew Burgess
2024-05-31  8:18 ` [PATCHv2 0/5] gdb/doc: parallel build fixes and improvements Andrew Burgess
2024-05-31  8:18   ` [PATCHv2 1/5] gdb/doc: don't try to copy GDBvn.texi from the source tree Andrew Burgess
2024-05-31  8:18   ` Andrew Burgess [this message]
2024-05-31 10:40     ` [PATCHv2 2/5] gdb/doc: allow for version.subst in " Eli Zaretskii
2024-06-03 14:22       ` Andrew Burgess
2024-06-06 11:59         ` Eli Zaretskii
2024-06-06 17:52           ` Andrew Burgess
2024-05-31  8:18   ` [PATCHv2 3/5] gdb/doc: also look in srcdir when running TEXI2POD Andrew Burgess
2024-05-31  8:18   ` [PATCHv2 4/5] gdb/doc: fix parallel build of refcard related targets Andrew Burgess
2024-05-31  8:18   ` [PATCHv2 5/5] gdb/doc: fix parallel build of pdf and dvi files Andrew Burgess
2024-06-06 17:49   ` [PATCHv3 0/6] gdb/doc: parallel build fixes and improvements Andrew Burgess
2024-06-06 17:49     ` [PATCHv3 1/6] gdb/doc: don't try to copy GDBvn.texi from the source tree Andrew Burgess
2024-06-14 18:45       ` Pedro Alves
2024-06-06 17:49     ` [PATCHv3 2/6] gdb/doc: merge rules for building .1 and .5 man pages Andrew Burgess
2024-06-06 17:49     ` [PATCHv3 3/6] gdb/doc: allow for version.subst in the source tree Andrew Burgess
2024-06-14 18:44       ` Pedro Alves
2024-06-06 17:49     ` [PATCHv3 4/6] gdb/doc: also look in srcdir when running TEXI2POD Andrew Burgess
2024-06-06 17:49     ` [PATCHv3 5/6] gdb/doc: fix parallel build of refcard related targets Andrew Burgess
2024-06-06 17:49     ` [PATCHv3 6/6] gdb/doc: fix parallel build of pdf and dvi files Andrew Burgess
2024-06-14 19:00       ` Pedro Alves
2024-06-15  9:44         ` Andrew Burgess
2024-06-15 12:40           ` Eli Zaretskii
2024-06-15 14:59             ` Andrew Burgess
2024-06-15 15:04             ` Andrew Burgess
2024-06-21 15:35               ` Pedro Alves
2024-06-24 11:16                 ` Andrew Burgess
2024-06-25 13:39               ` Andrew Burgess
2024-06-14 18:14     ` [PATCHv3 0/6] gdb/doc: parallel build fixes and improvements Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7d24d630fb96976deb225f1098df2b32e72643bd.1717142725.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).