]>
Commit | Line | Data |
---|---|---|
c61a25b1 DM |
1 | #! /bin/sh |
2 | # Install modified versions of certain ANSI-incompatible system header files | |
3 | # which are fixed to work correctly with ANSI C | |
4 | # and placed in a directory that GNU C will search. | |
5 | ||
6 | # See README-fixinc for more information. | |
7 | ||
cc08b87d ILT |
8 | # Command to run gcc. |
9 | GCCCMD=${4-${GCCCMD-gcc}} | |
10 | ||
b7b62369 RS |
11 | # Directory where gcc sources (and sometimes special include files) live. |
12 | # fixincludes doesn't use this, but fixinc.svr4 does, and I want to make | |
13 | # sure somebody doesn't try to use arg3 for something incompatible. -- gumby | |
14 | SRCDIR=${3-${SRCDIR-.}} | |
15 | ||
c61a25b1 DM |
16 | # Directory containing the original header files. |
17 | # (This was named INCLUDES, but that conflicts with a name in Makefile.in.) | |
18 | INPUT=${2-${INPUT-/usr/include}} | |
19 | ||
ffc47266 JW |
20 | # Directory in which to store the results. |
21 | LIB=${1?"fixincludes: output directory not specified"} | |
c61a25b1 | 22 | |
4ed15f9d RS |
23 | # Define PWDCMD as a command to use to get the working dir |
24 | # in the form that we want. | |
25 | PWDCMD=pwd | |
26 | case "`pwd`" in | |
27 | //*) | |
28 | # On an Apollo, discard everything before `/usr'. | |
d45ceebe | 29 | PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'" |
4ed15f9d RS |
30 | ;; |
31 | esac | |
32 | ||
631e21eb DE |
33 | # Original directory. |
34 | ORIGDIR=`${PWDCMD}` | |
35 | ||
c61a25b1 DM |
36 | # Make sure it exists. |
37 | if [ ! -d $LIB ]; then | |
38 | mkdir $LIB || exit 1 | |
39 | fi | |
40 | ||
e1fa48b5 RS |
41 | # Make LIB absolute only if needed to avoid problems with the amd. |
42 | case $LIB in | |
43 | /*) | |
44 | ;; | |
45 | *) | |
46 | cd $LIB; LIB=`${PWDCMD}` | |
47 | ;; | |
48 | esac | |
c61a25b1 | 49 | |
8befb954 RS |
50 | # Make SRCDIR absolute only if needed to avoid problems with the amd. |
51 | cd $ORIGDIR | |
52 | case $SRCDIR in | |
53 | /*) | |
54 | ;; | |
55 | *) | |
56 | cd $SRCDIR; SRCDIR=`${PWDCMD}` | |
57 | ;; | |
58 | esac | |
59 | ||
c61a25b1 DM |
60 | # Fail if no arg to specify a directory for the output. |
61 | if [ x$1 = x ] | |
62 | then echo fixincludes: no output directory specified | |
63 | exit 1 | |
64 | fi | |
65 | ||
1ac7d389 | 66 | echo Building fixed headers in ${LIB} |
c61a25b1 DM |
67 | |
68 | # Determine whether this system has symbolic links. | |
69 | if ln -s X $LIB/ShouldNotExist 2>/dev/null; then | |
70 | rm -f $LIB/ShouldNotExist | |
0fa2faf0 RS |
71 | LINKS=true |
72 | elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then | |
73 | rm -f /tmp/ShouldNotExist | |
c61a25b1 DM |
74 | LINKS=true |
75 | else | |
76 | LINKS=false | |
77 | fi | |
78 | ||
1ac7d389 | 79 | echo Finding directories and links to directories |
c61a25b1 | 80 | cd ${INPUT} |
3308e40a | 81 | # Find all directories and all symlinks that point to directories. |
f1f1ae8e RS |
82 | # Put the list in $files. |
83 | # Each time we find a symlink, add it to newdirs | |
84 | # so that we do another find within the dir the link points to. | |
85 | # Note that $files may have duplicates in it; | |
86 | # later parts of this file are supposed to ignore them. | |
87 | dirs="." | |
fd297e33 RS |
88 | levels=2 |
89 | while [ -n "$dirs" ] && [ $levels -gt 0 ] | |
f1f1ae8e | 90 | do |
fd297e33 | 91 | levels=`expr $levels - 1` |
f1f1ae8e | 92 | newdirs= |
fd297e33 | 93 | for d in $dirs |
f1f1ae8e | 94 | do |
1ac7d389 | 95 | echo " Searching $INPUT/$d" |
f1f1ae8e RS |
96 | if [ "$d" != . ] |
97 | then | |
98 | d=$d/. | |
99 | fi | |
100 | ||
fd297e33 | 101 | # Find all directories under $d, relative to $d, excluding $d itself. |
165b3941 RS |
102 | files="$files `find $d -type d -print | \ |
103 | sed -e '/\/\.$/d' -e '/^\.$/d'`" | |
104 | # Find all links to directories. | |
105 | # Using `-exec test -d' in find fails on some systems, | |
106 | # and trying to run test via sh fails on others, | |
107 | # so this is the simplest alternative left. | |
108 | # First find all the links, then test each one. | |
109 | theselinks= | |
f1f1ae8e | 110 | $LINKS && \ |
165b3941 RS |
111 | theselinks=`find $d -type l -print` |
112 | for d1 in $theselinks --dummy-- | |
113 | do | |
1ac7d389 RS |
114 | # If the link points to a directory, |
115 | # add that dir to $newdirs | |
165b3941 RS |
116 | if [ -d $d1 ] |
117 | then | |
118 | newdirs="$newdirs $d1" | |
119 | fi | |
120 | done | |
f1f1ae8e RS |
121 | done |
122 | ||
89ccb80f | 123 | files="$files $newdirs" |
f1f1ae8e | 124 | dirs="$newdirs" |
f1f1ae8e RS |
125 | done |
126 | ||
127 | dirs= | |
1ac7d389 | 128 | echo "All directories (including links to directories):" |
f1f1ae8e RS |
129 | echo $files |
130 | ||
c61a25b1 DM |
131 | for file in $files; do |
132 | rm -rf $LIB/$file | |
133 | if [ ! -d $LIB/$file ] | |
134 | then mkdir $LIB/$file | |
135 | fi | |
136 | done | |
1ac7d389 | 137 | mkdir $LIB/root |
c61a25b1 DM |
138 | |
139 | # treetops gets an alternating list | |
140 | # of old directories to copy | |
141 | # and the new directories to copy to. | |
142 | treetops="${INPUT} ${LIB}" | |
143 | ||
144 | if $LINKS; then | |
1ac7d389 | 145 | echo 'Making symbolic directory links' |
c61a25b1 DM |
146 | for file in $files; do |
147 | dest=`ls -ld $file | sed -n 's/.*-> //p'` | |
148 | if [ "$dest" ]; then | |
4ed15f9d | 149 | cwd=`${PWDCMD}` |
c61a25b1 DM |
150 | # In case $dest is relative, get to $file's dir first. |
151 | cd ${INPUT} | |
152 | cd `echo ./$file | sed -n 's&[^/]*$&&p'` | |
153 | # Check that the target directory exists. | |
154 | # Redirections changed to avoid bug in sh on Ultrix. | |
155 | (cd $dest) > /dev/null 2>&1 | |
156 | if [ $? = 0 ]; then | |
157 | cd $dest | |
158 | # X gets the dir that the link actually leads to. | |
4ed15f9d | 159 | x=`${PWDCMD}` |
1ac7d389 RS |
160 | # If a link points to ., make a similar link to . |
161 | if [ $x = $INPUT ]; then | |
162 | echo $file '->' . ': Making link' | |
163 | rm -fr ${LIB}/$file > /dev/null 2>&1 | |
164 | ln -s . ${LIB}/$file > /dev/null 2>&1 | |
c61a25b1 DM |
165 | # If link leads back into ${INPUT}, |
166 | # make a similar link here. | |
1ac7d389 | 167 | elif expr $x : "${INPUT}/.*" > /dev/null; then |
c61a25b1 DM |
168 | # Y gets the actual target dir name, relative to ${INPUT}. |
169 | y=`echo $x | sed -n "s&${INPUT}/&&p"` | |
884caf18 PE |
170 | # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. |
171 | dots=`echo "$file" | | |
172 | sed -e 's@^./@@' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` | |
173 | echo $file '->' $dots$y ': Making link' | |
c61a25b1 | 174 | rm -fr ${LIB}/$file > /dev/null 2>&1 |
884caf18 | 175 | ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 |
c61a25b1 | 176 | else |
1ac7d389 RS |
177 | # If the link is to a dir $target outside ${INPUT}, |
178 | # repoint the link at ${INPUT}/root$target | |
179 | # and process $target into ${INPUT}/root$target | |
c61a25b1 | 180 | # treat this directory as if it actually contained the files. |
1ac7d389 RS |
181 | echo $file '->' root$x ': Making link' |
182 | if [ -d $LIB/root$x ] | |
183 | then true | |
184 | else | |
185 | dirname=root$x/ | |
186 | dirmade=. | |
187 | cd $LIB | |
188 | while [ x$dirname != x ]; do | |
189 | component=`echo $dirname | sed -e 's|/.*$||'` | |
190 | mkdir $component >/dev/null 2>&1 | |
191 | cd $component | |
192 | dirmade=$dirmade/$component | |
193 | dirname=`echo $dirname | sed -e 's|[^/]*/||'` | |
194 | done | |
195 | fi | |
f744b2ce RS |
196 | # Duplicate directory structure created in ${LIB}/$file in new |
197 | # root area. | |
198 | for file2 in $files; do | |
199 | case $file2 in | |
638fa106 | 200 | $file/./*) |
f744b2ce RS |
201 | dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"` |
202 | echo "Duplicating ${file}'s ${dupdir}" | |
203 | if [ -d ${dupdir} ] | |
204 | then true | |
205 | else | |
206 | mkdir ${dupdir} | |
207 | fi | |
208 | ;; | |
638fa106 BK |
209 | *) |
210 | ;; | |
f744b2ce RS |
211 | esac |
212 | done | |
884caf18 PE |
213 | # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. |
214 | dots=`echo "$file" | | |
215 | sed -e 's@^./@@' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` | |
1ac7d389 | 216 | rm -fr ${LIB}/$file > /dev/null 2>&1 |
884caf18 | 217 | ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1 |
1ac7d389 | 218 | treetops="$treetops $x ${LIB}/root$x" |
c61a25b1 DM |
219 | fi |
220 | fi | |
221 | cd $cwd | |
222 | fi | |
223 | done | |
224 | fi | |
225 | ||
40f1c86c | 226 | required= |
25e51a69 ILT |
227 | set x $treetops |
228 | shift | |
c61a25b1 DM |
229 | while [ $# != 0 ]; do |
230 | # $1 is an old directory to copy, and $2 is the new directory to copy to. | |
c61a25b1 DM |
231 | cd ${INPUT} |
232 | cd $1 | |
1ac7d389 RS |
233 | # The same dir can appear more than once in treetops. |
234 | # There's no need to scan it more than once. | |
235 | if [ -f $2/DONE ] | |
236 | then | |
237 | files= | |
238 | else | |
239 | touch $2/DONE | |
240 | echo Fixing directory $1 into $2 | |
8c31e6b6 RS |
241 | # Check .h files which are symlinks as well as those which are files. |
242 | # A link to a header file will not be processed by anything but this. | |
73bdfabc RS |
243 | if $LINKS; then |
244 | files=`find . -name '*.h' \( -type f -o -type l \) -print` | |
245 | else | |
246 | files=`find . -name '*.h' -type f -print` | |
247 | fi | |
1ac7d389 RS |
248 | echo Checking header files |
249 | fi | |
c61a25b1 DM |
250 | # Note that BSD43_* are used on recent MIPS systems. |
251 | for file in $files; do | |
252 | # This call to egrep is essential, since checking a file with egrep | |
253 | # is much faster than actually trying to fix it. | |
3308e40a RS |
254 | # It is also essential that most files *not* match! |
255 | # Thus, matching every #endif is unacceptable. | |
c61a25b1 DM |
256 | # But the argument to egrep must be kept small, or many versions of egrep |
257 | # won't be able to handle it. | |
25e51a69 ILT |
258 | # |
259 | # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment | |
260 | # following #else or #endif because some buggy egreps think [^/] matches | |
261 | # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'. | |
262 | # | |
263 | # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier | |
264 | # following #if or #elif that is not surrounded by __. The `a-ce-km-z' | |
265 | # in this pattern lacks `d' and `l'; this means we don't worry about | |
266 | # identifiers starting with `d' or `l'. This is OK, since none of the | |
267 | # identifiers below start with `d' or `l'. It also greatly improves | |
268 | # performance, since many files contain lines of the form `#if ... defined ...' | |
269 | # or `#if lint'. | |
270 | if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-z][a-z0-9]' $file >/dev/null; then | |
c61a25b1 DM |
271 | if [ -r $file ]; then |
272 | cp $file $2/$file >/dev/null 2>&1 \ | |
273 | || echo "Can't copy $file" | |
274 | chmod +w $2/$file | |
2e4cd151 | 275 | chmod a+r $2/$file |
8caf703c RS |
276 | # Here is how the sed commands in braces work. |
277 | # (It doesn't work to put the comments inside the sed commands.) | |
278 | # Surround each word with spaces, to simplify matching below. | |
279 | # ANSIfy each pre-ANSI machine-dependent symbol | |
280 | # by surrounding it with __ __. | |
281 | # Remove the spaces that we inserted around each word. | |
c61a25b1 DM |
282 | sed -e ' |
283 | :loop | |
284 | /\\$/ N | |
285 | /\\$/ b loop | |
20c74d5e PE |
286 | s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1% |
287 | s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1% | |
288 | s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1% | |
ec4738c0 RS |
289 | s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1% |
290 | s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1% | |
883bc780 | 291 | /\/\/[^*]/ s|//\(.*\)$|/*\1*/| |
2a46424a | 292 | /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/ |
c61a25b1 | 293 | /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/ |
8bfed528 | 294 | /#define._IO/ s/'\''\([cgxtf]\)'\''/\1/g |
25e51a69 | 295 | /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g |
d7c768e7 RS |
296 | /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/ |
297 | /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/ | |
621b3771 RS |
298 | /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g |
299 | /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g | |
a2790172 | 300 | /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g |
25e51a69 | 301 | /#[el]*if/{ |
25e51a69 ILT |
302 | s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g |
303 | ||
25e51a69 ILT |
304 | s/ bsd4\([0-9]\) / __bsd4\1__ /g |
305 | s/ _*i386 / __i386__ /g | |
306 | s/ is68k / __is68k__ /g | |
307 | s/ m68k / __m68k__ /g | |
308 | s/ mc680\([0-9]\)0 / __mc680\10__ /g | |
309 | s/ news\([0-9]*\) / __news\1__ /g | |
310 | s/ ns32000 / __ns32000__ /g | |
311 | s/ pyr / __pyr__ /g | |
312 | s/ sony_news / __sony_news__ /g | |
313 | s/ sparc / __sparc__ /g | |
314 | s/ sun\([a-z0-9]*\) / __sun\1__ /g | |
315 | s/ unix / __unix__ /g | |
316 | s/ vax / __vax__ /g | |
317 | ||
25e51a69 ILT |
318 | s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g |
319 | } | |
45b33951 | 320 | /^#define.NULL[ ]/ i\ |
c61a25b1 | 321 | #undef NULL |
78c5c646 RS |
322 | ' $2/$file > $2/$file. |
323 | mv $2/$file. $2/$file | |
c61a25b1 | 324 | if cmp $file $2/$file >/dev/null 2>&1; then |
c61a25b1 | 325 | rm $2/$file |
b52a4b72 RS |
326 | else |
327 | echo Fixed $file | |
40f1c86c RS |
328 | # Find any include directives that use "file". |
329 | for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do | |
330 | dir=`echo $file | sed -e s'|/[^/]*$||'` | |
331 | required="$required $1 $dir/$include $2/$dir/$include" | |
332 | done | |
c61a25b1 DM |
333 | fi |
334 | fi | |
335 | fi | |
336 | done | |
337 | shift; shift | |
338 | done | |
339 | ||
40f1c86c RS |
340 | # Make sure that any include files referenced using double quotes |
341 | # exist in the fixed directory. | |
342 | set x $required | |
343 | shift | |
344 | while [ $# != 0 ]; do | |
345 | # $1 is the directory to copy from, $2 is the unfixed file, | |
346 | # $3 is the fixed file name. | |
347 | cd ${INPUT} | |
348 | cd $1 | |
349 | if [ -r $2 ] && [ ! -r $3 ]; then | |
350 | cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" | |
351 | chmod +w $3 2>/dev/null | |
352 | chmod a+r $3 2>/dev/null | |
353 | echo Copied $2 | |
354 | fi | |
355 | shift; shift; shift | |
356 | done | |
357 | ||
c61a25b1 DM |
358 | cd ${INPUT} |
359 | ||
cd3383a3 | 360 | # Install the proper definition of size_t in header files that it comes from. |
1f1ff018 | 361 | for file in sys/types.h stdlib.h sys/stdtypes.h; do |
cd3383a3 RS |
362 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then |
363 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
364 | chmod +w ${LIB}/$file 2>/dev/null | |
365 | chmod a+r ${LIB}/$file 2>/dev/null | |
366 | fi | |
367 | ||
368 | if [ -r ${LIB}/$file ]; then | |
369 | echo Fixing $file comment | |
cc08b87d | 370 | # Get the definition of __SIZE_TYPE__, if any. |
cd3383a3 | 371 | # (This file must be called something.c). |
cc08b87d ILT |
372 | echo "__SIZE_TYPE__" > ${LIB}/types.c |
373 | foo=`${GCCCMD} -E -P ${LIB}/types.c` | |
631e21eb | 374 | rm -f ${LIB}/types.c |
cd3383a3 | 375 | # Default to our preferred type. |
cc08b87d | 376 | if [ "$foo" = __SIZE_TYPE__ ]; then foo="unsigned long int"; fi |
cd3383a3 RS |
377 | sed -e "s/typedef[ a-z_]*[ ]size_t/typedef $foo size_t/" ${LIB}/$file > ${LIB}/${file}.sed |
378 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
379 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
380 | rm ${LIB}/$file | |
381 | fi | |
382 | fi | |
383 | done | |
384 | ||
c61a25b1 DM |
385 | # Fix one other error in this file: a mismatched quote not inside a C comment. |
386 | file=sundev/vuid_event.h | |
387 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
388 | mkdir ${LIB}/sundev 2>/dev/null | |
389 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
390 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 391 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
392 | fi |
393 | ||
394 | if [ -r ${LIB}/$file ]; then | |
395 | echo Fixing $file comment | |
ffc47266 JW |
396 | sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed |
397 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 398 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
399 | rm ${LIB}/$file |
400 | fi | |
401 | fi | |
402 | ||
4ba0ff2d JW |
403 | # Fix these Sun OS files to avoid an invalid identifier in an #ifdef. |
404 | file=sunwindow/win_cursor.h | |
405 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
406 | # mkdir ${LIB}/sunwindow 2>/dev/null | |
407 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
408 | chmod +w ${LIB}/$file 2>/dev/null | |
409 | fi | |
410 | if [ -r ${LIB}/$file ]; then | |
411 | echo Fixing $file | |
412 | sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed | |
413 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
414 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
415 | rm ${LIB}/$file | |
416 | fi | |
417 | fi | |
418 | file=sunwindow/win_lock.h | |
419 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
420 | # mkdir ${LIB}/sunwindow 2>/dev/null | |
421 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
422 | chmod +w ${LIB}/$file 2>/dev/null | |
423 | fi | |
424 | if [ -r ${LIB}/$file ]; then | |
425 | echo Fixing $file | |
426 | sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed | |
427 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
428 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
429 | rm ${LIB}/$file | |
430 | fi | |
431 | fi | |
432 | ||
6dc42e49 | 433 | # Fix this Sun file to avoid interfering with stddef.h. |
c61a25b1 DM |
434 | file=sys/stdtypes.h |
435 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
436 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
437 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 438 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
439 | fi |
440 | ||
441 | if [ -r ${LIB}/$file ]; then | |
442 | echo Fixing $file | |
daa4489f | 443 | sed -e '/[ ]size_t.*;/i\ |
ffc47266 JW |
444 | #ifndef _GCC_SIZE_T\ |
445 | #define _GCC_SIZE_T' \ | |
daa4489f | 446 | -e '/[ ]size_t.*;/a\ |
ffc47266 | 447 | #endif' \ |
daa4489f | 448 | -e '/[ ]ptrdiff_t.*;/i\ |
ffc47266 JW |
449 | #ifndef _GCC_PTRDIFF_T\ |
450 | #define _GCC_PTRDIFF_T' \ | |
daa4489f | 451 | -e '/[ ]ptrdiff_t.*;/a\ |
ffc47266 | 452 | #endif' \ |
daa4489f | 453 | -e '/[ ]wchar_t.*;/i\ |
ffc47266 JW |
454 | #ifndef _GCC_WCHAR_T\ |
455 | #define _GCC_WCHAR_T' \ | |
daa4489f | 456 | -e '/[ ]wchar_t.*;/a\ |
ffc47266 JW |
457 | #endif' ${LIB}/$file > ${LIB}/${file}.sed |
458 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
87394941 ILT |
459 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
460 | rm ${LIB}/$file | |
461 | fi | |
462 | fi | |
463 | ||
464 | # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t | |
465 | # in cc1plus. | |
466 | file=stdlib.h | |
467 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
468 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
469 | chmod +w ${LIB}/$file 2>/dev/null | |
470 | chmod a+r ${LIB}/$file 2>/dev/null | |
471 | fi | |
472 | ||
473 | if [ -r ${LIB}/$file ]; then | |
474 | echo Fixing $file | |
19571479 RS |
475 | sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \ |
476 | -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \ | |
87394941 ILT |
477 | ${LIB}/$file > ${LIB}/${file}.sed |
478 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 479 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
480 | rm ${LIB}/$file |
481 | fi | |
482 | fi | |
483 | ||
fd9287ae JW |
484 | # Fix this file to avoid interfering with stddef.h, but don't mistakenly |
485 | # match e.g. ssize_t present in AIX for the ps/2. | |
c61a25b1 DM |
486 | file=sys/types.h |
487 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
488 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
489 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 490 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
491 | fi |
492 | ||
493 | if [ -r ${LIB}/$file ]; then | |
494 | echo Fixing $file | |
590d6f8e | 495 | sed -e '/[ ]size_t.*;/i\ |
ffc47266 JW |
496 | #ifndef _GCC_SIZE_T\ |
497 | #define _GCC_SIZE_T' \ | |
590d6f8e | 498 | -e '/[ ]size_t.*;/a\ |
ffc47266 JW |
499 | #endif' ${LIB}/$file > ${LIB}/${file}.sed |
500 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 501 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
502 | rm ${LIB}/$file |
503 | fi | |
504 | fi | |
505 | ||
94e21bd7 DE |
506 | # Fix HP's use of ../machine/inline.h to refer to |
507 | # /usr/include/machine/inline.h | |
508 | file=sys/spinlock.h | |
e03bb072 | 509 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then |
94e21bd7 DE |
510 | cp $file ${LIB}/$file |
511 | fi | |
512 | if [ -r ${LIB}/$file ] ; then | |
513 | echo Fixing $file | |
514 | sed -e 's,"../machine/inline.h",<machine/inline.h>,' \ | |
515 | -e 's,"../machine/psl.h",<machine/psl.h>,' \ | |
516 | ${LIB}/$file > ${LIB}/${file}.sed | |
517 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
518 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
519 | rm ${LIB}/$file | |
520 | fi | |
521 | fi | |
522 | ||
08455880 TW |
523 | # Fix an error in this file: the #if says _cplusplus, not the double |
524 | # underscore __cplusplus that it should be | |
525 | file=tinfo.h | |
526 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
527 | mkdir ${LIB}/rpcsvc 2>/dev/null | |
528 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
529 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 530 | chmod a+r ${LIB}/$file 2>/dev/null |
08455880 TW |
531 | fi |
532 | ||
533 | if [ -r ${LIB}/$file ]; then | |
534 | echo Fixing $file, __cplusplus macro | |
535 | sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed | |
536 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
537 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
538 | rm ${LIB}/$file | |
539 | fi | |
540 | fi | |
541 | ||
c61a25b1 DM |
542 | # Fix an error in this file: a missing semi-colon at the end of the statsswtch |
543 | # structure definition. | |
544 | file=rpcsvc/rstat.h | |
545 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
546 | mkdir ${LIB}/rpcsvc 2>/dev/null | |
547 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
548 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 549 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
550 | fi |
551 | ||
552 | if [ -r ${LIB}/$file ]; then | |
553 | echo Fixing $file, definition of statsswtch | |
ffc47266 JW |
554 | sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed |
555 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 556 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
557 | rm ${LIB}/$file |
558 | fi | |
559 | fi | |
560 | ||
561 | # Fix an error in this file: a missing semi-colon at the end of the nodeent | |
562 | # structure definition. | |
563 | file=netdnet/dnetdb.h | |
564 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
565 | mkdir ${LIB}/netdnet 2>/dev/null | |
566 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
567 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 568 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
569 | fi |
570 | ||
571 | if [ -r ${LIB}/$file ]; then | |
572 | echo Fixing $file, definition of nodeent | |
ffc47266 JW |
573 | sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed |
574 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 575 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
576 | rm ${LIB}/$file |
577 | fi | |
578 | fi | |
579 | ||
580 | # Check for bad #ifdef line (in Ultrix 4.1) | |
581 | file=sys/file.h | |
582 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
583 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
584 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 585 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
586 | fi |
587 | ||
588 | if [ -r ${LIB}/$file ]; then | |
589 | echo Fixing $file, bad \#ifdef line | |
ffc47266 JW |
590 | sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed |
591 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 592 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
593 | rm ${LIB}/$file |
594 | fi | |
595 | fi | |
596 | ||
597 | # Check for superfluous `static' (in Ultrix 4.2) | |
598 | file=machine/cpu.h | |
599 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
600 | mkdir ${LIB}/machine 2>/dev/null | |
601 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
602 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 603 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
604 | fi |
605 | ||
606 | if [ -r ${LIB}/$file ]; then | |
607 | echo Fixing $file, superfluous static | |
ffc47266 JW |
608 | sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed |
609 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 610 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
611 | rm ${LIB}/$file |
612 | else | |
613 | # This file has an alternative name, mips/cpu.h. Fix that name, too. | |
1f1ff018 | 614 | if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then |
c61a25b1 DM |
615 | mkdir ${LIB}/mips 2>&- |
616 | ln ${LIB}/$file ${LIB}/mips/cpu.h | |
617 | fi | |
618 | fi | |
619 | fi | |
620 | ||
75251fe0 | 621 | # Incorrect sprintf declaration in X11/Xmu.h |
c61a25b1 DM |
622 | file=X11/Xmu.h |
623 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
624 | mkdir ${LIB}/X11 2>/dev/null | |
625 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
626 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 627 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
628 | fi |
629 | ||
630 | if [ -r ${LIB}/$file ]; then | |
631 | echo Fixing $file sprintf declaration | |
ffc47266 JW |
632 | sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\ |
633 | extern char * sprintf();\ | |
8739838d | 634 | #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed |
ffc47266 | 635 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
c61a25b1 | 636 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
637 | rm ${LIB}/$file |
638 | fi | |
639 | fi | |
640 | ||
3a6aca8e RS |
641 | # Incorrect sprintf declaration in X11/Xmu/Xmu.h |
642 | # (It's not clear whether the right file name is this or X11/Xmu.h.) | |
643 | file=X11/Xmu/Xmu.h | |
644 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
645 | mkdir ${LIB}/X11/Xmu 2>/dev/null | |
646 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
647 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 648 | chmod a+r ${LIB}/$file 2>/dev/null |
3a6aca8e RS |
649 | fi |
650 | ||
651 | if [ -r ${LIB}/$file ]; then | |
652 | echo Fixing $file sprintf declaration | |
ffc47266 JW |
653 | sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\ |
654 | extern char * sprintf();\ | |
8739838d | 655 | #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed |
ffc47266 | 656 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
3a6aca8e | 657 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
3a6aca8e RS |
658 | rm ${LIB}/$file |
659 | fi | |
660 | fi | |
661 | ||
c61a25b1 DM |
662 | # Check for missing ';' in struct |
663 | file=netinet/ip.h | |
664 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
665 | mkdir ${LIB}/netinet 2>/dev/null | |
666 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
667 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 668 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
669 | fi |
670 | ||
671 | if [ -r ${LIB}/$file ]; then | |
672 | echo Fixing $file | |
673 | sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed | |
674 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
675 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
676 | rm -f ${LIB}/$file |
677 | fi | |
678 | fi | |
679 | ||
75251fe0 | 680 | # Fix the CAT macro in SunOS memvar.h. |
c61a25b1 DM |
681 | file=pixrect/memvar.h |
682 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
683 | mkdir ${LIB}/pixrect 2>/dev/null | |
684 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
685 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 686 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
687 | fi |
688 | ||
689 | if [ -r ${LIB}/$file ]; then | |
690 | echo Fixing $file | |
691 | sed -e '/^#define.CAT(a,b)/ i\ | |
692 | #ifdef __STDC__ \ | |
693 | #define CAT(a,b) a##b\ | |
694 | #else | |
695 | /^#define.CAT(a,b)/ a\ | |
696 | #endif | |
697 | ' ${LIB}/$file > ${LIB}/${file}.sed | |
698 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
699 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
700 | rm -f ${LIB}/$file |
701 | fi | |
702 | fi | |
703 | ||
704 | # Check for yet more missing ';' in struct (in SunOS 4.0.x) | |
705 | file=rpcsvc/rusers.h | |
706 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
707 | mkdir ${LIB}/rpcsvc 2>/dev/null | |
708 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
709 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 710 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
711 | fi |
712 | ||
713 | if [ -r ${LIB}/$file ]; then | |
714 | echo Fixing $file | |
715 | sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed | |
716 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
717 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
718 | rm -f ${LIB}/$file |
719 | fi | |
720 | fi | |
721 | ||
722 | # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1. | |
c87e58bb | 723 | # Also wrap protection around size_t for m88k-sysv3 systems. |
c61a25b1 DM |
724 | file=stdlib.h |
725 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
726 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
727 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 728 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
729 | fi |
730 | ||
731 | if [ -r ${LIB}/$file ]; then | |
732 | echo Fixing $file | |
733 | sed -e 's/int abort/void abort/g' \ | |
25f75d8a RS |
734 | -e 's/int free/void free/g' \ |
735 | -e 's/char \* calloc/void \* calloc/g' \ | |
736 | -e 's/char \* malloc/void \* malloc/g' \ | |
737 | -e 's/char \* realloc/void \* realloc/g' \ | |
c87e58bb | 738 | -e 's/int exit/void exit/g' \ |
a3f6caa7 | 739 | -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\ |
c87e58bb RS |
740 | #ifndef _GCC_SIZE_T\ |
741 | #define _GCC_SIZE_T' \ | |
a3f6caa7 | 742 | -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\ |
c87e58bb RS |
743 | #endif' \ |
744 | ${LIB}/$file > ${LIB}/${file}.sed | |
c61a25b1 DM |
745 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
746 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
747 | rm -f ${LIB}/$file |
748 | fi | |
749 | fi | |
750 | ||
460d7c18 TG |
751 | # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1. |
752 | file=malloc.h | |
753 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
754 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
755 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 756 | chmod a+r ${LIB}/$file 2>/dev/null |
460d7c18 TG |
757 | fi |
758 | ||
759 | if [ -r ${LIB}/$file ]; then | |
760 | echo Fixing $file | |
350027ec | 761 | sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \ |
12fe670b | 762 | -e 's/int[ ][ ]*free/void free/g' \ |
460d7c18 TG |
763 | ${LIB}/$file > ${LIB}/${file}.sed |
764 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
765 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
460d7c18 TG |
766 | rm -f ${LIB}/$file |
767 | fi | |
768 | fi | |
769 | ||
c61a25b1 DM |
770 | # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1. |
771 | file=hsfs/hsfs_spec.h | |
772 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
773 | mkdir ${LIB}/hsfs 2>/dev/null | |
774 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
775 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 776 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
777 | fi |
778 | ||
779 | if [ -r ${LIB}/$file ]; then | |
780 | echo Fixing $file | |
781 | sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \ | |
78c5c646 RS |
782 | ${LIB}/$file > ${LIB}/${file}. |
783 | rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file | |
c61a25b1 | 784 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
785 | rm -f ${LIB}/$file |
786 | fi | |
787 | fi | |
788 | ||
789 | # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1. | |
790 | file=hsfs/hsnode.h | |
791 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
792 | mkdir ${LIB}/hsfs 2>/dev/null | |
793 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
794 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 795 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
796 | fi |
797 | ||
798 | if [ -r ${LIB}/$file ]; then | |
799 | echo Fixing $file | |
800 | sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \ | |
801 | ${LIB}/$file > ${LIB}/${file}.sed | |
802 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
803 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
804 | rm -f ${LIB}/$file |
805 | fi | |
806 | fi | |
807 | ||
808 | # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1. | |
809 | file=hsfs/iso_spec.h | |
810 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
811 | mkdir ${LIB}/hsfs 2>/dev/null | |
812 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
813 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 814 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
815 | fi |
816 | ||
817 | if [ -r ${LIB}/$file ]; then | |
818 | echo Fixing $file | |
819 | sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \ | |
820 | ${LIB}/$file > ${LIB}/${file}.sed | |
821 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
822 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
823 | rm -f ${LIB}/$file |
824 | fi | |
825 | fi | |
826 | ||
75251fe0 DM |
827 | # Incorrect #include in Sony News-OS 3.2. |
828 | file=machine/machparam.h | |
829 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
830 | mkdir ${LIB}/machine 2>/dev/null | |
831 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
832 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 833 | chmod a+r ${LIB}/$file 2>/dev/null |
75251fe0 DM |
834 | fi |
835 | ||
836 | if [ -r ${LIB}/$file ]; then | |
837 | echo Fixing $file, incorrect \#include | |
838 | sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \ | |
78c5c646 RS |
839 | ${LIB}/$file > ${LIB}/${file}. |
840 | rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file | |
75251fe0 | 841 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
75251fe0 DM |
842 | rm -f ${LIB}/$file |
843 | fi | |
844 | fi | |
845 | ||
846 | # Multiline comment after typedef on IRIX 4.0.1. | |
847 | file=sys/types.h | |
848 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
849 | mkdir ${LIB}/sys 2>/dev/null | |
850 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
851 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 852 | chmod a+r ${LIB}/$file 2>/dev/null |
75251fe0 DM |
853 | fi |
854 | ||
855 | if [ -r ${LIB}/$file ]; then | |
856 | echo Fixing $file, comment in the middle of \#ifdef | |
857 | sed -e 's@type of the result@type of the result */@' \ | |
858 | -e 's@of the sizeof@/* of the sizeof@' \ | |
859 | ${LIB}/$file > ${LIB}/${file}.sed | |
860 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
861 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
75251fe0 DM |
862 | rm -f ${LIB}/$file |
863 | fi | |
864 | fi | |
865 | ||
2a46424a ILT |
866 | # Turning // comments into /* */ comments trashes this IRIX 4.0.1 |
867 | # header file, which embeds // comments inside multi-line /* */ | |
868 | # comments. If this looks like the IRIX header file, we refix it by | |
869 | # just throwing away the // comments. | |
870 | file=fam.h | |
871 | if [ -r ${LIB}/$file ]; then | |
872 | if egrep indigo.esd ${LIB}/$file > /dev/null; then | |
873 | echo Fixing $file, overeager sed script | |
874 | rm ${LIB}/$file | |
875 | sed -e 's|//.*$||g' $file > ${LIB}/$file | |
876 | chmod +w ${LIB}/$file 2>/dev/null | |
877 | chmod a+r ${LIB}/$file 2>/dev/null | |
878 | fi | |
879 | fi | |
880 | ||
8bfed528 RS |
881 | # Some IRIX header files contains the string "//" |
882 | for file in elf_abi.h elf.h; do | |
883 | if [ -r ${LIB}/$file ]; then | |
884 | echo Fixing $file, overeager sed script | |
885 | sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed | |
886 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
887 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
888 | rm -f ${LIB}/$file | |
889 | fi | |
7313c84b | 890 | fi |
8bfed528 | 891 | done |
7313c84b | 892 | |
0ff76398 JW |
893 | # Same problem with a file from SunOS 4.1.3 : a header file containing |
894 | # the string "//" embedded in "/**/" | |
895 | file=sbusdev/audiovar.h | |
896 | if [ -r ${LIB}/$file ]; then | |
897 | echo Fixing $file, overeager sed script | |
898 | rm ${LIB}/$file | |
899 | sed -e 's|//.*$||g' $file > ${LIB}/$file | |
900 | chmod +w ${LIB}/$file 2>/dev/null | |
901 | chmod a+r ${LIB}/$file 2>/dev/null | |
902 | fi | |
903 | ||
4d449554 JW |
904 | # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin |
905 | # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because | |
906 | # many other systems have similar text but correct versions of the file. | |
907 | # To ensure only Sun's is fixed, we grep for a likely unique string. | |
908 | file=memory.h | |
6a25991d RS |
909 | if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then |
910 | if [ ! -r ${LIB}/$file ]; then | |
4d449554 JW |
911 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" |
912 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 913 | chmod a+r ${LIB}/$file 2>/dev/null |
4d449554 JW |
914 | fi |
915 | if [ -r ${LIB}/$file ]; then | |
916 | echo Replacing $file | |
917 | cat > ${LIB}/$file << EOF | |
918 | /* This file was generated by fixincludes */ | |
919 | #ifndef __memory_h__ | |
920 | #define __memory_h__ | |
921 | ||
922 | #ifdef __STDC__ | |
923 | extern void *memccpy(); | |
924 | extern void *memchr(); | |
925 | extern void *memcpy(); | |
926 | extern void *memset(); | |
927 | #else | |
928 | extern char *memccpy(); | |
929 | extern char *memchr(); | |
930 | extern char *memcpy(); | |
931 | extern char *memset(); | |
932 | #endif /* __STDC__ */ | |
933 | ||
934 | extern int memcmp(); | |
935 | ||
eb13d323 | 936 | #endif /* __memory_h__ */ |
4d449554 JW |
937 | EOF |
938 | fi | |
939 | fi | |
940 | ||
7d349561 JW |
941 | # parameters not const on DECstation Ultrix V4.0. |
942 | file=stdio.h | |
943 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
944 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
945 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 946 | chmod a+r ${LIB}/$file 2>/dev/null |
7d349561 JW |
947 | fi |
948 | ||
949 | if [ -r ${LIB}/$file ]; then | |
950 | echo Fixing $file, non-const arg | |
951 | sed -e 's@perror( char \*__s );@perror( const char *__s );@' \ | |
952 | -e 's@fputs( char \*__s,@fputs( const char *__s,@' \ | |
953 | -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \ | |
954 | -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \ | |
955 | -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \ | |
956 | -e 's@scanf( char \*__format,@scanf( const char *__format,@' \ | |
957 | -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \ | |
958 | ${LIB}/$file > ${LIB}/${file}.sed | |
959 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
960 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
7d349561 JW |
961 | rm -f ${LIB}/$file |
962 | fi | |
963 | fi | |
964 | ||
f45a4d6a | 965 | # parameters conflict with C++ new on rs/6000 |
255fccf3 PB |
966 | for file in stdio.h unistd.h ; do |
967 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
968 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
969 | chmod +w ${LIB}/$file 2>/dev/null | |
970 | fi | |
971 | ||
972 | if [ -r ${LIB}/$file ]; then | |
973 | echo Fixing $file, parameter name conflicts | |
974 | sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \ | |
975 | ${LIB}/$file > ${LIB}/${file}.sed | |
976 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
977 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
978 | rm -f ${LIB}/$file | |
979 | fi | |
980 | fi | |
981 | done | |
982 | ||
983 | # function class(double x) conflicts with C++ keyword on rs/6000 | |
984 | file=math.h | |
f45a4d6a JW |
985 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then |
986 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
987 | chmod +w ${LIB}/$file 2>/dev/null | |
255fccf3 | 988 | chmod a+r ${LIB}/$file 2>/dev/null |
f45a4d6a JW |
989 | fi |
990 | ||
991 | if [ -r ${LIB}/$file ]; then | |
255fccf3 PB |
992 | if grep 'class[(]' ${LIB}/$file >/dev/null; then |
993 | echo Fixing $file | |
994 | sed -e '/class[(]/i\ | |
995 | #ifndef __cplusplus' \ | |
996 | -e '/class[(]/a\ | |
997 | #endif' ${LIB}/$file > ${LIB}/${file}.sed | |
998 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
999 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1000 | rm ${LIB}/$file | |
1001 | fi | |
1002 | fi | |
1003 | fi | |
1004 | ||
e50ea3d0 RS |
1005 | # Wrong fchmod prototype on RS/6000. |
1006 | file=sys/stat.h | |
1007 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1008 | mkdir ${LIB}/sys 2>/dev/null | |
1009 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1010 | chmod +w ${LIB}/$file 2>/dev/null | |
1011 | chmod a+r ${LIB}/$file 2>/dev/null | |
1012 | fi | |
1013 | ||
1014 | if [ -r ${LIB}/$file ]; then | |
1015 | echo Fixing $file, fchmod prototype | |
1016 | sed -e 's/fchmod(char \*/fchmod(int/' \ | |
1017 | ${LIB}/$file > ${LIB}/$file.sed | |
1018 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1019 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1020 | rm -f ${LIB}/$file | |
1021 | fi | |
1022 | fi | |
1023 | ||
08432663 RS |
1024 | # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1. |
1025 | # Note that version 3 of the NeXT system has wait.h in a different directory, | |
1026 | # so that this code won't do anything. But wait.h in version 3 has a | |
1027 | # conditional, so it doesn't need this fix. So everything is okay. | |
255fccf3 PB |
1028 | file=sys/wait.h |
1029 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1030 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1031 | chmod +w ${LIB}/$file 2>/dev/null | |
1032 | fi | |
1033 | ||
1034 | if [ -r ${LIB}/$file ] \ | |
1035 | && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then | |
1036 | echo Fixing $file, bad wait formal | |
1037 | sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed | |
f45a4d6a JW |
1038 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
1039 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1040 | rm -f ${LIB}/$file | |
1041 | fi | |
1042 | fi | |
1043 | ||
1ac7d389 RS |
1044 | # Don't use or define the name va_list in stdio.h. |
1045 | # This is for ANSI and also to interoperate properly with gvarargs.h. | |
1046 | file=stdio.h | |
1047 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1048 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1049 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 1050 | chmod a+r ${LIB}/$file 2>/dev/null |
1ac7d389 RS |
1051 | fi |
1052 | ||
1053 | if [ -r ${LIB}/$file ]; then | |
1054 | echo Fixing $file, use of va_list | |
1055 | # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list | |
1056 | (echo "#define __need___va_list" | |
1057 | echo "#include <stdarg.h>") > ${LIB}/${file}.sed | |
1058 | # Use __gnuc_va_list in arg types in place of va_list. | |
d5891360 JW |
1059 | # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the |
1060 | # trailing parentheses and semicolon save all other systems from this. | |
1ac7d389 RS |
1061 | # Define __va_list__ (something harmless and unused) instead of va_list. |
1062 | # Don't claim to have defined va_list. | |
1063 | sed -e 's@ va_list @ __gnuc_va_list @' \ | |
8befb954 | 1064 | -e 's@ va_list)@ __gnuc_va_list)@' \ |
d5891360 | 1065 | -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \ |
1ac7d389 | 1066 | -e 's@ va_list@ __va_list__@' \ |
be71bebd | 1067 | -e 's@\*va_list@*__va_list__@' \ |
75d98655 | 1068 | -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \ |
1ac7d389 | 1069 | -e 's@VA_LIST@DUMMY_VA_LIST@' \ |
75d98655 | 1070 | -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \ |
1ac7d389 RS |
1071 | ${LIB}/$file >> ${LIB}/${file}.sed |
1072 | ||
1073 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1074 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1ac7d389 RS |
1075 | rm -f ${LIB}/$file |
1076 | fi | |
1077 | fi | |
1078 | ||
e63c1d35 RS |
1079 | # Cancel out ansi_compat.h on Ultrix. Replace it with empty file. |
1080 | file=ansi_compat.h | |
1081 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1082 | if grep -s ULTRIX $file; then | |
1083 | echo "/* This file intentionally left blank. */" > $LIB/$file | |
1084 | fi | |
1085 | fi | |
1086 | ||
7d349561 | 1087 | # parameter to atof not const on DECstation Ultrix V4.0. |
28bbe06b | 1088 | # also get rid of bogus inline definitions in HP-UX 8.0 |
7d349561 JW |
1089 | file=math.h |
1090 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1091 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1092 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 1093 | chmod a+r ${LIB}/$file 2>/dev/null |
7d349561 JW |
1094 | fi |
1095 | ||
1096 | if [ -r ${LIB}/$file ]; then | |
1097 | echo Fixing $file, non-const arg | |
1098 | sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \ | |
28bbe06b RS |
1099 | -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \ |
1100 | -e 's@inline double abs(double d) { return fabs(d); }@@' \ | |
7d349561 JW |
1101 | ${LIB}/$file > ${LIB}/${file}.sed |
1102 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1103 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
7d349561 JW |
1104 | rm -f ${LIB}/$file |
1105 | fi | |
1106 | fi | |
1107 | ||
e50ea3d0 RS |
1108 | # Avoid nested comments on Ultrix 4.3. |
1109 | file=rpc/svc.h | |
1110 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1111 | mkdir ${LIB}/rpc 2>/dev/null | |
1112 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1113 | chmod +w ${LIB}/$file 2>/dev/null | |
1114 | chmod a+r ${LIB}/$file 2>/dev/null | |
1115 | fi | |
1116 | ||
1117 | if [ -r ${LIB}/$file ]; then | |
1118 | echo Fixing $file, nested comment | |
1119 | sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \ | |
1120 | ${LIB}/$file > ${LIB}/$file.sed | |
1121 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1122 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1123 | rm -f ${LIB}/$file | |
1124 | fi | |
1125 | fi | |
1126 | ||
6ef797ea RS |
1127 | # In limits.h, put #ifndefs around things that are supposed to be defined |
1128 | # in float.h to avoid redefinition errors if float.h is included first. | |
c49c4803 ILT |
1129 | # On HP/UX this patch does not work, because on HP/UX limits.h uses |
1130 | # multi line comments and the inserted #endif winds up inside the | |
1131 | # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if | |
1132 | # we find a #ifndef FLT_MIN we assume that all the required #ifndefs | |
1133 | # are there, and we do not add them ourselves. | |
e50ea3d0 RS |
1134 | for file in limits.h sys/limits.h; do |
1135 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1136 | mkdir ${LIB}/sys 2>/dev/null | |
1137 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1138 | chmod +w ${LIB}/$file 2>/dev/null | |
1139 | chmod a+r ${LIB}/$file 2>/dev/null | |
1140 | fi | |
6ef797ea | 1141 | |
e50ea3d0 RS |
1142 | if [ -r ${LIB}/$file ]; then |
1143 | if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then | |
1144 | true | |
1145 | else | |
1146 | echo Fixing $file | |
1147 | sed -e '/[ ]FLT_MIN[ ]/i\ | |
6ef797ea | 1148 | #ifndef FLT_MIN'\ |
e50ea3d0 | 1149 | -e '/[ ]FLT_MIN[ ]/a\ |
6ef797ea | 1150 | #endif'\ |
e50ea3d0 | 1151 | -e '/[ ]FLT_MAX[ ]/i\ |
6ef797ea | 1152 | #ifndef FLT_MAX'\ |
e50ea3d0 | 1153 | -e '/[ ]FLT_MAX[ ]/a\ |
6ef797ea | 1154 | #endif'\ |
e50ea3d0 | 1155 | -e '/[ ]FLT_DIG[ ]/i\ |
6ef797ea | 1156 | #ifndef FLT_DIG'\ |
e50ea3d0 | 1157 | -e '/[ ]FLT_DIG[ ]/a\ |
6ef797ea | 1158 | #endif'\ |
e50ea3d0 | 1159 | -e '/[ ]DBL_MIN[ ]/i\ |
6ef797ea | 1160 | #ifndef DBL_MIN'\ |
e50ea3d0 | 1161 | -e '/[ ]DBL_MIN[ ]/a\ |
6ef797ea | 1162 | #endif'\ |
e50ea3d0 | 1163 | -e '/[ ]DBL_MAX[ ]/i\ |
6ef797ea | 1164 | #ifndef DBL_MAX'\ |
e50ea3d0 | 1165 | -e '/[ ]DBL_MAX[ ]/a\ |
6ef797ea | 1166 | #endif'\ |
e50ea3d0 | 1167 | -e '/[ ]DBL_DIG[ ]/i\ |
6ef797ea | 1168 | #ifndef DBL_DIG'\ |
e50ea3d0 | 1169 | -e '/[ ]DBL_DIG[ ]/a\ |
6ef797ea | 1170 | #endif'\ |
e50ea3d0 RS |
1171 | ${LIB}/$file > ${LIB}/${file}.sed |
1172 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1173 | fi | |
1174 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1175 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
1176 | rm -f ${LIB}/$file | |
1177 | fi | |
6ef797ea | 1178 | fi |
e50ea3d0 | 1179 | done |
6ef797ea | 1180 | |
303b6ca3 JW |
1181 | # In math.h, put #ifndefs around things that might be defined in a gcc |
1182 | # specific math-*.h file. | |
1183 | file=math.h | |
1184 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1185 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1186 | chmod +w ${LIB}/$file 2>/dev/null | |
1187 | chmod a+r ${LIB}/$file 2>/dev/null | |
1188 | fi | |
1189 | ||
1190 | if [ -r ${LIB}/$file ]; then | |
1191 | echo Fixing $file | |
1192 | sed -e '/define[ ]HUGE_VAL[ ]/i\ | |
1193 | #ifndef HUGE_VAL'\ | |
1194 | -e '/define[ ]HUGE_VAL[ ]/a\ | |
1195 | #endif'\ | |
1196 | ${LIB}/$file > ${LIB}/${file}.sed | |
1197 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1198 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1199 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
1200 | rm -f ${LIB}/$file | |
1201 | fi | |
1202 | fi | |
1203 | ||
f90ac35b RK |
1204 | # Remove erroneous parentheses in sym.h on Alpha OSF/1. |
1205 | file=sym.h | |
1206 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1207 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1208 | chmod +w ${LIB}/$file 2>/dev/null | |
1209 | chmod a+r ${LIB}/$file 2>/dev/null | |
1210 | fi | |
1211 | ||
1212 | if [ -r ${LIB}/$file ]; then | |
1213 | echo Fixing $file | |
1214 | sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \ | |
1215 | ${LIB}/$file > ${LIB}/${file}.sed | |
1216 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1217 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1218 | rm -f ${LIB}/$file | |
1219 | fi | |
1220 | fi | |
1221 | ||
1daf7029 RS |
1222 | # Fix incorrect S_IF* definitions on m88k-sysv3. |
1223 | file=sys/stat.h | |
1224 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1225 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1226 | chmod +w ${LIB}/$file 2>/dev/null | |
1227 | chmod a+r ${LIB}/$file 2>/dev/null | |
1228 | fi | |
1229 | ||
1230 | if [ -r ${LIB}/$file ]; then | |
1231 | echo Fixing $file | |
1232 | sed -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(S_IF[A-Z][A-Z][A-Z][A-Z]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \ | |
1233 | -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \ | |
1234 | ${LIB}/$file > ${LIB}/${file}.sed | |
1235 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1236 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1237 | rm -f ${LIB}/$file | |
1238 | fi | |
1239 | fi | |
1240 | ||
e50ea3d0 RS |
1241 | # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1. |
1242 | for file in stdio.h stdlib.h; do | |
1243 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1244 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1245 | chmod +w ${LIB}/$file 2>/dev/null | |
1246 | chmod a+r ${LIB}/$file 2>/dev/null | |
1247 | fi | |
1248 | ||
1249 | if [ -r ${LIB}/$file ]; then | |
1250 | echo Fixing $file, getopt declaration | |
1251 | sed -e 's/getopt(int, char \*\[\],char \*)/getopt(int, char *const[], const char *)/' \ | |
1252 | ${LIB}/$file > ${LIB}/${file}.sed | |
1253 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1254 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1255 | rm -f ${LIB}/$file | |
1256 | fi | |
1257 | fi | |
1258 | done | |
1259 | ||
5959a6cd RS |
1260 | # These two files on SunOS 4 are included by other files |
1261 | # in the same directory, using "...". So we must make sure they exist | |
cd10f7b6 RS |
1262 | # in the same directory as the other fixed files. |
1263 | if [ -r ${INPUT}/multimedia/audio_errno.h ] | |
5959a6cd | 1264 | then |
cd10f7b6 | 1265 | ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null |
5959a6cd | 1266 | fi |
cd10f7b6 | 1267 | if [ -r ${INPUT}/multimedia/audio_hdr.h ] |
5959a6cd | 1268 | then |
cd10f7b6 | 1269 | ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null |
5959a6cd RS |
1270 | fi |
1271 | ||
315198ab RS |
1272 | # Determine if we're on Interactive Unix 2.2 or later, in which case we |
1273 | # need to fix some additional files. This is the same test for ISC that | |
1274 | # Autoconf uses. | |
1275 | if test -d /etc/conf/kconfig.d \ | |
1276 | && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then | |
1277 | echo "Fixing ISC __STDC__ goof in several files..." | |
1278 | for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do | |
1279 | echo $name | |
1280 | if test -r ${LIB}/$name; then | |
1281 | file=${LIB}/$name | |
1282 | else | |
1283 | file=${INPUT}/$name | |
1284 | fi | |
1285 | # On Interactive 2.2, certain traditional Unix definitions | |
1286 | # (notably getc and putc in stdio.h) are omitted if __STDC__ is | |
1287 | # defined, not just if _POSIX_SOURCE is defined. This makes it | |
1288 | # impossible to compile any nontrivial program except with -posix. | |
1289 | sed \ | |
1290 | 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \ | |
1291 | < $file > ${LIB}/$name. | |
1292 | mv ${LIB}/$name. ${LIB}/$name | |
1293 | done | |
1294 | ||
1295 | echo "Fixing ISC fmod declaration" | |
1296 | # This one's already been fixed for other things. | |
1297 | file=${LIB}/math.h | |
1298 | sed 's/fmod(double)/fmod(double, double)/' <$file >$file. | |
1299 | mv $file. $file | |
1300 | ||
1301 | echo "Fixing nested comments in ISC <sys/limits.h>" | |
1302 | file=sys/limits.h | |
1303 | sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file. | |
1304 | sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file | |
1305 | fi | |
1306 | ||
3b8b3c98 JW |
1307 | # These files in Sun OS 4.x use /**/ to concatenate tokens. |
1308 | for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \ | |
1309 | sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \ | |
1310 | sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h; | |
19571479 RS |
1311 | do |
1312 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1313 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1314 | chmod +w ${LIB}/$file 2>/dev/null | |
1315 | chmod a+r ${LIB}/$file 2>/dev/null | |
1316 | fi | |
1317 | ||
1318 | if [ -r ${LIB}/$file ]; then | |
1319 | sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed | |
1320 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1321 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1322 | rm -f ${LIB}/$file | |
1323 | fi | |
1324 | fi | |
1325 | done | |
1326 | ||
1327 | # These files in ARM/RISCiX use /**/ to concatenate tokens. | |
1328 | for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \ | |
1f10df15 | 1329 | dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h |
3b8b3c98 JW |
1330 | do |
1331 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1332 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1333 | chmod +w ${LIB}/$file 2>/dev/null | |
1334 | chmod a+r ${LIB}/$file 2>/dev/null | |
1335 | fi | |
1336 | ||
1337 | if [ -r ${LIB}/$file ]; then | |
1338 | sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed | |
1339 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1340 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1341 | rm -f ${LIB}/$file | |
1342 | fi | |
1343 | fi | |
1344 | done | |
1345 | ||
c61a25b1 DM |
1346 | echo 'Removing unneeded directories:' |
1347 | cd $LIB | |
1348 | files=`find . -type d -print | sort -r` | |
1349 | for file in $files; do | |
1350 | rmdir $LIB/$file > /dev/null 2>&1 | |
1351 | done | |
1352 | ||
1353 | if $LINKS; then | |
1354 | echo 'Making internal symbolic non-directory links' | |
1355 | cd ${INPUT} | |
1356 | files=`find . -type l -print` | |
1357 | for file in $files; do | |
1358 | dest=`ls -ld $file | sed -n 's/.*-> //p'` | |
1359 | if expr "$dest" : '[^/].*' > /dev/null; then | |
1360 | target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"` | |
1361 | if [ -f $target ]; then | |
1362 | ln -s $dest ${LIB}/$file >/dev/null 2>&1 | |
1363 | fi | |
1364 | fi | |
1365 | done | |
1366 | fi | |
1367 | ||
25e51a69 ILT |
1368 | echo 'Cleaning up DONE files.' |
1369 | cd $LIB | |
dca82465 | 1370 | find . -name DONE -exec rm -f '{}' ';' |
db27aeec | 1371 | |
c61a25b1 | 1372 | exit 0 |