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 # Directory containing the original header files.
28 INPUT
=${2-${INPUT-/usr/include}}
30 # Fail if no arg to specify a directory for the output.
32 then echo fixincludes
: no output directory specified
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
46 # Make LIB absolute if it is relative.
47 # Don't do this if not necessary, since may screw up automounters.
52 cd $LIB; LIB
=`${PWDCMD-pwd}`
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
66 echo 'Making directories:'
69 files
=`ls -LR | sed -n s/:$//p`
71 files
=`find . -type d -print | sed '/^.$/d'`
73 for file in $files; do
75 if [ ! -d $LIB/$file ]
80 # treetops gets an alternating list
81 # of old directories to copy
82 # and the new directories to copy to.
83 treetops
="${INPUT} ${LIB}"
86 echo 'Making internal symbolic directory links'
87 for file in $files; do
88 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
91 # In case $dest is relative, get to $file's dir first.
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
99 # X gets the dir that the link actually leads to.
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}.
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
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"
126 # Completely replace <_int_varargs.h> with a file that defines
127 # va_list and gnuc_va_list
130 if [ -r ${INPUT}/$file ]; then
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
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 */
146 #endif /* not __GNUC_VA_LIST */
147 #endif /* 88k && dgux */
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:'
162 files
=`find . -type d -print | sort -r`
163 for file in $files; do
164 rmdir $LIB/$file > /dev
/null
2>&1
168 echo 'Making internal symbolic non-directory links'
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