bfd: add version check to makeinfo

Message ID OS3P286MB2152D2B8F88B6EB24B91BD8BF0939@OS3P286MB2152.JPNP286.PROD.OUTLOOK.COM
State Accepted
Headers
Series bfd: add version check to makeinfo |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

Enze Li April 4, 2023, 3:07 p.m. UTC
  In this commit,

  commit 8bb23cdbb498ff645bb0937bc8c0cb89e9e5ebd8
  Date:   Tue Feb 7 11:34:56 2023 -0700

    Simplify @node use in BFD documentation

we use a modern style available from makeinfo 5.0 or later.

This patch adds a check for makeinfo that no documentation will be
generated if it is below the specified version.

The motivation for this work comes from the fact that compiling GDB on
the latest version of NetBSD(9.3) produces the following errors because
it comes with makeinfo 4.8.  This patch workaround this issus.

======
  MAKEINFO doc/bfd.info
doc/bfd.texi:245: Node `Sections' requires a sectioning command (e.g., @unnumberedsubsec).
doc/bfd.texi:248: Node `Symbols' requires a sectioning command (e.g., @unnumberedsubsubsec).
doc/bfd.texi:251: Node `Archives' requires a sectioning command (e.g., @unnumberedsubsubsec).
doc/bfd.texi:254: Node `Formats' requires a sectioning command (e.g., @unnumberedsubsubsec).
doc/bfd.texi:257: Node `Relocations' requires a sectioning command (e.g., @unnumberedsubsubsec).
doc/bfd.texi:260: Node `Core Files' requires a sectioning command (e.g., @unnumberedsubsubsec).
doc/bfd.texi:263: Node `Targets' requires a sectioning command (e.g., @unnumberedsubsubsec).
doc/bfd.texi:266: Node `Architectures' requires a sectioning command (e.g., @unnumberedsubsubsec).
...
======

bfd/ChangeLog:

        * Makefile.in: Regenerated.
        * configure: Likewise.
        * configure.ac: Add check functions, etc.
        * doc/local.mk: Add the judgment of whether to generate document
          or not.
---
 bfd/Makefile.in  | 259 ++++++++++++++++++++++++-----------------------
 bfd/configure    |  85 +++++++++++++++-
 bfd/configure.ac |  24 +++++
 bfd/doc/local.mk |  10 ++
 4 files changed, 251 insertions(+), 127 deletions(-)


base-commit: 02d44d76584e4d483fe0fc677c12066ec23d67f4
  

Comments

Eli Zaretskii April 4, 2023, 3:24 p.m. UTC | #1
> Cc: gdb-patches@sourceware.org,
> 	enze.li@gmx.com
> Date: Tue,  4 Apr 2023 23:07:13 +0800
> From: Enze Li via Gdb-patches <gdb-patches@sourceware.org>
> 
> In this commit,
> 
>   commit 8bb23cdbb498ff645bb0937bc8c0cb89e9e5ebd8
>   Date:   Tue Feb 7 11:34:56 2023 -0700
> 
>     Simplify @node use in BFD documentation
> 
> we use a modern style available from makeinfo 5.0 or later.
> 
> This patch adds a check for makeinfo that no documentation will be
> generated if it is below the specified version.
> 
> The motivation for this work comes from the fact that compiling GDB on
> the latest version of NetBSD(9.3) produces the following errors because
> it comes with makeinfo 4.8.  This patch workaround this issus.

Some people still use makeinfo 4.x because it's at least an order of
magnitude faster than version 5 and later.  For such simple problems,
wouldn't it be better to add the missing sectioning commands, and let
those users of makeinfo 4.x keep using it?

Just asking.
  
