ubsan: som.c undefined shift in som_set_reloc_info
[binutils-gdb.git] / bfd / Makefile.am
index 2626ceb0a5933a1f828c96243dacbfce638be3cf..670e0598f55f29f3d5db4ffa18e40dcbc390f977 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to generate Makefile.in
 #
-#   Copyright (C) 2012-2018 Free Software Foundation, Inc.
+#   Copyright (C) 2012-2022 Free Software Foundation, Inc.
 #
 # This file is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # <http://www.gnu.org/licenses/>.
 #
 
-AUTOMAKE_OPTIONS = no-dist foreign
+AUTOMAKE_OPTIONS = no-dist foreign info-in-builddir no-texinfo.tex
 ACLOCAL_AMFLAGS = -I . -I .. -I ../config
 
+MOSTLYCLEANFILES =
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+
 INCDIR = $(srcdir)/../include
 CSEARCH = -I. -I$(srcdir) -I$(INCDIR)
 
-SUBDIRS = doc po
+SUBDIRS = po
 
 bfddocdir = doc
 
@@ -33,7 +38,7 @@ bfdlibdir = @bfdlibdir@
 bfdincludedir = @bfdincludedir@
 bfdlib_LTLIBRARIES = libbfd.la
 bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \
-                    $(INCDIR)/bfdlink.h $(INCDIR)/diagnostics.h
+                    $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h
 else !INSTALL_LIBBFD
 # Empty these so that the respective installation directories will not be created.
 bfdlibdir =
@@ -53,7 +58,7 @@ ZLIBINC = @zlibinc@
 WARN_CFLAGS = @WARN_CFLAGS@
 NO_WERROR = @NO_WERROR@
 AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
-AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
+AM_CPPFLAGS = -DBINDIR='"$(bindir)"' -DLIBDIR='"$(libdir)"' @LARGEFILE_CPPFLAGS@
 if PLUGINS
 bfdinclude_HEADERS += $(INCDIR)/plugin-api.h
 LIBDL = @lt_cv_dlopen_libs@
@@ -92,12 +97,13 @@ BFD64_LIBS_CFILES = archive64.c
 ALL_MACHINES = \
        cpu-aarch64.lo \
        cpu-alpha.lo \
+       cpu-amdgcn.lo \
        cpu-arc.lo \
        cpu-arm.lo \
        cpu-avr.lo \
        cpu-bfin.lo \
+       cpu-bpf.lo \
        cpu-cr16.lo \
-       cpu-cr16c.lo \
        cpu-cris.lo \
        cpu-crx.lo \
        cpu-csky.lo \
@@ -112,12 +118,11 @@ ALL_MACHINES = \
        cpu-hppa.lo \
        cpu-i386.lo \
        cpu-iamcu.lo \
-       cpu-l1om.lo \
-       cpu-k1om.lo \
        cpu-ia64.lo \
        cpu-ip2k.lo \
        cpu-iq2000.lo \
        cpu-lm32.lo \
+       cpu-loongarch.lo \
        cpu-m10200.lo \
        cpu-m10300.lo \
        cpu-m32c.lo \
@@ -144,7 +149,6 @@ ALL_MACHINES = \
        cpu-or1k.lo \
        cpu-pdp11.lo \
        cpu-pj.lo \
-       cpu-plugin.lo \
        cpu-powerpc.lo \
        cpu-pru.lo \
        cpu-rs6000.lo \
@@ -160,7 +164,6 @@ ALL_MACHINES = \
        cpu-tic4x.lo \
        cpu-tic54x.lo \
        cpu-tic6x.lo \
-       cpu-tic80.lo \
        cpu-tilegx.lo \
        cpu-tilepro.lo \
        cpu-v850.lo \
@@ -168,7 +171,6 @@ ALL_MACHINES = \
        cpu-vax.lo \
        cpu-visium.lo \
        cpu-wasm32.lo \
-       cpu-xc16x.lo \
        cpu-xgate.lo \
        cpu-xstormy16.lo \
        cpu-xtensa.lo \
@@ -178,12 +180,13 @@ ALL_MACHINES = \
 ALL_MACHINES_CFILES = \
        cpu-aarch64.c \
        cpu-alpha.c \
