bfd: move header updates up a directory
authorMike Frysinger <vapier@gentoo.org>
Fri, 3 Dec 2021 05:23:20 +0000 (00:23 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 4 Dec 2021 01:03:05 +0000 (20:03 -0500)
The rules for rebuilding the bfd headers live in the doc/ subdir
(most likely) because they rely on the chew & related tools.  But
we can collapse them into the main Makefile while keeping the tools
in the doc subdir easily enough.  This makes the code simpler and
allows for rebuilding them in parallel.

Also add automake silent rule support while we're here.

bfd/Makefile.am
bfd/Makefile.in
bfd/doc/Makefile.am
bfd/doc/Makefile.in

index 7a5a336f1d8531c29dea719a373b32e69066739c..bfe8d93e73da61b9babf61a01981402e01e45b09 100644 (file)
@@ -920,39 +920,81 @@ 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
+MKDOC = doc/chew$(EXEEXT_FOR_BUILD)
+
+$(MKDOC):
+       cd $(bfddocdir) && $(MAKE) chew$(EXEEXT_FOR_BUILD)
+
+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.
 
 $(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)( \
+       set -e; \
+       echo "$(BFD_H_FILES)" | sed -f $(srcdir)/doc/header.sed; \
+       for file in $(BFD_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) -f $(srcdir)/doc/proto.str < $$file;; \
+         esac; \
+       done; \
+       echo "#ifdef __cplusplus"; \
+       echo "}"; \
+       echo "#endif"; \
+       echo "#endif"; \
+       ) > 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)( \
+       set -e; \
+       echo "$(LIBBFD_H_FILES)" | sed -f $(srcdir)/doc/header.sed; \
+       for file in $(LIBBFD_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) -i -f $(srcdir)/doc/proto.str < $$file;; \
+         esac; \
+       done; \
+       echo "#ifdef __cplusplus"; \
+       echo "}"; \
+       echo "#endif"; \
+       echo "#endif"; \
+       ) > 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)( \
+       set -e; \
+       echo "$(LIBCOFF_H_FILES)" | sed -f $(srcdir)/doc/header.sed; \
+       for file in $(LIBCOFF_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) -i -f $(srcdir)/doc/proto.str < $$file;; \
+         esac; \
+       done; \
+       echo "#ifdef __cplusplus"; \
+       echo "}"; \
+       echo "#endif"; \
+       echo "#endif"; \
+       ) > 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
 
index 4286b5e1062cc9f28f4658c20e65acc4352a9d36..ec9ed2d183e162119e6ee288ccbd3981d1de7b7d 100644 (file)
@@ -1175,6 +1175,7 @@ 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
+MKDOC = doc/chew$(EXEEXT_FOR_BUILD)
 MOSTLYCLEANFILES = ofiles stamp-ofiles
 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
@@ -2044,39 +2045,79 @@ stmp-bfd-h: bfd-in3.h
        rm -f bfd-tmp.h
        touch stmp-bfd-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
