]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/fixinc/fixincl.sh
* class.c (layout_class_type): Put the fields required to make a
[thirdparty/gcc.git] / gcc / fixinc / fixincl.sh
CommitLineData
fdb8fb96 1#!/bin/sh
2#
c1b28c63 3# DO NOT EDIT THIS FILE - it has been generated
fdb8fb96 4#
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.
8#
ada96dc2 9# This script contains 113 fixup scripts.
fdb8fb96 10#
11# See README-fixinc for more information.
12#
d6d7d999 13# fixincludes copyright (c) 2000 The Free Software Foundation, Inc.
c1b28c63 14#
fdb8fb96 15# fixincludes is free software.
16#
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.
20#
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.
25#
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.
31#
32# # # # # # # # # # # # # # # # # # # # #
33#
34# Directory in which to store the results.
35# Fail if no arg to specify a directory for the output.
36if [ "x$1" = "x" ]
a98784e9 37then
38 echo fixincludes: no output directory specified
39 exit 1
fdb8fb96 40fi
41
42LIB=${1}
43shift
44
45# Make sure it exists.
46if [ ! -d $LIB ]; then
47 mkdir $LIB || {
48 echo fixincludes: output dir '`'$LIB"' cannot be created"
49 exit 1
50 }
51else
b4118095 52 ( cd $LIB && touch DONE && rm DONE ) || {
fdb8fb96 53 echo fixincludes: output dir '`'$LIB"' is an invalid directory"
54 exit 1
55 }
56fi
57
a98784e9 58if test -z "$VERBOSE"
59then
60 VERBOSE=2
61 export VERBOSE
62else
63 case "$VERBOSE" in
64 [0-9] ) : ;;
65 * ) VERBOSE=3 ;;
66 esac
67fi
68
fdb8fb96 69# Define what target system we're fixing.
70#
71if test -r ./Makefile; then
72 target_canonical="`sed -n -e 's,^target[ ]*=[ ]*\(.*\)$,\1,p' < Makefile`"
73fi
74
75# If not from the Makefile, then try config.guess
76#
77if 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
81fi
82export target_canonical
83
84# # # # # # # # # # # # # # # # # # # # #
85#
86# Define PWDCMD as a command to use to get the working dir
87# in the form that we want.
88PWDCMD=pwd
89
90case "`$PWDCMD`" in
91//*)
92 # On an Apollo, discard everything before `/usr'.
93 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
94 ;;
95esac
96
97# Original directory.
98ORIGDIR=`${PWDCMD}`
99FIXINCL=${ORIGDIR}/fixincl
100export FIXINCL
101
102# Make LIB absolute only if needed to avoid problems with the amd.
103case $LIB in
104/*)
105 ;;
106*)
107 cd $LIB; LIB=`${PWDCMD}`
108 ;;
109esac
110
a98784e9 111if test $VERBOSE -gt 0
112then echo Fixing headers into ${LIB} for ${target_canonical} target ; fi
38ebab8a 113
fdb8fb96 114# Determine whether this system has symbolic links.
115if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
116 rm -f $LIB/ShouldNotExist
117 LINKS=true
118elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
119 rm -f /tmp/ShouldNotExist
120 LINKS=true
121else
122 LINKS=false
123fi
38ebab8a 124
fdb8fb96 125# # # # # # # # # # # # # # # # # # # # #
126#
127# Search each input directory for broken header files.
128# This loop ends near the end of the file.
129#
130if test $# -eq 0
131then
132 INPUTLIST="/usr/include"
133else
134 INPUTLIST="$@"
135fi
136
137for INPUT in ${INPUTLIST} ; do
138
139cd ${ORIGDIR}
140
fa28adb8 141# Make sure a directory exists before changing into it,
142# otherwise Solaris2 will fail-exit the script.
143#
144if [ ! -d ${INPUT} ]; then
145 continue
146fi
147cd ${INPUT}
148
38ebab8a 149INPUT=`${PWDCMD}`
fdb8fb96 150
151#
152# # # # # # # # # # # # # # # # # # # # #
153#
a98784e9 154if test $VERBOSE -gt 1
155then echo Finding directories and links to directories ; fi
fdb8fb96 156
157# Find all directories and all symlinks that point to directories.
38ebab8a 158# Put the list in $all_dirs.
fdb8fb96 159# Each time we find a symlink, add it to newdirs
160# so that we do another find within the dir the link points to.
38ebab8a 161# Note that $all_dirs may have duplicates in it;
fdb8fb96 162# later parts of this file are supposed to ignore them.
163dirs="."
164levels=2
38ebab8a 165all_dirs=""
166search_dirs=""
167
fdb8fb96 168while [ -n "$dirs" ] && [ $levels -gt 0 ]
169do
38ebab8a 170 levels=`expr $levels - 1`
171 newdirs=
172 for d in $dirs
173 do
a98784e9 174 if test $VERBOSE -gt 1
175 then echo " Searching $INPUT/$d" ; fi
38ebab8a 176
fdb8fb96 177 # Find all directories under $d, relative to $d, excluding $d itself.
178 # (The /. is needed after $d in case $d is a symlink.)
38ebab8a 179 all_dirs="$all_dirs `find $d/. -type d -print | \
fdb8fb96 180 sed -e '/\/\.$/d' -e 's@/./@/@g'`"
181 # Find all links to directories.
182 # Using `-exec test -d' in find fails on some systems,
183 # and trying to run test via sh fails on others,
184 # so this is the simplest alternative left.
185 # First find all the links, then test each one.
186 theselinks=
187 $LINKS && \
188 theselinks=`find $d/. -type l -print | sed -e 's@/./@/@g'`
189 for d1 in $theselinks --dummy--
190 do
38ebab8a 191 # If the link points to a directory,
192 # add that dir to $newdirs
193 if [ -d $d1 ]
194 then
195 all_dirs="$all_dirs $d1"
fdb8fb96 196 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
197 then
38ebab8a 198 newdirs="$newdirs $d1"
199 search_dirs="$search_dirs $d1"
fdb8fb96 200 fi
38ebab8a 201 fi
fdb8fb96 202 done
38ebab8a 203 done
204
205 dirs="$newdirs"
fdb8fb96 206done
38ebab8a 207
fdb8fb96 208# # # # # # # # # # # # # # # # # # # # #
209#
210dirs=
a98784e9 211if test $VERBOSE -gt 2
212then echo "All directories (including links to directories):"
213 echo $all_dirs
214fi
38ebab8a 215
216for file in $all_dirs; do
fdb8fb96 217 rm -rf $LIB/$file
218 if [ ! -d $LIB/$file ]
219 then mkdir $LIB/$file
220 fi
221done
222mkdir $LIB/root
38ebab8a 223
fdb8fb96 224# # # # # # # # # # # # # # # # # # # # #
225#
226# treetops gets an alternating list
227# of old directories to copy
228# and the new directories to copy to.
38ebab8a 229treetops=". ${LIB}"
230
fdb8fb96 231if $LINKS; then
a98784e9 232 if test $VERBOSE -gt 1
233 then echo 'Making symbolic directory links' ; fi
38ebab8a 234 cwd=`${PWDCMD}`
235
236 for sym_link in $search_dirs; do
237 cd ${INPUT}
238 dest=`ls -ld ${sym_link} | sed -n 's/.*-> //p'`
239
240 # In case $dest is relative, get to ${sym_link}'s dir first.
241 #
242 cd ./`echo ${sym_link} | sed 's;/[^/]*$;;'`
243
244 # Check that the target directory exists.
245 # Redirections changed to avoid bug in sh on Ultrix.
246 #
247 (cd $dest) > /dev/null 2>&1
248 if [ $? = 0 ]; then
249 cd $dest
250
251 # full_dest_dir gets the dir that the link actually leads to.
252 #
253 full_dest_dir=`${PWDCMD}`
254
255 # Canonicalize ${INPUT} now to minimize the time an
256 # automounter has to change the result of ${PWDCMD}.
257 #
258 cinput=`cd ${INPUT}; ${PWDCMD}`
259
260 # If a link points to ., make a similar link to .
261 #
262 if [ ${full_dest_dir} = ${cinput} ]; then
a98784e9 263 if test $VERBOSE -gt 2
264 then echo ${sym_link} '->' . ': Making self link' ; fi
38ebab8a 265 rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
266 ln -s . ${LIB}/${sym_link} > /dev/null 2>&1
267
268 # If link leads back into ${INPUT},
269 # make a similar link here.
270 #
271 elif expr ${full_dest_dir} : "${cinput}/.*" > /dev/null; then
272 # Y gets the actual target dir name, relative to ${INPUT}.
273 y=`echo ${full_dest_dir} | sed -n "s&${cinput}/&&p"`
274 # DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}.
275 dots=`echo "${sym_link}" |
276 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
a98784e9 277 if test $VERBOSE -gt 2
278 then echo ${sym_link} '->' $dots$y ': Making local link' ; fi
38ebab8a 279 rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
280 ln -s $dots$y ${LIB}/${sym_link} > /dev/null 2>&1
281
fdb8fb96 282 else
38ebab8a 283 # If the link is to a dir $target outside ${INPUT},
284 # repoint the link at ${INPUT}/root$target
285 # and process $target into ${INPUT}/root$target
286 # treat this directory as if it actually contained the files.
287 #
a98784e9 288 if test $VERBOSE -gt 2
289 then echo ${sym_link} '->' root${full_dest_dir} ': Making rooted link'
290 fi
38ebab8a 291 if [ -d $LIB/root${full_dest_dir} ]
fdb8fb96 292 then true
293 else
38ebab8a 294 dirname=root${full_dest_dir}/
295 dirmade=.
296 cd $LIB
297 while [ x$dirname != x ]; do
298 component=`echo $dirname | sed -e 's|/.*$||'`
299 mkdir $component >/dev/null 2>&1
300 cd $component
301 dirmade=$dirmade/$component
302 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
fdb8fb96 303 done
38ebab8a 304 fi
305
306 # Duplicate directory structure created in ${LIB}/${sym_link} in new
307 # root area.
308 #
309 for file2 in $all_dirs; do
310 case $file2 in
311 ${sym_link}/*)
312 dupdir=${LIB}/root${full_dest_dir}/`echo $file2 |
313 sed -n "s|^${sym_link}/||p"`
a98784e9 314 if test $VERBOSE -gt 2
315 then echo "Duplicating ${sym_link}'s ${dupdir}" ; fi
38ebab8a 316 if [ -d ${dupdir} ]
317 then true
318 else
319 mkdir ${dupdir}
320 fi
321 ;;
322 *)
323 ;;
324 esac
325 done
326
327 # Get the path from ${LIB} to ${sym_link}, accounting for symlinks.
328 #
329 parent=`echo "${sym_link}" | sed -e 's@/[^/]*$@@'`
330 libabs=`cd ${LIB}; ${PWDCMD}`
331 file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"`
332
333 # DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}.
334 #
335 dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'`
336 rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
337 ln -s ${dots}root${full_dest_dir} ${LIB}/${sym_link} > /dev/null 2>&1
338 treetops="$treetops ${sym_link} ${LIB}/root${full_dest_dir}"
fdb8fb96 339 fi
fdb8fb96 340 fi
341 done
342fi
38ebab8a 343
fdb8fb96 344# # # # # # # # # # # # # # # # # # # # #
345#
346required=
347set x $treetops
348shift
349while [ $# != 0 ]; do
350 # $1 is an old directory to copy, and $2 is the new directory to copy to.
351 #
352 SRCDIR=`cd ${INPUT} ; cd $1 ; ${PWDCMD}`
353 export SRCDIR
38ebab8a 354
355 FIND_BASE=$1
356 export FIND_BASE
fdb8fb96 357 shift
358
359 DESTDIR=`cd $1;${PWDCMD}`
360 export DESTDIR
361 shift
362
363 # The same dir can appear more than once in treetops.
364 # There's no need to scan it more than once.
365 #
366 if [ -f ${DESTDIR}/DONE ]
367 then continue ; fi
368
369 touch ${DESTDIR}/DONE
a98784e9 370 if test $VERBOSE -gt 1
371 then echo Fixing directory ${SRCDIR} into ${DESTDIR} ; fi
fdb8fb96 372
38ebab8a 373 # Check files which are symlinks as well as those which are files.
fdb8fb96 374 #
38ebab8a 375 cd ${INPUT}
fdb8fb96 376 required="$required `if $LINKS; then
c1b28c63 377 find ${FIND_BASE}/. -name '*.h' \( -type f -o -type l \) -print
fdb8fb96 378 else
c1b28c63 379 find ${FIND_BASE}/. -name '*.h' -type f -print
38ebab8a 380 fi | \
b4136341 381 sed -e 's;/\./;/;g' -e 's;//*;/;g' | \
38ebab8a 382 ${FIXINCL}`"
fdb8fb96 383done
384
385## Make sure that any include files referenced using double quotes
386## exist in the fixed directory. This comes last since otherwise
387## we might end up deleting some of these files "because they don't
388## need any change."
389set x `echo $required`
390shift
391while [ $# != 0 ]; do
392 newreq=
393 while [ $# != 0 ]; do
394 # $1 is the directory to copy from,
395 # $2 is the unfixed file,
396 # $3 is the fixed file name.
397 #
398 cd ${INPUT}
399 cd $1
6bd06916 400 if [ -f $2 ] ; then
401 if [ -r $2 ] && [ ! -r $3 ]; then
402 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
403 chmod +w $3 2>/dev/null
404 chmod a+r $3 2>/dev/null
a98784e9 405 if test $VERBOSE -gt 2
406 then echo Copied $2 ; fi
6bd06916 407 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 |
fdb8fb96 408 sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`
6bd06916 409 do
410 dir=`echo $2 | sed -e s'|/[^/]*$||'`
411 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
412 newreq="$newreq $1 $dir/$include $dir2/$include"
413 done
414 fi
fdb8fb96 415 fi
416 shift; shift; shift
417 done
418 set x $newreq
419 shift
420done
421
a98784e9 422if test $VERBOSE -gt 2
423then echo 'Cleaning up DONE files.' ; fi
fdb8fb96 424cd $LIB
425find . -name DONE -exec rm -f '{}' ';'
426
a98784e9 427if test $VERBOSE -gt 1
428then echo 'Cleaning up unneeded directories:' ; fi
fdb8fb96 429cd $LIB
0f5d49d3 430all_dirs=`find . -type d \! -name '.' -print | sort -r`
38ebab8a 431for file in $all_dirs; do
5c8553ad 432 rmdir $LIB/$file > /dev/null 2>&1
fdb8fb96 433done
434
a98784e9 435if test $VERBOSE -gt 0
436then echo fixincludes is done ; fi
437
fdb8fb96 438# # # # # # # # # # # # # # # # # # # # #
439#
440# End of for INPUT directories
441#
442done
443#
444# # # # # # # # # # # # # # # # # # # # #
445
51c6d414 446if [ x${INSTALL_ASSERT_H} != x ] && [ -f ${srcdir}/assert.h ]
447then
448 cd $ORIGDIR
449 rm -f include/assert.h
450 cp ${srcdir}/assert.h include/assert.h || exit 1
451 chmod a+r include/assert.h
452fi