+       cpu-amdgcn.c \
        cpu-arc.c \
        cpu-arm.c \
        cpu-avr.c \
        cpu-bfin.c \
+       cpu-bpf.c \
        cpu-cr16.c \
-       cpu-cr16c.c \
        cpu-cris.c \
        cpu-crx.c \
        cpu-csky.c \
@@ -198,12 +201,11 @@ ALL_MACHINES_CFILES = \
        cpu-hppa.c \
        cpu-i386.c \
        cpu-iamcu.c \
-       cpu-l1om.c \
-       cpu-k1om.c \
        cpu-ia64.c \
        cpu-ip2k.c \
        cpu-iq2000.c \
        cpu-lm32.c \
+       cpu-loongarch.c \
        cpu-m10200.c \
        cpu-m10300.c \
        cpu-m32c.c \
@@ -230,7 +232,6 @@ ALL_MACHINES_CFILES = \
        cpu-or1k.c \
        cpu-pdp11.c \
        cpu-pj.c \
-       cpu-plugin.c \
        cpu-powerpc.c \
        cpu-pru.c \
        cpu-rs6000.c \
@@ -246,7 +247,6 @@ ALL_MACHINES_CFILES = \
        cpu-tic4x.c \
        cpu-tic54x.c \
        cpu-tic6x.c \
-       cpu-tic80.c \
        cpu-tilegx.c \
        cpu-tilepro.c \
        cpu-v850.c \
@@ -254,7 +254,6 @@ ALL_MACHINES_CFILES = \
        cpu-vax.c \
        cpu-visium.c \
        cpu-wasm32.c \
-       cpu-xc16x.c \
        cpu-xgate.c \
        cpu-xstormy16.c \
        cpu-xtensa.c \
@@ -266,7 +265,6 @@ ALL_MACHINES_CFILES = \
 BFD32_BACKENDS = \
        aout-cris.lo \
        aout-ns32k.lo \
-       aout-tic30.lo \
        aout32.lo \
        cf-i386lynx.lo \
        coff-go32.lo \
@@ -278,7 +276,6 @@ BFD32_BACKENDS = \
        coff-tic30.lo \
        coff-tic4x.lo \
        coff-tic54x.lo \
-       coff-tic80.lo \
        coff-z80.lo \
        coff-z8k.lo \
        coffgen.lo \
@@ -302,7 +299,6 @@ BFD32_BACKENDS = \
        elf32-avr.lo \
        elf32-bfin.lo \
        elf32-cr16.lo \
-       elf32-cr16c.lo \
        elf32-cris.lo \
        elf32-crx.lo \
        elf32-csky.lo \
@@ -354,10 +350,10 @@ BFD32_BACKENDS = \
        elf32-vax.lo \
        elf32-visium.lo \
        elf32-wasm32.lo \
-       elf32-xc16x.lo \
        elf32-xgate.lo \
        elf32-xstormy16.lo \
        elf32-xtensa.lo \
+       elf32-z80.lo \
        elf32.lo \
        elflink.lo \
        elfxx-sparc.lo \
@@ -376,14 +372,12 @@ BFD32_BACKENDS = \
        pe-arm.lo \
        pe-i386.lo \
        pe-mcore.lo \
-       pe-ppc.lo \
        pe-sh.lo \
        pef.lo \
        pei-arm-wince.lo \
        pei-arm.lo \
        pei-i386.lo \
        pei-mcore.lo \
-       pei-ppc.lo \
        pei-sh.lo \
        peigen.lo \
        plugin.lo \
@@ -403,7 +397,6 @@ BFD32_BACKENDS = \
 BFD32_BACKENDS_CFILES = \
        aout-cris.c \
        aout-ns32k.c \
-       aout-tic30.c \
        aout32.c \
        cf-i386lynx.c \
        coff-go32.c \
@@ -415,7 +408,6 @@ BFD32_BACKENDS_CFILES = \
        coff-tic30.c \
        coff-tic4x.c \
        coff-tic54x.c \
-       coff-tic80.c \
        coff-z80.c \
        coff-z8k.c \
        coffgen.c \
@@ -439,7 +431,6 @@ BFD32_BACKENDS_CFILES = \
        elf32-avr.c \
        elf32-bfin.c \
        elf32-cr16.c \
-       elf32-cr16c.c \
        elf32-cris.c \
        elf32-crx.c \
        elf32-csky.c \
