This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Allow options.[ch] to be possibly regenerated after reconfigure--enable-languages=xxx


Alexandre Oliva wrote:
On Jul 8, 2003, Kelley Cook <kcook34@ford.com> wrote:

b) Because of a) I ended up hardcoding "options.h" in the generated
"options.c" otherwise it was being created with '#include
"tmp-options.h"'  This may not be palatable to you in which case I am
open to other suggestions

Maybe move the move-if-change commands into opts.sh, and get opts.sh to choose the temporary names itself?

A most excellent idea, how's this?


Bootstrapped and tested on i686-pc-cygwin

Kelley Cook


2003-07-08  Kelley Cook  <kelleycook@wideopenwest.com>

	* Makefile.in (options.h): Depend on Makefile.  Add in $(srcdir)
	to opts.sh command line.
	* opts.sh: Write to temporary files with a move-if-change at the end.

--- Makefile.in.orig	2003-07-08 16:46:05.000000000 -0400
+++ Makefile.in	2003-07-08 16:44:39.000000000 -0400
@@ -1416,8 +1416,8 @@
 
 options.c: $(lang_opt_files) $(srcdir)/opts.sh options.h
 
-options.h: $(lang_opt_files) $(srcdir)/opts.sh
-	AWK=$(AWK) $(SHELL) $(srcdir)/opts.sh options.c options.h \
+options.h: $(lang_opt_files) $(srcdir)/opts.sh Makefile
+	AWK=$(AWK) $(SHELL) $(srcdir)/opts.sh $(srcdir) options.c options.h \
 		$(lang_opt_files)
 
 dumpvers: dumpvers.c
--- opts.sh.orig	2003-07-08 16:50:09.000000000 -0400
+++ opts.sh	2003-07-08 16:46:05.000000000 -0400
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Usage: opts.sh outfile.c outfile.h file1.opt [file2.opt, ...]
+# Usage: opts.sh srcdir outfile.c outfile.h file1.opt [file2.opt, ...]
 
 # Always operate in the C locale.
 LANG=C
@@ -30,8 +30,11 @@
 
 SORT=sort		# Could be /bin/sort or /usr/bin/sort
 
+SRCDIR=$1; shift
 C_FILE=$1; shift
 H_FILE=$1; shift
+TMP_C_FILE=tmp-${C_FILE}
+TMP_H_FILE=tmp-${H_FILE}
 
 ${AWK} '
 	# Ignore comments and blank lines
@@ -81,12 +84,13 @@
 # Dump out an enumeration into a .h file, and an array of options into a
 # C file.  Combine the flags of duplicate options.
     END {
-	c_file = "'${C_FILE}'"
-	h_file = "'${H_FILE}'"
+	c_file = "'${TMP_C_FILE}'"
+	h_file = "'${TMP_H_FILE}'"
+	realh_file = "'${H_FILE}'"
 	comma = ","
 
 	print "/* This file is auto-generated by opts.sh.  */\n" > c_file
-	print "#include \"" h_file "\""			>> c_file
+	print "#include \"" realh_file "\""		>> c_file
 	print "#include \"opts.h\"\n"			>> c_file
 	print "const char * const lang_names[] =\n{"	>> c_file
 
@@ -150,3 +154,6 @@
 	print "};"					>> c_file
     }
 '
+
+${SRCDIR}/move-if-change ${TMP_H_FILE} ${H_FILE}
+${SRCDIR}/move-if-change ${TMP_C_FILE} ${C_FILE}

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