3 # DO NOT EDIT THIS FILE - it has been generated
5 # Install modified versions of certain ANSI-incompatible system header
6 # files which are fixed to work correctly with ANSI C and placed in a
7 # directory that GNU C will search.
9 # This script contains 113 fixup scripts.
11 # See README-fixinc for more information.
13 # fixincludes copyright (c) 2000 The Free Software Foundation, Inc.
15 # fixincludes is free software.
17 # You may redistribute it and/or modify it under the terms of the
18 # GNU General Public License, as published by the Free Software
19 # Foundation; either version 2, or (at your option) any later version.
21 # fixincludes is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 # See the GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with fixincludes. See the file "COPYING". If not,
28 # write to: The Free Software Foundation, Inc.,
29 # 59 Temple Place - Suite 330,
30 # Boston, MA 02111-1307, USA.
32 # # # # # # # # # # # # # # # # # # # # #
34 # Directory in which to store the results.
35 # Fail if no arg to specify a directory for the output.
38 echo fixincludes: no output directory specified
45 # Make sure it exists.
46 if [ ! -d $LIB ]; then
48 echo fixincludes: output dir '`'$LIB"' cannot be created"
52 ( cd $LIB && touch DONE && rm DONE ) || {
53 echo fixincludes: output dir '`'$LIB"' is an invalid directory"
69 # Define what target system we're fixing.
71 if test -r ./Makefile; then
72 target_canonical="`sed -n -e 's,^target[ ]*=[ ]*\(.*\)$,\1,p' < Makefile`"
75 # If not from the Makefile, then try config.guess
77 if test -z "${target_canonical}" ; then
78 if test -x ./config.guess ; then
79 target_canonical="`config.guess`" ; fi
80 test -z "${target_canonical}" && target_canonical=unknown
82 export target_canonical
84 # # # # # # # # # # # # # # # # # # # # #
86 # Define PWDCMD as a command to use to get the working dir
87 # in the form that we want.
92 # On an Apollo, discard everything before `/usr'.
93 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
99 FIXINCL=${ORIGDIR}/fixincl
102 # Make LIB absolute only if needed to avoid problems with the amd.
107 cd $LIB; LIB=`${PWDCMD}`
111 if test $VERBOSE -gt 0
112 then echo Fixing headers into ${LIB} for ${target_canonical} target ; fi
114 # Determine whether this system has symbolic links.
115 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
116 rm -f $LIB/ShouldNotExist
118 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
119 rm -f /tmp/ShouldNotExist
125 # # # # # # # # # # # # # # # # # # # # #
127 # Search each input directory for broken header files.
128 # This loop ends near the end of the file.
132 INPUTLIST="/usr/include"
137 for INPUT in ${INPUTLIST} ; do
141 cd ${INPUT} || continue
145 # # # # # # # # # # # # # # # # # # # # #
147 if test $VERBOSE -gt 1
148 then echo Finding directories and links to directories ; fi
150 # Find all directories and all symlinks that point to directories.
151 # Put the list in $all_dirs.
152 # Each time we find a symlink, add it to newdirs
153 # so that we do another find within the dir the link points to.
154 # Note that $all_dirs may have duplicates in it;
155 # later parts of this file are supposed to ignore them.
161 while [ -n "$dirs" ] && [ $levels -gt 0 ]
163 levels=`expr $levels - 1`
167 if test $VERBOSE -gt 1
168 then echo " Searching $INPUT/$d" ; fi
170 # Find all directories under $d, relative to $d, excluding $d itself.
171 # (The /. is needed after $d in case $d is a symlink.)
172 all_dirs="$all_dirs `find $d/. -type d -print | \
173 sed -e '/\/\.$/d' -e 's@/./@/@g'`"
174 # Find all links to directories.
175 # Using `-exec test -d' in find fails on some systems,
176 # and trying to run test via sh fails on others,
177 # so this is the simplest alternative left.
178 # First find all the links, then test each one.
181 theselinks=`find $d/. -type l -print | sed -e 's@/./@/@g'`
182 for d1 in $theselinks --dummy--
184 # If the link points to a directory,
185 # add that dir to $newdirs
188 all_dirs="$all_dirs $d1"
189 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
191 newdirs="$newdirs $d1"
192 search_dirs="$search_dirs $d1"
201 # # # # # # # # # # # # # # # # # # # # #
204 if test $VERBOSE -gt 2
205 then echo "All directories (including links to directories):"
209 for file in $all_dirs; do
211 if [ ! -d $LIB/$file ]
212 then mkdir $LIB/$file
217 # # # # # # # # # # # # # # # # # # # # #
219 # treetops gets an alternating list
220 # of old directories to copy
221 # and the new directories to copy to.
225 if test $VERBOSE -gt 1
226 then echo 'Making symbolic directory links' ; fi
229 for sym_link in $search_dirs; do
231 dest=`ls -ld ${sym_link} | sed -n 's/.*-> //p'`
233 # In case $dest is relative, get to ${sym_link}'s dir first.
235 cd ./`echo ${sym_link} | sed 's;/[^/]*$;;'`
237 # Check that the target directory exists.
238 # Redirections changed to avoid bug in sh on Ultrix.
240 (cd $dest) > /dev/null 2>&1
244 # full_dest_dir gets the dir that the link actually leads to.
246 full_dest_dir=`${PWDCMD}`
248 # Canonicalize ${INPUT} now to minimize the time an
249 # automounter has to change the result of ${PWDCMD}.
251 cinput=`cd ${INPUT}; ${PWDCMD}`
253 # If a link points to ., make a similar link to .
255 if [ ${full_dest_dir} = ${cinput} ]; then
256 if test $VERBOSE -gt 2
257 then echo ${sym_link} '->' . ': Making self link' ; fi
258 rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
259 ln -s . ${LIB}/${sym_link} > /dev/null 2>&1
261 # If link leads back into ${INPUT},
262 # make a similar link here.
264 elif expr ${full_dest_dir} : "${cinput}/.*" > /dev/null; then
265 # Y gets the actual target dir name, relative to ${INPUT}.
266 y=`echo ${full_dest_dir} | sed -n "s&${cinput}/&&p"`
267 # DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}.
268 dots=`echo "${sym_link}" |
269 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
270 if test $VERBOSE -gt 2
271 then echo ${sym_link} '->' $dots$y ': Making local link' ; fi
272 rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
273 ln -s $dots$y ${LIB}/${sym_link} > /dev/null 2>&1
276 # If the link is to a dir $target outside ${INPUT},
277 # repoint the link at ${INPUT}/root$target
278 # and process $target into ${INPUT}/root$target
279 # treat this directory as if it actually contained the files.
281 if test $VERBOSE -gt 2
282 then echo ${sym_link} '->' root${full_dest_dir} ': Making rooted link'
284 if [ -d $LIB/root${full_dest_dir} ]
287 dirname=root${full_dest_dir}/
290 while [ x$dirname != x ]; do
291 component=`echo $dirname | sed -e 's|/.*$||'`
292 mkdir $component >/dev/null 2>&1
294 dirmade=$dirmade/$component
295 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
299 # Duplicate directory structure created in ${LIB}/${sym_link} in new
302 for file2 in $all_dirs; do
305 dupdir=${LIB}/root${full_dest_dir}/`echo $file2 |
306 sed -n "s|^${sym_link}/||p"`
307 if test $VERBOSE -gt 2
308 then echo "Duplicating ${sym_link}'s ${dupdir}" ; fi
320 # Get the path from ${LIB} to ${sym_link}, accounting for symlinks.
322 parent=`echo "${sym_link}" | sed -e 's@/[^/]*$@@'`
323 libabs=`cd ${LIB}; ${PWDCMD}`
324 file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"`
326 # DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}.
328 dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'`
329 rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
330 ln -s ${dots}root${full_dest_dir} ${LIB}/${sym_link} > /dev/null 2>&1
331 treetops="$treetops ${sym_link} ${LIB}/root${full_dest_dir}"
337 # # # # # # # # # # # # # # # # # # # # #
342 while [ $# != 0 ]; do
343 # $1 is an old directory to copy, and $2 is the new directory to copy to.
345 SRCDIR=`cd ${INPUT} ; cd $1 ; ${PWDCMD}`
352 DESTDIR=`cd $1;${PWDCMD}`
356 # The same dir can appear more than once in treetops.
357 # There's no need to scan it more than once.
359 if [ -f ${DESTDIR}/DONE ]
362 touch ${DESTDIR}/DONE
363 if test $VERBOSE -gt 1
364 then echo Fixing directory ${SRCDIR} into ${DESTDIR} ; fi
366 # Check files which are symlinks as well as those which are files.
369 required="$required `if $LINKS; then
370 find ${FIND_BASE}/. -name '*.h' \( -type f -o -type l \) -print
372 find ${FIND_BASE}/. -name '*.h' -type f -print
374 sed -e 's;/\./;/;g' -e 's;//*;/;g' | \
378 ## Make sure that any include files referenced using double quotes
379 ## exist in the fixed directory. This comes last since otherwise
380 ## we might end up deleting some of these files "because they don't
382 set x `echo $required`
384 while [ $# != 0 ]; do
386 while [ $# != 0 ]; do
387 # $1 is the directory to copy from,
388 # $2 is the unfixed file,
389 # $3 is the fixed file name.
394 if [ -r $2 ] && [ ! -r $3 ]; then
395 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
396 chmod +w $3 2>/dev/null
397 chmod a+r $3 2>/dev/null
398 if test $VERBOSE -gt 2
399 then echo Copied $2 ; fi
400 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 |
401 sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`
403 dir=`echo $2 | sed -e s'|/[^/]*$||'`
404 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
405 newreq="$newreq $1 $dir/$include $dir2/$include"
415 if test $VERBOSE -gt 2
416 then echo 'Cleaning up DONE files.' ; fi
418 find . -name DONE -exec rm -f '{}' ';'
420 if test $VERBOSE -gt 1
421 then echo 'Cleaning up unneeded directories:' ; fi
423 all_dirs=`find . -type d \! -name '.' -print | sort -r`
424 for file in $all_dirs; do
425 rmdir $LIB/$file > /dev/null 2>&1
428 if test $VERBOSE -gt 0
429 then echo fixincludes is done ; fi
431 # # # # # # # # # # # # # # # # # # # # #
433 # End of for INPUT directories
437 # # # # # # # # # # # # # # # # # # # # #
439 if [ x${INSTALL_ASSERT_H} != x ] && [ -f ${srcdir}/assert.h ]
442 rm -f include/assert.h
443 cp ${srcdir}/assert.h include/assert.h || exit 1
444 chmod a+r include/assert.h