1 [= autogen template include =]
3 # $Id: hackshell.tpl,v 1.2 1998/12/16 21:19:08 law Exp $
5 # This file contanes the shell template replacement for the
6 # fixincl program. It is the repetitive guts of the fixincludes logic.
10 files=`find . -name '*.h' \( -type f -o -type l \) -print`
12 files=`find . -name '*.h' -type f -print`
14 echo Checking header files
15 for file in $files; do
17 if ( test ! -r $file -o \
18 -n "`fgrep 'This file is part of the GNU C Library' $file`" )
24 # FOR every fix description,
25 # DO: emit the shell text to apply the fix to the current file
31 # Fix [=_eval _index 1 + #%3d _printf=]: [=hackname _Cap=]
34 case "$file" in [=_FOR files " | \\\n\t"=]./[=files=][=/files=] )[=
38 case "$target_canonical" in [=
39 _FOR mach " | \\\n\t" =][=
42 _IF mach_unmatched _exist =] : ;;
48 # There are three conditional tests: select, bypass and test.
49 They may appear as often as desired. They must all pass for
50 the fix to be applied. "select" and "bypass" are egrep expressions
51 that must each appear (or not appear) in the target file.
52 "test" is an arbitrary test program expression that must yield
53 true or false. It is enclosed in parenthesis to avoid
54 precedence problems. The output looks like this:
56 if ( test -n "`egrep 'find-expr' $file`" -a
57 -z "`egrep 'not-find' $file`" -a
58 '(' <some-test-expression> ')'
59 ) > /dev/null 2>&1 ; then
65 _FOR select " -a \\\n "
66 =]-n [=select _shrstr "#`egrep %s $file`"
70 _IF bypass _exist =][=
72 -z [=bypass _shrstr "#`egrep %s $file`"
82 ) > /dev/null 2>&1 ; then[=
93 -z [=bypass _shrstr "#`egrep %s $file`"
97 ) > /dev/null 2>&1 ; then[=
100 _ELIF bypass _exist =]
101 if ( test [=_FOR bypass " -a \\\n "
102 =]-z [=bypass _shrstr "#`egrep %s $file`"
103 _printf _shstr=][=/bypass=]
104 ) > /dev/null 2>&1 ; then[=
109 if [ ! -r ${DESTDIR}/$file ]
111 else infile=${DESTDIR}/$file ; fi [=
114 _IF shell _exist =][=
116 "fixincludes Error: %s fix has multiple fixups" _printf=][=
120 _FOR sed =]-e [=sed _shrstr=] \
122 /sed=] < $infile > ${DESTDIR}/$file.[=
125 _ELIF shell _exist =]
126 ( [=shell=] ) < $infile > ${DESTDIR}/$file.
128 # Shell scripts have the potential of removing the output
129 # We interpret that to mean the file is not to be altered
131 if test ! -f ${DESTDIR}/$file.
132 then continue ; fi [=
136 _ERROR hackname _get "ERROR: %s has no fixup" _printf=][=
140 mv -f ${DESTDIR}/$file. ${DESTDIR}/$file[=
142 # Close off any opened "if" or "case" statements in reverse order
146 _IF select _exist test _exist | bypass _exist | =]
147 fi # end of selection 'if'[=
151 ;; # case end for machine type test
156 ;; # case end for file name test
162 # DONE with every fix for the current file
165 # IF the output has been removed OR it is unchanged,
166 # THEN ensure the output is gone
167 # ELSE look for local directory include syntax
169 if ( test ! -f ${DESTDIR}/$file || \
170 cmp $file ${DESTDIR}/$file ) > /dev/null 2>&1
172 rm -f ${DESTDIR}/$file
174 echo "Fixed $file:${fixlist}"
176 # Find any include directives that use "file".
179 egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${DESTDIR}/$file |
180 sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`
182 dir=`echo $file | sed -e s'|/[^/]*$||'`
183 required="$required ${SRCDIR} $dir/$include ${DESTDIR}/$dir/$include"
186 done # for file in $files