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, 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.
29 then echo fixincludes
: no output directory specified
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
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.
49 cd $LIB; LIB
=`${PWDCMD-pwd}`
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
63 echo 'Making directories:'
64 # Directory containing the original header files.
66 if [ $# -eq 0 ] ; then
72 for INPUT
in ${INLIST} ; do
77 files
=`ls -LR | sed -n s/:$//p`
79 files
=`find . -type d -print | sed '/^.$/d'`
81 for file in $files; do
83 if [ ! -d $LIB/$file ]
88 # treetops gets an alternating list
89 # of old directories to copy
90 # and the new directories to copy to.
91 treetops
="${INPUT} ${LIB}"
94 echo 'Making internal symbolic directory links'
95 for file in $files; do
96 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
99 # In case $dest is relative, get to $file's dir first.
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
107 # X gets the dir that the link actually leads to.
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}.
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
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"
134 # Completely replace <_int_varargs.h> with a file that defines
135 # va_list and gnuc_va_list
138 if [ -r ${INPUT}/$file ]; then
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>
149 #if !(defined(_VA_LIST) || defined(_VA_LIST_))
156 typedef void * va_list;
158 typedef char * va_list;
172 #else /* ! defined(__DCC__) */
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 */
180 #endif /* ! defined(__DCC__) */
184 #if defined(__GNUC__) || defined(__STDC__)
185 typedef void * va_list;
187 typedef char * va_list;
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:'
202 files
=`find . -type d -print | sort -r`
203 for file in $files; do
204 rmdir $LIB/$file > /dev
/null
2>&1
208 echo 'Making internal symbolic non-directory links'
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