+$(MKDOC):
+       cd $(bfddocdir) && $(MAKE) chew$(EXEEXT_FOR_BUILD)
+
+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.
 
 $(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)( \
+       set -e; \
+       echo "$(BFD_H_FILES)" | sed -f $(srcdir)/doc/header.sed; \
+       for file in $(BFD_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) -f $(srcdir)/doc/proto.str < $$file;; \
+         esac; \
+       done; \
+       echo "#ifdef __cplusplus"; \
+       echo "}"; \
+       echo "#endif"; \
+       echo "#endif"; \
+       ) > 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)( \
+       set -e; \
+       echo "$(LIBBFD_H_FILES)" | sed -f $(srcdir)/doc/header.sed; \
+       for file in $(LIBBFD_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) -i -f $(srcdir)/doc/proto.str < $$file;; \
+         esac; \
+       done; \
+       echo "#ifdef __cplusplus"; \
+       echo "}"; \
+       echo "#endif"; \
+       echo "#endif"; \
+       ) > 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)( \
+       set -e; \
+       echo "$(LIBCOFF_H_FILES)" | sed -f $(srcdir)/doc/header.sed; \
+       for file in $(LIBCOFF_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) -i -f $(srcdir)/doc/proto.str < $$file;; \
+         esac; \
+       done; \
+       echo "#ifdef __cplusplus"; \
+       echo "}"; \
+       echo "#endif"; \
+       echo "#endif"; \
+       ) > libcoff.h-new
+       $(AM_V_at)$(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
+       $(AM_V_at)touch stmp-lcoff-h
 
 bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
        $(AM_V_GEN)\
index 67f1042b0a17937c799eedcfc4acd13e98ce979b..3b24d1af222aa51002ab79071aadb63e73aa591b 100644 (file)
@@ -77,8 +77,6 @@ chew.stamp: $(srcdir)/chew.c
          chw$$$$$(EXEEXT_FOR_BUILD) $(MKDOC); \
        touch $@
 
-protos: libbfd.h libcoff.h bfd.h
-
 # We can't replace these rules with an implicit rule, because
 # makes without VPATH support couldn't find the .h files in `..'.
 
@@ -243,98 +241,6 @@ linker.stamp: $(srcdir)/../linker.c $(srcdir)/doc.str $(MKDOC)
        $(SHELL) $(srcdir)/../../move-if-change linker.tmp linker.texi
        touch $@
 
-LIBBFD_H_DEP = \
-       $(srcdir)/../libbfd-in.h        \
-       $(srcdir)/../libbfd.c           \
-       $(srcdir)/../bfdio.c            \
-       $(srcdir)/../bfdwin.c           \
-       $(srcdir)/../cache.c            \
-       $(srcdir)/../reloc.c            \
-       $(srcdir)/../archures.c         \
-       $(srcdir)/../linker.c           \
-       $(srcdir)/header.sed            \
-       $(srcdir)/proto.str             \
-       $(MKDOC)
-
-libbfd.h: $(LIBBFD_H_DEP)
-       echo "$(LIBBFD_H_DEP)" | sed -f $(srcdir)/header.sed > $@
-       for file in $(LIBBFD_H_DEP); do \
-         case $$file in \
-           *-in.h) cat $$file >> $@ ;; \
-           */header.sed) break ;; \
-           *)  echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \
-                               -e 's,$$,.  */,' >> $@ ; \
-               ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \
-         esac; \
-       done
-       echo "#ifdef __cplusplus" >> $@
-       echo "}" >> $@
-       echo "#endif" >> $@
-       echo "#endif" >> $@
-
-LIBCOFF_H_DEP = \
-       $(srcdir)/../libcoff-in.h       \
-       $(srcdir)/../coffcode.h         \
-       $(srcdir)/header.sed            \
-       $(srcdir)/proto.str             \
-       $(MKDOC)
-
-libcoff.h: $(LIBCOFF_H_DEP)
-       echo "$(LIBCOFF_H_DEP)" | sed -f $(srcdir)/header.sed > $@
-       for file in $(LIBCOFF_H_DEP); do \
-         case $$file in \
-           *-in.h) cat $$file >> $@ ;; \
-           */header.sed) break ;; \
-           *)  echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \
-                               -e 's,$$,.  */,' >> $@ ; \
-               ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \
-         esac; \
-       done
-       echo "#ifdef __cplusplus" >> $@
-       echo "}" >> $@
-       echo "#endif" >> $@
-       echo "#endif" >> $@
-
-BFD_H_DEP = \
-       $(srcdir)/../bfd-in.h           \
-       $(srcdir)/../init.c             \
-       $(srcdir)/../opncls.c           \
-       $(srcdir)/../libbfd.c           \
-       $(srcdir)/../bfdio.c            \
-       $(srcdir)/../bfdwin.c           \
-       $(srcdir)/../section.c          \
-       $(srcdir)/../archures.c         \
-       $(srcdir)/../reloc.c            \
-       $(srcdir)/../syms.c             \
-       $(srcdir)/../bfd.c              \
-       $(srcdir)/../archive.c          \
-       $(srcdir)/../corefile.c         \
-       $(srcdir)/../targets.c          \
-       $(srcdir)/../format.c           \
-       $(srcdir)/../linker.c           \
-       $(srcdir)/../simple.c           \
-       $(srcdir)/../compress.c         \
-       $(srcdir)/header.sed            \
-       $(srcdir)/proto.str             \
-       $(srcdir)/../version.h          \
-       $(MKDOC)
-
-bfd.h: $(BFD_H_DEP)
-       echo "$(BFD_H_DEP)" | sed -f $(srcdir)/header.sed > $@
-       for file in $(BFD_H_DEP); do \
-         case $$file in \
-           *-in.h) cat $$file >> $@ ;; \
-           */header.sed) break ;; \
-           *)  echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \
-                               -e 's,$$,.  */,' >> $@ ; \
-               ./$(MKDOC) -f $(srcdir)/proto.str < $$file >> $@ ;; \
-         esac; \
-       done
-       echo "#ifdef __cplusplus" >> $@
-       echo "}" >> $@
-       echo "#endif" >> $@
-       echo "#endif" >> $@
-
 bfdver.texi: $(srcdir)/Makefile.in
        @echo "creating $@"; \
        echo "@set VERSION $(VERSION)" > bfdver.texi; \
index 185786cecca609f02326ba34fb211130b67ad190..c461094c80c54db664c6b1873719db2c7b9c48c3 100644 (file)
@@ -442,50 +442,6 @@ MKDOC = chew$(EXEEXT_FOR_BUILD)
 AM_CPPFLAGS = -I.. -I$(srcdir)/.. -I$(srcdir)/../../include \
        -I$(srcdir)/../../intl -I../../intl
 
