This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

A better warning for bfd generated files


Inspired by http://gcc.gnu.org/ml/gcc-patches/2001-09/msg01289.html,
this patch adds a better warning header to generated header files in bfd.

bfd/ChangeLog
	* bfd-in.h: Remove comments regarding generated files.
	* libbfd-in.h: Likewise.
	* libcoff-in.h: Likewise.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Likewise.
	* libcoff.h: Likewise.

bfd/doc/ChangeLog
	* header.sed: New file, adds header to generated files.
	* Makefile.am: Rewrite rules generating libbfd.h, libcoff.h and
	bfd.h, using above.  Add missing elf.c dependecy for libbfd.h.
	* Makefile.in: Regenerate.

-- 
Alan Modra

Index: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.33
diff -u -p -r1.33 bfd-in.h
--- bfd-in.h	2001/09/18 09:57:21	1.33
+++ bfd-in.h	2001/10/01 13:14:47
@@ -4,10 +4,6 @@
    Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
-** NOTE: bfd.h and bfd-in2.h are GENERATED files.  Don't change them;
-** instead, change bfd-in.h or the other BFD source files processed to
-** generate these files.
-
 This file is part of BFD, the Binary File Descriptor library.
 
 This program is free software; you can redistribute it and/or modify
@@ -23,25 +19,6 @@ GNU General Public License for more deta
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-
-/* bfd.h -- The only header file required by users of the bfd library
-
-The bfd.h file is generated from bfd-in.h and various .c files; if you
-change it, your changes will probably be lost.
-
-All the prototypes and definitions following the comment "THE FOLLOWING
-IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
-BFD.  If you change it, someone oneday will extract it from the source
-again, and your changes will be lost.  To save yourself from this bind,
-change the definitions in the source in the bfd directory.  Type "make
-docs" and then "make headers" in that directory, and magically this file
-will change to reflect your changes.
-
-If you don't have the tools to perform the extraction, then you are
-safe from someone on your system trampling over your header files.
-You should still maintain the equivalence between the source and this
-file though; every change you make to the .c file should be reflected
-here.  */
 
 #ifndef __BFD_H_SEEN__
 #define __BFD_H_SEEN__
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.121
diff -u -p -r1.121 bfd-in2.h
--- bfd-in2.h	2001/09/29 12:07:00	1.121
+++ bfd-in2.h	2001/10/01 13:14:49
@@ -1,13 +1,15 @@
+/* DO NOT EDIT!  -*- buffer-read-only: t -*-  This file is automatically 
+   generated from "bfd-in.h", "init.c", "opncls.c", "libbfd.c", 
+   "section.c", "archures.c", "reloc.c", "syms.c", "bfd.c", "archive.c", 
+   "corefile.c", "targets.c" and "format.c".
+   Run "make headers" in your build bfd/ to regenerate.  */
+
 /* Main header file for the bfd library -- portable access to object files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    2000, 2001
    Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
-** NOTE: bfd.h and bfd-in2.h are GENERATED files.  Don't change them;
-** instead, change bfd-in.h or the other BFD source files processed to
-** generate these files.
-
 This file is part of BFD, the Binary File Descriptor library.
 
 This program is free software; you can redistribute it and/or modify
@@ -23,25 +25,6 @@ GNU General Public License for more deta
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-
-/* bfd.h -- The only header file required by users of the bfd library
-
-The bfd.h file is generated from bfd-in.h and various .c files; if you
-change it, your changes will probably be lost.
-
-All the prototypes and definitions following the comment "THE FOLLOWING
-IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
-BFD.  If you change it, someone oneday will extract it from the source
-again, and your changes will be lost.  To save yourself from this bind,
-change the definitions in the source in the bfd directory.  Type "make
-docs" and then "make headers" in that directory, and magically this file
-will change to reflect your changes.
-
-If you don't have the tools to perform the extraction, then you are
-safe from someone on your system trampling over your header files.
-You should still maintain the equivalence between the source and this
-file though; every change you make to the .c file should be reflected
-here.  */
 
 #ifndef __BFD_H_SEEN__
 #define __BFD_H_SEEN__