@@ -491,10 +482,10 @@ BFD32_BACKENDS_CFILES = \
        elf32-vax.c \
        elf32-visium.c \
        elf32-wasm32.c \
-       elf32-xc16x.c \
        elf32-xgate.c \
        elf32-xstormy16.c \
        elf32-xtensa.c \
+       elf32-z80.c \
        elf32.c \
        elflink.c \
        elfxx-sparc.c \
@@ -513,14 +504,12 @@ BFD32_BACKENDS_CFILES = \
        pe-arm.c \
        pe-i386.c \
        pe-mcore.c \
-       pe-ppc.c \
        pe-sh.c \
        pef.c \
        pei-arm-wince.c \
        pei-arm.c \
        pei-i386.c \
        pei-mcore.c \
-       pei-ppc.c \
        pei-sh.c \
        plugin.c \
        ppcboot.c \
@@ -555,11 +544,15 @@ BFD64_BACKENDS = \
        elf32-score.lo \
        elf32-score7.lo \
        elf64-alpha.lo \
+       elf64-amdgcn.lo \
        elf64-gen.lo \
        elf64-hppa.lo \
        elf64-ia64.lo \
        elf64-ia64-vms.lo \
        elfxx-ia64.lo \
+       elf32-loongarch.lo \
+       elf64-loongarch.lo \
+       elfxx-loongarch.lo \
        elfn32-mips.lo \
        elf64-mips.lo \
        elfxx-mips.lo \
@@ -574,11 +567,14 @@ BFD64_BACKENDS = \
        elf64-tilegx.lo \
        elf64-x86-64.lo \
        elfxx-x86.lo \
+       elf64-bpf.lo \
        elf64.lo \
        mach-o-aarch64.lo \
        mach-o-x86-64.lo \
        mmo.lo \
+       pe-aarch64igen.lo \
        pe-x86_64.lo \
+       pei-aarch64.lo \
        pei-ia64.lo \
        pei-x86_64.lo \
        pepigen.lo \
@@ -595,6 +591,7 @@ BFD64_BACKENDS_CFILES = \
        elf32-score.c \
        elf32-score7.c \
        elf64-alpha.c \
+       elf64-amdgcn.c \
        elf64-gen.c \
        elf64-hppa.c \
        elf64-ia64-vms.c \
@@ -607,16 +604,19 @@ BFD64_BACKENDS_CFILES = \
        elf64-tilegx.c \
        elf64-x86-64.c \
        elfxx-x86.c \
+       elf64-bpf.c \
        elf64.c \
        elfn32-mips.c \
        elfxx-aarch64.c \
        elfxx-ia64.c \
+       elfxx-loongarch.c \
        elfxx-mips.c \
        elfxx-riscv.c \
        mach-o-aarch64.c \
        mach-o-x86-64.c \
        mmo.c \
        pe-x86_64.c \
+       pei-aarch64.c \
        pei-ia64.c \
        pei-x86_64.c \
        vms-alpha.c
@@ -675,32 +675,58 @@ SOURCE_CFILES = \
 BUILD_CFILES = \
        elf32-aarch64.c elf64-aarch64.c \
        elf32-ia64.c elf64-ia64.c \
+       elf32-loongarch.c elf64-loongarch.c \
        elf32-riscv.c elf64-riscv.c \
-       peigen.c pepigen.c pex64igen.c
+       peigen.c pepigen.c pex64igen.c pe-aarch64igen.c
 
 CFILES = $(SOURCE_CFILES) $(BUILD_CFILES)
 
-## This is a list of all .h files which are in the source tree.
+## This is a list of all .h files in the source tree minus those that
+## are processed to produce other .h files
 SOURCE_HFILES = \
