1[= autogen template include =] 2[= 3# 4# This file contanes the shell template replacement for the 5# fixincl program. It is the repetitive guts of the fixincludes logic. 6# 7=] 8 echo Checking header files 9 for file in $files; do 10 11 # Skip unreadable files, symlinks to directories and glibc files 12 if test ! -r "${file}" || test -d "${file}/." \ 13 || fgrep 'This file is part of the GNU C Library' "${file}" \ 14 > /dev/null 2>&1; then 15 continue 16 fi 17 18 fixlist="" 19 DESTFILE=${DESTDIR}/`echo ${file} | sed "s;${FIND_BASE}/;;" ` 20[= 21# 22# FOR every fix description, 23# DO: emit the shell text to apply the fix to the current file 24# 25# =][= 26 27_FOR fix "\n\n" =] 28 # 29 # Fix [=_eval _index 1 + #%3d _printf=]: [=hackname _Cap=] 30 #[= 31 _IF files _exist=] 32 case "${file}" in [=_FOR files " | \\\n\t"=]./[=files=][=/files=] )[= 33 _ENDIF=][= 34 35 _IF mach _exist=] 36 case "$target_canonical" in [= 37 _FOR mach " | \\\n\t" =][= 38 mach =][= 39 /mach =] )[= 40 _IF mach_unmatched _exist =] : ;; 41 * )[= 42 _ENDIF =][= 43 44 _ENDIF=][= 45 46 # There are three conditional tests: select, bypass and test. 47 They may appear as often as desired. They must all pass for 48 the fix to be applied. "select" and "bypass" are egrep expressions 49 that must each appear (or not appear) in the target file. 50 "test" is an arbitrary test program expression that must yield 51 true or false. It is enclosed in parenthesis to avoid 52 precedence problems. The output looks like this: 53 54 if ( test -n "`egrep 'find-expr' ${file}`" -a 55 -z "`egrep 'not-find' ${file}`" -a 56 '(' <some-test-expression> ')' 57 ) > /dev/null 2>&1 ; then 58 59 # =][= 60 61 _IF select _exist =] 62 if ( test [= 63 _FOR select " -a \\\n " 64 =]-n [=select _shrstr "#`egrep %s ${file}`" 65 _printf _shstr =][= 66 /select=][= 67 68 _IF bypass _exist =][= 69 _FOR bypass=] -a \ 70 -z [=bypass _shrstr "#`egrep %s ${file}`" 71 _printf _shstr =][= 72 /bypass=][= 73 _ENDIF=][= 74 75 _IF test _exist=][= 76 _FOR test=] -a \ 77 '(' [=test=] ')'[= 78 /test=][= 79 _ENDIF=] 80 ) > /dev/null 2>&1 ; then[= 81 82 83 _ELIF test _exist =] 84 if ( test [= 85 _FOR test " -a \\\n " 86 =]'(' [=test=] ')'[= 87 /test=][= 88 89 _IF bypass _exist=][= 90 _FOR bypass=] -a \ 91 -z [=bypass _shrstr "#`egrep %s ${file}`" 92 _printf _shstr=][= 93 /bypass=][= 94 _ENDIF=] 95 ) > /dev/null 2>&1 ; then[= 96 97 98 _ELIF bypass _exist =] 99 if ( test [=_FOR bypass " -a \\\n " 100 =]-z [=bypass _shrstr "#`egrep %s ${file}`" 101 _printf _shstr=][=/bypass=] 102 ) > /dev/null 2>&1 ; then[= 103 104 _ENDIF=] 105 fixlist="${fixlist} 106 [=hackname=]" 107 if [ ! -r ${DESTFILE} ] 108 then infile=${file} 109 else infile=${DESTFILE} ; fi [= 110 111 _IF sed _exist=][= 112 _IF shell _exist =][= 113 _ERROR hackname _get 114 "fixincludes Error: %s fix has multiple fixups" _printf=][= 115 _ENDIF=] 116 117 sed [= 118 _FOR sed =]-e [=sed _shrstr=] \ 119 [= 120 /sed=] < $infile > ${DESTDIR}/fixinc.tmp[= 121 122 123 _ELIF shell _exist =] 124 ( [=shell=] ) < $infile > ${DESTDIR}/fixinc.tmp 125 126 # Shell scripts have the potential of removing the output 127 # We interpret that to mean the file is not to be altered 128 # 129 if test ! -f ${DESTDIR}/fixinc.tmp 130 then continue ; fi [= 131 132 133 _ELSE=][= 134 _ERROR hackname _get "ERROR: %s has no fixup" _printf=][= 135 136 _ENDIF=] 137 rm -f ${DESTFILE} 138 mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}[= 139 140 # Close off any opened "if" or "case" statements in reverse order 141 142 # =][= 143 144 _IF select _exist test _exist | bypass _exist | =] 145 fi # end of selection 'if'[= 146 _ENDIF =][= 147 148 _IF mach _exist=] 149 ;; # case end for machine type test 150 esac[= 151 _ENDIF =][= 152 153 _IF files _exist=] 154 ;; # case end for file name test 155 esac[= 156 _ENDIF =][= 157 158/fix =][= 159# 160# DONE with every fix for the current file 161# 162#=] 163 # IF the output has been removed OR it is unchanged, 164 # THEN ensure the output is gone 165 # ELSE look for local directory include syntax 166 # 167 if ( test ! -f ${DESTFILE} || \ 168 cmp ${file} ${DESTFILE} ) > /dev/null 2>&1 169 then 170 rm -f ${DESTFILE} 171 else 172 echo "Fixed ${file}:${fixlist}" 173 174 # Find any include directives that use "file". 175 # 176 dir=`echo ${file} | sed -e s';/[^/]*$;;'` 177 ddir=${DESTDIR}/$dir 178 179 for include in ` 180 egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${DESTFILE} | 181 sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'` 182 do 183 required="$required ${SRCDIR} $dir/$include ${ddir}/$include" 184 done 185 fi 186 done # for file in $files 187