* config/i386/netbsd-elf.h (LINK_SPEC): Define as
[official-gcc.git] / gcc / fixinc / fixinc.dgux
blob39a5b63f00eb3d4676e156605bd3d2dff2db5171
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 # Fail if no arg to specify a directory for the output.
28 if [ x$1 = x ]
29 then echo fixincludes: no output directory specified
30 exit 1
33 # Directory in which to store the results.
34 LIB=${1?"fixincludes: output directory not specified"}
36 # Make sure it exists.
37 if [ ! -d $LIB ]; then
38 mkdir $LIB || exit 1
41 ORIG_DIR=`${PWDCMD-pwd}`
43 # Make LIB absolute if it is relative.
44 # Don't do this if not necessary, since may screw up automounters.
45 case $LIB in
46 /*)
49 cd $LIB; LIB=`${PWDCMD-pwd}`
51 esac
53 echo 'Building fixincludes in ' ${LIB}
55 # Determine whether this filesystem has symbolic links.
56 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
57 rm -f $LIB/ShouldNotExist
58 LINKS=true
59 else
60 LINKS=false
63 echo 'Making directories:'
64 # Directory containing the original header files.
65 shift
66 if [ $# -eq 0 ] ; then
67 set /usr/include
70 INLIST="$@"
72 for INPUT in ${INLIST} ; do
73 cd ${ORIG_DIR}
74 cd ${INPUT}
76 if $LINKS; then
77 files=`ls -LR | sed -n s/:$//p`
78 else
79 files=`find . -type d -print | sed '/^.$/d'`
81 for file in $files; do
82 rm -rf $LIB/$file
83 if [ ! -d $LIB/$file ]
84 then mkdir $LIB/$file
86 done
88 # treetops gets an alternating list
89 # of old directories to copy
90 # and the new directories to copy to.
91 treetops="${INPUT} ${LIB}"
93 if $LINKS; then
94 echo 'Making internal symbolic directory links'
95 for file in $files; do
96 dest=`ls -ld $file | sed -n 's/.*-> //p'`
97 if [ "$dest" ]; then
98 cwd=`${PWDCMD-pwd}`
99 # In case $dest is relative, get to $file's dir first.
100 cd ${INPUT}
101 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
102 # Check that the target directory exists.
103 # Redirections changed to avoid bug in sh on Ultrix.
104 (cd $dest) > /dev/null 2>&1
105 if [ $? = 0 ]; then
106 cd $dest
107 # X gets the dir that the link actually leads to.
108 x=`${PWDCMD-pwd}`
109 # If link leads back into ${INPUT},
110 # make a similar link here.
111 if expr $x : "${INPUT}/.*" > /dev/null; then
112 # Y gets the actual target dir name, relative to ${INPUT}.
113 y=`echo $x | sed -n "s&${INPUT}/&&p"`
114 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
115 dots=`echo "$file" |
116 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
117 echo $file '->' $dots$y ': Making link'
118 rm -fr ${LIB}/$file > /dev/null 2>&1
119 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
120 else
121 # If the link is to outside ${INPUT},
122 # treat this directory as if it actually contained the files.
123 # This line used to have $dest instead of $x.
124 # $dest seemed to be wrong for links found in subdirectories
125 # of ${INPUT}. Does this change break anything?
126 treetops="$treetops $x ${LIB}/$file"
129 cd $cwd
131 done
134 # Completely replace <_int_varargs.h> with a file that defines
135 # va_list and gnuc_va_list
137 file=_int_varargs.h
138 if [ -r ${INPUT}/$file ]; then
139 echo Replacing $file
140 cat > ${LIB}/$file << EOF
141 /* This file was generated by fixinc.dgux. */
142 #ifndef __INT_VARARGS_H
143 #define __INT_VARARGS_H
145 #ifndef ___int_features_h
146 #include <sys/_int_features.h>
147 #endif
149 #if !(defined(_VA_LIST) || defined(_VA_LIST_))
150 #define _VA_LIST
151 #define _VA_LIST_
153 #ifdef __LINT__
155 #ifdef __STDC__
156 typedef void * va_list;
157 #else
158 typedef char * va_list;
159 #endif
161 #else
162 #if _M88K_ANY
164 #if defined(__DCC__)
166 typedef struct {
167 int next_arg;
168 int *mem_ptr;
169 int *reg_ptr;
170 } va_list;
172 #else /* ! defined(__DCC__) */
174 typedef struct {
175 int __va_arg; /* argument number */
176 int *__va_stk; /* start of args passed on stack */
177 int *__va_reg; /* start of args passed in regs */
178 } va_list;
180 #endif /* ! defined(__DCC__) */
182 #elif _IX86_ANY
184 #if defined(__GNUC__) || defined(__STDC__)
185 typedef void * va_list;
186 #else
187 typedef char * va_list;
188 #endif
190 #endif /* _IX86_ANY */
192 #endif /* __LINT__ */
193 #endif /* !(defined(_VA_LIST) || defined(_VA_LIST_)) */
194 #endif /* #ifndef __INT_VARARGS_H */
197 chmod a+r ${LIB}/$file
200 echo 'Removing unneeded directories:'
201 cd $LIB
202 files=`find . -type d -print | sort -r`
203 for file in $files; do
204 rmdir $LIB/$file > /dev/null 2>&1
205 done
207 if $LINKS; then
208 echo 'Making internal symbolic non-directory links'
209 cd ${INPUT}
210 files=`find . -type l -print`
211 for file in $files; do
212 dest=`ls -ld $file | sed -n 's/.*-> //p'`
213 if expr "$dest" : '[^/].*' > /dev/null; then
214 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
215 if [ -f $target ]; then
216 ln -s $dest ${LIB}/$file >/dev/null 2>&1
219 done
222 done
224 exit 0