-       aout-target.h aoutx.h coffcode.h coffswap.h ecoffswap.h \
-       elf-bfd.h elf-hppa.h elf-linux-core.h elf32-hppa.h \
-       elf64-hppa.h elfcode.h elfcore.h \
+       aout-target.h aoutx.h arc-got.h arc-plt.h \
+       coff-arm.h coff-bfd.h coffcode.h coffswap.h \
+       cpu-aarch64.h cpu-arm.h cpu-h8300.h cpu-m68k.h cpu-riscv.h \
+       ecoff-bfd.h ecoffswap.h \
+       elf32-arm.h elf32-avr.h elf32-bfin.h elf32-cr16.h elf32-csky.h \
+       elf32-dlx.h elf32-hppa.h elf32-m68hc1x.h elf32-m68k.h \
+       elf32-metag.h elf32-nds32.h elf32-nios2.h elf32-ppc.h \
+       elf32-rx.h elf32-score.h elf32-sh-relocs.h elf32-spu.h \
+       elf32-tic6x.h elf32-tilegx.h elf32-tilepro.h elf32-v850.h \
+       elf64-hppa.h elf64-ppc.h elf64-tilegx.h \
+       elf-bfd.h elfcode.h elfcore.h elf-hppa.h elf-linker-x86.h \
+       elf-linux-core.h elf-nacl.h elf-s390.h elf-vxworks.h \
+       elfxx-aarch64.h elfxx-ia64.h elfxx-mips.h elfxx-riscv.h \
+       elfxx-sparc.h elfxx-tilegx.h elfxx-x86.h elfxx-loongarch.h \
        genlink.h go32stub.h \
        libaout.h libbfd.h libcoff.h libecoff.h libhppa.h \
-       libpei.h libxcoff.h mach-o.h \
+       libpei.h libxcoff.h \
+       mach-o.h \
        netbsd.h ns32k.h \
-       pef.h pef-traceback.h peicode.h som.h version.h \
-       vms.h xsym.h
+       pef.h pef-traceback.h peicode.h plugin.h \
+       som.h sysdep.h \
+       version.h vms.h \
+       wasm-module.h \
+       xcofflink.h xsym.h
 
-## ... and all .h files which are in the build tree.
+## ... and .h files which are in the build tree, minus config.h and bfd.h
 BUILD_HFILES = \
-       bfdver.h elf32-target.h elf64-target.h targmatch.h bfd_stdint.h
+       bfdver.h elf32-target.h elf64-target.h targmatch.h
 
 # Ensure they are built early:
 BUILT_SOURCES = $(BUILD_HFILES)
 
 HFILES = $(SOURCE_HFILES) $(BUILD_HFILES)
 
