]> gcc.gnu.org Git - gcc.git/blob - gcc/fixincludes
Edit to add a missing $(exeext) for CCCP.
[gcc.git] / gcc / fixincludes
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
8 # Directory containing the original header files.
9 # (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
10 INPUT=${2-${INPUT-/usr/include}}
11
12 # Directory in which to store the results.
13 LIB=${1?"fixincludes: output directory not specified"}
14
15 # Define PWDCMD as a command to use to get the working dir
16 # in the form that we want.
17 PWDCMD=pwd
18 case "`pwd`" in
19 //*)
20 # On an Apollo, discard everything before `/usr'.
21 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
22 ;;
23 esac
24
25 # Original directory.
26 ORIGDIR=`${PWDCMD}`
27
28 # Make sure it exists.
29 if [ ! -d $LIB ]; then
30 mkdir $LIB || exit 1
31 fi
32
33 # Make LIB absolute only if needed to avoid problems with the amd.
34 case $LIB in
35 /*)
36 ;;
37 *)
38 cd $LIB; LIB=`${PWDCMD}`
39 ;;
40 esac
41
42 # Fail if no arg to specify a directory for the output.
43 if [ x$1 = x ]
44 then echo fixincludes: no output directory specified
45 exit 1
46 fi
47
48 echo Building fixed headers in ${LIB}
49
50 # Determine whether this system has symbolic links.
51 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
52 rm -f $LIB/ShouldNotExist
53 LINKS=true
54 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
55 rm -f /tmp/ShouldNotExist
56 LINKS=true
57 else
58 LINKS=false
59 fi
60
61 echo Finding directories and links to directories
62 cd ${INPUT}
63 # Find all directories and all symlinks that point to directories.
64 # Put the list in $files.
65 # Each time we find a symlink, add it to newdirs
66 # so that we do another find within the dir the link points to.
67 # Note that $files may have duplicates in it;
68 # later parts of this file are supposed to ignore them.
69 dirs="."
70 levels=2
71 while [ -n "$dirs" ] && [ $levels -gt 0 ]
72 do
73 levels=`expr $levels - 1`
74 newdirs=
75 for d in $dirs
76 do
77 echo " Searching $INPUT/$d"
78 if [ "$d" != . ]
79 then
80 d=$d/.
81 fi
82
83 # Find all directories under $d, relative to $d, excluding $d itself.
84 files="$files `find $d -type d -print | \
85 sed -e '/\/\.$/d' -e '/^\.$/d'`"
86 # Find all links to directories.
87 # Using `-exec test -d' in find fails on some systems,
88 # and trying to run test via sh fails on others,
89 # so this is the simplest alternative left.
90 # First find all the links, then test each one.
91 theselinks=
92 $LINKS && \
93 theselinks=`find $d -type l -print`
94 for d1 in $theselinks --dummy--
95 do
96 # If the link points to a directory,
97 # add that dir to $newdirs
98 if [ -d $d1 ]
99 then
100 files="$files $d1"
101 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
102 then
103 newdirs="$newdirs $d1"
104 fi
105 fi
106 done
107 done
108
109 dirs="$newdirs"
110 done
111
112 dirs=
113 echo "All directories (including links to directories):"
114 echo $files
115
116 for file in $files; do
117 rm -rf $LIB/$file
118 if [ ! -d $LIB/$file ]
119 then mkdir $LIB/$file
120 fi
121 done
122 mkdir $LIB/root
123
124 # treetops gets an alternating list
125 # of old directories to copy
126 # and the new directories to copy to.
127 treetops="${INPUT} ${LIB}"
128
129 if $LINKS; then
130 echo 'Making symbolic directory links'
131 for file in $files; do
132 dest=`ls -ld $file | sed -n 's/.*-> //p'`
133 if [ "$dest" ]; then
134 cwd=`${PWDCMD}`
135 # In case $dest is relative, get to $file's dir first.
136 cd ${INPUT}
137 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
138 # Check that the target directory exists.
139 # Redirections changed to avoid bug in sh on Ultrix.
140 (cd $dest) > /dev/null 2>&1
141 if [ $? = 0 ]; then
142 cd $dest
143 # X gets the dir that the link actually leads to.
144 x=`${PWDCMD}`
145 # Canonicalize ${INPUT} now to minimize the time an
146 # automounter has to change the result of ${PWDCMD}.
147 cinput=`cd ${INPUT}; ${PWDCMD}`
148 # If a link points to ., make a similar link to .
149 if [ $x = ${cinput} ]; then
150 echo $file '->' . ': Making link'
151 rm -fr ${LIB}/$file > /dev/null 2>&1
152 ln -s . ${LIB}/$file > /dev/null 2>&1
153 # If link leads back into ${INPUT},
154 # make a similar link here.
155 elif expr $x : "${cinput}/.*" > /dev/null; then
156 # Y gets the actual target dir name, relative to ${INPUT}.
157 y=`echo $x | sed -n "s&${cinput}/&&p"`
158 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
159 dots=`echo "$file" |
160 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
161 echo $file '->' $dots$y ': Making link'
162 rm -fr ${LIB}/$file > /dev/null 2>&1
163 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
164 else
165 # If the link is to a dir $target outside ${INPUT},
166 # repoint the link at ${INPUT}/root$target
167 # and process $target into ${INPUT}/root$target
168 # treat this directory as if it actually contained the files.
169 echo $file '->' root$x ': Making link'
170 if [ -d $LIB/root$x ]
171 then true
172 else
173 dirname=root$x/
174 dirmade=.
175 cd $LIB
176 while [ x$dirname != x ]; do
177 component=`echo $dirname | sed -e 's|/.*$||'`
178 mkdir $component >/dev/null 2>&1
179 cd $component
180 dirmade=$dirmade/$component
181 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
182 done
183 fi
184 # Duplicate directory structure created in ${LIB}/$file in new
185 # root area.
186 for file2 in $files; do
187 case $file2 in
188 $file/./*)
189 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
190 echo "Duplicating ${file}'s ${dupdir}"
191 if [ -d ${dupdir} ]
192 then true
193 else
194 mkdir ${dupdir}
195 fi
196 ;;
197 *)
198 ;;
199 esac
200 done
201 # Get the path from ${LIB} to $file, accounting for symlinks.
202 parent=`echo "$file" | sed -e 's@/[^/]*$@@'`
203 libabs=`cd ${LIB}; ${PWDCMD}`
204 file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"`
205 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
206 dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'`
207 rm -fr ${LIB}/$file > /dev/null 2>&1
208 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
209 treetops="$treetops $x ${LIB}/root$x"
210 fi
211 fi
212 cd $cwd
213 fi
214 done
215 fi
216
217 required=
218 set x $treetops
219 shift
220 while [ $# != 0 ]; do
221 # $1 is an old directory to copy, and $2 is the new directory to copy to.
222 cd ${INPUT}
223 cd $1
224 # The same dir can appear more than once in treetops.
225 # There's no need to scan it more than once.
226 if [ -f $2/DONE ]
227 then
228 files=
229 else
230 touch $2/DONE
231 echo Fixing directory $1 into $2
232 # Check .h files which are symlinks as well as those which are files.
233 # A link to a header file will not be processed by anything but this.
234 if $LINKS; then
235 files=`find . -name '*.h' \( -type f -o -type l \) -print`
236 else
237 files=`find . -name '*.h' -type f -print`
238 fi
239 echo Checking header files
240 fi
241 # Note that BSD43_* are used on recent MIPS systems.
242 for file in $files; do
243 # This call to egrep is essential, since checking a file with egrep
244 # is much faster than actually trying to fix it.
245 # It is also essential that most files *not* match!
246 # Thus, matching every #endif is unacceptable.
247 # But the argument to egrep must be kept small, or many versions of egrep
248 # won't be able to handle it.
249 #
250 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
251 # following #else or #endif because some buggy egreps think [^/] matches
252 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
253 #
254 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
255 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
256 # in this pattern lacks `d' and `l'; this means we don't worry about
257 # identifiers starting with `d' or `l'. This is OK, since none of the
258 # identifiers below start with `d' or `l'. It also greatly improves
259 # performance, since many files contain lines of the form `#if ... defined ...'
260 # or `#if lint'.
261 if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-zA-Z][a-zA-Z0-9]' $file >/dev/null; then
262 if [ -r $file ]; then
263 cp $file $2/$file >/dev/null 2>&1 \
264 || echo "Can't copy $file"
265 chmod +w $2/$file
266 chmod a+r $2/$file
267 # Here is how the sed commands in braces work.
268 # (It doesn't work to put the comments inside the sed commands.)
269 # Surround each word with spaces, to simplify matching below.
270 # ANSIfy each pre-ANSI machine-dependent symbol
271 # by surrounding it with __ __.
272 # Remove the spaces that we inserted around each word.
273 sed -e '
274 :loop
275 /\\$/ N
276 /\\$/ b loop
277 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
278 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
279 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
280 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
281 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
282 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
283 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
284 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
285 /#define._IO/ s/'\''\([cgxtf]\)'\''/\1/g
286 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
287 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
288 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
289 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
290 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
291 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
292 /#[ ]*[el]*if/{
293 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
294
295 s/ bsd4\([0-9]\) / __bsd4\1__ /g
296 s/ _*host_mips / __host_mips__ /g
297 s/ _*i386 / __i386__ /g
298 s/ M32 / __M32__ /g
299 s/ is68k / __is68k__ /g
300 s/ m68k / __m68k__ /g
301 s/ mc680\([0-9]\)0 / __mc680\10__ /g
302 s/ m88k / __m88k__ /g
303 s/ _*mips / __mips__ /g
304 s/ news\([0-9]*\) / __news\1__ /g
305 s/ ns32000 / __ns32000__ /g
306 s/ pdp11 / __pdp11__ /g
307 s/ pyr / __pyr__ /g
308 s/ sel / __sel__ /g
309 s/ sony_news / __sony_news__ /g
310 s/ sparc / __sparc__ /g
311 s/ sun\([a-z0-9]*\) / __sun\1__ /g
312 s/ tahoe / __tahoe__ /g
313 s/ tower\([_0-9]*\) / __tower\1__ /g
314 s/ u370 / __u370__ /g
315 s/ u3b\([0-9]*\) / __u3b\1__ /g
316 s/ unix / __unix__ /g
317 s/ vax / __vax__ /g
318 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
319 s/ _*\([Rr][34]\)000 / __\1000__ /g
320 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
321
322 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
323 }
324 /^#define.NULL[ ]/ i\
325 #undef NULL
326 ' $2/$file > $2/$file.
327 mv $2/$file. $2/$file
328 if cmp $file $2/$file >/dev/null 2>&1 \
329 || egrep 'This file is part of the GNU C Library' $2/$file >/dev/null 2>&1; then
330 rm $2/$file
331 else
332 echo Fixed $file
333 # Find any include directives that use "file".
334 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
335 dir=`echo $file | sed -e s'|/[^/]*$||'`
336 required="$required $1 $dir/$include $2/$dir/$include"
337 done
338 fi
339 fi
340 fi
341 done
342 shift; shift
343 done
344
345 cd ${INPUT}
346
347 # Install the proper definition of the three standard types in header files
348 # that they come from.
349 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
350 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
351 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
352 chmod +w ${LIB}/$file 2>/dev/null
353 chmod a+r ${LIB}/$file 2>/dev/null
354 fi
355
356 if [ -r ${LIB}/$file ]; then
357 echo Fixing size_t, ptrdiff_t and wchar_t in $file
358 sed \
359 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
360 #ifndef __SIZE_TYPE__\
361 #define __SIZE_TYPE__ long unsigned int\
362 #endif
363 ' \
364 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
365 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
366 #ifndef __PTRDIFF_TYPE__\
367 #define __PTRDIFF_TYPE__ long int\
368 #endif
369 ' \
370 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
371 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
372 #ifndef __WCHAR_TYPE__\
373 #define __WCHAR_TYPE__ int\
374 #endif\
375 #ifndef __cplusplus
376 ' \
377 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/a\
378 #endif
379 ' \
380 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
381 ${LIB}/$file > ${LIB}/${file}.sed
382 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
383 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
384 rm ${LIB}/$file
385 else
386 # Find any include directives that use "file".
387 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
388 dir=`echo $file | sed -e s'|/[^/]*$||'`
389 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
390 done
391 fi
392 fi
393 done
394
395 # Fix one other error in this file: a mismatched quote not inside a C comment.
396 file=sundev/vuid_event.h
397 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
398 mkdir ${LIB}/sundev 2>/dev/null
399 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
400 chmod +w ${LIB}/$file 2>/dev/null
401 chmod a+r ${LIB}/$file 2>/dev/null
402 fi
403
404 if [ -r ${LIB}/$file ]; then
405 echo Fixing $file comment
406 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
407 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
408 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
409 rm ${LIB}/$file
410 else
411 # Find any include directives that use "file".
412 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
413 dir=`echo $file | sed -e s'|/[^/]*$||'`
414 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
415 done
416 fi
417 fi
418
419 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
420 file=sunwindow/win_cursor.h
421 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
422 # mkdir ${LIB}/sunwindow 2>/dev/null
423 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
424 chmod +w ${LIB}/$file 2>/dev/null
425 fi
426 if [ -r ${LIB}/$file ]; then
427 echo Fixing $file
428 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
429 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
430 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
431 rm ${LIB}/$file
432 else
433 # Find any include directives that use "file".
434 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
435 dir=`echo $file | sed -e s'|/[^/]*$||'`
436 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
437 done
438 fi
439 fi
440 file=sunwindow/win_lock.h
441 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
442 # mkdir ${LIB}/sunwindow 2>/dev/null
443 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
444 chmod +w ${LIB}/$file 2>/dev/null
445 fi
446 if [ -r ${LIB}/$file ]; then
447 echo Fixing $file
448 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
449 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
450 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
451 rm ${LIB}/$file
452 else
453 # Find any include directives that use "file".
454 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
455 dir=`echo $file | sed -e s'|/[^/]*$||'`
456 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
457 done
458 fi
459 fi
460
461 # Fix this Sun file to avoid interfering with stddef.h.
462 file=sys/stdtypes.h
463 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
464 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
465 chmod +w ${LIB}/$file 2>/dev/null
466 chmod a+r ${LIB}/$file 2>/dev/null
467 fi
468
469 if [ -r ${LIB}/$file ]; then
470 echo Fixing $file
471 sed -e '/[ ]size_t.*;/i\
472 #ifndef _GCC_SIZE_T\
473 #define _GCC_SIZE_T
474 ' \
475 -e '/[ ]size_t.*;/a\
476 #endif
477 ' \
478 -e '/[ ]ptrdiff_t.*;/i\
479 #ifndef _GCC_PTRDIFF_T\
480 #define _GCC_PTRDIFF_T
481 ' \
482 -e '/[ ]ptrdiff_t.*;/a\
483 #endif
484 ' \
485 -e '/[ ]wchar_t.*;/i\
486 #ifndef _GCC_WCHAR_T\
487 #define _GCC_WCHAR_T
488 ' \
489 -e '/[ ]wchar_t.*;/a\
490 #endif
491 ' ${LIB}/$file > ${LIB}/${file}.sed
492 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
493 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
494 rm ${LIB}/$file
495 else
496 # Find any include directives that use "file".
497 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
498 dir=`echo $file | sed -e s'|/[^/]*$||'`
499 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
500 done
501 fi
502 fi
503
504 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
505 # in cc1plus.
506 file=stdlib.h
507 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
508 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
509 chmod +w ${LIB}/$file 2>/dev/null
510 chmod a+r ${LIB}/$file 2>/dev/null
511 fi
512
513 if [ -r ${LIB}/$file ]; then
514 echo Fixing $file
515 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
516 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
517 ${LIB}/$file > ${LIB}/${file}.sed
518 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
519 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
520 rm ${LIB}/$file
521 else
522 # Find any include directives that use "file".
523 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
524 dir=`echo $file | sed -e s'|/[^/]*$||'`
525 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
526 done
527 fi
528 fi
529
530 # Fix this ARM/RISCiX file where ___type is a Compiler hint that is specific to
531 # the Norcroft compiler.
532 file=X11/Intrinsic.h
533 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
534 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
535 chmod +w ${LIB}/$file 2>/dev/null
536 chmod a+r ${LIB}/$file 2>/dev/null
537 fi
538
539 if [ -r ${LIB}/$file ]; then
540 echo Fixing $file
541 sed -e "s/___type p_type/p_type/" \
542 ${LIB}/$file > ${LIB}/${file}.sed
543 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
544 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
545 rm ${LIB}/$file
546 else
547 # Find any include directives that use "file".
548 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
549 dir=`echo $file | sed -e s'|/[^/]*$||'`
550 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
551 done
552 fi
553 fi
554
555 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
556 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
557 # set) size_t.
558 file=sys/types.h
559 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
560 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
561 chmod +w ${LIB}/$file 2>/dev/null
562 chmod a+r ${LIB}/$file 2>/dev/null
563 fi
564
565 if [ -r ${LIB}/$file ]; then
566 echo Fixing $file
567 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
568 #ifndef _GCC_SIZE_T\
569 #define _GCC_SIZE_T
570 ' \
571 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
572 #endif
573 ' ${LIB}/$file > ${LIB}/${file}.sed
574 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
575 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
576 rm ${LIB}/$file
577 else
578 # Find any include directives that use "file".
579 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
580 dir=`echo $file | sed -e s'|/[^/]*$||'`
581 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
582 done
583 fi
584 fi
585
586 # Fix HP's use of ../machine/inline.h to refer to
587 # /usr/include/machine/inline.h
588 file=sys/spinlock.h
589 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
590 cp $file ${LIB}/$file
591 fi
592 if [ -r ${LIB}/$file ] ; then
593 echo Fixing $file
594 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
595 -e 's,"../machine/psl.h",<machine/psl.h>,' \
596 ${LIB}/$file > ${LIB}/${file}.sed
597 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
598 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
599 rm ${LIB}/$file
600 else
601 # Find any include directives that use "file".
602 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
603 dir=`echo $file | sed -e s'|/[^/]*$||'`
604 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
605 done
606 fi
607 fi
608
609 # Fix an error in this file: the #if says _cplusplus, not the double
610 # underscore __cplusplus that it should be
611 file=tinfo.h
612 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
613 mkdir ${LIB}/rpcsvc 2>/dev/null
614 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
615 chmod +w ${LIB}/$file 2>/dev/null
616 chmod a+r ${LIB}/$file 2>/dev/null
617 fi
618
619 if [ -r ${LIB}/$file ]; then
620 echo Fixing $file, __cplusplus macro
621 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
622 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
623 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
624 rm ${LIB}/$file
625 else
626 # Find any include directives that use "file".
627 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
628 dir=`echo $file | sed -e s'|/[^/]*$||'`
629 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
630 done
631 fi
632 fi
633
634 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
635 # structure definition.
636 file=rpcsvc/rstat.h
637 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
638 mkdir ${LIB}/rpcsvc 2>/dev/null
639 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
640 chmod +w ${LIB}/$file 2>/dev/null
641 chmod a+r ${LIB}/$file 2>/dev/null
642 fi
643
644 if [ -r ${LIB}/$file ]; then
645 echo Fixing $file, definition of statsswtch
646 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
647 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
648 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
649 rm ${LIB}/$file
650 else
651 # Find any include directives that use "file".
652 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
653 dir=`echo $file | sed -e s'|/[^/]*$||'`
654 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
655 done
656 fi
657 fi
658
659 # Fix an error in this file: a missing semi-colon at the end of the nodeent
660 # structure definition.
661 file=netdnet/dnetdb.h
662 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
663 mkdir ${LIB}/netdnet 2>/dev/null
664 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
665 chmod +w ${LIB}/$file 2>/dev/null
666 chmod a+r ${LIB}/$file 2>/dev/null
667 fi
668
669 if [ -r ${LIB}/$file ]; then
670 echo Fixing $file, definition of nodeent
671 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
672 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
673 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
674 rm ${LIB}/$file
675 else
676 # Find any include directives that use "file".
677 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
678 dir=`echo $file | sed -e s'|/[^/]*$||'`
679 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
680 done
681 fi
682 fi
683
684 # Check for bad #ifdef line (in Ultrix 4.1)
685 file=sys/file.h
686 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
687 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
688 chmod +w ${LIB}/$file 2>/dev/null
689 chmod a+r ${LIB}/$file 2>/dev/null
690 fi
691
692 if [ -r ${LIB}/$file ]; then
693 echo Fixing $file, bad \#ifdef line
694 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
695 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
696 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
697 rm ${LIB}/$file
698 else
699 # Find any include directives that use "file".
700 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
701 dir=`echo $file | sed -e s'|/[^/]*$||'`
702 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
703 done
704 fi
705 fi
706
707 # Check for superfluous `static' (in Ultrix 4.2)
708 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
709 file=machine/cpu.h
710 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
711 mkdir ${LIB}/machine 2>/dev/null
712 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
713 chmod +w ${LIB}/$file 2>/dev/null
714 chmod a+r ${LIB}/$file 2>/dev/null
715 fi
716
717 if [ -r ${LIB}/$file ]; then
718 echo Fixing $file, superfluous static and broken includes of other files.
719 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
720 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
721 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
722 ${LIB}/$file > ${LIB}/${file}.sed
723 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
724 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
725 rm ${LIB}/$file
726 else
727 # Find any include directives that use "file".
728 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
729 dir=`echo $file | sed -e s'|/[^/]*$||'`
730 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
731 done
732 # This file has an alternative name, mips/cpu.h. Fix that name, too.
733 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
734 mkdir ${LIB}/mips 2>&-
735 # Don't remove the file first, they may be the same file!
736 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
737 fi
738 fi
739 fi
740
741 # Incorrect sprintf declaration in X11/Xmu.h
742 file=X11/Xmu.h
743 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
744 mkdir ${LIB}/X11 2>/dev/null
745 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
746 chmod +w ${LIB}/$file 2>/dev/null
747 chmod a+r ${LIB}/$file 2>/dev/null
748 fi
749
750 if [ -r ${LIB}/$file ]; then
751 echo Fixing $file sprintf declaration
752 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
753 extern char * sprintf();\
754 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
755 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
756 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
757 rm ${LIB}/$file
758 else
759 # Find any include directives that use "file".
760 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
761 dir=`echo $file | sed -e s'|/[^/]*$||'`
762 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
763 done
764 fi
765 fi
766
767 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
768 # (It's not clear whether the right file name is this or X11/Xmu.h.)
769 file=X11/Xmu/Xmu.h
770 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
771 mkdir ${LIB}/X11/Xmu 2>/dev/null
772 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
773 chmod +w ${LIB}/$file 2>/dev/null
774 chmod a+r ${LIB}/$file 2>/dev/null
775 fi
776
777 if [ -r ${LIB}/$file ]; then
778 echo Fixing $file sprintf declaration
779 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
780 extern char * sprintf();\
781 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
782 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
783 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
784 rm ${LIB}/$file
785 else
786 # Find any include directives that use "file".
787 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
788 dir=`echo $file | sed -e s'|/[^/]*$||'`
789 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
790 done
791 fi
792 fi
793
794 # Check for missing ';' in struct
795 file=netinet/ip.h
796 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
797 mkdir ${LIB}/netinet 2>/dev/null
798 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
799 chmod +w ${LIB}/$file 2>/dev/null
800 chmod a+r ${LIB}/$file 2>/dev/null
801 fi
802
803 if [ -r ${LIB}/$file ]; then
804 echo Fixing $file
805 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
806 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
807 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
808 rm -f ${LIB}/$file
809 else
810 # Find any include directives that use "file".
811 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
812 dir=`echo $file | sed -e s'|/[^/]*$||'`
813 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
814 done
815 fi
816 fi
817
818 # Fix the CAT macro in SunOS memvar.h.
819 file=pixrect/memvar.h
820 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
821 mkdir ${LIB}/pixrect 2>/dev/null
822 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
823 chmod +w ${LIB}/$file 2>/dev/null
824 chmod a+r ${LIB}/$file 2>/dev/null
825 fi
826
827 if [ -r ${LIB}/$file ]; then
828 echo Fixing $file
829 sed -e '/^#define.CAT(a,b)/ i\
830 #ifdef __STDC__ \
831 #define CAT(a,b) a##b\
832 #else
833 /^#define.CAT(a,b)/ a\
834 #endif
835 ' ${LIB}/$file > ${LIB}/${file}.sed
836 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
837 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
838 rm -f ${LIB}/$file
839 else
840 # Find any include directives that use "file".
841 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
842 dir=`echo $file | sed -e s'|/[^/]*$||'`
843 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
844 done
845 fi
846 fi
847
848 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
849 file=rpcsvc/rusers.h
850 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
851 mkdir ${LIB}/rpcsvc 2>/dev/null
852 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
853 chmod +w ${LIB}/$file 2>/dev/null
854 chmod a+r ${LIB}/$file 2>/dev/null
855 fi
856
857 if [ -r ${LIB}/$file ]; then
858 echo Fixing $file
859 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${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
862 rm -f ${LIB}/$file
863 else
864 # Find any include directives that use "file".
865 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
866 dir=`echo $file | sed -e s'|/[^/]*$||'`
867 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
868 done
869 fi
870 fi
871
872 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
873 # Also wrap protection around size_t for m88k-sysv3 systems.
874 file=stdlib.h
875 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
876 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
877 chmod +w ${LIB}/$file 2>/dev/null
878 chmod a+r ${LIB}/$file 2>/dev/null
879 fi
880
881 if [ -r ${LIB}/$file ]; then
882 echo Fixing $file
883 sed -e 's/int abort/void abort/g' \
884 -e 's/int free/void free/g' \
885 -e 's/char \* calloc/void \* calloc/g' \
886 -e 's/char \* malloc/void \* malloc/g' \
887 -e 's/char \* realloc/void \* realloc/g' \
888 -e 's/int exit/void exit/g' \
889 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
890 #ifndef _GCC_SIZE_T\
891 #define _GCC_SIZE_T
892 ' \
893 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
894 #endif
895 ' \
896 ${LIB}/$file > ${LIB}/${file}.sed
897 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
898 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
899 rm -f ${LIB}/$file
900 else
901 # Find any include directives that use "file".
902 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
903 dir=`echo $file | sed -e s'|/[^/]*$||'`
904 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
905 done
906 fi
907 fi
908
909 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
910 file=malloc.h
911 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
912 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
913 chmod +w ${LIB}/$file 2>/dev/null
914 chmod a+r ${LIB}/$file 2>/dev/null
915 fi
916
917 if [ -r ${LIB}/$file ]; then
918 echo Fixing $file
919 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
920 -e 's/int[ ][ ]*free/void free/g' \
921 ${LIB}/$file > ${LIB}/${file}.sed
922 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
923 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
924 rm -f ${LIB}/$file
925 else
926 # Find any include directives that use "file".
927 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
928 dir=`echo $file | sed -e s'|/[^/]*$||'`
929 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
930 done
931 fi
932 fi
933
934 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
935 file=hsfs/hsfs_spec.h
936 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
937 mkdir ${LIB}/hsfs 2>/dev/null
938 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
939 chmod +w ${LIB}/$file 2>/dev/null
940 chmod a+r ${LIB}/$file 2>/dev/null
941 fi
942
943 if [ -r ${LIB}/$file ]; then
944 echo Fixing $file
945 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
946 ${LIB}/$file > ${LIB}/${file}.
947 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
948 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
949 rm -f ${LIB}/$file
950 else
951 # Find any include directives that use "file".
952 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
953 dir=`echo $file | sed -e s'|/[^/]*$||'`
954 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
955 done
956 fi
957 fi
958
959 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
960 file=hsfs/hsnode.h
961 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
962 mkdir ${LIB}/hsfs 2>/dev/null
963 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
964 chmod +w ${LIB}/$file 2>/dev/null
965 chmod a+r ${LIB}/$file 2>/dev/null
966 fi
967
968 if [ -r ${LIB}/$file ]; then
969 echo Fixing $file
970 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
971 ${LIB}/$file > ${LIB}/${file}.sed
972 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
973 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
974 rm -f ${LIB}/$file
975 else
976 # Find any include directives that use "file".
977 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
978 dir=`echo $file | sed -e s'|/[^/]*$||'`
979 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
980 done
981 fi
982 fi
983
984 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
985 file=hsfs/iso_spec.h
986 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
987 mkdir ${LIB}/hsfs 2>/dev/null
988 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
989 chmod +w ${LIB}/$file 2>/dev/null
990 chmod a+r ${LIB}/$file 2>/dev/null
991 fi
992
993 if [ -r ${LIB}/$file ]; then
994 echo Fixing $file
995 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
996 ${LIB}/$file > ${LIB}/${file}.sed
997 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
998 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
999 rm -f ${LIB}/$file
1000 else
1001 # Find any include directives that use "file".
1002 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1003 dir=`echo $file | sed -e s'|/[^/]*$||'`
1004 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1005 done
1006 fi
1007 fi
1008
1009 # Incorrect #include in Sony News-OS 3.2.
1010 file=machine/machparam.h
1011 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1012 mkdir ${LIB}/machine 2>/dev/null
1013 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1014 chmod +w ${LIB}/$file 2>/dev/null
1015 chmod a+r ${LIB}/$file 2>/dev/null
1016 fi
1017
1018 if [ -r ${LIB}/$file ]; then
1019 echo Fixing $file, incorrect \#include
1020 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
1021 ${LIB}/$file > ${LIB}/${file}.
1022 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
1023 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1024 rm -f ${LIB}/$file
1025 else
1026 # Find any include directives that use "file".
1027 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1028 dir=`echo $file | sed -e s'|/[^/]*$||'`
1029 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1030 done
1031 fi
1032 fi
1033
1034 # Multiline comment after typedef on IRIX 4.0.1.
1035 file=sys/types.h
1036 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1037 mkdir ${LIB}/sys 2>/dev/null
1038 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1039 chmod +w ${LIB}/$file 2>/dev/null
1040 chmod a+r ${LIB}/$file 2>/dev/null
1041 fi
1042
1043 if [ -r ${LIB}/$file ]; then
1044 echo Fixing $file, comment in the middle of \#ifdef
1045 sed -e 's@type of the result@type of the result */@' \
1046 -e 's@of the sizeof@/* of the sizeof@' \
1047 ${LIB}/$file > ${LIB}/${file}.sed
1048 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1049 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1050 rm -f ${LIB}/$file
1051 else
1052 # Find any include directives that use "file".
1053 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1054 dir=`echo $file | sed -e s'|/[^/]*$||'`
1055 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1056 done
1057 fi
1058 fi
1059
1060 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
1061 # header file, which embeds // comments inside multi-line /* */
1062 # comments. If this looks like the IRIX header file, we refix it by
1063 # just throwing away the // comments.
1064 file=fam.h
1065 if [ -r ${LIB}/$file ]; then
1066 if egrep indigo.esd ${LIB}/$file > /dev/null; then
1067 echo Fixing $file, overeager sed script
1068 rm ${LIB}/$file
1069 sed -e 's|//.*$||g' $file > ${LIB}/$file
1070 chmod +w ${LIB}/$file 2>/dev/null
1071 chmod a+r ${LIB}/$file 2>/dev/null
1072 fi
1073 fi
1074
1075 # Some IRIX header files contains the string "//"
1076 for file in elf_abi.h elf.h; do
1077 if [ -r ${LIB}/$file ]; then
1078 echo Fixing $file, overeager sed script
1079 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
1080 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1081 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1082 rm -f ${LIB}/$file
1083 else
1084 # Find any include directives that use "file".
1085 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1086 dir=`echo $file | sed -e s'|/[^/]*$||'`
1087 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1088 done
1089 fi
1090 fi
1091 done
1092
1093 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
1094 # previous definition.
1095 file=rpc/auth.h
1096 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1097 mkdir ${LIB}/rpc 2>/dev/null
1098 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1099 chmod +w ${LIB}/$file 2>/dev/null
1100 chmod a+r ${LIB}/$file 2>/dev/null
1101 fi
1102
1103 if [ -r ${LIB}/$file ]; then
1104 echo Fixing $file, undefined type
1105 sed -e '/authdes_create.*struct sockaddr/i\
1106 struct sockaddr;
1107 ' \
1108 ${LIB}/$file > ${LIB}/$file.sed
1109 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1110 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1111 rm -f ${LIB}/$file
1112 else
1113 # Find any include directives that use "file".
1114 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1115 dir=`echo $file | sed -e s'|/[^/]*$||'`
1116 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1117 done
1118 fi
1119 fi
1120
1121 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
1122 # definition.
1123 file=rpc/xdr.h
1124 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1125 mkdir ${LIB}/rpc 2>/dev/null
1126 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1127 chmod +w ${LIB}/$file 2>/dev/null
1128 chmod a+r ${LIB}/$file 2>/dev/null
1129 fi
1130
1131 if [ -r ${LIB}/$file ]; then
1132 echo Fixing $file, undefined type
1133 sed -e '/xdrstdio_create.*struct __file_s/i\
1134 struct __file_s;
1135 ' \
1136 ${LIB}/$file > ${LIB}/$file.sed
1137 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1138 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1139 rm -f ${LIB}/$file
1140 else
1141 # Find any include directives that use "file".
1142 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1143 dir=`echo $file | sed -e s'|/[^/]*$||'`
1144 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1145 done
1146 fi
1147 fi
1148
1149 # Same problem with a file from SunOS 4.1.3 : a header file containing
1150 # the string "//" embedded in "/**/"
1151 file=sbusdev/audiovar.h
1152 if [ -r ${LIB}/$file ]; then
1153 echo Fixing $file, overeager sed script
1154 rm ${LIB}/$file
1155 sed -e 's|//.*$||g' $file > ${LIB}/$file
1156 chmod +w ${LIB}/$file 2>/dev/null
1157 chmod a+r ${LIB}/$file 2>/dev/null
1158 fi
1159
1160 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
1161 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
1162 # many other systems have similar text but correct versions of the file.
1163 # To ensure only Sun's is fixed, we grep for a likely unique string.
1164 file=memory.h
1165 if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
1166 if [ ! -r ${LIB}/$file ]; then
1167 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1168 chmod +w ${LIB}/$file 2>/dev/null
1169 chmod a+r ${LIB}/$file 2>/dev/null
1170 fi
1171 if [ -r ${LIB}/$file ]; then
1172 echo Replacing $file
1173 cat > ${LIB}/$file << EOF
1174 /* This file was generated by fixincludes */
1175 #ifndef __memory_h__
1176 #define __memory_h__
1177
1178 #ifdef __STDC__
1179 extern void *memccpy();
1180 extern void *memchr();
1181 extern void *memcpy();
1182 extern void *memset();
1183 #else
1184 extern char *memccpy();
1185 extern char *memchr();
1186 extern char *memcpy();
1187 extern char *memset();
1188 #endif /* __STDC__ */
1189
1190 extern int memcmp();
1191
1192 #endif /* __memory_h__ */
1193 EOF
1194 fi
1195 fi
1196
1197 # parameters not const on DECstation Ultrix V4.0 and OSF/1.
1198 file=stdio.h
1199 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1200 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1201 chmod +w ${LIB}/$file 2>/dev/null
1202 chmod a+r ${LIB}/$file 2>/dev/null
1203 fi
1204
1205 if [ -r ${LIB}/$file ]; then
1206 echo Fixing $file, non-const arg
1207 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1208 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1209 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1210 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1211 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1212 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1213 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1214 -e 's@popen(char \*, char \*);@popen(const char *, const char *);@' \
1215 -e 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@' \
1216 ${LIB}/$file > ${LIB}/${file}.sed
1217 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1218 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1219 rm -f ${LIB}/$file
1220 else
1221 # Find any include directives that use "file".
1222 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1223 dir=`echo $file | sed -e s'|/[^/]*$||'`
1224 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1225 done
1226 fi
1227 fi
1228
1229 # parameters conflict with C++ new on rs/6000
1230 for file in stdio.h unistd.h ; do
1231 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1232 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1233 chmod +w ${LIB}/$file 2>/dev/null
1234 fi
1235
1236 if [ -r ${LIB}/$file ]; then
1237 echo Fixing $file, parameter name conflicts
1238 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1239 ${LIB}/$file > ${LIB}/${file}.sed
1240 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1241 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1242 rm -f ${LIB}/$file
1243 else
1244 # Find any include directives that use "file".
1245 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1246 dir=`echo $file | sed -e s'|/[^/]*$||'`
1247 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1248 done
1249 fi
1250 fi
1251 done
1252
1253 # function class(double x) conflicts with C++ keyword on rs/6000
1254 file=math.h
1255 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1256 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1257 chmod +w ${LIB}/$file 2>/dev/null
1258 chmod a+r ${LIB}/$file 2>/dev/null
1259 fi
1260
1261 if [ -r ${LIB}/$file ]; then
1262 if grep 'class[(]' ${LIB}/$file >/dev/null; then
1263 echo Fixing $file
1264 sed -e '/class[(]/i\
1265 #ifndef __cplusplus
1266 ' \
1267 -e '/class[(]/a\
1268 #endif
1269 ' ${LIB}/$file > ${LIB}/${file}.sed
1270 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1271 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1272 rm ${LIB}/$file
1273 else
1274 # Find any include directives that use "file".
1275 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1276 dir=`echo $file | sed -e s'|/[^/]*$||'`
1277 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1278 done
1279 fi
1280 fi
1281 fi
1282
1283 # Wrong fchmod prototype on RS/6000.
1284 file=sys/stat.h
1285 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1286 mkdir ${LIB}/sys 2>/dev/null
1287 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1288 chmod +w ${LIB}/$file 2>/dev/null
1289 chmod a+r ${LIB}/$file 2>/dev/null
1290 fi
1291
1292 if [ -r ${LIB}/$file ]; then
1293 echo Fixing $file, fchmod prototype
1294 sed -e 's/fchmod(char \*/fchmod(int/' \
1295 ${LIB}/$file > ${LIB}/$file.sed
1296 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1297 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1298 rm -f ${LIB}/$file
1299 else
1300 # Find any include directives that use "file".
1301 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1302 dir=`echo $file | sed -e s'|/[^/]*$||'`
1303 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1304 done
1305 fi
1306 fi
1307
1308 # There are several name conflicts with C++ reserved words in X11
1309 # header files. These are fixed in some versions, so don't do the
1310 # fixes if we find __cplusplus in the file. These were found on the
1311 # RS/6000.
1312
1313 # class in X11/ShellP.h
1314 file=X11/ShellP.h
1315 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1316 mkdir ${LIB}/sys 2>/dev/null
1317 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1318 chmod +w ${LIB}/$file 2>/dev/null
1319 chmod a+r ${LIB}/$file 2>/dev/null
1320 fi
1321
1322 if [ -r ${LIB}/$file ]; then
1323 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1324 true;
1325 else
1326 echo Fixing $file, field class
1327 sed -e '/char [*]class;/i\
1328 #ifdef __cplusplus\
1329 char *c_class;\
1330 #else
1331 ' \
1332 -e '/char [*]class;/a\
1333 #endif
1334 ' ${LIB}/$file > ${LIB}/${file}.sed
1335 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1336 fi
1337 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1338 rm -f ${LIB}/$file
1339 else
1340 # Find any include directives that use "file".
1341 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1342 dir=`echo $file | sed -e s'|/[^/]*$||'`
1343 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1344 done
1345 fi
1346 fi
1347 # new in Xm/Traversal.h
1348 file=Xm/Traversal.h
1349 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1350 mkdir ${LIB}/sys 2>/dev/null
1351 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1352 chmod +w ${LIB}/$file 2>/dev/null
1353 chmod a+r ${LIB}/$file 2>/dev/null
1354 fi
1355
1356 if [ -r ${LIB}/$file ]; then
1357 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1358 true;
1359 else
1360 echo Fixing $file, uses of new
1361 sed -e '/Widget old, new;/i\
1362 #ifdef __cplusplus\
1363 Widget old, c_new;\
1364 #else
1365 ' \
1366 -e '/Widget old, new;/a\
1367 #endif
1368 ' \
1369 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1370 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1371 fi
1372 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1373 rm -f ${LIB}/$file
1374 else
1375 # Find any include directives that use "file".
1376 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1377 dir=`echo $file | sed -e s'|/[^/]*$||'`
1378 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1379 done
1380 fi
1381 fi
1382 # class in Xm/BaseClassI.h
1383 file=Xm/BaseClassI.h
1384 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1385 mkdir ${LIB}/sys 2>/dev/null
1386 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1387 chmod +w ${LIB}/$file 2>/dev/null
1388 chmod a+r ${LIB}/$file 2>/dev/null
1389 fi
1390
1391 if [ -r ${LIB}/$file ]; then
1392 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1393 true;
1394 else
1395 echo Fixing $file, prototype parameter name
1396 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1397 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1398 fi
1399 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1400 rm -f ${LIB}/$file
1401 else
1402 # Find any include directives that use "file".
1403 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1404 dir=`echo $file | sed -e s'|/[^/]*$||'`
1405 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1406 done
1407 fi
1408 fi
1409
1410 # NeXT 3.2 adds const prefix to some math functions. These conflict
1411 # with the built-in functions.
1412 file=ansi/math.h
1413 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1414 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1415 chmod +w ${LIB}/$file 2>/dev/null
1416 fi
1417 if [ -r ${LIB}/$file ]; then
1418 echo Fixing $file
1419 sed -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
1420 -e '/^extern.*double.*__const__.*sin(/s/__const__//' ${LIB}/$file > ${LIB}/${file}.sed
1421 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1422 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1423 rm -f ${LIB}/$file
1424 else
1425 # Find any include directives that use "file".
1426 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1427 dir=`echo $file | sed -e s'|/[^/]*$||'`
1428 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1429 done
1430 fi
1431 fi
1432
1433 # NeXT 3.2 uses the word "template" as a parameter for some
1434 # functions. GCC reports an invalid use of a reserved key word
1435 # with the built-in functions. NeXT 3.2 includes the keyword
1436 # volatile in the prototype for abort(). This conflicts with
1437 # the built-in definition.
1438 file=bsd/libc.h
1439 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1440 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1441 chmod +w ${LIB}/$file 2>/dev/null
1442 fi
1443 if [ -r ${LIB}/$file ]; then
1444 echo Fixing $file
1445 sed -e '/\(.*template\)/s/template//' \
1446 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1447 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1448 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1449 rm -f ${LIB}/$file
1450 else
1451 # Find any include directives that use "file".
1452 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1453 dir=`echo $file | sed -e s'|/[^/]*$||'`
1454 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1455 done
1456 fi
1457 fi
1458
1459 # NeXT 3.2 includes the keyword volatile in the abort() and
1460 # exit() function prototypes. That conflicts with the
1461 # built-in functions.
1462 file=ansi/stdlib.h
1463 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1464 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1465 chmod +w ${LIB}/$file 2>/dev/null
1466 fi
1467 if [ -r ${LIB}/$file ]; then
1468 echo Fixing $file
1469 sed -e '/extern.*volatile.*void.*exit/s/volatile//' \
1470 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1471 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1472 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1473 rm -f ${LIB}/$file
1474 else
1475 # Find any include directives that use "file".
1476 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1477 dir=`echo $file | sed -e s'|/[^/]*$||'`
1478 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1479 done
1480 fi
1481 fi
1482
1483 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1484 # Note that version 3 of the NeXT system has wait.h in a different directory,
1485 # so that this code won't do anything. But wait.h in version 3 has a
1486 # conditional, so it doesn't need this fix. So everything is okay.
1487 file=sys/wait.h
1488 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1489 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1490 chmod +w ${LIB}/$file 2>/dev/null
1491 fi
1492
1493 if [ -r ${LIB}/$file ] \
1494 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1495 echo Fixing $file, bad wait formal
1496 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1497 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1498 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1499 rm -f ${LIB}/$file
1500 else
1501 # Find any include directives that use "file".
1502 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1503 dir=`echo $file | sed -e s'|/[^/]*$||'`
1504 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1505 done
1506 fi
1507 fi
1508
1509 # Don't use or define the name va_list in stdio.h.
1510 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1511 file=stdio.h
1512 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1513 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1514 chmod +w ${LIB}/$file 2>/dev/null
1515 chmod a+r ${LIB}/$file 2>/dev/null
1516 fi
1517
1518 if [ -r ${LIB}/$file ]; then
1519 echo Fixing $file, use of va_list
1520 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1521 if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
1522 touch ${LIB}/${file}.sed
1523 else
1524 (echo "#define __need___va_list"
1525 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1526 fi
1527 # Use __gnuc_va_list in arg types in place of va_list.
1528 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1529 # trailing parentheses and semicolon save all other systems from this.
1530 # Define __va_list__ (something harmless and unused) instead of va_list.
1531 # Don't claim to have defined va_list.
1532 sed -e 's@ va_list @ __gnuc_va_list @' \
1533 -e 's@ va_list)@ __gnuc_va_list)@' \
1534 -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \
1535 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1536 -e 's@ va_list@ __va_list__@' \
1537 -e 's@\*va_list@*__va_list__@' \
1538 -e 's@ __va_list)@ __gnuc_va_list)@' \
1539 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
1540 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1541 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1542 -e 's@_Va_LIST@_VA_LIST@' \
1543 ${LIB}/$file >> ${LIB}/${file}.sed
1544
1545 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1546 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1547 rm -f ${LIB}/$file
1548 else
1549 # Find any include directives that use "file".
1550 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1551 dir=`echo $file | sed -e s'|/[^/]*$||'`
1552 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1553 done
1554 fi
1555 fi
1556
1557 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1558 file=ansi_compat.h
1559 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1560 if grep -s ULTRIX $file; then
1561 echo "/* This file intentionally left blank. */" > $LIB/$file
1562 fi
1563 fi
1564
1565 # parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
1566 # also get rid of bogus inline definitions in HP-UX 8.0
1567 file=math.h
1568 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1569 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1570 chmod +w ${LIB}/$file 2>/dev/null
1571 chmod a+r ${LIB}/$file 2>/dev/null
1572 fi
1573
1574 if [ -r ${LIB}/$file ]; then
1575 echo Fixing $file, non-const arg
1576 sed -e 's@atof(\([ ]*char[ ]*\*[^)]*\))@atof(const \1)@' \
1577 -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \
1578 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1579 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1580 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1581 ${LIB}/$file > ${LIB}/${file}.sed
1582 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1583 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1584 rm -f ${LIB}/$file
1585 else
1586 # Find any include directives that use "file".
1587 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1588 dir=`echo $file | sed -e s'|/[^/]*$||'`
1589 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1590 done
1591 fi
1592 fi
1593
1594 # fix bogus recursive stdlib.h in NEWS-OS 4.0C
1595 file=stdlib.h
1596 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1597 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1598 chmod +w ${LIB}/$file 2>/dev/null
1599 chmod a+r ${LIB}/$file 2>/dev/null
1600 fi
1601
1602 if [ -r ${LIB}/$file ]; then
1603 echo Fixing $file, recursive inclusion
1604 sed -e '/^#include <stdlib.h>/i\
1605 #if 0
1606 ' \
1607 -e '/^#include <stdlib.h>/a\
1608 #endif
1609 ' \
1610 ${LIB}/$file > ${LIB}/${file}.sed
1611 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1612 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1613 rm -f ${LIB}/$file
1614 else
1615 # Find any include directives that use "file".
1616 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1617 dir=`echo $file | sed -e s'|/[^/]*$||'`
1618 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1619 done
1620 fi
1621 fi
1622
1623 # Avoid nested comments on Ultrix 4.3.
1624 file=rpc/svc.h
1625 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1626 mkdir ${LIB}/rpc 2>/dev/null
1627 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1628 chmod +w ${LIB}/$file 2>/dev/null
1629 chmod a+r ${LIB}/$file 2>/dev/null
1630 fi
1631
1632 if [ -r ${LIB}/$file ]; then
1633 echo Fixing $file, nested comment
1634 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1635 ${LIB}/$file > ${LIB}/$file.sed
1636 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1637 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1638 rm -f ${LIB}/$file
1639 else
1640 # Find any include directives that use "file".
1641 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1642 dir=`echo $file | sed -e s'|/[^/]*$||'`
1643 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1644 done
1645 fi
1646 fi
1647
1648 # This file in RISC/os uses /**/ to concatenate two tokens.
1649 file=bsd43/bsd43_.h
1650 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1651 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1652 chmod +w ${LIB}/$file 2>/dev/null
1653 chmod a+r ${LIB}/$file 2>/dev/null
1654 fi
1655 if [ -r ${LIB}/$file ]; then
1656 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1657 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1658 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1659 rm -f ${LIB}/$file
1660 else
1661 # Find any include directives that use "file".
1662 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1663 dir=`echo $file | sed -e s'|/[^/]*$||'`
1664 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1665 done
1666 fi
1667 fi
1668
1669 file=rpc/rpc.h
1670 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1671 mkdir ${LIB}/rpc 2>/dev/null
1672 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1673 chmod +w ${LIB}/$file 2>/dev/null
1674 chmod a+r ${LIB}/$file 2>/dev/null
1675 fi
1676
1677 if [ -r ${LIB}/$file ]; then
1678 echo Fixing $file, nested comment
1679 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1680 ${LIB}/$file > ${LIB}/$file.sed
1681 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1682 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1683 rm -f ${LIB}/$file
1684 else
1685 # Find any include directives that use "file".
1686 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1687 dir=`echo $file | sed -e s'|/[^/]*$||'`
1688 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1689 done
1690 fi
1691 fi
1692
1693 # In limits.h, put #ifndefs around things that are supposed to be defined
1694 # in float.h to avoid redefinition errors if float.h is included first.
1695 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1696 # multi line comments and the inserted #endif winds up inside the
1697 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1698 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1699 # are there, and we do not add them ourselves.
1700 for file in limits.h sys/limits.h; do
1701 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1702 mkdir ${LIB}/sys 2>/dev/null
1703 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1704 chmod +w ${LIB}/$file 2>/dev/null
1705 chmod a+r ${LIB}/$file 2>/dev/null
1706 fi
1707
1708 if [ -r ${LIB}/$file ]; then
1709 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1710 true
1711 else
1712 echo Fixing $file
1713 sed -e '/[ ]FLT_MIN[ ]/i\
1714 #ifndef FLT_MIN
1715 '\
1716 -e '/[ ]FLT_MIN[ ]/a\
1717 #endif
1718 '\
1719 -e '/[ ]FLT_MAX[ ]/i\
1720 #ifndef FLT_MAX
1721 '\
1722 -e '/[ ]FLT_MAX[ ]/a\
1723 #endif
1724 '\
1725 -e '/[ ]FLT_DIG[ ]/i\
1726 #ifndef FLT_DIG
1727 '\
1728 -e '/[ ]FLT_DIG[ ]/a\
1729 #endif
1730 '\
1731 -e '/[ ]DBL_MIN[ ]/i\
1732 #ifndef DBL_MIN
1733 '\
1734 -e '/[ ]DBL_MIN[ ]/a\
1735 #endif
1736 '\
1737 -e '/[ ]DBL_MAX[ ]/i\
1738 #ifndef DBL_MAX
1739 '\
1740 -e '/[ ]DBL_MAX[ ]/a\
1741 #endif
1742 '\
1743 -e '/[ ]DBL_DIG[ ]/i\
1744 #ifndef DBL_DIG
1745 '\
1746 -e '/[ ]DBL_DIG[ ]/a\
1747 #endif
1748 '\
1749 ${LIB}/$file > ${LIB}/${file}.sed
1750 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1751 fi
1752 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1753 echo Deleting ${LIB}/$file\; no fixes were needed.
1754 rm -f ${LIB}/$file
1755 else
1756 # Find any include directives that use "file".
1757 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1758 dir=`echo $file | sed -e s'|/[^/]*$||'`
1759 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1760 done
1761 fi
1762 fi
1763 done
1764
1765 # In math.h, put #ifndefs around things that might be defined in a gcc
1766 # specific math-*.h file.
1767 file=math.h
1768 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1769 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1770 chmod +w ${LIB}/$file 2>/dev/null
1771 chmod a+r ${LIB}/$file 2>/dev/null
1772 fi
1773
1774 if [ -r ${LIB}/$file ]; then
1775 echo Fixing $file
1776 sed -e '/define[ ]HUGE_VAL[ ]/i\
1777 #ifndef HUGE_VAL
1778 '\
1779 -e '/define[ ]HUGE_VAL[ ]/a\
1780 #endif
1781 '\
1782 ${LIB}/$file > ${LIB}/${file}.sed
1783 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1784
1785 # In addition, copy the definition of DBL_MAX from float.h
1786 # if math.h requires one. The Lynx math.h requires it.
1787 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
1788 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
1789 true;
1790 else
1791 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
1792 if [ "$dbl_max_def" != "" ]; then
1793 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
1794 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
1795 ${LIB}/$file > ${LIB}/${file}.sed
1796 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1797 fi
1798 fi
1799 fi
1800
1801 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1802 echo Deleting ${LIB}/$file\; no fixes were needed.
1803 rm -f ${LIB}/$file
1804 else
1805 # Find any include directives that use "file".
1806 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1807 dir=`echo $file | sed -e s'|/[^/]*$||'`
1808 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1809 done
1810 fi
1811 fi
1812
1813 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1814 file=sym.h
1815 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1816 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1817 chmod +w ${LIB}/$file 2>/dev/null
1818 chmod a+r ${LIB}/$file 2>/dev/null
1819 fi
1820
1821 if [ -r ${LIB}/$file ]; then
1822 echo Fixing $file
1823 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1824 ${LIB}/$file > ${LIB}/${file}.sed
1825 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1826 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1827 rm -f ${LIB}/$file
1828 else
1829 # Find any include directives that use "file".
1830 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1831 dir=`echo $file | sed -e s'|/[^/]*$||'`
1832 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1833 done
1834 fi
1835 fi
1836
1837 # Correct the return type for strlen in string.h on Lynx.
1838 # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
1839 # Add missing const for strdup on OSF/1 V3.0.
1840 file=string.h
1841 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1842 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1843 chmod +w ${LIB}/$file 2>/dev/null
1844 chmod a+r ${LIB}/$file 2>/dev/null
1845 fi
1846
1847 if [ -r ${LIB}/$file ]; then
1848 echo Fixing $file
1849 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
1850 -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \
1851 -e 's/strdup(char \*s1);/strdup(const char *s1);/' \
1852 ${LIB}/$file > ${LIB}/${file}.sed
1853 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1854 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1855 rm -f ${LIB}/$file
1856 else
1857 # Find any include directives that use "file".
1858 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1859 dir=`echo $file | sed -e s'|/[^/]*$||'`
1860 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1861 done
1862 fi
1863 fi
1864
1865 # Correct the return type for strlen in strings.h in SunOS 4.
1866 file=strings.h
1867 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1868 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1869 chmod +w ${LIB}/$file 2>/dev/null
1870 chmod a+r ${LIB}/$file 2>/dev/null
1871 fi
1872
1873 if [ -r ${LIB}/$file ]; then
1874 echo Fixing $file
1875 sed -e 's/int[ ]*strlen();/__SIZE_TYPE__ strlen();/' \
1876 ${LIB}/$file > ${LIB}/${file}.sed
1877 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1878 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1879 rm -f ${LIB}/$file
1880 else
1881 # Find any include directives that use "file".
1882 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1883 dir=`echo $file | sed -e s'|/[^/]*$||'`
1884 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1885 done
1886 fi
1887 fi
1888
1889 # Delete the '#define void int' line from curses.h on Lynx
1890 file=curses.h
1891 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1892 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1893 chmod +w ${LIB}/$file 2>/dev/null
1894 chmod a+r ${LIB}/$file 2>/dev/null
1895 fi
1896
1897 if [ -r ${LIB}/$file ]; then
1898 echo Fixing $file
1899 sed -e '/#[ ]*define[ ][ ]*void[ ]int/d' \
1900 ${LIB}/$file > ${LIB}/${file}.sed
1901 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1902 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1903 rm -f ${LIB}/$file
1904 else
1905 # Find any include directives that use "file".
1906 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1907 dir=`echo $file | sed -e s'|/[^/]*$||'`
1908 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1909 done
1910 fi
1911 fi
1912
1913 # Fix `typedef struct term;' on hppa1.1-hp-hpux9.
1914 file=curses.h
1915 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1916 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1917 chmod +w ${LIB}/$file 2>/dev/null
1918 chmod a+r ${LIB}/$file 2>/dev/null
1919 fi
1920
1921 if [ -r ${LIB}/$file ]; then
1922 echo Fixing $file
1923 sed -e 's/^[ ]*typedef[ ][ ]*\(struct[ ][ ]*term[ ]*;[ ]*\)$/\1/' \
1924 ${LIB}/$file > ${LIB}/${file}.sed
1925 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1926 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1927 rm -f ${LIB}/$file
1928 else
1929 # Find any include directives that use "file".
1930 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1931 dir=`echo $file | sed -e s'|/[^/]*$||'`
1932 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1933 done
1934 fi
1935 fi
1936
1937 # For C++, avoid any typedef or macro definition of bool, and use the
1938 # built in type instead.
1939 for files in curses.h; do
1940 if [ -r $file ] && egrep bool $file >/dev/null 2>&1; then
1941 if [ ! -r ${LIB}/$file ]; then
1942 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1943 chmod +w ${LIB}/$file 2>/dev/null
1944 chmod a+r ${LIB}/$file 2>/dev/null
1945 fi
1946
1947 echo Fixing $file
1948 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
1949 #ifndef __cplusplus'\
1950 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
1951 #endif'\
1952 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;[ ]*$/i\
1953 #ifndef __cplusplus'\
1954 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;[ ]*$/a\
1955 #endif'\
1956 ${LIB}/$file > ${LIB}/${file}.sed
1957 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1958 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1959 rm -f ${LIB}/$file
1960 else
1961 # Find any include directives that use "file".
1962 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1963 dir=`echo $file | sed -e s'|/[^/]*$||'`
1964 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1965 done
1966 fi
1967 fi
1968 done
1969
1970 # Fix incorrect S_IF* definitions on m88k-sysv3.
1971 file=sys/stat.h
1972 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1973 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1974 chmod +w ${LIB}/$file 2>/dev/null
1975 chmod a+r ${LIB}/$file 2>/dev/null
1976 fi
1977
1978 if [ -r ${LIB}/$file ]; then
1979 echo Fixing $file
1980 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)/' \
1981 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1982 ${LIB}/$file > ${LIB}/${file}.sed
1983 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1984 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1985 rm -f ${LIB}/$file
1986 else
1987 # Find any include directives that use "file".
1988 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1989 dir=`echo $file | sed -e s'|/[^/]*$||'`
1990 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1991 done
1992 fi
1993 fi
1994
1995 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
1996 for file in stdio.h stdlib.h; do
1997 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1998 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1999 chmod +w ${LIB}/$file 2>/dev/null
2000 chmod a+r ${LIB}/$file 2>/dev/null
2001 fi
2002
2003 if [ -r ${LIB}/$file ]; then
2004 echo Fixing $file, getopt declaration
2005 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
2006 ${LIB}/$file > ${LIB}/${file}.sed
2007 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2008 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2009 rm -f ${LIB}/$file
2010 else
2011 # Find any include directives that use "file".
2012 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2013 dir=`echo $file | sed -e s'|/[^/]*$||'`
2014 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2015 done
2016 fi
2017 fi
2018 done
2019
2020 # Determine if we're on Interactive Unix 2.2 or later, in which case we
2021 # need to fix some additional files. This is the same test for ISC that
2022 # Autoconf uses.
2023 if test -d /etc/conf/kconfig.d \
2024 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
2025 echo "Fixing ISC __STDC__ goof in several files..."
2026 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
2027 echo $name
2028 if test -r ${LIB}/$name; then
2029 file=${LIB}/$name
2030 else
2031 file=${INPUT}/$name
2032 fi
2033 # On Interactive 2.2, certain traditional Unix definitions
2034 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
2035 # defined, not just if _POSIX_SOURCE is defined. This makes it
2036 # impossible to compile any nontrivial program except with -posix.
2037 sed \
2038 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
2039 < $file > ${LIB}/$name.
2040 mv ${LIB}/$name. ${LIB}/$name
2041 done
2042
2043 echo "Fixing ISC fmod declaration"
2044 # This one's already been fixed for other things.
2045 file=${LIB}/math.h
2046 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
2047 mv $file. $file
2048
2049 echo "Fixing nested comments in ISC <sys/limits.h>"
2050 file=sys/limits.h
2051 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
2052 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
2053 fi
2054
2055 # These files in Sun OS 4.x use /**/ to concatenate tokens.
2056 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
2057 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
2058 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
2059 do
2060 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2061 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2062 chmod +w ${LIB}/$file 2>/dev/null
2063 chmod a+r ${LIB}/$file 2>/dev/null
2064 fi
2065
2066 if [ -r ${LIB}/$file ]; then
2067 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2068 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2069 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2070 rm -f ${LIB}/$file
2071 else
2072 # Find any include directives that use "file".
2073 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2074 dir=`echo $file | sed -e s'|/[^/]*$||'`
2075 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2076 done
2077 fi
2078 fi
2079 done
2080
2081 # These files in ARM/RISCiX use /**/ to concatenate tokens.
2082 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
2083 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
2084 do
2085 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2086 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2087 chmod +w ${LIB}/$file 2>/dev/null
2088 chmod a+r ${LIB}/$file 2>/dev/null
2089 fi
2090
2091 if [ -r ${LIB}/$file ]; then
2092 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2093 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2094 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2095 rm -f ${LIB}/$file
2096 else
2097 # Find any include directives that use "file".
2098 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2099 dir=`echo $file | sed -e s'|/[^/]*$||'`
2100 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2101 done
2102 fi
2103 fi
2104 done
2105
2106 # math.h on SunOS 4 puts the declaration of matherr before the definition
2107 # of struct exception, so the prototype (added by fixproto) causes havoc.
2108 file=math.h
2109 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2110 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2111 chmod +w ${LIB}/$file 2>/dev/null
2112 chmod a+r ${LIB}/$file 2>/dev/null
2113 fi
2114
2115 if [ -r ${LIB}/$file ]; then
2116 echo Fixing $file, matherr declaration
2117 sed -e '/^struct exception/,$b' \
2118 -e '/matherr/i\
2119 struct exception;
2120 '\
2121 ${LIB}/$file > ${LIB}/${file}.sed
2122 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2123 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2124 rm -f ${LIB}/$file
2125 else
2126 # Find any include directives that use "file".
2127 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2128 dir=`echo $file | sed -e s'|/[^/]*$||'`
2129 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2130 done
2131 fi
2132 fi
2133
2134 # assert.h on HP/UX is not C++ ready, even though NO_IMPLICIT_EXTERN_C
2135 # is defined on HP/UX.
2136 file=assert.h
2137 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2138 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2139 chmod +w ${LIB}/$file 2>/dev/null
2140 chmod a+r ${LIB}/$file 2>/dev/null
2141 fi
2142
2143 if [ -r ${LIB}/$file ]; then
2144 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
2145 || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
2146 true
2147 else
2148 echo Fixing $file
2149 echo '#ifdef __cplusplus
2150 extern "C" {
2151 #endif' > ${LIB}/${file}.sed
2152 cat ${LIB}/${file} >> ${LIB}/${file}.sed
2153 echo '#ifdef __cplusplus
2154 }
2155 #endif' >> ${LIB}/${file}.sed
2156 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2157 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2158 rm -f ${LIB}/$file
2159 else
2160 # Find any include directives that use "file".
2161 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2162 dir=`echo $file | sed -e s'|/[^/]*$||'`
2163 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2164 done
2165 fi
2166 fi
2167 fi
2168
2169 # check for broken assert.h that needs stdio.h or stdlib.h
2170 file=assert.h
2171 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2172 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2173 chmod +w ${LIB}/$file 2>/dev/null
2174 chmod a+r ${LIB}/$file 2>/dev/null
2175 fi
2176
2177 if [ -r ${LIB}/$file ]; then
2178 if grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
2179 if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
2180 true
2181 else
2182 echo "Fixing $file (needs stdio.h)"
2183 echo '#ifdef __cplusplus
2184 #include <stdio.h>
2185 #endif' >>${LIB}/$file
2186 fi
2187 fi
2188 if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null ||
2189 grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
2190 if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
2191 true
2192 else
2193 echo "Fixing $file (needs stdlib.h)"
2194 echo '#ifdef __cplusplus
2195 #include <stdlib.h>
2196 #endif' >>${LIB}/$file
2197 fi
2198 fi
2199 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2200 rm -f ${LIB}/$file
2201 else
2202 # Find any include directives that use "file".
2203 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2204 dir=`echo $file | sed -e s'|/[^/]*$||'`
2205 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2206 done
2207 fi
2208 fi
2209
2210 # Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
2211 file=unistd.h
2212 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2213 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2214 chmod +w ${LIB}/$file 2>/dev/null
2215 chmod a+r ${LIB}/$file 2>/dev/null
2216 fi
2217
2218 if [ -r ${LIB}/$file ]; then
2219 echo Fixing $file, sbrk declaration
2220 sed -e 's/char\([ ]*\*[ ]*sbrk[ ]*(\)/void\1/' \
2221 ${LIB}/$file > ${LIB}/${file}.sed
2222 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2223 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2224 rm -f ${LIB}/$file
2225 else
2226 # Find any include directives that use "file".
2227 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2228 dir=`echo $file | sed -e s'|/[^/]*$||'`
2229 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2230 done
2231 fi
2232 fi
2233
2234 # This file on SunOS 4 has a very large macro. When the sed loop
2235 # tries pull it in, it overflows the pattern space size of the SunOS
2236 # sed (GNU sed does not have this problem). Since the file does not
2237 # require fixing, we remove it from the fixed directory.
2238 file=sundev/ipi_error.h
2239 if [ -r ${LIB}/$file ]; then
2240 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
2241 rm -f ${LIB}/$file
2242 fi
2243
2244 # Put cpp wrappers around these include files to avoid redeclaration
2245 # errors during multiple inclusion on m88k-tektronix-sysv3.
2246 for file in time.h sys/time.h ; do
2247 if egrep '#ifndef' $file >/dev/null 2>&1; then
2248 true
2249 else
2250 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2251 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2252 chmod +w ${LIB}/$file 2>/dev/null
2253 fi
2254 if [ -r ${LIB}/$file ]; then
2255 echo Fixing $file, to protect against multiple inclusion.
2256 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
2257 (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
2258 echo "#define __GCC_GOT_${cpp_wrapper}_"
2259 cat ${LIB}/${file}
2260 echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */') > ${LIB}/${file}.new
2261 rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
2262 fi
2263 fi
2264 done
2265
2266 # Fix fcntl prototype in fcntl.h on LynxOS.
2267 file=fcntl.h
2268 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2269 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2270 chmod +w ${LIB}/$file 2>/dev/null
2271 chmod a+r ${LIB}/$file 2>/dev/null
2272 fi
2273
2274 if [ -r ${LIB}/$file ]; then
2275 echo Fixing $file, fcntl declaration
2276 sed -e 's/\(fcntl.*(int, int, \)int)/\1...)/' \
2277 ${LIB}/$file > ${LIB}/${file}.sed
2278 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2279 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2280 rm -f ${LIB}/$file
2281 else
2282 # Find any include directives that use "file".
2283 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2284 dir=`echo $file | sed -e s'|/[^/]*$||'`
2285 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2286 done
2287 fi
2288 fi
2289
2290 # Fix definitions of macros used by va-i960.h in VxWorks header file.
2291 file=arch/i960/archI960.h
2292 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2293 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2294 chmod +w ${LIB}/$file 2>/dev/null
2295 chmod a+r ${LIB}/$file 2>/dev/null
2296 fi
2297
2298 if [ -r ${LIB}/$file ]; then
2299 echo Fixing $file
2300 sed -e 's/__vsiz/__vxvsiz/' -e 's/__vali/__vxvali/' \
2301 -e s'/__vpad/__vxvpad/' -e 's/__alignof__/__vxalignof__/' \
2302 ${LIB}/$file > ${LIB}/${file}.sed
2303 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2304 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2305 rm -f ${LIB}/$file
2306 else
2307 # Find any include directives that use "file".
2308 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2309 dir=`echo $file | sed -e s'|/[^/]*$||'`
2310 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2311 done
2312 fi
2313 fi
2314
2315 # Make VxWorks header which is almost gcc ready fully gcc ready.
2316 file=types/vxTypesBase.h
2317 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2318 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2319 chmod +w ${LIB}/$file 2>/dev/null
2320 chmod a+r ${LIB}/$file 2>/dev/null
2321 fi
2322
2323 if [ -r ${LIB}/$file ]; then
2324 echo Fixing $file
2325 sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \
2326 -e '/[ ]size_t/i\
2327 #ifndef _GCC_SIZE_T\
2328 #define _GCC_SIZE_T
2329 ' \
2330 -e '/[ ]size_t/a\
2331 #endif
2332 ' \
2333 -e '/[ ]ptrdiff_t/i\
2334 #ifndef _GCC_PTRDIFF_T\
2335 #define _GCC_PTRDIFF_T
2336 ' \
2337 -e '/[ ]ptrdiff_t/a\
2338 #endif
2339 ' \
2340 -e '/[ ]wchar_t/i\
2341 #ifndef _GCC_WCHAR_T\
2342 #define _GCC_WCHAR_T
2343 ' \
2344 -e '/[ ]wchar_t/a\
2345 #endif
2346 ' \
2347 ${LIB}/$file > ${LIB}/${file}.sed
2348 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2349 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2350 rm -f ${LIB}/$file
2351 else
2352 # Find any include directives that use "file".
2353 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2354 dir=`echo $file | sed -e s'|/[^/]*$||'`
2355 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2356 done
2357 fi
2358 fi
2359
2360 # Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
2361 file=sys/stat.h
2362 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2363 mkdir ${LIB}/sys 2>/dev/null
2364 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2365 chmod +w ${LIB}/$file 2>/dev/null
2366 chmod a+r ${LIB}/$file 2>/dev/null
2367 fi
2368
2369 if [ -r ${LIB}/$file ]; then
2370 if egrep '#include' ${LIB}/$file >/dev/null 2>&1; then
2371 :
2372 else
2373 if egrep 'ULONG' ${LIB}/$file >/dev/null 2>&1 \
2374 && [ -r types/vxTypesOld.h ]; then
2375 echo Fixing $file
2376 sed -e '/#define[ ][ ]*__INCstath/a\
2377 #include <types/vxTypesOld.h>
2378 ' \
2379 ${LIB}/$file > ${LIB}/${file}.sed
2380 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2381 fi
2382 fi
2383 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2384 rm -f ${LIB}/$file
2385 else
2386 # Find any include directives that use "file".
2387 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2388 dir=`echo $file | sed -e s'|/[^/]*$||'`
2389 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2390 done
2391 fi
2392 fi
2393
2394 # Fix VxWorks <time.h> to not require including <vxTypes.h>.
2395 file=time.h
2396 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2397 mkdir ${LIB}/sys 2>/dev/null
2398 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2399 chmod +w ${LIB}/$file 2>/dev/null
2400 chmod a+r ${LIB}/$file 2>/dev/null
2401 fi
2402
2403 if [ -r ${LIB}/$file ]; then
2404 if egrep 'uint_t[ ][ ]*_clocks_per_sec' ${LIB}/$file >/dev/null 2>&1; then
2405 echo Fixing $file
2406 sed -e 's/uint_t/unsigned int/' ${LIB}/$file > ${LIB}/${file}.sed
2407 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2408 fi
2409 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2410 rm -f ${LIB}/$file
2411 else
2412 # Find any include directives that use "file".
2413 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2414 dir=`echo $file | sed -e s'|/[^/]*$||'`
2415 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2416 done
2417 fi
2418 fi
2419
2420
2421 # This loop does not appear to do anything, because it uses file
2422 # rather than $file when setting target. It also appears to be
2423 # unnecessary, since the main loop processes symbolic links.
2424 #if $LINKS; then
2425 # echo 'Making internal symbolic non-directory links'
2426 # cd ${INPUT}
2427 # files=`find . -type l -print`
2428 # for file in $files; do
2429 # dest=`ls -ld $file | sed -n 's/.*-> //p'`
2430 # if expr "$dest" : '[^/].*' > /dev/null; then
2431 # target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
2432 # if [ -f $target ]; then
2433 # ln -s $dest ${LIB}/$file >/dev/null 2>&1
2434 # fi
2435 # fi
2436 # done
2437 #fi
2438
2439 # Make sure that any include files referenced using double quotes
2440 # exist in the fixed directory. This comes last since otherwise
2441 # we might end up deleting some of these files "because they don't
2442 # need any change."
2443 set x $required
2444 shift
2445 while [ $# != 0 ]; do
2446 newreq=
2447 while [ $# != 0 ]; do
2448 # $1 is the directory to copy from, $2 is the unfixed file,
2449 # $3 is the fixed file name.
2450 cd ${INPUT}
2451 cd $1
2452 if [ -r $2 ] && [ ! -r $3 ]; then
2453 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
2454 chmod +w $3 2>/dev/null
2455 chmod a+r $3 2>/dev/null
2456 echo Copied $2
2457 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2458 dir=`echo $2 | sed -e s'|/[^/]*$||'`
2459 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
2460 newreq="$newreq $1 $dir/$include $dir2/$include"
2461 done
2462 fi
2463 shift; shift; shift
2464 done
2465 set x $newreq
2466 shift
2467 done
2468
2469 echo 'Cleaning up DONE files.'
2470 cd $LIB
2471 find . -name DONE -exec rm -f '{}' ';'
2472
2473 echo 'Removing unneeded directories:'
2474 cd $LIB
2475 files=`find . -type d -print | sort -r`
2476 for file in $files; do
2477 rmdir $LIB/$file > /dev/null 2>&1
2478 done
2479
2480 exit 0
This page took 0.259986 seconds and 5 git commands to generate.