Enze Li April 6, 2023, 3 p.m. UTC | #2
On Tue, 2023-04-04 at 11:24 -0400, Eli Zaretskii wrote:
> > Cc: gdb-patches@sourceware.org,
> >         enze.li@gmx.com
> > Date: Tue,  4 Apr 2023 23:07:13 +0800
> > From: Enze Li via Gdb-patches <gdb-patches@sourceware.org>
> > 
> > In this commit,
> > 
> >   commit 8bb23cdbb498ff645bb0937bc8c0cb89e9e5ebd8
> >   Date:   Tue Feb 7 11:34:56 2023 -0700
> > 
> >     Simplify @node use in BFD documentation
> > 
> > we use a modern style available from makeinfo 5.0 or later.
> > 
> > This patch adds a check for makeinfo that no documentation will be
> > generated if it is below the specified version.
> > 
> > The motivation for this work comes from the fact that compiling GDB
> > on
> > the latest version of NetBSD(9.3) produces the following errors
> > because
> > it comes with makeinfo 4.8.  This patch workaround this issus.
> 
> Some people still use makeinfo 4.x because it's at least an order of
> magnitude faster than version 5 and later.  For such simple problems,
> wouldn't it be better to add the missing sectioning commands, and let
> those users of makeinfo 4.x keep using it?

Yeah, that's an easy way out.  I'll send another patch shortly.

BTW, I found the thread[1] where this was discussed a month ago and it
seems that both approaches are possible.

> 
> Just asking.

[1]
https://inbox.sourceware.org/binutils/8392b8ac-2447-2721-706b-aae4c3021404@suse.com/

Thanks,
Enze
  
Eli Zaretskii April 6, 2023, 3:38 p.m. UTC | #3
> From: Enze Li <enze.li@hotmail.com>
> Cc: binutils@sourceware.org, gdb-patches@sourceware.org, enze.li@gmx.com, 
> 	jbeulich@suse.com, tom@tromey.com
> Date: Thu, 06 Apr 2023 23:00:38 +0800
> 
> On Tue, 2023-04-04 at 11:24 -0400, Eli Zaretskii wrote:
> > Some people still use makeinfo 4.x because it's at least an order of
> > magnitude faster than version 5 and later.  For such simple problems,
> > wouldn't it be better to add the missing sectioning commands, and let
> > those users of makeinfo 4.x keep using it?
> 
> Yeah, that's an easy way out.  I'll send another patch shortly.
> 
> BTW, I found the thread[1] where this was discussed a month ago and it
> seems that both approaches are possible.

I was just expressing my opinion.  I don't have the authority to make
the decision that this should be what Binutils does.
  

Patch

diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 5be3d1b6e9f1..633805214c0f 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -110,6 +110,10 @@  host_triplet = @host@
 target_triplet = @target@
 @INSTALL_LIBBFD_FALSE@am__append_1 = -rpath $(rpath_bfdlibdir)
 @PLUGINS_TRUE@am__append_2 = $(INCDIR)/plugin-api.h
