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.
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)
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, 675 Mass Ave, Cambridge, MA 02139, USA.
24 # See README-fixinc for more information.
26 # Directory where gcc sources (and sometimes special include files) live.
27 SRCDIR=${3-${SRCDIR-.}}
29 # Directory containing the original header files.
30 INPUT=${2-${INPUT-/usr/include}}
32 # Fail if no arg to specify a directory for the output.
34 then echo fixincludes: no output directory specified
38 # Directory in which to store the results.
39 LIB=${1?"fixincludes: output directory not specified"}
41 # Make sure it exists.
42 if [ ! -d $LIB ]; then
48 # Make LIB absolute if it is relative.
49 # Don't do this if not necessary, since may screw up automounters.
54 cd $LIB; LIB=`${PWDCMD-pwd}`
58 echo 'Building fixincludes in ' ${LIB}
60 # Determine whether this filesystem has symbolic links.
61 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
62 rm -f $LIB/ShouldNotExist
68 echo 'Making directories:'
71 files=`ls -LR | sed -n s/:$//p`
73 files=`find . -type d -print | sed '/^.$/d'`
75 for file in $files; do
77 if [ ! -d $LIB/$file ]
82 # treetops gets an alternating list
83 # of old directories to copy
84 # and the new directories to copy to.
85 treetops="${INPUT} ${LIB}"
88 echo 'Making internal symbolic directory links'
89 for file in $files; do
90 dest=`ls -ld $file | sed -n 's/.*-> //p'`
93 # In case $dest is relative, get to $file's dir first.
95 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
96 # Check that the target directory exists.
97 # Redirections changed to avoid bug in sh on Ultrix.
98 (cd $dest) > /dev/null 2>&1
101 # X gets the dir that the link actually leads to.
103 # If link leads back into ${INPUT},
104 # make a similar link here.
105 if expr $x : "${INPUT}/.*" > /dev/null; then
106 # Y gets the actual target dir name, relative to ${INPUT}.
107 y=`echo $x | sed -n "s&${INPUT}/&&p"`
108 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
110 sed -e 's@^./@@' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
111 echo $file '->' $dots$y ': Making link'
112 rm -fr ${LIB}/$file > /dev/null 2>&1
113 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
115 # If the link is to outside ${INPUT},
116 # treat this directory as if it actually contained the files.
117 # This line used to have $dest instead of $x.
118 # $dest seemed to be wrong for links found in subdirectories
119 # of ${INPUT}. Does this change break anything?
120 treetops="$treetops $x ${LIB}/$file"
128 # Completely replace <_int_varargs.h> with a file that defines
129 # va_list and gnuc_va_list
132 if [ -r ${INPUT}/$file ]; then
134 cat > ${LIB}/$file << EOF
135 /* This file was generated by fixinc.dgux. */
136 #ifndef __INT_VARARGS_H
137 #define __INT_VARARGS_H
139 #if defined(__m88k__) && defined (__DGUX__)
140 #ifndef __GNUC_VA_LIST
141 #define __GNUC_VA_LIST
144 int __va_arg; /* argument number */
145 int *__va_stk; /* start of args passed on stack */
146 int *__va_reg; /* start of args passed in regs */
148 #endif /* not __GNUC_VA_LIST */
149 #endif /* 88k && dgux */
153 typedef __gnuc_va_list va_list;
154 #endif /* _VA_LIST_ */
156 #endif /* __INT_VARARGS_H */
159 chmod a+r ${LIB}/$file
162 echo 'Removing unneeded directories:'
164 files=`find . -type d -print | sort -r`
165 for file in $files; do
166 rmdir $LIB/$file > /dev/null 2>&1
170 echo 'Making internal symbolic non-directory links'
172 files=`find . -type l -print`
173 for file in $files; do
174 dest=`ls -ld $file | sed -n 's/.*-> //p'`
175 if expr "$dest" : '[^/].*' > /dev/null; then
176 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
177 if [ -f $target ]; then
178 ln -s $dest ${LIB}/$file >/dev/null 2>&1