From db025289c4d6d4d798c3cc80c118b84ba13b6c76 Mon Sep 17 00:00:00 2001 From: Bruce Korb Date: Tue, 19 Oct 1999 13:22:45 +0000 Subject: [PATCH] use genfixes within Makefile.in and move comments to README From-SVN: r30086 --- gcc/ChangeLog | 8 ++ gcc/fixinc/Makefile.in | 28 +----- gcc/fixinc/README | 218 +++++++++++++++++++++++++++++++++------- gcc/fixinc/genfixes | 48 +++++++-- gcc/fixinc/inclhack.def | 63 +----------- 5 files changed, 239 insertions(+), 126 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 54dc7154700..fa012f66d06 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +1999-10-19 Bruce Korb + + * fixinc/Makefile.in: Change the generation rules to run `genfixes' + in the source tree when the generated targets are out of date + * fixinc/genfixes: Alter it to run individual fixes for make. + * fixinc/README: rewrite + * fixinc/inclhack.def: moved initial comments to README + Tue Oct 19 14:01:34 1999 Nick Clifton * toplev.c (main): Do not generate an error message if an diff --git a/gcc/fixinc/Makefile.in b/gcc/fixinc/Makefile.in index 62df3378dff..8c3f5dcfa47 100644 --- a/gcc/fixinc/Makefile.in +++ b/gcc/fixinc/Makefile.in @@ -76,7 +76,7 @@ gen : $(SH_TARGET) fixincl.x $(FIOBJ): $(HDR) -fixincl: $(FIOBJ) +fixincl: $(FIOBJ) fixfixes fixtests @echo $(CC) -o $@ $(FIOBJ) $(LIBERTY) $(LIB) ; \ if $(CC) -o $@ $(FIOBJ) $(LIBERTY) $(LIB) ; then : ; else \ rm -f $@ ; (echo "#! /bin/sh" ; echo exit 1 ) > $@ ; \ @@ -99,33 +99,13 @@ server.o : server.c server.h procopen.o : procopen.c server.h fixincl.x: fixincl.tpl inclhack.def - @if ( autogen --help > /dev/null 2>&1 ) ; then \ - echo autogen -T fixincl.tpl -b fixincl inclhack.def ; \ - autogen -T $(srcdir)/fixincl.tpl -b fixincl \ - $(srcdir)/inclhack.def ; \ - else echo You need to install autogen ; \ - if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \ - cp $(srcdir)/$@ . ; \ - else touch $@ ; fi ; fi + cd $(srcdir) ; ./genfixes $@ inclhack.sh: inclhack.def inclhack.tpl hackshell.tpl - @if ( autogen --help > /dev/null 2>&1 ) ; then \ - echo autogen inclhack.def ; \ - autogen -L$(srcdir) $(srcdir)/inclhack.def ; \ - else echo You need to install autogen ; \ - if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \ - cp $(srcdir)/$@ . ; \ - else touch $@ ; fi ; fi + cd $(srcdir) ; ./genfixes $@ fixincl.sh: inclhack.def inclhack.tpl - @if ( autogen --help > /dev/null 2>&1 ) ; then \ - echo autogen -DPROGRAM=1 -b fixincl inclhack.def ; \ - autogen -DPROGRAM=1 -b fixincl -L$(srcdir) \ - $(srcdir)/inclhack.def ; touch $@ ; \ - else echo You need to install autogen ; \ - if [ `pwd` != `cd $(srcdir) ; pwd` ] ; then \ - cp $(srcdir)/$@ . ; \ - else touch $@ ; fi ; fi + cd $(srcdir) ; ./genfixes $@ clean: rm -f *.o $(TARGETS) fixincl.x diff --git a/gcc/fixinc/README b/gcc/fixinc/README index bd5a8011f3f..85117f47550 100644 --- a/gcc/fixinc/README +++ b/gcc/fixinc/README @@ -1,42 +1,13 @@ -The fast-fixincludes system now, to the best of our collective belief, -correctly implements exactly the same functionality as the previous -fixincludes and fixinc.* shell scripts. On systems where many fixes -are required, this is accomplished by putting most of the -functionality into a binary executable. On systems that had dedicated -fixinc.* shell scripts, those scripts are still used by default until -they can be converted. +FIXINCLUDES OPERATION +===================== -POSSIBLE PROBLEMS - -There may be some systems on which the fixinc binary program appears -to be functional, but fails to work. Current thinking is that this -is due to some new process limitations (fork() calls) on those -systems. If you are experiencing this problem, then copy the script -${src}/gcc/fixinc/inclhack.sh into ${builddir}/gcc/fixinc.sh and run -make again. - -And, *please* also report the problem with a description of -the failure mode (symptoms) and the output from: - - egcs/config.guess - -to me: Bruce Korb - -TO DO - -* fixincl needs to be converted to use gcc's system.h, libiberty, and - other portability frameworks. - - -THEORY OF OPERATION - -See also: http://autogen.freeservers.com +See also: http://autogen.linuxbox.com/fixincludes The set of fixes required was distilled down to just the data required to specify what needed to happen for each fix. Those data were edited into a new file named gcc/fixinc/inclhack.def. A program called -AutoGen (http://autogen.freeservers.com) uses these definitions to +AutoGen (http://autogen.linuxbox.com) uses these definitions to instantiate several different templates (gcc/fixinc/*.tpl) that then produces a fixincludes replacement shell script (inclhack.sh), a replacement binary program (fixincl.x) and a script to drive the @@ -51,9 +22,182 @@ use the current fixinc.* for that system instead. Usually, the mkfixinc.sh script will be able to detect when the binary is not runable. If you do have problems, however, -please see "POSSIBLE PROBLEMS" above. Thank you. +please try configuring "--without-fast-fixincludes". Thank you. Regards, - Bruce - Robert - Manfred + Bruce + + + +POSSIBLE PROBLEMS +================= + +There may be some systems on which the fixinc binary program appears +to be functional, but fails to work. If you are experiencing this +problem, then copy the script ${src}/gcc/fixinc/inclhack.sh into +${builddir}/gcc/fixinc.sh and run make again. + +And, *please* also report the problem with a description of +the failure mode (symptoms) and the output from: + + egcs/config.guess + +to me: Bruce Korb + + + +GCC MAINTAINER INFORMATION +========================== + +If you are having some problem with a system header that is either +broken by the manufacturer, or is broken by the fixinclude process, +then you will need to alter or add information to the include fix +definitions file, ``inclhack.def''. Please also send relevant +information to gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org and, +please, to me: autogen@linuxbox.com. + +Here are the rules for making fixes in the inclhack.def file: + +1. Every fix must have a "hackname" that is compatible with C syntax + for variable names and is unique without regard to alphabetic case. + Please keep them alphabetical by this name. :-) + +2. If the problem is known to exist only in certain files, + then name each such file with a "files = " entry. + +3. It is relatively expensive to fire off a process to fix a source + file, therefore write apply tests to avoid unnecessary fix + processes. The preferred apply tests are "select", "bypass" and + "c_test" because they are performed internally. "test" sends + a command to a server shell that actually fires off one or more + processes to do the testing. Avoid it, if you can, but it is + still more efficient than a fix process. + + These tests are required to: + + 1. Be positive for all header files that require the fix. + + It is desireable to: + + 2. Be negative as often as possible whenever the fix is not + required, avoiding the process overhead. + + It is nice if: + + 3. The expression is as simple as possible to both + process and uderstand by people. :-) + + Please take advantage of the fact AutoGen will glue + together string fragments. It helps. Also take note + that double quote strings and single quote strings have + different formation rules. Double quote strings are + a tiny superset of C string syntax. Single quote strings + follow shell single quote string formation rules, except + that the backslash is processed before '\\', '\'' and '#' + characters (using C character syntax). + + Examples of test specifications: + + hackname = broken_assert_stdio; + files = assert.h; + select = stderr; + bypass = "include.*stdio.h"; + + The ``broken_assert_stdio'' fix will be applied only to a file + named "assert.h" if it contains the string "stderr" _and_ it + does _not_ contain the expression "include.*stdio.h". + + hackname = no_double_slash; + c_test = "double_slash"; + + The ``no_double_slash'' fix will be applied if the + ``double_slash_test()'' function says to. See ``fixtests.c'' + for documentation on how to include new functions into that + module. + +4. There are currently four methods of fixing a file: + + 1. a series of sed expressions. Each will be an individual + "-e" argument to a single invocation of sed. + + 2. a shell script. These scripts are _required_ to read all + of stdin in order to avoid pipe stalls. They may choose to + discard the input. + + 3. A C language subroutine method for both tests and fixes. + + 4. Replacement text. If the replacement is empty, then + no fix is applied. Otherwise, the replacement text is written + to the output file and no further fixes are applied. + + Replacement text "fixes" must be first in this file!! + + Examples of fixes: + ------------------ + + hackname = AAA_ki_iface; + replace; /* empty replacement -> no fixing the file */ + + When this ``fix'' is invoked, it will prevent any fixes + from being applied. + + ------------------ + + hackname = AAB_svr4_no_varargs; + replace = "/* This file was generated by fixincludes. */\n" + "#ifndef _SYS_VARARGS_H\n" + "#define _SYS_VARARGS_H\n\n" + + "#ifdef __STDC__\n" + "#include \n" + "#else\n" + "#include \n" + "#endif\n\n" + + "#endif /* _SYS_VARARGS_H */\n"; + + When this ``fix'' is invoked, the replacement text will be + emitted into the replacement include file. No further fixes + will be applied. + + ------------------ + + hackname = dec_intern_asm; + files = c_asm.h; + sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n"; + sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n" + "#endif\n"; + + When this ``fix'' is invoked, sed will be run on the original + file with two "-e" arguments. Since these arguments have double + quoted string values, the strings actually passed to ``sed'' + will have been processed in the same fashion that the C compiler + processes its string specifications. Including the concatenation + of the two pieces of the second sed "-e" argument. + + ------------------ + + hackname = m88k_multi_incl; + shell = + "echo Fixing $file, to protect against multiple inclusion. >&2 + cpp_wrapper=`echo $file | sed -e 's,\\.,_,g' -e 's,/,_,g'` + echo \"#ifndef __GCC_GOT_${cpp_wrapper}_\" + echo \"#define __GCC_GOT_${cpp_wrapper}_\" + cat + echo \"#endif /* ! __GCC_GOT_${cpp_wrapper}_ */\""; + + This is a shell script fix. Note the ``cat'' without any arguments. + This will drain stdin. If the contents of the file were to be + discarded, you would have to have something like ``cat > /dev/null'' + in the script. + + ------------------ + + hackname = no_double_slash; + c_fix = "no_double_slash"; + + This specifies a fix to be supplied via a hand coded internal + function named ``no_double_slash_fix()''. See ``fixfixes.c'' + for documentation on how to include new functions into that + module. + diff --git a/gcc/fixinc/genfixes b/gcc/fixinc/genfixes index 18b042a83a3..25964a0ea03 100755 --- a/gcc/fixinc/genfixes +++ b/gcc/fixinc/genfixes @@ -3,11 +3,47 @@ SHELL=/bin/sh export SHELL -echo AutoGen-ing inclhack.sh -autogen inclhack.def +if [ $# -eq 0 ] ; then + echo AutoGen-ing inclhack.sh + autogen inclhack.def -echo AutoGen-ing fixincl.x -autogen -T fixincl.tpl -b fixincl inclhack.def + echo AutoGen-ing fixincl.x + autogen -T fixincl.tpl -b fixincl inclhack.def -echo AutoGen-ing fixincl.sh -autogen -DPROGRAM=1 -b fixincl inclhack.def + echo AutoGen-ing fixincl.sh + autogen -DPROGRAM=1 -b fixincl inclhack.def + exit 0 +fi + +if (autogen --help > /dev/null 2>&1) ; then : ; else + echo "AutoGen does not appear to be correctly installed." + echo "Please download and install:" + echo " ftp://sourceware.cygnus.com/pub/egcs/infrastructure/autogen.tar.gz" + exit 1 +fi + +set -e + +case "$1" in +inclhack.def ) + echo AutoGen-ing inclhack.sh + autogen inclhack.sh + ;; + +fixincl.x ) + echo AutoGen-ing fixincl.x + autogen -T fixincl.tpl -b fixincl inclhack.def + ;; + +fixincl.sh ) + echo AutoGen-ing fixincl.sh + autogen -DPROGRAM=1 -b fixincl inclhack.def + ;; + +* ) + echo genfixes cannot create $1 + exit 1 + ;; +esac + +exit 0 diff --git a/gcc/fixinc/inclhack.def b/gcc/fixinc/inclhack.def index 266f3aeb56b..43847f8eb5d 100644 --- a/gcc/fixinc/inclhack.def +++ b/gcc/fixinc/inclhack.def @@ -1,69 +1,14 @@ + /* -*- Mode: C -*- */ autogen definitions inclhack; /* -Define all the fixes we know about for repairing damaged headers - -The rules for making fixes: - -1. Every fix must have a "hackname" that is compatible with C syntax - for variable names and is unique without regard to alphabetic case. - -2. If the problem is known to exist only in certain files, - then name each such file with a "files = " entry. - -3. It is relatively expensive to fire off a process to fix a source - file, therefore write apply tests to avoid unnecessary fix - processes. The preferred apply tests are "select" and "bypass" - because they are performed internally. "test" sends a command - to a server shell that actually fires off one or more processes - to do the testing. Avoid it, if you can, but it is still more - efficient than a fix process. - - These tests are required to: - - 1. Be positive for all header files that require the fix. - - It is desireable to: - - 2. Be negative as often as possible whenever the fix is not - required, avoiding the process overhead. - - It is nice if: - - 3. The expression is as simple as possible to both - process and uderstand by people. :-) - - Please take advantage of the fact AutoGen will glue - together string fragments. It helps. Also take note - that double quote strings and single quote strings have - different formation rules. Double quote strings are - a tiny superset of C string syntax. Single quote strings - follow shell single quote string formation rules, except - that the backslash is processed before '\\', '\'' and '#' - characters (using C character syntax). - -4. There are currently four methods of fixing a file: - - 1. a series of sed expressions. Each will be an individual - "-e" argument to a single invocation of sed. - - 2. a shell script. These scripts are _required_ to read all - of stdin in order to avoid pipe stalls. They may choose to - discard the input. - - 3. A C language subroutine method for both tests and fixes. - - 4. Replacement text. If the replacement is empty, then - no fix is applied. Otherwise, the replacement text is written - to the output file and no further fixes are applied. - - Replacement text "fixes" must be first in this file!! - +Define all the fixes we know about for repairing damaged headers. +Please see the README before adding or changing entries in this file. - Now, first: DO NOT DO BROKEN FIXES (empty replacement fixes) */ +Now, first: DO NOT DO BROKEN FIXES (empty replacement fixes) */ /* -- 2.30.2