-LIBBFD_H_DEP = \
-       $(srcdir)/../libbfd-in.h        \
-       $(srcdir)/../libbfd.c           \
-       $(srcdir)/../bfdio.c            \
-       $(srcdir)/../bfdwin.c           \
-       $(srcdir)/../cache.c            \
-       $(srcdir)/../reloc.c            \
-       $(srcdir)/../archures.c         \
-       $(srcdir)/../linker.c           \
-       $(srcdir)/header.sed            \
-       $(srcdir)/proto.str             \
-       $(MKDOC)
-
-LIBCOFF_H_DEP = \
-       $(srcdir)/../libcoff-in.h       \
-       $(srcdir)/../coffcode.h         \
-       $(srcdir)/header.sed            \
-       $(srcdir)/proto.str             \
-       $(MKDOC)
-
-BFD_H_DEP = \
-       $(srcdir)/../bfd-in.h           \
-       $(srcdir)/../init.c             \
-       $(srcdir)/../opncls.c           \
-       $(srcdir)/../libbfd.c           \
-       $(srcdir)/../bfdio.c            \
-       $(srcdir)/../bfdwin.c           \
-       $(srcdir)/../section.c          \
-       $(srcdir)/../archures.c         \
-       $(srcdir)/../reloc.c            \
-       $(srcdir)/../syms.c             \
-       $(srcdir)/../bfd.c              \
-       $(srcdir)/../archive.c          \
-       $(srcdir)/../corefile.c         \
-       $(srcdir)/../targets.c          \
-       $(srcdir)/../format.c           \
-       $(srcdir)/../linker.c           \
-       $(srcdir)/../simple.c           \
-       $(srcdir)/../compress.c         \
-       $(srcdir)/header.sed            \
-       $(srcdir)/proto.str             \
-       $(srcdir)/../version.h          \
-       $(MKDOC)
-
 noinst_TEXINFOS = bfdint.texi
 MOSTLYCLEANFILES = $(MKDOC) *.o *.stamp
 DISTCLEANFILES = bfd.?? bfd.??? bfd.h libbfd.h libcoff.h texput.log
@@ -929,8 +885,6 @@ chew.stamp: $(srcdir)/chew.c
          chw$$$$$(EXEEXT_FOR_BUILD) $(MKDOC); \
        touch $@
 
-protos: libbfd.h libcoff.h bfd.h
-
 # We can't replace these rules with an implicit rule, because
 # makes without VPATH support couldn't find the .h files in `..'.
 
@@ -1095,54 +1049,6 @@ linker.stamp: $(srcdir)/../linker.c $(srcdir)/doc.str $(MKDOC)
        $(SHELL) $(srcdir)/../../move-if-change linker.tmp linker.texi
        touch $@
 
-libbfd.h: $(LIBBFD_H_DEP)
-       echo "$(LIBBFD_H_DEP)" | sed -f $(srcdir)/header.sed > $@
-       for file in $(LIBBFD_H_DEP); do \
-         case $$file in \
-           *-in.h) cat $$file >> $@ ;; \
-           */header.sed) break ;; \
-           *)  echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \
-                               -e 's,$$,.  */,' >> $@ ; \
-               ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \
-         esac; \
-       done
-       echo "#ifdef __cplusplus" >> $@
-       echo "}" >> $@
-       echo "#endif" >> $@
-       echo "#endif" >> $@
-
-libcoff.h: $(LIBCOFF_H_DEP)
-       echo "$(LIBCOFF_H_DEP)" | sed -f $(srcdir)/header.sed > $@
-       for file in $(LIBCOFF_H_DEP); do \
-         case $$file in \
-           *-in.h) cat $$file >> $@ ;; \
-           */header.sed) break ;; \
-           *)  echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \
-                               -e 's,$$,.  */,' >> $@ ; \
-               ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \
-         esac; \
-       done
-       echo "#ifdef __cplusplus" >> $@
-       echo "}" >> $@
-       echo "#endif" >> $@
-       echo "#endif" >> $@
-
-bfd.h: $(BFD_H_DEP)
-       echo "$(BFD_H_DEP)" | sed -f $(srcdir)/header.sed > $@
-       for file in $(BFD_H_DEP); do \
-         case $$file in \
-           *-in.h) cat $$file >> $@ ;; \
-           */header.sed) break ;; \
-           *)  echo $$file | sed -e 's,.*/,,' -e 's,^,/* Extracted from ,' \
-                               -e 's,$$,.  */,' >> $@ ; \
-               ./$(MKDOC) -f $(srcdir)/proto.str < $$file >> $@ ;; \
-         esac; \
-       done
-       echo "#ifdef __cplusplus" >> $@
-       echo "}" >> $@
-       echo "#endif" >> $@
-       echo "#endif" >> $@
-
 bfdver.texi: $(srcdir)/Makefile.in
        @echo "creating $@"; \
        echo "@set VERSION $(VERSION)" > bfdver.texi; \