+BFD_H_DEPS = $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/diagnostics.h
+LOCAL_H_DEPS = libbfd.h sysdep.h config.h
+$(BFD32_LIBS) \
+ $(BFD64_LIBS) \
+ $(ALL_MACHINES) \
+ $(BFD32_BACKENDS) \
+ $(BFD64_BACKENDS) \
+ $(OPTIONAL_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
+
 SRC_POTFILES = $(SOURCE_CFILES) $(SOURCE_HFILES)
 BLD_POTFILES = $(BUILD_CFILES) $(BUILD_HFILES)
 
@@ -771,116 +797,102 @@ libbfd.a: stamp-lib ; @true
 # vector names.  It is built from config.bfd.  It is not compiled by
 # itself, but is included by targets.c.
 targmatch.h: config.bfd targmatch.sed
-       rm -f targmatch.h
-       $(SED) -f $(srcdir)/targmatch.sed < $(srcdir)/config.bfd > targmatch.new
-       mv -f targmatch.new targmatch.h
+       $(AM_V_at)rm -f targmatch.new
+       $(AM_V_GEN)$(SED) -f $(srcdir)/targmatch.sed < $(srcdir)/config.bfd > targmatch.new
+       $(AM_V_at)mv -f targmatch.new targmatch.h
 
 # When compiling archures.c and targets.c, supply the default target
 # info from configure.
 
 targets.lo: targets.c Makefile
 if am__fastdepCC
-       $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(TDEFAULTS) $(srcdir)/targets.c
-       mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+       $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(TDEFAULTS) $(srcdir)/targets.c
+       $(AM_V_at)mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
 else
 if AMDEP
        source='targets.c' object='$@' libtool=yes @AMDEPBACKSLASH@
        DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 endif
-       $(LTCOMPILE) -c -o $@ $(TDEFAULTS) $(srcdir)/targets.c
+       $(AM_V_CC)$(LTCOMPILE) -c -o $@ $(TDEFAULTS) $(srcdir)/targets.c
 endif
 
 archures.lo: archures.c Makefile
 if am__fastdepCC
-       $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(TDEFAULTS) $(srcdir)/archures.c
-       mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+       $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $(TDEFAULTS) $(srcdir)/archures.c
+       $(AM_V_at)mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
 else
 if AMDEP
        source='archures.c' object='$@' libtool=yes @AMDEPBACKSLASH@
        DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 endif
-       $(LTCOMPILE) -c -o $@ $(TDEFAULTS) $(srcdir)/archures.c
+       $(AM_V_CC)$(LTCOMPILE) -c -o $@ $(TDEFAULTS) $(srcdir)/archures.c
 endif
 
 dwarf2.lo: dwarf2.c Makefile
 if am__fastdepCC
-       $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ -DDEBUGDIR=\"$(DEBUGDIR)\" $(srcdir)/dwarf2.c
-       mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+       $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ -DDEBUGDIR=\"$(DEBUGDIR)\" $(srcdir)/dwarf2.c
+       $(AM_V_at)mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
 else
 if AMDEP
        source='dwarf2.c' object='$@' libtool=yes @AMDEPBACKSLASH@
        DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 endif
-       $(LTCOMPILE) -c -o $@ -DDEBUGDIR=\"$(DEBUGDIR)\" $(srcdir)/dwarf2.c
+       $(AM_V_CC)$(LTCOMPILE) -c -o $@ -DDEBUGDIR=\"$(DEBUGDIR)\" $(srcdir)/dwarf2.c
 endif
 
 elf32-target.h : elfxx-target.h
-       rm -f elf32-target.h
-       $(SED) -e s/NN/32/g < $(srcdir)/elfxx-target.h > elf32-target.new
-       mv -f elf32-target.new elf32-target.h
+       $(AM_V_GEN)$(SED) -e s/NN/32/g < $< > $@
 
 elf64-target.h : elfxx-target.h
-       rm -f elf64-target.h
-       $(SED) -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new
-       mv -f elf64-target.new elf64-target.h
+       $(AM_V_GEN)$(SED) -e s/NN/64/g < $< > $@
 
 elf32-aarch64.c : elfnn-aarch64.c
-       rm -f elf32-aarch64.c
-       echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf32-aarch64.new
-       $(SED) -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c >> elf32-aarch64.new
-       mv -f elf32-aarch64.new elf32-aarch64.c
+       $(AM_V_at)echo "#line 1 \"elfnn-aarch64.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/NN/32/g < $< >> $@
 
 elf64-aarch64.c : elfnn-aarch64.c
-       rm -f elf64-aarch64.c
-       echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf64-aarch64.new
-       $(SED) -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c >> elf64-aarch64.new
-       mv -f elf64-aarch64.new elf64-aarch64.c
+       $(AM_V_at)echo "#line 1 \"elfnn-aarch64.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/NN/64/g < $< >> $@
 
 elf32-ia64.c : elfnn-ia64.c
-       rm -f elf32-ia64.c
-       $(SED) -e s/NN/32/g < $(srcdir)/elfnn-ia64.c > elf32-ia64.new
-       mv -f elf32-ia64.new elf32-ia64.c
+       $(AM_V_at)echo "#line 1 \"elfnn-ia64.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/NN/32/g < $< >> $@
 
 elf64-ia64.c : elfnn-ia64.c
-       rm -f elf64-ia64.c
-       $(SED) -e s/NN/64/g < $(srcdir)/elfnn-ia64.c > elf64-ia64.new
-       mv -f elf64-ia64.new elf64-ia64.c
+       $(AM_V_at)echo "#line 1 \"elfnn-ia64.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/NN/64/g < $< >> $@
+
+elf32-loongarch.c : elfnn-loongarch.c
+       $(AM_V_at)echo "#line 1 \"elfnn-loongarch.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/NN/32/g < $< >> $@
+
+elf64-loongarch.c : elfnn-loongarch.c
+       $(AM_V_at)echo "#line 1 \"elfnn-loongarch.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/NN/64/g < $< >> $@
 
 elf32-riscv.c : elfnn-riscv.c
-       rm -f elf32-riscv.c
-       echo "#line 1 \"$(srcdir)/elfnn-riscv.c\"" > elf32-riscv.new
-       sed -e s/NN/32/g < $(srcdir)/elfnn-riscv.c >> elf32-riscv.new
-       mv -f elf32-riscv.new elf32-riscv.c
+       $(AM_V_at)echo "#line 1 \"elfnn-riscv.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/NN/32/g < $< >> $@
 
 elf64-riscv.c : elfnn-riscv.c
-       rm -f elf64-riscv.c
-       echo "#line 1 \"$(srcdir)/elfnn-riscv.c\"" > elf64-riscv.new
-       sed -e s/NN/64/g < $(srcdir)/elfnn-riscv.c >> elf64-riscv.new
-       mv -f elf64-riscv.new elf64-riscv.c
+       $(AM_V_at)echo "#line 1 \"elfnn-riscv.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/NN/64/g < $< >> $@
 
 peigen.c : peXXigen.c
-       rm -f peigen.c
-       $(SED) -e s/XX/pe/g < $(srcdir)/peXXigen.c > peigen.new
-       mv -f peigen.new peigen.c
+       $(AM_V_at)echo "#line 1 \"peXXigen.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/XX/pe/g < $< >> $@
 
 pepigen.c : peXXigen.c
-       rm -f pepigen.c
-       $(SED) -e s/XX/pep/g < $(srcdir)/peXXigen.c > pepigen.new
-       mv -f pepigen.new pepigen.c
+       $(AM_V_at)echo "#line 1 \"peXXigen.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/XX/pep/g < $< >> $@
 
 pex64igen.c: peXXigen.c
-       rm -f pex64igen.c
-       $(SED) -e s/XX/pex64/g < $(srcdir)/peXXigen.c > pex64igen.new
-       mv -f pex64igen.new pex64igen.c
+       $(AM_V_at)echo "#line 1 \"peXXigen.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/XX/pex64/g < $< >> $@
 
-BFD_H_DEPS= $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
-LOCAL_H_DEPS= libbfd.h sysdep.h config.h
-$(BFD32_LIBS) \
- $(BFD64_LIBS) \
- $(ALL_MACHINES) \
- $(BFD32_BACKENDS) \
- $(BFD64_BACKENDS) \
- $(OPTIONAL_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
+pe-aarch64igen.c: peXXigen.c
+       $(AM_V_at)echo "#line 1 \"peXXigen.c\"" > $@
+       $(AM_V_GEN)$(SED) -e s/XX/peAArch64/g < $< >> $@
 
 host-aout.lo: Makefile
 
@@ -909,50 +921,58 @@ LIBBFD_H_FILES = libbfd-in.h libbfd.c bfdio.c bfdwin.c \
        cache.c reloc.c archures.c linker.c
 LIBCOFF_H_FILES = libcoff-in.h coffcode.h
 
-# Could really use a "copy-if-change"...
-headers:
-       (cd $(bfddocdir); $(MAKE) protos $(FLAGS_TO_PASS))
-       cp $(bfddocdir)/bfd.h bfd-in2.h-new
-       $(SHELL) $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
-       cp $(bfddocdir)/libbfd.h libbfd.h-new
-       $(SHELL) $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
-       cp $(bfddocdir)/libcoff.h libcoff.h-new
-       $(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
+headers: stmp-bin2-h stmp-lbfd-h stmp-lcoff-h
 
 # We only rebuild the header files automatically if we have been
 # configured with --enable-maintainer-mode.
 
+REGEN_HEADER = \
+       ( \
+       set -e; \
+       echo "$$H_FILES" | sed -f $(srcdir)/doc/header.sed; \
+       for file in $$H_FILES; do \
+         file="$(srcdir)/$$file"; \
+         case $$file in \
+           *-in.h) cat $$file;; \
+           *)  echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \
+                               -e 's,$$,.  */,'; \
+               $(MKDOC) $$CHEW_FLAGS -f $(srcdir)/doc/proto.str < $$file;; \
+         esac; \
+       done; \
+       echo "\#ifdef __cplusplus"; \
+       echo "}"; \
+       echo "\#endif"; \
+       echo "\#endif"; \
+       )
+
 $(srcdir)/bfd-in2.h: @MAINT@ stmp-bin2-h ; @true
-stmp-bin2-h: $(BFD_H_FILES) $(BFD64_H_FILES)
-       (cd $(bfddocdir); $(MAKE) $(FLAGS_TO_PASS) bfd.h)
-       cp $(bfddocdir)/bfd.h bfd-in2.h-new
-       $(SHELL) $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
-       touch stmp-bin2-h
+stmp-bin2-h: $(BFD_H_FILES) $(BFD64_H_FILES) $(MKDOC)
+       $(AM_V_GEN)H_FILES="$(BFD_H_FILES)" CHEW_FLAGS= ; $(REGEN_HEADER) > bfd-in2.h-new
+       $(AM_V_at)$(SHELL) $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
+       $(AM_V_at)touch stmp-bin2-h
 
 $(srcdir)/libbfd.h: @MAINT@ stmp-lbfd-h ; @true
-stmp-lbfd-h: $(LIBBFD_H_FILES)
-       (cd $(bfddocdir); $(MAKE) $(FLAGS_TO_PASS) libbfd.h)
-       cp $(bfddocdir)/libbfd.h libbfd.h-new
-       $(SHELL) $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
-       touch stmp-lbfd-h
+stmp-lbfd-h: $(LIBBFD_H_FILES) $(MKDOC)
+       $(AM_V_GEN)H_FILES="$(LIBBFD_H_FILES)" CHEW_FLAGS=-i ; $(REGEN_HEADER) > libbfd.h-new
+       $(AM_V_at)$(SHELL) $(srcdir)/../move-if-change libbfd.h-new $(srcdir)/libbfd.h
+       $(AM_V_at)touch stmp-lbfd-h
 
 $(srcdir)/libcoff.h: @MAINT@ stmp-lcoff-h ; @true
-stmp-lcoff-h: $(LIBCOFF_H_FILES)
-       (cd $(bfddocdir); $(MAKE) $(FLAGS_TO_PASS) libcoff.h)
-       cp $(bfddocdir)/libcoff.h libcoff.h-new
-       $(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
-       touch stmp-lcoff-h
+stmp-lcoff-h: $(LIBCOFF_H_FILES) $(MKDOC)
+       $(AM_V_GEN)H_FILES="$(LIBCOFF_H_FILES)" CHEW_FLAGS=-i ; $(REGEN_HEADER) > libcoff.h-new
+       $(AM_V_at)$(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
+       $(AM_V_at)touch stmp-lcoff-h
 
-MOSTLYCLEANFILES = ofiles stamp-ofiles
+MOSTLYCLEANFILES += ofiles stamp-ofiles
 
-CLEANFILES = bfd.h dep.sed stmp-bfd-h DEP DEPA DEP1 DEP2 libbfd.a stamp-lib \
+CLEANFILES += bfd.h dep.sed stmp-bfd-h DEP DEPA DEP1 DEP2 libbfd.a stamp-lib \
        stmp-bin2-h stmp-lbfd-h stmp-lcoff-h
 
-DISTCLEANFILES = $(BUILD_CFILES) $(BUILD_HFILES) libtool-soversion
+DISTCLEANFILES += $(BUILD_CFILES) $(BUILD_HFILES) libtool-soversion
 
 bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
-       @echo "creating $@"
-       @bfd_version=`echo "$(VERSION)" | $(SED) -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\
+       $(AM_V_GEN)\
+       bfd_version=`echo "$(VERSION)" | $(SED) -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\
        bfd_version_string="\"$(VERSION)\"" ;\
        bfd_soversion="$(VERSION)" ;\
        bfd_version_package="\"$(PKGVERSION)\"" ;\
@@ -973,15 +993,17 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
 # Disable -Werror, if it has been enabled, since coffswap.h won't
 # compile with gcc 4.5 and above.
 coff-tic4x.lo: coff-tic4x.c
-@am__fastdepCC_TRUE@   $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< $(NO_WERROR)
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< $(NO_WERROR)
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $< $(NO_WERROR)
+@am__fastdepCC_FALSE@  $(AM_V_CC)$(LTCOMPILE) -c -o $@ $< $(NO_WERROR)
 
 coff-tic54x.lo: coff-tic54x.c
-@am__fastdepCC_TRUE@   $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< $(NO_WERROR)
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< $(NO_WERROR)
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $< $(NO_WERROR)
+@am__fastdepCC_FALSE@  $(AM_V_CC)$(LTCOMPILE) -c -o $@ $< $(NO_WERROR)
+
+include doc/local.mk