+TEXI2DVI = texi2dvi
+@BUILD_INFO_TRUE@am__append_3 = $(MKDOC) doc/*.o doc/*.stamp
+@BUILD_INFO_TRUE@am__append_4 = doc/bfd.?? doc/bfd.??? texput.log
+@BUILD_INFO_TRUE@am__append_5 = $(DOCFILES) doc/bfd.info
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
@@ -259,7 +263,7 @@  DVIS = doc/bfd.dvi
 PDFS = doc/bfd.pdf
 PSS = doc/bfd.ps
 HTMLS = doc/bfd.html
-TEXINFOS = doc/bfd.texi
+TEXINFOS =
 TEXI2PDF = $(TEXI2DVI) --pdf --batch
 MAKEINFOHTML = $(MAKEINFO) --html
 AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS)
@@ -488,12 +492,12 @@  zlibdir = @zlibdir@
 zlibinc = @zlibinc@
 AUTOMAKE_OPTIONS = no-dist foreign info-in-builddir no-texinfo.tex
 ACLOCAL_AMFLAGS = -I . -I .. -I ../config
-MOSTLYCLEANFILES = ofiles stamp-ofiles $(MKDOC) doc/*.o doc/*.stamp
+MOSTLYCLEANFILES = ofiles stamp-ofiles $(am__append_3)
 CLEANFILES = bfd.h dep.sed stmp-bfd-h DEP DEPA DEP1 DEP2 stmp-bin2-h \
 	stmp-lbfd-h stmp-lcoff-h
 DISTCLEANFILES = $(BUILD_CFILES) $(BUILD_HFILES) libtool-soversion \
-	doc/bfd.?? doc/bfd.??? texput.log
-MAINTAINERCLEANFILES = $(DOCFILES) doc/bfd.info
+	$(am__append_4)
+MAINTAINERCLEANFILES = $(am__append_5)
 INCDIR = $(srcdir)/../include
 CSEARCH = -I. -I$(srcdir) -I$(INCDIR)
 SUBDIRS = po
@@ -1228,66 +1232,66 @@  REGEN_HEADER = \
 	echo "\#endif"; \
 	)
 
-DOCFILES = \
-	doc/aoutx.texi \
-	doc/archive.texi \
-	doc/archures.texi \
-	doc/bfdio.texi \
-	doc/bfdt.texi \
-	doc/bfdver.texi \
-	doc/bfdwin.texi \
-	doc/cache.texi \
-	doc/coffcode.texi \
-	doc/corefile.texi \
-	doc/elfcode.texi \
-	doc/elf.texi \
-	doc/format.texi \
-	doc/hash.texi \
-	doc/libbfd.texi \
-	doc/linker.texi \
-	doc/mmo.texi \
-	doc/opncls.texi \
-	doc/reloc.texi \
-	doc/section.texi \
-	doc/syms.texi \
-	doc/targets.texi
+@BUILD_INFO_TRUE@DOCFILES = \
+@BUILD_INFO_TRUE@	doc/aoutx.texi \
+@BUILD_INFO_TRUE@	doc/archive.texi \
+@BUILD_INFO_TRUE@	doc/archures.texi \
+@BUILD_INFO_TRUE@	doc/bfdio.texi \
+@BUILD_INFO_TRUE@	doc/bfdt.texi \
+@BUILD_INFO_TRUE@	doc/bfdver.texi \
+@BUILD_INFO_TRUE@	doc/bfdwin.texi \
+@BUILD_INFO_TRUE@	doc/cache.texi \
+@BUILD_INFO_TRUE@	doc/coffcode.texi \
+@BUILD_INFO_TRUE@	doc/corefile.texi \
+@BUILD_INFO_TRUE@	doc/elfcode.texi \
+@BUILD_INFO_TRUE@	doc/elf.texi \
+@BUILD_INFO_TRUE@	doc/format.texi \
+@BUILD_INFO_TRUE@	doc/hash.texi \
+@BUILD_INFO_TRUE@	doc/libbfd.texi \
+@BUILD_INFO_TRUE@	doc/linker.texi \
+@BUILD_INFO_TRUE@	doc/mmo.texi \
+@BUILD_INFO_TRUE@	doc/opncls.texi \
+@BUILD_INFO_TRUE@	doc/reloc.texi \
+@BUILD_INFO_TRUE@	doc/section.texi \
+@BUILD_INFO_TRUE@	doc/syms.texi \
+@BUILD_INFO_TRUE@	doc/targets.texi
 
 
 # SRCDOC, SRCPROT, SRCIPROT only used to sidestep Sun Make bug in interaction
 # between VPATH and suffix rules.  If you use GNU Make, perhaps other Makes,
 # you don't need these three:
-SRCDOC = \
-	$(srcdir)/aoutx.h $(srcdir)/archive.c \
-	$(srcdir)/archures.c $(srcdir)/bfd.c \
-	$(srcdir)/bfdio.c $(srcdir)/bfdwin.c \
-	$(srcdir)/cache.c $(srcdir)/coffcode.h \
-	$(srcdir)/corefile.c $(srcdir)/elf.c \
-	$(srcdir)/elfcode.h $(srcdir)/format.c \
-	$(srcdir)/libbfd.c $(srcdir)/opncls.c \
-	$(srcdir)/reloc.c $(srcdir)/section.c \
-	$(srcdir)/syms.c $(srcdir)/targets.c \
-	$(srcdir)/hash.c $(srcdir)/linker.c \
-	$(srcdir)/mmo.c
-
-SRCPROT = $(srcdir)/archive.c $(srcdir)/archures.c \
-	$(srcdir)/bfd.c $(srcdir)/coffcode.h $(srcdir)/corefile.c \
-	$(srcdir)/format.c $(srcdir)/libbfd.c \
-	$(srcdir)/bfdio.c $(srcdir)/bfdwin.c \
-	$(srcdir)/opncls.c $(srcdir)/reloc.c \
-	$(srcdir)/section.c $(srcdir)/syms.c \
-	$(srcdir)/targets.c
-
-SRCIPROT = $(srcdir)/cache.c $(srcdir)/libbfd.c \
-	$(srcdir)/bfdio.c $(srcdir)/bfdwin.c \
-	$(srcdir)/reloc.c $(srcdir)/cpu-h8300.c \
-	$(srcdir)/archures.c
-
-TEXIDIR = $(srcdir)/../texinfo/fsf
-info_TEXINFOS = doc/bfd.texi
-doc_bfd_TEXINFOS = $(DOCFILES) doc/bfdsumm.texi
-AM_MAKEINFOFLAGS = --no-split -I "$(srcdir)/doc" -I doc
-TEXI2DVI = texi2dvi -I "$(srcdir)/doc" -I doc
-MKDOC = doc/chew$(EXEEXT_FOR_BUILD)
+@BUILD_INFO_TRUE@SRCDOC = \
+@BUILD_INFO_TRUE@	$(srcdir)/aoutx.h $(srcdir)/archive.c \
+@BUILD_INFO_TRUE@	$(srcdir)/archures.c $(srcdir)/bfd.c \
+@BUILD_INFO_TRUE@	$(srcdir)/bfdio.c $(srcdir)/bfdwin.c \
+@BUILD_INFO_TRUE@	$(srcdir)/cache.c $(srcdir)/coffcode.h \
+@BUILD_INFO_TRUE@	$(srcdir)/corefile.c $(srcdir)/elf.c \
+@BUILD_INFO_TRUE@	$(srcdir)/elfcode.h $(srcdir)/format.c \
+@BUILD_INFO_TRUE@	$(srcdir)/libbfd.c $(srcdir)/opncls.c \
+@BUILD_INFO_TRUE@	$(srcdir)/reloc.c $(srcdir)/section.c \
+@BUILD_INFO_TRUE@	$(srcdir)/syms.c $(srcdir)/targets.c \
+@BUILD_INFO_TRUE@	$(srcdir)/hash.c $(srcdir)/linker.c \
+@BUILD_INFO_TRUE@	$(srcdir)/mmo.c
+
+@BUILD_INFO_TRUE@SRCPROT = $(srcdir)/archive.c $(srcdir)/archures.c \
+@BUILD_INFO_TRUE@	$(srcdir)/bfd.c $(srcdir)/coffcode.h $(srcdir)/corefile.c \
+@BUILD_INFO_TRUE@	$(srcdir)/format.c $(srcdir)/libbfd.c \
+@BUILD_INFO_TRUE@	$(srcdir)/bfdio.c $(srcdir)/bfdwin.c \
+@BUILD_INFO_TRUE@	$(srcdir)/opncls.c $(srcdir)/reloc.c \
+@BUILD_INFO_TRUE@	$(srcdir)/section.c $(srcdir)/syms.c \
+@BUILD_INFO_TRUE@	$(srcdir)/targets.c
+
+@BUILD_INFO_TRUE@SRCIPROT = $(srcdir)/cache.c $(srcdir)/libbfd.c \
+@BUILD_INFO_TRUE@	$(srcdir)/bfdio.c $(srcdir)/bfdwin.c \
+@BUILD_INFO_TRUE@	$(srcdir)/reloc.c $(srcdir)/cpu-h8300.c \
+@BUILD_INFO_TRUE@	$(srcdir)/archures.c
+
+@BUILD_INFO_TRUE@TEXIDIR = $(srcdir)/../texinfo/fsf
+@BUILD_INFO_TRUE@info_TEXINFOS = doc/bfd.texi
+@BUILD_INFO_TRUE@doc_bfd_TEXINFOS = $(DOCFILES) doc/bfdsumm.texi
+@BUILD_INFO_TRUE@AM_MAKEINFOFLAGS = --no-split -I "$(srcdir)/doc" -I doc
+@BUILD_INFO_TRUE@TEXI2DVI = texi2dvi -I "$(srcdir)/doc" -I doc
+@BUILD_INFO_TRUE@MKDOC = doc/chew$(EXEEXT_FOR_BUILD)
 
 # We can't replace these rules with an implicit rule, because
 # makes without VPATH support couldn't find the .h files in `..'.
@@ -1296,18 +1300,18 @@  MKDOC = doc/chew$(EXEEXT_FOR_BUILD)
 # files, and permit people to rebuild them, without requiring the makeinfo
 # program.  If somebody tries to rebuild info, but none of the .texi files
 # have changed, then nothing will be rebuilt.
-REGEN_TEXI = \
-	( \
-	set -e; \
-	$(MKDOC) -f $(srcdir)/doc/doc.str < $< > $@.tmp; \
-	texi=$@; \
-	texi=$${texi%.stamp}.texi; \
-	test -e $$texi || test ! -f $(srcdir)/$$texi || $(LN_S) $(srcdir)/$$texi .; \
-	$(SHELL) $(srcdir)/../move-if-change $@.tmp $$texi; \
-	touch $@; \
-	)
-
-noinst_TEXINFOS = doc/bfdint.texi
+@BUILD_INFO_TRUE@REGEN_TEXI = \
+@BUILD_INFO_TRUE@	( \
+@BUILD_INFO_TRUE@	set -e; \
+@BUILD_INFO_TRUE@	$(MKDOC) -f $(srcdir)/doc/doc.str < $< > $@.tmp; \
+@BUILD_INFO_TRUE@	texi=$@; \
+@BUILD_INFO_TRUE@	texi=$${texi%.stamp}.texi; \
+@BUILD_INFO_TRUE@	test -e $$texi || test ! -f $(srcdir)/$$texi || $(LN_S) $(srcdir)/$$texi .; \
+@BUILD_INFO_TRUE@	$(SHELL) $(srcdir)/../move-if-change $@.tmp $$texi; \
+@BUILD_INFO_TRUE@	touch $@; \
+@BUILD_INFO_TRUE@	)
+
+@BUILD_INFO_TRUE@noinst_TEXINFOS = doc/bfdint.texi
 all: $(BUILT_SOURCES) config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
@@ -1758,24 +1762,24 @@  doc/$(am__dirstamp):
 	@$(MKDIR_P) doc
 	@: > doc/$(am__dirstamp)
 
-doc/bfd.info: doc/bfd.texi $(doc_bfd_TEXINFOS)
-	@test -f doc/$(am__dirstamp) || $(MAKE) $(AM_MAKEFLAGS) doc/$(am__dirstamp)
-	$(AM_V_MAKEINFO)restore=: && backupdir="$(am__leading_dot)am$$$$" && \
-	rm -rf $$backupdir && mkdir $$backupdir && \
-	if ($(MAKEINFO) --version) >/dev/null 2>&1; then \
-	  for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
-	    if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \
-	  done; \
-	else :; fi && \
-	if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
-	 -o $@ `test -f 'doc/bfd.texi' || echo '$(srcdir)/'`doc/bfd.texi; \
-	then \
-	  rc=0; \
-	else \
-	  rc=$$?; \
-	  $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
-	fi; \
-	rm -rf $$backupdir; exit $$rc
+@BUILD_INFO_TRUE@doc/bfd.info: doc/bfd.texi $(doc_bfd_TEXINFOS)
+@BUILD_INFO_TRUE@	@test -f doc/$(am__dirstamp) || $(MAKE) $(AM_MAKEFLAGS) doc/$(am__dirstamp)
+@BUILD_INFO_TRUE@	$(AM_V_MAKEINFO)restore=: && backupdir="$(am__leading_dot)am$$$$" && \
+@BUILD_INFO_TRUE@	rm -rf $$backupdir && mkdir $$backupdir && \
+@BUILD_INFO_TRUE@	if ($(MAKEINFO) --version) >/dev/null 2>&1; then \
+@BUILD_INFO_TRUE@	  for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
+@BUILD_INFO_TRUE@	    if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \
+@BUILD_INFO_TRUE@	  done; \
+@BUILD_INFO_TRUE@	else :; fi && \
+@BUILD_INFO_TRUE@	if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
+@BUILD_INFO_TRUE@	 -o $@ `test -f 'doc/bfd.texi' || echo '$(srcdir)/'`doc/bfd.texi; \
+@BUILD_INFO_TRUE@	then \
+@BUILD_INFO_TRUE@	  rc=0; \
+@BUILD_INFO_TRUE@	else \
+@BUILD_INFO_TRUE@	  rc=$$?; \
+@BUILD_INFO_TRUE@	  $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
+@BUILD_INFO_TRUE@	fi; \
+@BUILD_INFO_TRUE@	rm -rf $$backupdir; exit $$rc
 
 doc/bfd.dvi: doc/bfd.texi $(doc_bfd_TEXINFOS) doc/$(am__dirstamp)
 	$(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
@@ -2064,6 +2068,7 @@  maintainer-clean-generic:
 	@echo "it deletes files that may require special tools to rebuild."
 	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
 	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+@BUILD_INFO_FALSE@html-local:
 clean: clean-recursive
 
 clean-am: clean-aminfo clean-bfdlibLTLIBRARIES clean-generic \
@@ -2457,48 +2462,52 @@  coff-tic54x.lo: coff-tic54x.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC)$(LTCOMPILE) -c -o $@ $< $(NO_WERROR)
 
-$(MKDOC): doc/chew.stamp ; @true
-doc/chew.stamp: $(srcdir)/doc/chew.c doc/$(am__dirstamp)
-	$(AM_V_CCLD)$(CC_FOR_BUILD) -o doc/chw$$$$$(EXEEXT_FOR_BUILD) $(CFLAGS_FOR_BUILD) \
-	  $(LDFLAGS_FOR_BUILD) \
-	  -I. -I$(srcdir) -Idoc -I$(srcdir)/../include -I$(srcdir)/../intl -I../intl \
-	  $(srcdir)/doc/chew.c && \
-	$(SHELL) $(srcdir)/../move-if-change \
-	  doc/chw$$$$$(EXEEXT_FOR_BUILD) $(MKDOC) && \
-	touch $@
-
-.PRECIOUS: doc/%.stamp
-doc/%.texi: doc/%.stamp ; @true
-doc/%.stamp: $(srcdir)/%.h $(srcdir)/doc/doc.str $(MKDOC) doc/$(am__dirstamp)
-	$(AM_V_GEN)$(REGEN_TEXI)
-doc/%.stamp: $(srcdir)/%.c $(srcdir)/doc/doc.str $(MKDOC) doc/$(am__dirstamp)
-	$(AM_V_GEN)$(REGEN_TEXI)
+@BUILD_INFO_TRUE@$(MKDOC): doc/chew.stamp ; @true
+@BUILD_INFO_TRUE@doc/chew.stamp: $(srcdir)/doc/chew.c doc/$(am__dirstamp)
+@BUILD_INFO_TRUE@	$(AM_V_CCLD)$(CC_FOR_BUILD) -o doc/chw$$$$$(EXEEXT_FOR_BUILD) $(CFLAGS_FOR_BUILD) \
+@BUILD_INFO_TRUE@	  $(LDFLAGS_FOR_BUILD) \
+@BUILD_INFO_TRUE@	  -I. -I$(srcdir) -Idoc -I$(srcdir)/../include -I$(srcdir)/../intl -I../intl \
+@BUILD_INFO_TRUE@	  $(srcdir)/doc/chew.c && \
+@BUILD_INFO_TRUE@	$(SHELL) $(srcdir)/../move-if-change \
+@BUILD_INFO_TRUE@	  doc/chw$$$$$(EXEEXT_FOR_BUILD) $(MKDOC) && \
+@BUILD_INFO_TRUE@	touch $@
+
+@BUILD_INFO_TRUE@.PRECIOUS: doc/%.stamp
+@BUILD_INFO_TRUE@doc/%.texi: doc/%.stamp ; @true
+@BUILD_INFO_TRUE@doc/%.stamp: $(srcdir)/%.h $(srcdir)/doc/doc.str $(MKDOC) doc/$(am__dirstamp)
+@BUILD_INFO_TRUE@	$(AM_V_GEN)$(REGEN_TEXI)
+@BUILD_INFO_TRUE@doc/%.stamp: $(srcdir)/%.c $(srcdir)/doc/doc.str $(MKDOC) doc/$(am__dirstamp)
+@BUILD_INFO_TRUE@	$(AM_V_GEN)$(REGEN_TEXI)
 
 # Avoid the %.stamp generating a builddir/bfd.texi that overrides the
 # srcdir/ as well as regenerating doc/bfd.info for each make run.
-doc/bfd.stamp: $(srcdir)/doc/bfd.texi ; $(AM_V_at)touch $@
+@BUILD_INFO_TRUE@doc/bfd.stamp: $(srcdir)/doc/bfd.texi ; $(AM_V_at)touch $@
 
 # We use bfdt.texi, rather than bfd.texi, to avoid conflicting with
 # bfd.texi on an 8.3 filesystem.
-doc/bfdt.stamp: $(srcdir)/bfd.c $(srcdir)/doc/doc.str $(MKDOC) doc/$(am__dirstamp)
-	$(AM_V_GEN)$(REGEN_TEXI)
-
-doc/bfdver.texi: $(srcdir)/Makefile.in
-	$(AM_V_GEN)\
-	$(MKDIR_P) $(@D); \
-	echo "@set VERSION $(VERSION)" > $@; \
-	if test -n "$(PKGVERSION)"; then \
-	  echo "@set VERSION_PACKAGE $(PKGVERSION)" >> $@; \
-	fi; \
-	echo "@set UPDATED `date '+%B %Y'`" >> $@; \
-	if test -n "$(REPORT_BUGS_TEXI)"; then \
-	  echo "@set BUGURL $(REPORT_BUGS_TEXI)" >> $@; \
-	fi
-
-html-local: doc/bfd/index.html
-doc/bfd/index.html: doc/bfd.texi $(bfd_TEXINFOS) doc/$(am__dirstamp)
-	$(AM_V_at)$(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) \
-	  --split=node -o doc/bfd $(srcdir)/doc/bfd.texi
+@BUILD_INFO_TRUE@doc/bfdt.stamp: $(srcdir)/bfd.c $(srcdir)/doc/doc.str $(MKDOC) doc/$(am__dirstamp)
+@BUILD_INFO_TRUE@	$(AM_V_GEN)$(REGEN_TEXI)
+
+@BUILD_INFO_TRUE@doc/bfdver.texi: $(srcdir)/Makefile.in
+@BUILD_INFO_TRUE@	$(AM_V_GEN)\
+@BUILD_INFO_TRUE@	$(MKDIR_P) $(@D); \
+@BUILD_INFO_TRUE@	echo "@set VERSION $(VERSION)" > $@; \
+@BUILD_INFO_TRUE@	if test -n "$(PKGVERSION)"; then \
+@BUILD_INFO_TRUE@	  echo "@set VERSION_PACKAGE $(PKGVERSION)" >> $@; \
+@BUILD_INFO_TRUE@	fi; \
+@BUILD_INFO_TRUE@	echo "@set UPDATED `date '+%B %Y'`" >> $@; \
+@BUILD_INFO_TRUE@	if test -n "$(REPORT_BUGS_TEXI)"; then \
+@BUILD_INFO_TRUE@	  echo "@set BUGURL $(REPORT_BUGS_TEXI)" >> $@; \
+@BUILD_INFO_TRUE@	fi
+
+@BUILD_INFO_TRUE@html-local: doc/bfd/index.html
+@BUILD_INFO_TRUE@doc/bfd/index.html: doc/bfd.texi $(bfd_TEXINFOS) doc/$(am__dirstamp)
+@BUILD_INFO_TRUE@	$(AM_V_at)$(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) \
+@BUILD_INFO_TRUE@	  --split=node -o doc/bfd $(srcdir)/doc/bfd.texi
+
+# Workaround bug in automake: it can't handle conditionally building info pages
+# since GNU projects normally include info pages in the source distributions.
+@BUILD_INFO_FALSE@doc/bfd.info:
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/bfd/configure b/bfd/configure
index 41d280ef461d..e2377e8b80b7 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -651,6 +651,8 @@  wordsize
 TDEFINES
 SHARED_LIBADD
 SHARED_LDFLAGS
+BUILD_INFO_FALSE
+BUILD_INFO_TRUE
 LIBM
 ZSTD_LIBS
 ZSTD_CFLAGS
@@ -11106,7 +11108,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11109 "configure"
+#line 11111 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11212,7 +11214,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11215 "configure"
+#line 11217 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13697,6 +13699,81 @@  esac
 
 
 
+build_info=
+makeinfo_too_old=
+for ac_prog in makeinfo
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_MAKEINFO+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$MAKEINFO"; then
+  ac_cv_prog_MAKEINFO="$MAKEINFO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_MAKEINFO="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+MAKEINFO=$ac_cv_prog_MAKEINFO
+if test -n "$MAKEINFO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKEINFO" >&5
+$as_echo "$MAKEINFO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$MAKEINFO" && break
+done
+test -n "$MAKEINFO" || MAKEINFO="$MISSING makeinfo"
+
+case " $build_configdirs " in
+  *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+esac
+
+    # We require texinfo to be 5.0 or later, otherwise we fall back
+    # to /bin/true.
+    if ${MAKEINFO} --version \
+       | egrep 'texinfo[^0-9]*([5-9]|[1-9][0-9]\.)' >/dev/null 2>&1; then
+      build_info=yes
+    else
+      build_info=
+      makeinfo_too_old=t
+    fi
+
+if test -n "$makeinfo_too_old"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
+*** Makeinfo is too old. Info documentation for BFD will not be built." >&5
+$as_echo "$as_me: WARNING:
+*** Makeinfo is too old. Info documentation for BFD will not be built." >&2;}
+fi
+
+ if test "${build_info}" = yes; then
+  BUILD_INFO_TRUE=
+  BUILD_INFO_FALSE='#'
+else
+  BUILD_INFO_TRUE='#'
+  BUILD_INFO_FALSE=
+fi
+
+
 # When building a shared libbfd, link against the pic version of libiberty
 # so that apps that use libbfd won't need libiberty just to satisfy any
 # libbfd references.
@@ -15706,6 +15783,10 @@  if test -z "${INSTALL_LIBBFD_TRUE}" && test -z "${INSTALL_LIBBFD_FALSE}"; then
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
 
+if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then
+  as_fn_error $? "conditional \"BUILD_INFO\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
diff --git a/bfd/configure.ac b/bfd/configure.ac
index f044616f4d97..f761d0632215 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -262,6 +262,30 @@  AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
 
 LT_LIB_M
 
+build_info=
+makeinfo_too_old=
+AC_CHECK_PROGS([MAKEINFO], makeinfo, [$MISSING makeinfo])
+case " $build_configdirs " in
+  *" texinfo "*) MAKEINFO='$$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo' ;;
+esac
+changequote(,)
+    # We require texinfo to be 5.0 or later, otherwise we fall back
+    # to /bin/true.
+    if ${MAKEINFO} --version \
+       | egrep 'texinfo[^0-9]*([5-9]|[1-9][0-9]\.)' >/dev/null 2>&1; then
+      build_info=yes
+    else
+      build_info=
+      makeinfo_too_old=t
+    fi
+changequote([,])
+if test -n "$makeinfo_too_old"; then
+    AC_MSG_WARN([
+*** Makeinfo is too old. Info documentation for BFD will not be built.])
+fi
+AC_SUBST(MAKEINFO)
+AM_CONDITIONAL(BUILD_INFO, test "${build_info}" = yes)
+
 # When building a shared libbfd, link against the pic version of libiberty
 # so that apps that use libbfd won't need libiberty just to satisfy any
 # libbfd references.
diff --git a/bfd/doc/local.mk b/bfd/doc/local.mk
index d80f70416a3f..fca382851f2d 100644
--- a/bfd/doc/local.mk
+++ b/bfd/doc/local.mk
@@ -17,6 +17,8 @@ 
 ## <http://www.gnu.org/licenses/>.
 ##
 
+if BUILD_INFO
+
 DOCFILES = \
 	%D%/aoutx.texi \
 	%D%/archive.texi \
@@ -151,3 +153,11 @@  html-local: %D%/bfd/index.html
 	  --split=node -o %D%/bfd $(srcdir)/%D%/bfd.texi
 
 MAINTAINERCLEANFILES += %D%/bfd.info
+
+else
+
+# Workaround bug in automake: it can't handle conditionally building info pages
+# since GNU projects normally include info pages in the source distributions.
+%D%/bfd.info:
+
+endif