|
|
1.1 root 1: #!/bin/sh
2: #
3: # modified for dgux by [email protected] based on
4: #
5: # fixinc.svr4 written by Ron Guilmette ([email protected]).
6: #
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.
13: #
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.
18: #
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.
22: #
23: #
24: # See README-fixinc for more information.
25:
26: # Directory containing the original header files.
27: INPUT=${2-${INPUT-/usr/include}}
28:
29: # Fail if no arg to specify a directory for the output.
30: if [ x$1 = x ]
31: then echo fixincludes: no output directory specified
32: exit 1
33: fi
34:
35: # Directory in which to store the results.
36: LIB=${1?"fixincludes: output directory not specified"}
37:
38: # Make sure it exists.
39: if [ ! -d $LIB ]; then
40: mkdir $LIB || exit 1
41: fi
42:
43: ORIG_DIR=`pwd`
44:
45: # Make LIB absolute if it is relative.
46: # Don't do this if not necessary, since may screw up automounters.
47: case $LIB in
48: /*)
49: ;;
50: *)
51: cd $LIB; LIB=`${PWDCMD-pwd}`
52: ;;
53: esac
54:
55: echo 'Building fixincludes in ' ${LIB}
56:
57: # Determine whether this filesystem has symbolic links.
58: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
59: rm -f $LIB/ShouldNotExist
60: LINKS=true
61: else
62: LINKS=false
63: fi
64:
65: echo 'Making directories:'
66: cd ${INPUT}
67: if $LINKS; then
68: files=`ls -LR | sed -n s/:$//p`
69: else
70: files=`find . -type d -print | sed '/^.$/d'`
71: fi
72: for file in $files; do
73: rm -rf $LIB/$file
74: if [ ! -d $LIB/$file ]
75: then mkdir $LIB/$file
76: fi
77: done
78:
79: # treetops gets an alternating list
80: # of old directories to copy
81: # and the new directories to copy to.
82: treetops="${INPUT} ${LIB}"
83:
84: if $LINKS; then
85: echo 'Making internal symbolic directory links'
86: for file in $files; do
87: dest=`ls -ld $file | sed -n 's/.*-> //p'`
88: if [ "$dest" ]; then
89: cwd=`pwd`
90: # In case $dest is relative, get to $file's dir first.
91: cd ${INPUT}
92: cd `echo ./$file | sed -n 's&[^/]*$&&p'`
93: # Check that the target directory exists.
94: # Redirections changed to avoid bug in sh on Ultrix.
95: (cd $dest) > /dev/null 2>&1
96: if [ $? = 0 ]; then
97: cd $dest
98: # X gets the dir that the link actually leads to.
99: x=`pwd`
100: # If link leads back into ${INPUT},
101: # make a similar link here.
102: if expr $x : "${INPUT}/.*" > /dev/null; then
103: # Y gets the actual target dir name, relative to ${INPUT}.
104: y=`echo $x | sed -n "s&${INPUT}/&&p"`
105: # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
106: dots=`echo "$file" |
107: sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
108: echo $file '->' $dots$y ': Making link'
109: rm -fr ${LIB}/$file > /dev/null 2>&1
110: ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
111: else
112: # If the link is to outside ${INPUT},
113: # treat this directory as if it actually contained the files.
114: # This line used to have $dest instead of $x.
115: # $dest seemed to be wrong for links found in subdirectories
116: # of ${INPUT}. Does this change break anything?
117: treetops="$treetops $x ${LIB}/$file"
118: fi
119: fi
120: cd $cwd
121: fi
122: done
123: fi
124:
125: # Completely replace <_int_varargs.h> with a file that defines
126: # va_list and gnuc_va_list
127:
128: file=_int_varargs.h
129: if [ -r ${INPUT}/$file ]; then
130: echo Replacing $file
131: cat > ${LIB}/$file << EOF
132: /* This file was generated by fixinc.dgux. */
133: #ifndef __INT_VARARGS_H
134: #define __INT_VARARGS_H
135:
136: #if defined(__m88k__) && defined (__DGUX__)
137: #ifndef __GNUC_VA_LIST
138: #define __GNUC_VA_LIST
139: typedef struct
140: {
141: int __va_arg; /* argument number */
142: int *__va_stk; /* start of args passed on stack */
143: int *__va_reg; /* start of args passed in regs */
144: } __gnuc_va_list;
145: #endif /* not __GNUC_VA_LIST */
146: #endif /* 88k && dgux */
147:
148: #ifndef _VA_LIST_
149: #define _VA_LIST_
150: typedef __gnuc_va_list va_list;
151: #endif /* _VA_LIST_ */
152:
153: #endif /* __INT_VARARGS_H */
154:
155: EOF
156: chmod a+r ${LIB}/$file
157: fi
158:
159: echo 'Removing unneeded directories:'
160: cd $LIB
161: files=`find . -type d -print | sort -r`
162: for file in $files; do
163: rmdir $LIB/$file > /dev/null 2>&1
164: done
165:
166: if $LINKS; then
167: echo 'Making internal symbolic non-directory links'
168: cd ${INPUT}
169: files=`find . -type l -print`
170: for file in $files; do
171: dest=`ls -ld $file | sed -n 's/.*-> //p'`
172: if expr "$dest" : '[^/].*' > /dev/null; then
173: target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
174: if [ -f $target ]; then
175: ln -s $dest ${LIB}/$file >/dev/null 2>&1
176: fi
177: fi
178: done
179: fi
180:
181: cd ${ORIG_DIR}
182:
183: exit 0
184:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.