* except.c (expand_start_catch_block): We only need the rethrow
[official-gcc.git] / gcc / fixinc.dgux
blob422ba5f725fd0d3ef3ed5986db8b5a1002f8fafb
1 #!/bin/sh
3 # modified for dgux by hassey@dg-rtp.dg.com based on
5 # fixinc.svr4 written by Ron Guilmette (rfg@ncd.com).
7 # This file is part of GNU CC.
8 #
9 # GNU CC is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
14 # GNU CC is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU CC; see the file COPYING. If not, write to
21 # the Free Software Foundation, 59 Temple Place - Suite 330,
22 # Boston, MA 02111-1307, USA.
25 # See README-fixinc for more information.
27 # Directory containing the original header files.
28 INPUT=${2-${INPUT-/usr/include}}
30 # Fail if no arg to specify a directory for the output.
31 if [ x$1 = x ]
32 then echo fixincludes: no output directory specified
33 exit 1
36 # Directory in which to store the results.
37 LIB=${1?"fixincludes: output directory not specified"}
39 # Make sure it exists.
40 if [ ! -d $LIB ]; then
41 mkdir $LIB || exit 1
44 ORIG_DIR=`pwd`
46 # Make LIB absolute if it is relative.
47 # Don't do this if not necessary, since may screw up automounters.
48 case $LIB in
49 /*)
52 cd $LIB; LIB=`${PWDCMD-pwd}`
54 esac
56 echo 'Building fixincludes in ' ${LIB}
58 # Determine whether this filesystem has symbolic links.
59 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
60 rm -f $LIB/ShouldNotExist
61 LINKS=true
62 else
63 LINKS=false
66 echo 'Making directories:'
67 cd ${INPUT}
68 if $LINKS; then
69 files=`ls -LR | sed -n s/:$//p`
70 else
71 files=`find . -type d -print | sed '/^.$/d'`
73 for file in $files; do
74 rm -rf $LIB/$file
75 if [ ! -d $LIB/$file ]
76 then mkdir $LIB/$file
78 done
80 # treetops gets an alternating list
81 # of old directories to copy
82 # and the new directories to copy to.
83 treetops="${INPUT} ${LIB}"
85 if $LINKS; then
86 echo 'Making internal symbolic directory links'
87 for file in $files; do
88 dest=`ls -ld $file | sed -n 's/.*-> //p'`
89 if [ "$dest" ]; then
90 cwd=`pwd`
91 # In case $dest is relative, get to $file's dir first.
92 cd ${INPUT}
93 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
94 # Check that the target directory exists.
95 # Redirections changed to avoid bug in sh on Ultrix.
96 (cd $dest) > /dev/null 2>&1
97 if [ $? = 0 ]; then
98 cd $dest
99 # X gets the dir that the link actually leads to.
100 x=`pwd`
101 # If link leads back into ${INPUT},
102 # make a similar link here.
103 if expr $x : "${INPUT}/.*" > /dev/null; then
104 # Y gets the actual target dir name, relative to ${INPUT}.
105 y=`echo $x | sed -n "s&${INPUT}/&&p"`
106 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
107 dots=`echo "$file" |
108 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
109 echo $file '->' $dots$y ': Making link'
110 rm -fr ${LIB}/$file > /dev/null 2>&1
111 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
112 else
113 # If the link is to outside ${INPUT},
114 # treat this directory as if it actually contained the files.
115 # This line used to have $dest instead of $x.
116 # $dest seemed to be wrong for links found in subdirectories
117 # of ${INPUT}. Does this change break anything?
118 treetops="$treetops $x ${LIB}/$file"
121 cd $cwd
123 done
126 # Completely replace <_int_varargs.h> with a file that defines
127 # va_list and gnuc_va_list
129 file=_int_varargs.h
130 if [ -r ${INPUT}/$file ]; then
131 echo Replacing $file
132 cat > ${LIB}/$file << EOF
133 /* This file was generated by fixinc.dgux. */
134 #ifndef __INT_VARARGS_H
135 #define __INT_VARARGS_H
137 #if defined(__m88k__) && defined (__DGUX__)
138 #ifndef __GNUC_VA_LIST
139 #define __GNUC_VA_LIST
140 typedef struct
142 int __va_arg; /* argument number */
143 int *__va_stk; /* start of args passed on stack */
144 int *__va_reg; /* start of args passed in regs */
145 } __gnuc_va_list;
146 #endif /* not __GNUC_VA_LIST */
147 #endif /* 88k && dgux */
149 #ifndef _VA_LIST_
150 #define _VA_LIST_
151 typedef __gnuc_va_list va_list;
152 #endif /* _VA_LIST_ */
154 #endif /* __INT_VARARGS_H */
157 chmod a+r ${LIB}/$file
160 echo 'Removing unneeded directories:'
161 cd $LIB
162 files=`find . -type d -print | sort -r`
163 for file in $files; do
164 rmdir $LIB/$file > /dev/null 2>&1
165 done
167 if $LINKS; then
168 echo 'Making internal symbolic non-directory links'
169 cd ${INPUT}
170 files=`find . -type l -print`
171 for file in $files; do
172 dest=`ls -ld $file | sed -n 's/.*-> //p'`
173 if expr "$dest" : '[^/].*' > /dev/null; then
174 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
175 if [ -f $target ]; then
176 ln -s $dest ${LIB}/$file >/dev/null 2>&1
179 done
182 cd ${ORIG_DIR}
184 exit 0