Index: bfd/libbfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd-in.h,v
retrieving revision 1.15
diff -u -p -r1.15 libbfd-in.h
--- libbfd-in.h	2001/09/18 09:57:25	1.15
+++ libbfd-in.h	2001/10/01 13:15:06
@@ -5,10 +5,6 @@
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
-** NOTE: libbfd.h is a GENERATED file.  Don't change it; instead,
-** change libbfd-in.h or the other BFD source files processed to
-** generate this file.
-
 This file is part of BFD, the Binary File Descriptor library.
 
 This program is free software; you can redistribute it and/or modify
Index: bfd/libbfd.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd.h,v
retrieving revision 1.46
diff -u -p -r1.46 libbfd.h
--- libbfd.h	2001/09/18 09:57:25	1.46
+++ libbfd.h	2001/10/01 13:15:08
@@ -1,13 +1,14 @@
+/* DO NOT EDIT!  -*- buffer-read-only: t -*-  This file is automatically 
+   generated from "libbfd-in.h", "init.c", "libbfd.c", "cache.c", 
+   "reloc.c", "archures.c" and "elf.c".
+   Run "make headers" in your build bfd/ to regenerate.  */
+
 /* libbfd.h -- Declarations used by bfd library *implementation*.
    (This include file is not for users of the library.)
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    2000, 2001
    Free Software Foundation, Inc.
    Written by Cygnus Support.
-
-** NOTE: libbfd.h is a GENERATED file.  Don't change it; instead,
-** change libbfd-in.h or the other BFD source files processed to
-** generate this file.
 
 This file is part of BFD, the Binary File Descriptor library.
 
Index: bfd/libcoff-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libcoff-in.h,v
retrieving revision 1.12
diff -u -p -r1.12 libcoff-in.h
--- libcoff-in.h	2001/09/18 09:57:25	1.12
+++ libcoff-in.h	2001/10/01 13:15:08
@@ -4,9 +4,6 @@
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
-** NOTE: libcoff.h is a GENERATED file.  Don't change it; instead,
-** change libcoff-in.h or coffcode.h.
-
 This file is part of BFD, the Binary File Descriptor library.
 
 This program is free software; you can redistribute it and/or modify
Index: bfd/libcoff.h
===================================================================
RCS file: /cvs/src/src/bfd/libcoff.h,v
retrieving revision 1.21
diff -u -p -r1.21 libcoff.h
--- libcoff.h	2001/09/18 09:57:25	1.21
+++ libcoff.h	2001/10/01 13:15:08
@@ -1,11 +1,12 @@
+/* DO NOT EDIT!  -*- buffer-read-only: t -*-  This file is automatically 
+   generated from "libcoff-in.h" and "coffcode.h".
+   Run "make headers" in your build bfd/ to regenerate.  */
+
 /* BFD COFF object file private structure.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    2000, 2001
    Free Software Foundation, Inc.
    Written by Cygnus Support.
-
-** NOTE: libcoff.h is a GENERATED file.  Don't change it; instead,
-** change libcoff-in.h or coffcode.h.
 
 This file is part of BFD, the Binary File Descriptor library.
 
Index: bfd/doc/Makefile.am
===================================================================
RCS file: /cvs/src/src/bfd/doc/Makefile.am,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Makefile.am
--- Makefile.am	1999/05/03 07:28:58	1.1.1.1
+++ Makefile.am	2001/10/01 13:15:09
@@ -183,30 +183,44 @@ s-linker: $(MKDOC) $(srcdir)/../linker.c
 	touch s-linker
 linker.texi: s-linker
 
-libbfd.h: $(srcdir)/../libbfd-in.h	\
+LIBBFD_H_DEP = $(srcdir)/../libbfd-in.h	\
 	$(srcdir)/../init.c		\
 	$(srcdir)/../libbfd.c		\
 	$(srcdir)/../cache.c		\
 	$(srcdir)/../reloc.c		\
 	$(srcdir)/../archures.c		\
+	$(srcdir)/../elf.c		\
+	$(srcdir)/header.sed		\
 	$(srcdir)/proto.str		\
 	$(MKDOC)
-	cat $(srcdir)/../libbfd-in.h >libbfd.h 
-	./$(MKDOC) -i -f $(srcdir)/proto.str  < $(srcdir)/../init.c >>libbfd.h
-	./$(MKDOC) -i -f $(srcdir)/proto.str  < $(srcdir)/../libbfd.c >>libbfd.h
-	./$(MKDOC) -i -f $(srcdir)/proto.str  < $(srcdir)/../cache.c >>libbfd.h
-	./$(MKDOC) -i -f $(srcdir)/proto.str  < $(srcdir)/../reloc.c >>libbfd.h
-	./$(MKDOC) -i -f $(srcdir)/proto.str  < $(srcdir)/../archures.c >>libbfd.h
-	./$(MKDOC) -i -f $(srcdir)/proto.str  < $(srcdir)/../elf.c >>libbfd.h
 
-libcoff.h: $(srcdir)/../libcoff-in.h	\
+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 ;; \
+	    *) ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \
+	  esac; \
+	done
+
+LIBCOFF_H_DEP = $(srcdir)/../libcoff-in.h	\
 	$(srcdir)/../coffcode.h		\
+	$(srcdir)/header.sed		\
 	$(srcdir)/proto.str		\
 	$(MKDOC)
-	cat $(srcdir)/../libcoff-in.h >libcoff.h
-	./$(MKDOC) -i -f $(srcdir)/proto.str  < $(srcdir)/../coffcode.h >>libcoff.h
+
+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 ;; \
+	    *) ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \
+	  esac; \
+	done
 
-bfd.h: $(srcdir)/../bfd-in.h 		\
+BFD_H_DEP = $(srcdir)/../bfd-in.h 	\
 	$(srcdir)/../init.c 		\
 	$(srcdir)/../opncls.c 		\
 	$(srcdir)/../libbfd.c 		\
@@ -219,25 +233,23 @@ bfd.h: $(srcdir)/../bfd-in.h 		\
 	$(srcdir)/../corefile.c		\
 	$(srcdir)/../targets.c		\
 	$(srcdir)/../format.c		\
+	$(srcdir)/header.sed		\
 	$(srcdir)/proto.str		\
 	$(MKDOC)
-	cat $(srcdir)/../bfd-in.h >bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../init.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../opncls.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../libbfd.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../section.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../archures.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../reloc.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../syms.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../bfd.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../archive.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../corefile.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../targets.c >>bfd.h
-	./$(MKDOC) -f $(srcdir)/proto.str<$(srcdir)/../format.c >>bfd.h	
-	echo "#ifdef __cplusplus" >>bfd.h
-	echo "}" >>bfd.h
-	echo "#endif" >>bfd.h
-	echo "#endif" >>bfd.h
+
+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 ;; \
+	    *) ./$(MKDOC) -f $(srcdir)/proto.str < $$file >> $@ ;; \
+	  esac; \
+	done
+	echo "#ifdef __cplusplus" >> $@
+	echo "}" >> $@
+	echo "#endif" >> $@
+	echo "#endif" >> $@
 
 noinst_TEXINFOS = bfdint.texi
 
Index: bfd/doc/header.sed
===================================================================
RCS file: header.sed
diff -N header.sed
--- /dev/null	Tue May  5 13:32:27 1998
+++ header.sed	Mon Oct  1 06:48:12 2001
@@ -0,0 +1,12 @@
+s|\(.*\) [^ ]*header.sed.*|\1|
+s|[^ ]*/||g
+s|^ *|"|
+s| |", "|g
+s|$|"|
+s|, \([^ ]*\)$| and \1|
+s|^|/* DO NOT EDIT!  -*- buffer-read-only: t -*-  This file is automatically generated from |
+s|\(.\{60\}[^ ]* \)|\1\
+   |g
+s|$|.\
+   Run "make headers" in your build bfd/ to regenerate.  */\
+|


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]