* except.c (expand_start_catch_block): We only need the rethrow
[official-gcc.git] / gcc / fixincludes
blob89c9f71741765a1db6aa4ec94fd62c1560d4d23c
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.
6 # See README-fixinc for more information.
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}}
12 # Directory in which to store the results.
13 LIB=${1?"fixincludes: output directory not specified"}
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/,'"
23 esac
25 # Original directory.
26 ORIGDIR=`${PWDCMD}`
28 # Make sure it exists.
29 if [ ! -d $LIB ]; then
30 mkdir $LIB || exit 1
33 # Make LIB absolute only if needed to avoid problems with the amd.
34 case $LIB in
35 /*)
38 cd $LIB; LIB=`${PWDCMD}`
40 esac
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
48 echo Building fixed headers in ${LIB}
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
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 ]
73 levels=`expr $levels - 1`
74 newdirs=
75 for d in $dirs
77 echo " Searching $INPUT/$d"
79 # Find all directories under $d, relative to $d, excluding $d itself.
80 # (The /. is needed after $d in case $d is a symlink.)
81 files="$files `find $d/. -type d -print | \
82 sed -e '/\/\.$/d' -e 's@/./@/@g'`"
83 # Find all links to directories.
84 # Using `-exec test -d' in find fails on some systems,
85 # and trying to run test via sh fails on others,
86 # so this is the simplest alternative left.
87 # First find all the links, then test each one.
88 theselinks=
89 $LINKS && \
90 theselinks=`find $d/. -type l -print | sed -e 's@/./@/@g'`
91 for d1 in $theselinks --dummy--
93 # If the link points to a directory,
94 # add that dir to $newdirs
95 if [ -d $d1 ]
96 then
97 files="$files $d1"
98 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
99 then
100 newdirs="$newdirs $d1"
103 done
104 done
106 dirs="$newdirs"
107 done
109 dirs=
110 echo "All directories (including links to directories):"
111 echo $files
113 for file in $files; do
114 rm -rf $LIB/$file
115 if [ ! -d $LIB/$file ]
116 then mkdir $LIB/$file
118 done
119 mkdir $LIB/root
121 # treetops gets an alternating list
122 # of old directories to copy
123 # and the new directories to copy to.
124 treetops="${INPUT} ${LIB}"
126 if $LINKS; then
127 echo 'Making symbolic directory links'
128 for file in $files; do
129 dest=`ls -ld $file | sed -n 's/.*-> //p'`
130 if [ "$dest" ]; then
131 cwd=`${PWDCMD}`
132 # In case $dest is relative, get to $file's dir first.
133 cd ${INPUT}
134 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
135 # Check that the target directory exists.
136 # Redirections changed to avoid bug in sh on Ultrix.
137 (cd $dest) > /dev/null 2>&1
138 if [ $? = 0 ]; then
139 cd $dest
140 # X gets the dir that the link actually leads to.
141 x=`${PWDCMD}`
142 # Canonicalize ${INPUT} now to minimize the time an
143 # automounter has to change the result of ${PWDCMD}.
144 cinput=`cd ${INPUT}; ${PWDCMD}`
145 # If a link points to ., make a similar link to .
146 if [ $x = ${cinput} ]; then
147 echo $file '->' . ': Making link'
148 rm -fr ${LIB}/$file > /dev/null 2>&1
149 ln -s . ${LIB}/$file > /dev/null 2>&1
150 # If link leads back into ${INPUT},
151 # make a similar link here.
152 elif expr $x : "${cinput}/.*" > /dev/null; then
153 # Y gets the actual target dir name, relative to ${INPUT}.
154 y=`echo $x | sed -n "s&${cinput}/&&p"`
155 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
156 dots=`echo "$file" |
157 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
158 echo $file '->' $dots$y ': Making link'
159 rm -fr ${LIB}/$file > /dev/null 2>&1
160 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
161 else
162 # If the link is to a dir $target outside ${INPUT},
163 # repoint the link at ${INPUT}/root$target
164 # and process $target into ${INPUT}/root$target
165 # treat this directory as if it actually contained the files.
166 echo $file '->' root$x ': Making link'
167 if [ -d $LIB/root$x ]
168 then true
169 else
170 dirname=root$x/
171 dirmade=.
172 cd $LIB
173 while [ x$dirname != x ]; do
174 component=`echo $dirname | sed -e 's|/.*$||'`
175 mkdir $component >/dev/null 2>&1
176 cd $component
177 dirmade=$dirmade/$component
178 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
179 done
181 # Duplicate directory structure created in ${LIB}/$file in new
182 # root area.
183 for file2 in $files; do
184 case $file2 in
185 $file/*)
186 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
187 echo "Duplicating ${file}'s ${dupdir}"
188 if [ -d ${dupdir} ]
189 then true
190 else
191 mkdir ${dupdir}
196 esac
197 done
198 # Get the path from ${LIB} to $file, accounting for symlinks.
199 parent=`echo "$file" | sed -e 's@/[^/]*$@@'`
200 libabs=`cd ${LIB}; ${PWDCMD}`
201 file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"`
202 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
203 dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'`
204 rm -fr ${LIB}/$file > /dev/null 2>&1
205 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
206 treetops="$treetops $x ${LIB}/root$x"
209 cd $cwd
211 done
214 required=
215 set x $treetops
216 shift
217 while [ $# != 0 ]; do
218 # $1 is an old directory to copy, and $2 is the new directory to copy to.
219 cd ${INPUT}
220 cd $1
221 # The same dir can appear more than once in treetops.
222 # There's no need to scan it more than once.
223 if [ -f $2/DONE ]
224 then
225 files=
226 else
227 touch $2/DONE
228 echo Fixing directory $1 into $2
229 # Check .h files which are symlinks as well as those which are files.
230 # A link to a header file will not be processed by anything but this.
231 if $LINKS; then
232 files=`find . -name '*.h' \( -type f -o -type l \) -print`
233 else
234 files=`find . -name '*.h' -type f -print`
236 echo Checking header files
238 # Note that BSD43_* are used on recent MIPS systems.
239 for file in $files; do
240 # This call to egrep is essential, since checking a file with egrep
241 # is much faster than actually trying to fix it.
242 # It is also essential that most files *not* match!
243 # Thus, matching every #endif is unacceptable.
244 # But the argument to egrep must be kept small, or many versions of egrep
245 # won't be able to handle it.
247 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
248 # following #else or #endif because some buggy egreps think [^/] matches
249 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
251 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
252 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
253 # in this pattern lacks `d' and `l'; this means we don't worry about
254 # identifiers starting with `d' or `l'. This is OK, since none of the
255 # identifiers below start with `d' or `l'. It also greatly improves
256 # performance, since many files contain lines of the form `#if ... defined ...'
257 # or `#if lint'.
258 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
259 if [ -r $file ]; then
260 cp $file $2/$file >/dev/null 2>&1 \
261 || echo "Can't copy $file"
262 chmod +w $2/$file
263 chmod a+r $2/$file
264 # The fixinc_eol stuff is to work around a bug in the sed
265 # program on HP/UX 10.20.
266 # Here is how the sed commands in braces work.
267 # (It doesn't work to put the comments inside the sed commands.)
268 # Surround each word with spaces, to simplify matching below.
269 # ANSIfy each pre-ANSI machine-dependent symbol
270 # by surrounding it with __ __.
271 # Remove the spaces that we inserted around each word.
272 sed -e '
273 :loop
274 /\\$/ N
275 s/\\$/\\*fixinc_eol*/
276 /\\$/ b loop
277 s/\\\*fixinc_eol\*/\\/g
278 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
279 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
280 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
281 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
282 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
283 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
284 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
285 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
286 /#[ ]*define[ ]*[ ]_IO/ s/'\''\([cgxtf]\)'\''/\1/g
287 /#[ ]*define[ ]*[ ]BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
288 /#[ ]*define[ ]*[ ]DESIOC/ s/'\''\([cdgx]\)'\''/\1/g
289 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
290 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
291 /#[ ]*define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
292 /#[ ]*define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
293 /#[ ]*define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
294 /#[ ]*[el]*if/{
295 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
297 s/ bsd4\([0-9]\) / __bsd4\1__ /g
298 s/ _*host_mips / __host_mips__ /g
299 s/ _*i386 / __i386__ /g
300 s/ M32 / __M32__ /g
301 s/ is68k / __is68k__ /g
302 s/ m68k / __m68k__ /g
303 s/ mc680\([0-9]\)0 / __mc680\10__ /g
304 s/ m88k / __m88k__ /g
305 s/ _*mips / __mips__ /g
306 s/ news\([0-9]*\) / __news\1__ /g
307 s/ ns32000 / __ns32000__ /g
308 s/ pdp11 / __pdp11__ /g
309 s/ pyr / __pyr__ /g
310 s/ sel / __sel__ /g
311 s/ sony_news / __sony_news__ /g
312 s/ sparc / __sparc__ /g
313 s/ sun\([a-z0-9]*\) / __sun\1__ /g
314 s/ tahoe / __tahoe__ /g
315 s/ tower\([_0-9]*\) / __tower\1__ /g
316 s/ u370 / __u370__ /g
317 s/ u3b\([0-9]*\) / __u3b\1__ /g
318 s/ unix / __unix__ /g
319 s/ vax / __vax__ /g
320 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
321 s/ _*\([Rr][34]\)000 / __\1000__ /g
322 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
324 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
326 /^#define.NULL[ ]/ i\
327 #undef NULL
328 ' $2/$file > $2/$file.
329 mv $2/$file. $2/$file
330 if cmp $file $2/$file >/dev/null 2>&1 \
331 || egrep 'This file is part of the GNU C Library' $2/$file >/dev/null 2>&1; then
332 rm $2/$file
333 else
334 echo Fixed $file
335 # Find any include directives that use "file".
336 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
337 dir=`echo $file | sed -e s'|/[^/]*$||'`
338 required="$required $1 $dir/$include $2/$dir/$include"
339 done
343 done
344 shift; shift
345 done
347 cd ${INPUT}
349 # Install the proper definition of the three standard types in header files
350 # that they come from.
351 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
352 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
353 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
354 chmod +w ${LIB}/$file 2>/dev/null
355 chmod a+r ${LIB}/$file 2>/dev/null
358 if [ -r ${LIB}/$file ]; then
359 echo Fixing size_t, ptrdiff_t and wchar_t in $file
360 sed \
361 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
362 #ifndef __SIZE_TYPE__\
363 #define __SIZE_TYPE__ long unsigned int\
364 #endif
366 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
367 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
368 #ifndef __PTRDIFF_TYPE__\
369 #define __PTRDIFF_TYPE__ long int\
370 #endif
372 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
373 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
374 #ifndef __WCHAR_TYPE__\
375 #define __WCHAR_TYPE__ int\
376 #endif\
377 #ifndef __cplusplus
379 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/a\
380 #endif
382 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
383 ${LIB}/$file > ${LIB}/${file}.sed
384 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
385 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
386 rm ${LIB}/$file
387 else
388 # Find any include directives that use "file".
389 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
390 dir=`echo $file | sed -e s'|/[^/]*$||'`
391 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
392 done
395 done
397 # Fix one other error in this file: a mismatched quote not inside a C comment.
398 file=sundev/vuid_event.h
399 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
400 mkdir ${LIB}/sundev 2>/dev/null
401 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
402 chmod +w ${LIB}/$file 2>/dev/null
403 chmod a+r ${LIB}/$file 2>/dev/null
406 if [ -r ${LIB}/$file ]; then
407 echo Fixing $file comment
408 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
409 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
410 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
411 rm ${LIB}/$file
412 else
413 # Find any include directives that use "file".
414 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
415 dir=`echo $file | sed -e s'|/[^/]*$||'`
416 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
417 done
421 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
422 file=sunwindow/win_cursor.h
423 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
424 # mkdir ${LIB}/sunwindow 2>/dev/null
425 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
426 chmod +w ${LIB}/$file 2>/dev/null
428 if [ -r ${LIB}/$file ]; then
429 echo Fixing $file
430 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
431 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
432 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
433 rm ${LIB}/$file
434 else
435 # Find any include directives that use "file".
436 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
437 dir=`echo $file | sed -e s'|/[^/]*$||'`
438 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
439 done
442 file=sunwindow/win_lock.h
443 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
444 # mkdir ${LIB}/sunwindow 2>/dev/null
445 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
446 chmod +w ${LIB}/$file 2>/dev/null
448 if [ -r ${LIB}/$file ]; then
449 echo Fixing $file
450 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
451 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
452 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
453 rm ${LIB}/$file
454 else
455 # Find any include directives that use "file".
456 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
457 dir=`echo $file | sed -e s'|/[^/]*$||'`
458 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
459 done
463 # Fix this Sun file to avoid interfering with stddef.h.
464 file=sys/stdtypes.h
465 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
466 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
467 chmod +w ${LIB}/$file 2>/dev/null
468 chmod a+r ${LIB}/$file 2>/dev/null
471 if [ -r ${LIB}/$file ]; then
472 echo Fixing $file
473 sed -e '/[ ]size_t.*;/i\
474 #ifndef _GCC_SIZE_T\
475 #define _GCC_SIZE_T
477 -e '/[ ]size_t.*;/a\
478 #endif
480 -e '/[ ]ptrdiff_t.*;/i\
481 #ifndef _GCC_PTRDIFF_T\
482 #define _GCC_PTRDIFF_T
484 -e '/[ ]ptrdiff_t.*;/a\
485 #endif
487 -e '/[ ]wchar_t.*;/i\
488 #ifndef _GCC_WCHAR_T\
489 #define _GCC_WCHAR_T
491 -e '/[ ]wchar_t.*;/a\
492 #endif
493 ' ${LIB}/$file > ${LIB}/${file}.sed
494 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
495 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
496 rm ${LIB}/$file
497 else
498 # Find any include directives that use "file".
499 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
500 dir=`echo $file | sed -e s'|/[^/]*$||'`
501 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
502 done
506 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
507 # in cc1plus.
508 file=stdlib.h
509 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
510 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
511 chmod +w ${LIB}/$file 2>/dev/null
512 chmod a+r ${LIB}/$file 2>/dev/null
515 if [ -r ${LIB}/$file ]; then
516 echo Fixing $file
517 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
518 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
519 ${LIB}/$file > ${LIB}/${file}.sed
520 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
521 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
522 rm ${LIB}/$file
523 else
524 # Find any include directives that use "file".
525 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
526 dir=`echo $file | sed -e s'|/[^/]*$||'`
527 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
528 done
532 # Fix this ARM/RISCiX file where ___type is a Compiler hint that is specific to
533 # the Norcroft compiler.
534 file=X11/Intrinsic.h
535 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
536 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
537 chmod +w ${LIB}/$file 2>/dev/null
538 chmod a+r ${LIB}/$file 2>/dev/null
541 if [ -r ${LIB}/$file ]; then
542 echo Fixing $file
543 sed -e "s/___type p_type/p_type/" \
544 ${LIB}/$file > ${LIB}/${file}.sed
545 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
546 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
547 rm ${LIB}/$file
548 else
549 # Find any include directives that use "file".
550 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
551 dir=`echo $file | sed -e s'|/[^/]*$||'`
552 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
553 done
557 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
558 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
559 # set) size_t.
560 file=sys/types.h
561 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
562 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
563 chmod +w ${LIB}/$file 2>/dev/null
564 chmod a+r ${LIB}/$file 2>/dev/null
567 if [ -r ${LIB}/$file ]; then
568 echo Fixing $file
569 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
570 #ifndef _GCC_SIZE_T\
571 #define _GCC_SIZE_T
573 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
574 #endif
575 ' ${LIB}/$file > ${LIB}/${file}.sed
576 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
577 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
578 rm ${LIB}/$file
579 else
580 # Find any include directives that use "file".
581 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
582 dir=`echo $file | sed -e s'|/[^/]*$||'`
583 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
584 done
588 # Fix HP's use of ../machine/inline.h to refer to
589 # /usr/include/machine/inline.h
590 file=sys/spinlock.h
591 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
592 cp $file ${LIB}/$file
594 if [ -r ${LIB}/$file ] ; then
595 echo Fixing $file
596 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
597 -e 's,"../machine/psl.h",<machine/psl.h>,' \
598 ${LIB}/$file > ${LIB}/${file}.sed
599 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
600 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
601 rm ${LIB}/$file
602 else
603 # Find any include directives that use "file".
604 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
605 dir=`echo $file | sed -e s'|/[^/]*$||'`
606 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
607 done
611 # Fix an error in this file: the #if says _cplusplus, not the double
612 # underscore __cplusplus that it should be
613 file=tinfo.h
614 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
615 mkdir ${LIB}/rpcsvc 2>/dev/null
616 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
617 chmod +w ${LIB}/$file 2>/dev/null
618 chmod a+r ${LIB}/$file 2>/dev/null
621 if [ -r ${LIB}/$file ]; then
622 echo Fixing $file, __cplusplus macro
623 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
624 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
625 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
626 rm ${LIB}/$file
627 else
628 # Find any include directives that use "file".
629 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
630 dir=`echo $file | sed -e s'|/[^/]*$||'`
631 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
632 done
636 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
637 # structure definition.
638 file=rpcsvc/rstat.h
639 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
640 mkdir ${LIB}/rpcsvc 2>/dev/null
641 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
642 chmod +w ${LIB}/$file 2>/dev/null
643 chmod a+r ${LIB}/$file 2>/dev/null
646 if [ -r ${LIB}/$file ]; then
647 echo Fixing $file, definition of statsswtch
648 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
649 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
650 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
651 rm ${LIB}/$file
652 else
653 # Find any include directives that use "file".
654 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
655 dir=`echo $file | sed -e s'|/[^/]*$||'`
656 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
657 done
661 # Fix an error in this file: a missing semi-colon at the end of the nodeent
662 # structure definition.
663 file=netdnet/dnetdb.h
664 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
665 mkdir ${LIB}/netdnet 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
668 chmod a+r ${LIB}/$file 2>/dev/null
671 if [ -r ${LIB}/$file ]; then
672 echo Fixing $file, definition of nodeent
673 sed -e 's/char.*na_addr *$/char *na_addr;/' ${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
676 rm ${LIB}/$file
677 else
678 # Find any include directives that use "file".
679 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
680 dir=`echo $file | sed -e s'|/[^/]*$||'`
681 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
682 done
686 # Check for bad #ifdef line (in Ultrix 4.1)
687 file=sys/file.h
688 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
689 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
690 chmod +w ${LIB}/$file 2>/dev/null
691 chmod a+r ${LIB}/$file 2>/dev/null
694 if [ -r ${LIB}/$file ]; then
695 echo Fixing $file, bad \#ifdef line
696 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
697 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
698 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
699 rm ${LIB}/$file
700 else
701 # Find any include directives that use "file".
702 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
703 dir=`echo $file | sed -e s'|/[^/]*$||'`
704 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
705 done
709 # Check for (...) in C++ code in HP/UX sys/file.h.
710 file=sys/file.h
711 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
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
717 if [ -r ${LIB}/$file ]; then
718 if egrep HPUX_SOURCE ${LIB}/$file > /dev/null; then
719 echo Fixing $file, use of '(...)'
720 sed -e 's/(\.\.\.)/(struct file * ...)/' ${LIB}/$file > ${LIB}/${file}.sed
721 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
722 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
723 rm ${LIB}/$file
724 else
725 # Find any include directives that use "file".
726 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
727 dir=`echo $file | sed -e s'|/[^/]*$||'`
728 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
729 done
734 # Check for superfluous `static' (in Ultrix 4.2)
735 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
736 file=machine/cpu.h
737 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
738 mkdir ${LIB}/machine 2>/dev/null
739 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
740 chmod +w ${LIB}/$file 2>/dev/null
741 chmod a+r ${LIB}/$file 2>/dev/null
744 if [ -r ${LIB}/$file ]; then
745 echo Fixing $file, superfluous static and broken includes of other files.
746 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
747 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
748 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
749 ${LIB}/$file > ${LIB}/${file}.sed
750 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
751 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
752 rm ${LIB}/$file
753 else
754 # Find any include directives that use "file".
755 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
756 dir=`echo $file | sed -e s'|/[^/]*$||'`
757 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
758 done
759 # This file has an alternative name, mips/cpu.h. Fix that name, too.
760 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
761 mkdir ${LIB}/mips 2>&-
762 # Don't remove the file first, they may be the same file!
763 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
768 # Incorrect sprintf declaration in X11/Xmu.h
769 file=X11/Xmu.h
770 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
771 mkdir ${LIB}/X11 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
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
794 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
795 # (It's not clear whether the right file name is this or X11/Xmu.h.)
796 file=X11/Xmu/Xmu.h
797 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
798 mkdir ${LIB}/X11/Xmu 2>/dev/null
799 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
800 chmod +w ${LIB}/$file 2>/dev/null
801 chmod a+r ${LIB}/$file 2>/dev/null
804 if [ -r ${LIB}/$file ]; then
805 echo Fixing $file sprintf declaration
806 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
807 extern char * sprintf();\
808 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
809 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
810 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
811 rm ${LIB}/$file
812 else
813 # Find any include directives that use "file".
814 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
815 dir=`echo $file | sed -e s'|/[^/]*$||'`
816 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
817 done
821 # Check for missing ';' in struct
822 file=netinet/ip.h
823 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
824 mkdir ${LIB}/netinet 2>/dev/null
825 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
826 chmod +w ${LIB}/$file 2>/dev/null
827 chmod a+r ${LIB}/$file 2>/dev/null
830 if [ -r ${LIB}/$file ]; then
831 echo Fixing $file
832 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
833 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
834 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
835 rm -f ${LIB}/$file
836 else
837 # Find any include directives that use "file".
838 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
839 dir=`echo $file | sed -e s'|/[^/]*$||'`
840 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
841 done
845 # Fix the CAT macro in SunOS memvar.h.
846 file=pixrect/memvar.h
847 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
848 mkdir ${LIB}/pixrect 2>/dev/null
849 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
850 chmod +w ${LIB}/$file 2>/dev/null
851 chmod a+r ${LIB}/$file 2>/dev/null
854 if [ -r ${LIB}/$file ]; then
855 echo Fixing $file
856 sed -e '/^#define.CAT(a,b)/ i\
857 #ifdef __STDC__ \
858 #define CAT(a,b) a##b\
859 #else
860 /^#define.CAT(a,b)/ a\
861 #endif
862 ' ${LIB}/$file > ${LIB}/${file}.sed
863 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
864 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
865 rm -f ${LIB}/$file
866 else
867 # Find any include directives that use "file".
868 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
869 dir=`echo $file | sed -e s'|/[^/]*$||'`
870 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
871 done
875 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
876 file=rpcsvc/rusers.h
877 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
878 mkdir ${LIB}/rpcsvc 2>/dev/null
879 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
880 chmod +w ${LIB}/$file 2>/dev/null
881 chmod a+r ${LIB}/$file 2>/dev/null
884 if [ -r ${LIB}/$file ]; then
885 echo Fixing $file
886 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
887 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
888 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
889 rm -f ${LIB}/$file
890 else
891 # Find any include directives that use "file".
892 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
893 dir=`echo $file | sed -e s'|/[^/]*$||'`
894 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
895 done
899 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
900 # Also wrap protection around size_t for m88k-sysv3 systems.
901 file=stdlib.h
902 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
903 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
904 chmod +w ${LIB}/$file 2>/dev/null
905 chmod a+r ${LIB}/$file 2>/dev/null
908 if [ -r ${LIB}/$file ]; then
909 echo Fixing $file
910 sed -e 's/int abort/void abort/g' \
911 -e 's/int free/void free/g' \
912 -e 's/char[ ]*\*[ ]*calloc/void \* calloc/g' \
913 -e 's/char[ ]*\*[ ]*malloc/void \* malloc/g' \
914 -e 's/char[ ]*\*[ ]*realloc/void \* realloc/g' \
915 -e 's/int[ ][ ]*exit/void exit/g' \
916 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
917 #ifndef _GCC_SIZE_T\
918 #define _GCC_SIZE_T
920 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
921 #endif
923 ${LIB}/$file > ${LIB}/${file}.sed
924 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
925 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
926 rm -f ${LIB}/$file
927 else
928 # Find any include directives that use "file".
929 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
930 dir=`echo $file | sed -e s'|/[^/]*$||'`
931 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
932 done
936 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
937 # Also fix return type of {m,re}alloc in <malloc.h> on sysV68
938 file=malloc.h
939 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
940 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
941 chmod +w ${LIB}/$file 2>/dev/null
942 chmod a+r ${LIB}/$file 2>/dev/null
945 if [ -r ${LIB}/$file ]; then
946 echo Fixing $file
947 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
948 -e 's/int[ ][ ]*free/void free/g' \
949 -e 's/char\([ ]*\*[ ]*malloc\)/void\1/g' \
950 -e 's/char\([ ]*\*[ ]*realloc\)/void\1/g' \
951 ${LIB}/$file > ${LIB}/${file}.sed
952 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
953 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
954 rm -f ${LIB}/$file
955 else
956 # Find any include directives that use "file".
957 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
958 dir=`echo $file | sed -e s'|/[^/]*$||'`
959 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
960 done
964 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
965 file=hsfs/hsfs_spec.h
966 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
967 mkdir ${LIB}/hsfs 2>/dev/null
968 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
969 chmod +w ${LIB}/$file 2>/dev/null
970 chmod a+r ${LIB}/$file 2>/dev/null
973 if [ -r ${LIB}/$file ]; then
974 echo Fixing $file
975 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
976 ${LIB}/$file > ${LIB}/${file}.
977 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
978 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
979 rm -f ${LIB}/$file
980 else
981 # Find any include directives that use "file".
982 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
983 dir=`echo $file | sed -e s'|/[^/]*$||'`
984 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
985 done
989 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
990 file=hsfs/hsnode.h
991 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
992 mkdir ${LIB}/hsfs 2>/dev/null
993 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
994 chmod +w ${LIB}/$file 2>/dev/null
995 chmod a+r ${LIB}/$file 2>/dev/null
998 if [ -r ${LIB}/$file ]; then
999 echo Fixing $file
1000 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
1001 ${LIB}/$file > ${LIB}/${file}.sed
1002 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1003 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1004 rm -f ${LIB}/$file
1005 else
1006 # Find any include directives that use "file".
1007 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1008 dir=`echo $file | sed -e s'|/[^/]*$||'`
1009 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1010 done
1014 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
1015 file=hsfs/iso_spec.h
1016 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1017 mkdir ${LIB}/hsfs 2>/dev/null
1018 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1019 chmod +w ${LIB}/$file 2>/dev/null
1020 chmod a+r ${LIB}/$file 2>/dev/null
1023 if [ -r ${LIB}/$file ]; then
1024 echo Fixing $file
1025 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
1026 ${LIB}/$file > ${LIB}/${file}.sed
1027 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1028 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1029 rm -f ${LIB}/$file
1030 else
1031 # Find any include directives that use "file".
1032 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1033 dir=`echo $file | sed -e s'|/[^/]*$||'`
1034 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1035 done
1039 # Incorrect #include in Sony News-OS 3.2.
1040 file=machine/machparam.h
1041 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1042 mkdir ${LIB}/machine 2>/dev/null
1043 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1044 chmod +w ${LIB}/$file 2>/dev/null
1045 chmod a+r ${LIB}/$file 2>/dev/null
1048 if [ -r ${LIB}/$file ]; then
1049 echo Fixing $file, incorrect \#include
1050 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
1051 ${LIB}/$file > ${LIB}/${file}.
1052 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
1053 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1054 rm -f ${LIB}/$file
1055 else
1056 # Find any include directives that use "file".
1057 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1058 dir=`echo $file | sed -e s'|/[^/]*$||'`
1059 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1060 done
1064 # Multiline comment after typedef on IRIX 4.0.1.
1065 file=sys/types.h
1066 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1067 mkdir ${LIB}/sys 2>/dev/null
1068 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1069 chmod +w ${LIB}/$file 2>/dev/null
1070 chmod a+r ${LIB}/$file 2>/dev/null
1073 if [ -r ${LIB}/$file ]; then
1074 echo Fixing $file, comment in the middle of \#ifdef
1075 sed -e 's@type of the result@type of the result */@' \
1076 -e 's@of the sizeof@/* of the sizeof@' \
1077 ${LIB}/$file > ${LIB}/${file}.sed
1078 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1079 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1080 rm -f ${LIB}/$file
1081 else
1082 # Find any include directives that use "file".
1083 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1084 dir=`echo $file | sed -e s'|/[^/]*$||'`
1085 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1086 done
1090 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
1091 # header file, which embeds // comments inside multi-line /* */
1092 # comments. If this looks like the IRIX header file, we refix it by
1093 # just throwing away the // comments.
1094 file=fam.h
1095 if [ -r ${LIB}/$file ]; then
1096 if egrep indigo.esd ${LIB}/$file > /dev/null; then
1097 echo Fixing $file, overeager sed script
1098 rm ${LIB}/$file
1099 sed -e 's|//.*$||g' $file > ${LIB}/$file
1100 chmod +w ${LIB}/$file 2>/dev/null
1101 chmod a+r ${LIB}/$file 2>/dev/null
1105 # There is a similar problem with the VxWorks drv/netif/if_med.h file.
1106 file=drv/netif/if_med.h
1107 if [ -r ${LIB}/$file ]; then
1108 if egrep 'Wind River' ${LIB}/$file > /dev/null; then
1109 echo Fixing $file, overeager sed script
1110 rm ${LIB}/$file
1111 sed -e 's|//.*$||g' $file > ${LIB}/$file
1112 chmod +w ${LIB}/$file 2>/dev/null
1113 chmod a+r ${LIB}/$file 2>/dev/null
1117 # And also with the HP-UX 10 sys/pci.h file
1118 file=sys/pci.h
1119 if [ -r ${LIB}/$file ]; then
1120 if egrep 'System Private Structures' ${LIB}/$file > /dev/null; then
1121 echo Fixing $file, overeager sed script
1122 rm ${LIB}/$file
1123 sed -e 's|//.*$||g' $file > ${LIB}/$file
1124 chmod +w ${LIB}/$file 2>/dev/null
1125 chmod a+r ${LIB}/$file 2>/dev/null
1129 # Some IRIX header files contains the string "//"
1130 for file in elf_abi.h elf.h; do
1131 if [ -r ${LIB}/$file ]; then
1132 echo Fixing $file, overeager sed script
1133 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
1134 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1135 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1136 rm -f ${LIB}/$file
1137 else
1138 # Find any include directives that use "file".
1139 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1140 dir=`echo $file | sed -e s'|/[^/]*$||'`
1141 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1142 done
1145 done
1147 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
1148 # previous definition.
1149 file=rpc/auth.h
1150 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1151 mkdir ${LIB}/rpc 2>/dev/null
1152 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1153 chmod +w ${LIB}/$file 2>/dev/null
1154 chmod a+r ${LIB}/$file 2>/dev/null
1157 if [ -r ${LIB}/$file ]; then
1158 echo Fixing $file, undefined type
1159 sed -e '/authdes_create.*struct sockaddr/i\
1160 struct sockaddr;
1162 ${LIB}/$file > ${LIB}/$file.sed
1163 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1164 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1165 rm -f ${LIB}/$file
1166 else
1167 # Find any include directives that use "file".
1168 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1169 dir=`echo $file | sed -e s'|/[^/]*$||'`
1170 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1171 done
1175 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
1176 # definition.
1177 file=rpc/xdr.h
1178 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1179 mkdir ${LIB}/rpc 2>/dev/null
1180 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1181 chmod +w ${LIB}/$file 2>/dev/null
1182 chmod a+r ${LIB}/$file 2>/dev/null
1185 if [ -r ${LIB}/$file ]; then
1186 echo Fixing $file, undefined type
1187 sed -e '/xdrstdio_create.*struct __file_s/i\
1188 struct __file_s;
1190 ${LIB}/$file > ${LIB}/$file.sed
1191 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1192 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1193 rm -f ${LIB}/$file
1194 else
1195 # Find any include directives that use "file".
1196 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1197 dir=`echo $file | sed -e s'|/[^/]*$||'`
1198 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1199 done
1203 # Same problem with a file from SunOS 4.1.3 : a header file containing
1204 # the string "//" embedded in "/**/"
1205 file=sbusdev/audiovar.h
1206 if [ -r ${LIB}/$file ]; then
1207 echo Fixing $file, overeager sed script
1208 rm ${LIB}/$file
1209 sed -e 's|//.*$||g' $file > ${LIB}/$file
1210 chmod +w ${LIB}/$file 2>/dev/null
1211 chmod a+r ${LIB}/$file 2>/dev/null
1214 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
1215 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
1216 # many other systems have similar text but correct versions of the file.
1217 # To ensure only Sun's is fixed, we grep for a likely unique string.
1218 # Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
1219 file=memory.h
1220 if [ -r $file ] && egrep '/\* @\(#\)(head/memory.h 50.1 |memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 )\*/' $file > /dev/null; then
1221 if [ ! -r ${LIB}/$file ]; then
1222 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1223 chmod +w ${LIB}/$file 2>/dev/null
1224 chmod a+r ${LIB}/$file 2>/dev/null
1226 if [ -r ${LIB}/$file ]; then
1227 echo Replacing $file
1228 cat > ${LIB}/$file << EOF
1229 /* This file was generated by fixincludes */
1230 #ifndef __memory_h__
1231 #define __memory_h__
1233 #ifdef __STDC__
1234 extern void *memccpy();
1235 extern void *memchr();
1236 extern void *memcpy();
1237 extern void *memset();
1238 #else
1239 extern char *memccpy();
1240 extern char *memchr();
1241 extern char *memcpy();
1242 extern char *memset();
1243 #endif /* __STDC__ */
1245 extern int memcmp();
1247 #endif /* __memory_h__ */
1252 # Fix return type of fread and fwrite on sysV68
1253 file=stdio.h
1254 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1255 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1256 chmod +w ${LIB}/$file 2>/dev/null
1257 chmod a+r ${LIB}/$file 2>/dev/null
1260 if [ -r ${LIB}/$file ]; then
1261 echo Fixing $file, fread and fwrite return type
1262 sed -e 's/^\(extern int fclose(), fflush()\), \(fread(), fwrite()\)\(.*\)$/extern unsigned int \2;\
1263 \1\3/' \
1264 ${LIB}/$file > ${LIB}/${file}.sed
1265 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1266 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1267 rm -f ${LIB}/$file
1268 else
1269 # Find any include directives that use "file".
1270 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1271 dir=`echo $file | sed -e s'|/[^/]*$||'`
1272 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1273 done
1277 # parameters not const on DECstation Ultrix V4.0 and OSF/1.
1278 file=stdio.h
1279 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1280 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1281 chmod +w ${LIB}/$file 2>/dev/null
1282 chmod a+r ${LIB}/$file 2>/dev/null
1285 if [ -r ${LIB}/$file ]; then
1286 echo Fixing $file, non-const arg
1287 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1288 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1289 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1290 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1291 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1292 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1293 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1294 -e 's@popen(char \*, char \*);@popen(const char *, const char *);@' \
1295 -e 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@' \
1296 ${LIB}/$file > ${LIB}/${file}.sed
1297 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1298 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1299 rm -f ${LIB}/$file
1300 else
1301 # Find any include directives that use "file".
1302 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1303 dir=`echo $file | sed -e s'|/[^/]*$||'`
1304 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1305 done
1309 # parameters conflict with C++ new on rs/6000
1310 for file in stdio.h unistd.h ; do
1311 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1312 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1313 chmod +w ${LIB}/$file 2>/dev/null
1316 if [ -r ${LIB}/$file ]; then
1317 echo Fixing $file, parameter name conflicts
1318 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1319 ${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 else
1324 # Find any include directives that use "file".
1325 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1326 dir=`echo $file | sed -e s'|/[^/]*$||'`
1327 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1328 done
1331 done
1333 # function class(double x) conflicts with C++ keyword on rs/6000
1334 file=math.h
1335 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1336 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1337 chmod +w ${LIB}/$file 2>/dev/null
1338 chmod a+r ${LIB}/$file 2>/dev/null
1341 if [ -r ${LIB}/$file ]; then
1342 if grep '[^a-zA-Z_]class[(]' ${LIB}/$file >/dev/null; then
1343 echo Fixing $file
1344 sed -e '/class[(]/i\
1345 #ifndef __cplusplus
1347 -e '/class[(]/a\
1348 #endif
1349 ' ${LIB}/$file > ${LIB}/${file}.sed
1350 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1351 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1352 rm ${LIB}/$file
1353 else
1354 # Find any include directives that use "file".
1355 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1356 dir=`echo $file | sed -e s'|/[^/]*$||'`
1357 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1358 done
1363 # Wrong fchmod prototype on RS/6000.
1364 file=sys/stat.h
1365 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1366 mkdir ${LIB}/sys 2>/dev/null
1367 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1368 chmod +w ${LIB}/$file 2>/dev/null
1369 chmod a+r ${LIB}/$file 2>/dev/null
1372 if [ -r ${LIB}/$file ]; then
1373 echo Fixing $file, fchmod prototype
1374 sed -e 's/fchmod(char \*/fchmod(int/' \
1375 ${LIB}/$file > ${LIB}/$file.sed
1376 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1377 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1378 rm -f ${LIB}/$file
1379 else
1380 # Find any include directives that use "file".
1381 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1382 dir=`echo $file | sed -e s'|/[^/]*$||'`
1383 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1384 done
1388 # There are several name conflicts with C++ reserved words in X11
1389 # header files. These are fixed in some versions, so don't do the
1390 # fixes if we find __cplusplus in the file. These were found on the
1391 # RS/6000.
1393 # class in X11/ShellP.h
1394 file=X11/ShellP.h
1395 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1396 mkdir ${LIB}/sys 2>/dev/null
1397 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1398 chmod +w ${LIB}/$file 2>/dev/null
1399 chmod a+r ${LIB}/$file 2>/dev/null
1402 if [ -r ${LIB}/$file ]; then
1403 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1404 true;
1405 else
1406 echo Fixing $file, field class
1407 sed -e '/char [*]class;/i\
1408 #ifdef __cplusplus\
1409 char *c_class;\
1410 #else
1412 -e '/char [*]class;/a\
1413 #endif
1414 ' ${LIB}/$file > ${LIB}/${file}.sed
1415 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1417 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1418 rm -f ${LIB}/$file
1419 else
1420 # Find any include directives that use "file".
1421 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1422 dir=`echo $file | sed -e s'|/[^/]*$||'`
1423 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1424 done
1427 # new in Xm/Traversal.h
1428 file=Xm/Traversal.h
1429 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1430 mkdir ${LIB}/sys 2>/dev/null
1431 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1432 chmod +w ${LIB}/$file 2>/dev/null
1433 chmod a+r ${LIB}/$file 2>/dev/null
1436 if [ -r ${LIB}/$file ]; then
1437 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1438 true;
1439 else
1440 echo Fixing $file, uses of new
1441 sed -e '/Widget old, new;/i\
1442 #ifdef __cplusplus\
1443 Widget old, c_new;\
1444 #else
1446 -e '/Widget old, new;/a\
1447 #endif
1449 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1450 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1452 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1453 rm -f ${LIB}/$file
1454 else
1455 # Find any include directives that use "file".
1456 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1457 dir=`echo $file | sed -e s'|/[^/]*$||'`
1458 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1459 done
1462 # class in Xm/BaseClassI.h
1463 file=Xm/BaseClassI.h
1464 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1465 mkdir ${LIB}/sys 2>/dev/null
1466 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1467 chmod +w ${LIB}/$file 2>/dev/null
1468 chmod a+r ${LIB}/$file 2>/dev/null
1471 if [ -r ${LIB}/$file ]; then
1472 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1473 true;
1474 else
1475 echo Fixing $file, prototype parameter name
1476 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1477 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1479 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1480 rm -f ${LIB}/$file
1481 else
1482 # Find any include directives that use "file".
1483 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1484 dir=`echo $file | sed -e s'|/[^/]*$||'`
1485 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1486 done
1490 # NeXT 3.2 adds const prefix to some math functions. These conflict
1491 # with the built-in functions.
1492 file=ansi/math.h
1493 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1494 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1495 chmod +w ${LIB}/$file 2>/dev/null
1497 if [ -r ${LIB}/$file ]; then
1498 echo Fixing $file
1499 sed -e '/^extern.*double.*__const__.*sqrt(/s/__const__//' \
1500 -e '/^extern.*double.*__const__.*fabs(/s/__const__//' \
1501 -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
1502 -e '/^extern.*double.*__const__.*hypot(/s/__const__//' \
1503 -e '/^extern.*double.*__const__.*sin(/s/__const__//' ${LIB}/$file > ${LIB}/${file}.sed
1504 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1505 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1506 rm -f ${LIB}/$file
1507 else
1508 # Find any include directives that use "file".
1509 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1510 dir=`echo $file | sed -e s'|/[^/]*$||'`
1511 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1512 done
1516 # NeXT 3.2 uses the word "template" as a parameter for some
1517 # functions. GCC reports an invalid use of a reserved key word
1518 # with the built-in functions. NeXT 3.2 includes the keyword
1519 # volatile in the prototype for abort(). This conflicts with
1520 # the built-in definition.
1521 file=bsd/libc.h
1522 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1523 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1524 chmod +w ${LIB}/$file 2>/dev/null
1526 if [ -r ${LIB}/$file ]; then
1527 echo Fixing $file
1528 sed -e '/\(.*template\)/s/template//' \
1529 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1530 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1531 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1532 rm -f ${LIB}/$file
1533 else
1534 # Find any include directives that use "file".
1535 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1536 dir=`echo $file | sed -e s'|/[^/]*$||'`
1537 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1538 done
1542 # NeXT 3.2 includes the keyword volatile in the abort() and
1543 # exit() function prototypes. That conflicts with the
1544 # built-in functions.
1545 file=ansi/stdlib.h
1546 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1547 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1548 chmod +w ${LIB}/$file 2>/dev/null
1550 if [ -r ${LIB}/$file ]; then
1551 echo Fixing $file
1552 sed -e '/extern.*volatile.*void.*exit/s/volatile//' \
1553 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1554 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1555 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1556 rm -f ${LIB}/$file
1557 else
1558 # Find any include directives that use "file".
1559 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1560 dir=`echo $file | sed -e s'|/[^/]*$||'`
1561 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1562 done
1566 # sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition
1567 # of struct rusage, so the prototype (added by fixproto) causes havoc.
1568 file=sys/wait.h
1569 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1570 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1571 chmod +w ${LIB}/$file 2>/dev/null
1574 if [ -r ${LIB}/$file ] \
1575 && grep 'bos325,' ${LIB}/$file >/dev/null; then
1576 echo Fixing $file, wait3 declaration
1577 sed -e '/^extern pid_t wait3();$/i\
1578 struct rusage;
1580 ${LIB}/$file > ${LIB}/${file}.sed
1581 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1582 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1583 rm -f ${LIB}/$file
1584 else
1585 # Find any include directives that use "file".
1586 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1587 dir=`echo $file | sed -e s'|/[^/]*$||'`
1588 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1589 done
1593 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1594 # Note that version 3 of the NeXT system has wait.h in a different directory,
1595 # so that this code won't do anything. But wait.h in version 3 has a
1596 # conditional, so it doesn't need this fix. So everything is okay.
1597 file=sys/wait.h
1598 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1599 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1600 chmod +w ${LIB}/$file 2>/dev/null
1603 if [ -r ${LIB}/$file ] \
1604 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1605 echo Fixing $file, bad wait formal
1606 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1607 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1608 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1609 rm -f ${LIB}/$file
1610 else
1611 # Find any include directives that use "file".
1612 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1613 dir=`echo $file | sed -e s'|/[^/]*$||'`
1614 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1615 done
1619 # Don't use or define the name va_list in stdio.h.
1620 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1621 file=stdio.h
1622 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1623 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1624 chmod +w ${LIB}/$file 2>/dev/null
1625 chmod a+r ${LIB}/$file 2>/dev/null
1628 if [ -r ${LIB}/$file ]; then
1629 echo Fixing $file, use of va_list
1630 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1631 if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
1632 touch ${LIB}/${file}.sed
1633 else
1634 (echo "#define __need___va_list"
1635 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1637 # Use __gnuc_va_list in arg types in place of va_list.
1638 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1639 # trailing parentheses and semicolon save all other systems from this.
1640 # Define __va_list__ (something harmless and unused) instead of va_list.
1641 # Don't claim to have defined va_list.
1642 sed -e 's@ va_list @ __gnuc_va_list @' \
1643 -e 's@ va_list)@ __gnuc_va_list)@' \
1644 -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \
1645 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1646 -e 's@ va_list@ __va_list__@' \
1647 -e 's@\*va_list@*__va_list__@' \
1648 -e 's@ __va_list)@ __gnuc_va_list)@' \
1649 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
1650 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1651 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1652 -e 's@_Va_LIST@_VA_LIST@' \
1653 ${LIB}/$file >> ${LIB}/${file}.sed
1655 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1656 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1657 rm -f ${LIB}/$file
1658 else
1659 # Find any include directives that use "file".
1660 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1661 dir=`echo $file | sed -e s'|/[^/]*$||'`
1662 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1663 done
1667 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1668 file=ansi_compat.h
1669 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1670 if grep -s ULTRIX $file; then
1671 echo "/* This file intentionally left blank. */" > $LIB/$file
1675 # parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
1676 # also get rid of bogus inline definitions in HP-UX 8.0
1677 file=math.h
1678 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1679 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1680 chmod +w ${LIB}/$file 2>/dev/null
1681 chmod a+r ${LIB}/$file 2>/dev/null
1684 if [ -r ${LIB}/$file ]; then
1685 echo Fixing $file, non-const arg
1686 sed -e 's@atof(\([ ]*char[ ]*\*[^)]*\))@atof(const \1)@' \
1687 -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \
1688 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1689 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1690 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1691 ${LIB}/$file > ${LIB}/${file}.sed
1692 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1693 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1694 rm -f ${LIB}/$file
1695 else
1696 # Find any include directives that use "file".
1697 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1698 dir=`echo $file | sed -e s'|/[^/]*$||'`
1699 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1700 done
1704 # fix bogus recursive stdlib.h in NEWS-OS 4.0C
1705 file=stdlib.h
1706 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1707 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1708 chmod +w ${LIB}/$file 2>/dev/null
1709 chmod a+r ${LIB}/$file 2>/dev/null
1712 if [ -r ${LIB}/$file ]; then
1713 echo Fixing $file, recursive inclusion
1714 sed -e '/^#include <stdlib.h>/i\
1715 #if 0
1717 -e '/^#include <stdlib.h>/a\
1718 #endif
1720 ${LIB}/$file > ${LIB}/${file}.sed
1721 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1722 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1723 rm -f ${LIB}/$file
1724 else
1725 # Find any include directives that use "file".
1726 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1727 dir=`echo $file | sed -e s'|/[^/]*$||'`
1728 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1729 done
1733 # Avoid nested comments on Ultrix 4.3.
1734 file=rpc/svc.h
1735 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1736 mkdir ${LIB}/rpc 2>/dev/null
1737 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1738 chmod +w ${LIB}/$file 2>/dev/null
1739 chmod a+r ${LIB}/$file 2>/dev/null
1742 if [ -r ${LIB}/$file ]; then
1743 echo Fixing $file, nested comment
1744 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1745 ${LIB}/$file > ${LIB}/$file.sed
1746 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1747 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1748 rm -f ${LIB}/$file
1749 else
1750 # Find any include directives that use "file".
1751 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1752 dir=`echo $file | sed -e s'|/[^/]*$||'`
1753 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1754 done
1758 # This file in RISC/os uses /**/ to concatenate two tokens.
1759 file=bsd43/bsd43_.h
1760 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1761 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1762 chmod +w ${LIB}/$file 2>/dev/null
1763 chmod a+r ${LIB}/$file 2>/dev/null
1765 if [ -r ${LIB}/$file ]; then
1766 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1767 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1768 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1769 rm -f ${LIB}/$file
1770 else
1771 # Find any include directives that use "file".
1772 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1773 dir=`echo $file | sed -e s'|/[^/]*$||'`
1774 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1775 done
1779 file=rpc/rpc.h
1780 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1781 mkdir ${LIB}/rpc 2>/dev/null
1782 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1783 chmod +w ${LIB}/$file 2>/dev/null
1784 chmod a+r ${LIB}/$file 2>/dev/null
1787 if [ -r ${LIB}/$file ]; then
1788 echo Fixing $file, nested comment
1789 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1790 ${LIB}/$file > ${LIB}/$file.sed
1791 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1792 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1793 rm -f ${LIB}/$file
1794 else
1795 # Find any include directives that use "file".
1796 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1797 dir=`echo $file | sed -e s'|/[^/]*$||'`
1798 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1799 done
1803 # rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C
1804 # is defined for the alpha. The problem is the declaration of malloc.
1805 file=rpc/types.h
1806 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1807 mkdir ${LIB}/rpc 2>/dev/null
1808 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1809 chmod +w ${LIB}/$file 2>/dev/null
1810 chmod a+r ${LIB}/$file 2>/dev/null
1812 if [ -r ${LIB}/$file ]; then
1813 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1; then
1814 true
1815 else
1816 echo Fixing $file
1817 echo '#ifdef __cplusplus
1818 extern "C" {
1819 #endif' > ${LIB}/${file}.sed
1820 cat ${LIB}/${file} >> ${LIB}/${file}.sed
1821 echo '#ifdef __cplusplus
1823 #endif' >> ${LIB}/${file}.sed
1824 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1825 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1826 rm -f ${LIB}/$file
1827 else
1828 # Find any include directives that use "file".
1829 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1830 dir=`echo $file | sed -e s'|/[^/]*$||'`
1831 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1832 done
1837 # In limits.h, put #ifndefs around things that are supposed to be defined
1838 # in float.h to avoid redefinition errors if float.h is included first.
1839 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1840 # multi line comments and the inserted #endif winds up inside the
1841 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1842 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1843 # are there, and we do not add them ourselves.
1844 for file in limits.h sys/limits.h; do
1845 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1846 mkdir ${LIB}/sys 2>/dev/null
1847 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1848 chmod +w ${LIB}/$file 2>/dev/null
1849 chmod a+r ${LIB}/$file 2>/dev/null
1852 if [ -r ${LIB}/$file ]; then
1853 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1854 true
1855 else
1856 echo Fixing $file
1857 sed -e '/[ ]FLT_MIN[ ]/i\
1858 #ifndef FLT_MIN
1860 -e '/[ ]FLT_MIN[ ]/a\
1861 #endif
1863 -e '/[ ]FLT_MAX[ ]/i\
1864 #ifndef FLT_MAX
1866 -e '/[ ]FLT_MAX[ ]/a\
1867 #endif
1869 -e '/[ ]FLT_DIG[ ]/i\
1870 #ifndef FLT_DIG
1872 -e '/[ ]FLT_DIG[ ]/a\
1873 #endif
1875 -e '/[ ]DBL_MIN[ ]/i\
1876 #ifndef DBL_MIN
1878 -e '/[ ]DBL_MIN[ ]/a\
1879 #endif
1881 -e '/[ ]DBL_MAX[ ]/i\
1882 #ifndef DBL_MAX
1884 -e '/[ ]DBL_MAX[ ]/a\
1885 #endif
1887 -e '/[ ]DBL_DIG[ ]/i\
1888 #ifndef DBL_DIG
1890 -e '/[ ]DBL_DIG[ ]/a\
1891 #endif
1893 ${LIB}/$file > ${LIB}/${file}.sed
1894 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1896 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1897 echo Deleting ${LIB}/$file\; no fixes were needed.
1898 rm -f ${LIB}/$file
1899 else
1900 # Find any include directives that use "file".
1901 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1902 dir=`echo $file | sed -e s'|/[^/]*$||'`
1903 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1904 done
1907 done
1909 # In math.h, put #ifndefs around things that might be defined in a gcc
1910 # specific math-*.h file.
1911 file=math.h
1912 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1913 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1914 chmod +w ${LIB}/$file 2>/dev/null
1915 chmod a+r ${LIB}/$file 2>/dev/null
1918 if [ -r ${LIB}/$file ]; then
1919 echo Fixing $file
1920 sed -e '/define[ ]HUGE_VAL[ ]/i\
1921 #ifndef HUGE_VAL
1923 -e '/define[ ]HUGE_VAL[ ]/a\
1924 #endif
1926 ${LIB}/$file > ${LIB}/${file}.sed
1927 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1929 # In addition, copy the definition of DBL_MAX from float.h
1930 # if math.h requires one. The Lynx math.h requires it.
1931 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
1932 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
1933 true;
1934 else
1935 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
1936 if [ "$dbl_max_def" != "" ]; then
1937 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
1938 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
1939 ${LIB}/$file > ${LIB}/${file}.sed
1940 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1945 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1946 echo Deleting ${LIB}/$file\; no fixes were needed.
1947 rm -f ${LIB}/$file
1948 else
1949 # Find any include directives that use "file".
1950 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1951 dir=`echo $file | sed -e s'|/[^/]*$||'`
1952 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1953 done
1957 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1958 file=sym.h
1959 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1960 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1961 chmod +w ${LIB}/$file 2>/dev/null
1962 chmod a+r ${LIB}/$file 2>/dev/null
1965 if [ -r ${LIB}/$file ]; then
1966 echo Fixing $file
1967 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1968 ${LIB}/$file > ${LIB}/${file}.sed
1969 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1970 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1971 rm -f ${LIB}/$file
1972 else
1973 # Find any include directives that use "file".
1974 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1975 dir=`echo $file | sed -e s'|/[^/]*$||'`
1976 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1977 done
1981 # Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
1982 # in string.h on sysV68
1983 # Correct the return type for strlen in string.h on Lynx.
1984 # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
1985 # Add missing const for strdup on OSF/1 V3.0.
1986 file=string.h
1987 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1988 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1989 chmod +w ${LIB}/$file 2>/dev/null
1990 chmod a+r ${LIB}/$file 2>/dev/null
1993 if [ -r ${LIB}/$file ]; then
1994 echo Fixing $file, mem{ccpy,chr,cpy,set} and str{len,spn,cspn} return value
1995 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
1996 -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \
1997 -e 's/strdup(char \*s1);/strdup(const char *s1);/' \
1998 -e '/^extern char$/N' \
1999 -e 's/^extern char\(\n \*memccpy(),\)$/extern void\1/'\
2000 -e '/^ strncmp(),$/N'\
2001 -e 's/^\( strncmp()\),\n\( strlen(),\)$/\1;\
2002 extern unsigned int\
2003 \2/'\
2004 ${LIB}/$file > ${LIB}/${file}.sed
2005 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2006 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2007 rm -f ${LIB}/$file
2008 else
2009 # Find any include directives that use "file".
2010 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2011 dir=`echo $file | sed -e s'|/[^/]*$||'`
2012 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2013 done
2017 # Correct the return type for strlen in strings.h in SunOS 4.
2018 file=strings.h
2019 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2020 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2021 chmod +w ${LIB}/$file 2>/dev/null
2022 chmod a+r ${LIB}/$file 2>/dev/null
2025 if [ -r ${LIB}/$file ]; then
2026 echo Fixing $file
2027 sed -e 's/int[ ]*strlen();/__SIZE_TYPE__ strlen();/' \
2028 ${LIB}/$file > ${LIB}/${file}.sed
2029 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2030 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2031 rm -f ${LIB}/$file
2032 else
2033 # Find any include directives that use "file".
2034 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2035 dir=`echo $file | sed -e s'|/[^/]*$||'`
2036 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2037 done
2041 # Delete the '#define void int' line from curses.h on Lynx
2042 file=curses.h
2043 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2044 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2045 chmod +w ${LIB}/$file 2>/dev/null
2046 chmod a+r ${LIB}/$file 2>/dev/null
2049 if [ -r ${LIB}/$file ]; then
2050 echo Fixing $file
2051 sed -e '/#[ ]*define[ ][ ]*void[ ]int/d' \
2052 ${LIB}/$file > ${LIB}/${file}.sed
2053 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2054 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2055 rm -f ${LIB}/$file
2056 else
2057 # Find any include directives that use "file".
2058 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2059 dir=`echo $file | sed -e s'|/[^/]*$||'`
2060 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2061 done
2065 # Fix `typedef struct term;' on hppa1.1-hp-hpux9.
2066 file=curses.h
2067 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2068 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2069 chmod +w ${LIB}/$file 2>/dev/null
2070 chmod a+r ${LIB}/$file 2>/dev/null
2073 if [ -r ${LIB}/$file ]; then
2074 echo Fixing $file
2075 sed -e 's/^[ ]*typedef[ ][ ]*\(struct[ ][ ]*term[ ]*;[ ]*\)$/\1/' \
2076 ${LIB}/$file > ${LIB}/${file}.sed
2077 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2078 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2079 rm -f ${LIB}/$file
2080 else
2081 # Find any include directives that use "file".
2082 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2083 dir=`echo $file | sed -e s'|/[^/]*$||'`
2084 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2085 done
2089 # For C++, avoid any typedef or macro definition of bool, and use the
2090 # built in type instead.
2091 for files in curses.h; do
2092 if [ -r $file ] && egrep bool $file >/dev/null 2>&1; then
2093 if [ ! -r ${LIB}/$file ]; then
2094 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2095 chmod +w ${LIB}/$file 2>/dev/null
2096 chmod a+r ${LIB}/$file 2>/dev/null
2099 echo Fixing $file
2100 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
2101 #ifndef __cplusplus
2103 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
2104 #endif
2106 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/i\
2107 #ifndef __cplusplus
2109 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/a\
2110 #endif
2112 ${LIB}/$file > ${LIB}/${file}.sed
2113 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2114 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2115 rm -f ${LIB}/$file
2116 else
2117 # Find any include directives that use "file".
2118 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2119 dir=`echo $file | sed -e s'|/[^/]*$||'`
2120 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2121 done
2124 done
2126 # Fix incorrect S_IF* definitions on m88k-sysv3.
2127 file=sys/stat.h
2128 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2129 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2130 chmod +w ${LIB}/$file 2>/dev/null
2131 chmod a+r ${LIB}/$file 2>/dev/null
2134 if [ -r ${LIB}/$file ]; then
2135 echo Fixing $file
2136 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)/' \
2137 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
2138 ${LIB}/$file > ${LIB}/${file}.sed
2139 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2140 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2141 rm -f ${LIB}/$file
2142 else
2143 # Find any include directives that use "file".
2144 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2145 dir=`echo $file | sed -e s'|/[^/]*$||'`
2146 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2147 done
2151 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
2152 for file in stdio.h stdlib.h; do
2153 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2154 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2155 chmod +w ${LIB}/$file 2>/dev/null
2156 chmod a+r ${LIB}/$file 2>/dev/null
2159 if [ -r ${LIB}/$file ]; then
2160 echo Fixing $file, getopt declaration
2161 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
2162 ${LIB}/$file > ${LIB}/${file}.sed
2163 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2164 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2165 rm -f ${LIB}/$file
2166 else
2167 # Find any include directives that use "file".
2168 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2169 dir=`echo $file | sed -e s'|/[^/]*$||'`
2170 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2171 done
2174 done
2176 # Fix __page_size* declarations in pthread.h AIX 4.1.[34].
2177 # The original ones fail if uninitialized externs are not common.
2178 # This is the default for all ANSI standard C++ compilers.
2179 for file in pthread.h; do
2180 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2181 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2182 chmod +w ${LIB}/$file 2>/dev/null
2183 chmod a+r ${LIB}/$file 2>/dev/null
2186 if [ -r ${LIB}/$file ]; then
2187 echo Fixing $file, __page_size* declarations
2188 sed -e 's/^int __page_size/extern int __page_size/' \
2189 ${LIB}/$file > ${LIB}/${file}.sed
2190 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2191 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2192 rm -f ${LIB}/$file
2193 else
2194 # Find any include directives that use "file".
2195 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2196 dir=`echo $file | sed -e s'|/[^/]*$||'`
2197 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2198 done
2201 done
2203 # Determine if we're on Interactive Unix 2.2 or later, in which case we
2204 # need to fix some additional files. This is the same test for ISC that
2205 # Autoconf uses.
2206 if test -d /etc/conf/kconfig.d \
2207 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
2208 echo "Fixing ISC __STDC__ goof in several files..."
2209 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
2210 echo $name
2211 if test -r ${LIB}/$name; then
2212 file=${LIB}/$name
2213 else
2214 file=${INPUT}/$name
2216 # On Interactive 2.2, certain traditional Unix definitions
2217 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
2218 # defined, not just if _POSIX_SOURCE is defined. This makes it
2219 # impossible to compile any nontrivial program except with -posix.
2220 sed \
2221 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
2222 < $file > ${LIB}/$name.
2223 mv ${LIB}/$name. ${LIB}/$name
2224 done
2226 echo "Fixing ISC fmod declaration"
2227 # This one's already been fixed for other things.
2228 file=${LIB}/math.h
2229 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
2230 mv $file. $file
2232 echo "Fixing nested comments in ISC <sys/limits.h>"
2233 file=sys/limits.h
2234 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
2235 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
2238 # These files in Sun OS 4.x use /**/ to concatenate tokens.
2239 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
2240 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
2241 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
2243 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2244 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2245 chmod +w ${LIB}/$file 2>/dev/null
2246 chmod a+r ${LIB}/$file 2>/dev/null
2249 if [ -r ${LIB}/$file ]; then
2250 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2251 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2252 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2253 rm -f ${LIB}/$file
2254 else
2255 # Find any include directives that use "file".
2256 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2257 dir=`echo $file | sed -e s'|/[^/]*$||'`
2258 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2259 done
2262 done
2264 # These files in ARM/RISCiX use /**/ to concatenate tokens.
2265 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
2266 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.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
2274 if [ -r ${LIB}/$file ]; then
2275 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2276 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2277 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2278 rm -f ${LIB}/$file
2279 else
2280 # Find any include directives that use "file".
2281 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2282 dir=`echo $file | sed -e s'|/[^/]*$||'`
2283 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2284 done
2287 done
2289 # math.h on SunOS 4 puts the declaration of matherr before the definition
2290 # of struct exception, so the prototype (added by fixproto) causes havoc.
2291 file=math.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
2298 if [ -r ${LIB}/$file ]; then
2299 echo Fixing $file, matherr declaration
2300 sed -e '/^struct exception/,$b' \
2301 -e '/matherr/i\
2302 struct exception;
2304 ${LIB}/$file > ${LIB}/${file}.sed
2305 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2306 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2307 rm -f ${LIB}/$file
2308 else
2309 # Find any include directives that use "file".
2310 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2311 dir=`echo $file | sed -e s'|/[^/]*$||'`
2312 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2313 done
2317 # assert.h and sys/mman.h on HP/UX are not C++ ready, even though
2318 # NO_IMPLICIT_EXTERN_C is defined on HP/UX.
2319 for file in assert.h sys/mman.h; do
2320 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2321 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2322 chmod +w ${LIB}/$file 2>/dev/null
2323 chmod a+r ${LIB}/$file 2>/dev/null
2326 if [ -r ${LIB}/$file ]; then
2327 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
2328 || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
2329 true
2330 else
2331 echo Fixing $file
2332 echo '#ifdef __cplusplus
2333 extern "C" {
2334 #endif' > ${LIB}/${file}.sed
2335 cat ${LIB}/${file} >> ${LIB}/${file}.sed
2336 echo '#ifdef __cplusplus
2338 #endif' >> ${LIB}/${file}.sed
2339 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2341 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2342 rm -f ${LIB}/$file
2343 else
2344 # Find any include directives that use "file".
2345 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2346 dir=`echo $file | sed -e s'|/[^/]*$||'`
2347 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2348 done
2351 done
2353 # check for broken assert.h that needs stdio.h or stdlib.h
2354 file=assert.h
2355 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2356 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2357 chmod +w ${LIB}/$file 2>/dev/null
2358 chmod a+r ${LIB}/$file 2>/dev/null
2361 if [ -r ${LIB}/$file ]; then
2362 if grep 'stderr' ${LIB}/$file >/dev/null 2>/dev/null; then
2363 if grep 'include.*stdio.h' ${LIB}/$file >/dev/null 2>/dev/null; then
2364 true
2365 else
2366 echo "Fixing $file (needs stdio.h)"
2367 echo '#include <stdio.h>' >>${LIB}/$file
2370 if grep 'exit *(' ${LIB}/$file >/dev/null 2>/dev/null ||
2371 grep 'abort *(' ${LIB}/$file >/dev/null 2>/dev/null; then
2372 if grep 'include.*stdlib.h' ${LIB}/$file >/dev/null 2>/dev/null; then
2373 true
2374 else
2375 echo "Fixing $file (needs stdlib.h)"
2376 echo '#ifdef __cplusplus
2377 #include <stdlib.h>
2378 #endif' >>${LIB}/$file
2381 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2382 rm -f ${LIB}/$file
2383 else
2384 # Find any include directives that use "file".
2385 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2386 dir=`echo $file | sed -e s'|/[^/]*$||'`
2387 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2388 done
2392 # Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
2393 file=unistd.h
2394 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2395 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2396 chmod +w ${LIB}/$file 2>/dev/null
2397 chmod a+r ${LIB}/$file 2>/dev/null
2400 if [ -r ${LIB}/$file ]; then
2401 echo Fixing $file, sbrk declaration
2402 sed -e 's/char\([ ]*\*[ ]*sbrk[ ]*(\)/void\1/' \
2403 ${LIB}/$file > ${LIB}/${file}.sed
2404 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2405 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2406 rm -f ${LIB}/$file
2407 else
2408 # Find any include directives that use "file".
2409 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2410 dir=`echo $file | sed -e s'|/[^/]*$||'`
2411 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2412 done
2416 # This file on SunOS 4 has a very large macro. When the sed loop
2417 # tries pull it in, it overflows the pattern space size of the SunOS
2418 # sed (GNU sed does not have this problem). Since the file does not
2419 # require fixing, we remove it from the fixed directory.
2420 file=sundev/ipi_error.h
2421 if [ -r ${LIB}/$file ]; then
2422 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
2423 rm -f ${LIB}/$file
2426 # Put cpp wrappers around these include files to avoid redeclaration
2427 # errors during multiple inclusion on m88k-tektronix-sysv3.
2428 for file in time.h sys/time.h ; do
2429 if egrep '#ifndef' $file >/dev/null 2>&1; then
2430 true
2431 else
2432 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2433 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2434 chmod +w ${LIB}/$file 2>/dev/null
2436 if [ -r ${LIB}/$file ]; then
2437 echo Fixing $file, to protect against multiple inclusion.
2438 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
2439 (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
2440 echo "#define __GCC_GOT_${cpp_wrapper}_"
2441 cat ${LIB}/${file}
2442 echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */') > ${LIB}/${file}.new
2443 rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
2446 done
2448 # Fix fcntl prototype in fcntl.h on LynxOS.
2449 file=fcntl.h
2450 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2451 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2452 chmod +w ${LIB}/$file 2>/dev/null
2453 chmod a+r ${LIB}/$file 2>/dev/null
2456 if [ -r ${LIB}/$file ]; then
2457 echo Fixing $file, fcntl declaration
2458 sed -e 's/\(fcntl.*(int, int, \)int)/\1...)/' \
2459 ${LIB}/$file > ${LIB}/${file}.sed
2460 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2461 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2462 rm -f ${LIB}/$file
2463 else
2464 # Find any include directives that use "file".
2465 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2466 dir=`echo $file | sed -e s'|/[^/]*$||'`
2467 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2468 done
2472 # Fix definitions of macros used by va-i960.h in VxWorks header file.
2473 file=arch/i960/archI960.h
2474 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2475 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2476 chmod +w ${LIB}/$file 2>/dev/null
2477 chmod a+r ${LIB}/$file 2>/dev/null
2480 if [ -r ${LIB}/$file ]; then
2481 echo Fixing $file
2482 sed -e 's/__vsiz/__vxvsiz/' -e 's/__vali/__vxvali/' \
2483 -e s'/__vpad/__vxvpad/' -e 's/__alignof__/__vxalignof__/' \
2484 ${LIB}/$file > ${LIB}/${file}.sed
2485 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2486 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2487 rm -f ${LIB}/$file
2488 else
2489 # Find any include directives that use "file".
2490 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2491 dir=`echo $file | sed -e s'|/[^/]*$||'`
2492 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2493 done
2497 # Make VxWorks header which is almost gcc ready fully gcc ready.
2498 file=types/vxTypesBase.h
2499 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2500 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2501 chmod +w ${LIB}/$file 2>/dev/null
2502 chmod a+r ${LIB}/$file 2>/dev/null
2505 if [ -r ${LIB}/$file ]; then
2506 echo Fixing $file
2507 sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \
2508 -e '/[ ]size_t/i\
2509 #ifndef _GCC_SIZE_T\
2510 #define _GCC_SIZE_T
2512 -e '/[ ]size_t/a\
2513 #endif
2515 -e '/[ ]ptrdiff_t/i\
2516 #ifndef _GCC_PTRDIFF_T\
2517 #define _GCC_PTRDIFF_T
2519 -e '/[ ]ptrdiff_t/a\
2520 #endif
2522 -e '/[ ]wchar_t/i\
2523 #ifndef _GCC_WCHAR_T\
2524 #define _GCC_WCHAR_T
2526 -e '/[ ]wchar_t/a\
2527 #endif
2529 ${LIB}/$file > ${LIB}/${file}.sed
2530 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2531 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2532 rm -f ${LIB}/$file
2533 else
2534 # Find any include directives that use "file".
2535 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2536 dir=`echo $file | sed -e s'|/[^/]*$||'`
2537 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2538 done
2542 # Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
2543 file=sys/stat.h
2544 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2545 mkdir ${LIB}/sys 2>/dev/null
2546 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2547 chmod +w ${LIB}/$file 2>/dev/null
2548 chmod a+r ${LIB}/$file 2>/dev/null
2551 if [ -r ${LIB}/$file ]; then
2552 if egrep '#include' ${LIB}/$file >/dev/null 2>&1; then
2554 else
2555 if egrep 'ULONG' ${LIB}/$file >/dev/null 2>&1 \
2556 && [ -r types/vxTypesOld.h ]; then
2557 echo Fixing $file
2558 sed -e '/#define[ ][ ]*__INCstath/a\
2559 #include <types/vxTypesOld.h>
2561 ${LIB}/$file > ${LIB}/${file}.sed
2562 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2565 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2566 rm -f ${LIB}/$file
2567 else
2568 # Find any include directives that use "file".
2569 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2570 dir=`echo $file | sed -e s'|/[^/]*$||'`
2571 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2572 done
2576 # Fix VxWorks <time.h> to not require including <vxTypes.h>.
2577 file=time.h
2578 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2579 mkdir ${LIB}/sys 2>/dev/null
2580 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2581 chmod +w ${LIB}/$file 2>/dev/null
2582 chmod a+r ${LIB}/$file 2>/dev/null
2585 if [ -r ${LIB}/$file ]; then
2586 if egrep 'uint_t[ ][ ]*_clocks_per_sec' ${LIB}/$file >/dev/null 2>&1; then
2587 echo Fixing $file
2588 sed -e 's/uint_t/unsigned int/' ${LIB}/$file > ${LIB}/${file}.sed
2589 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2591 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2592 rm -f ${LIB}/$file
2593 else
2594 # Find any include directives that use "file".
2595 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2596 dir=`echo $file | sed -e s'|/[^/]*$||'`
2597 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2598 done
2602 # Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2603 file=sys/time.h
2604 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2605 mkdir ${LIB}/sys 2>/dev/null
2606 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2607 chmod +w ${LIB}/$file 2>/dev/null
2608 chmod a+r ${LIB}/$file 2>/dev/null
2611 if [ -r ${LIB}/$file ]; then
2612 if egrep '^extern struct sigevent;' ${LIB}/$file >/dev/null 2>&1; then
2613 echo Fixing $file
2614 sed -e 's/^extern struct sigevent;/struct sigevent;/' ${LIB}/$file > ${LIB}/${file}.sed
2615 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2617 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2618 rm -f ${LIB}/$file
2619 else
2620 # Find any include directives that use "file".
2621 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2622 dir=`echo $file | sed -e s'|/[^/]*$||'`
2623 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2624 done
2628 # Another bad dependency in VxWorks 5.2 <time.h>.
2629 file=time.h
2630 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2631 mkdir ${LIB}/sys 2>/dev/null
2632 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2633 chmod +w ${LIB}/$file 2>/dev/null
2634 chmod a+r ${LIB}/$file 2>/dev/null
2637 if [ -r ${LIB}/$file ]; then
2638 if egrep VOIDFUNCPTR ${LIB}/$file >/dev/null 2>&1; then
2639 if [ -r vxWorks.h ]; then
2640 echo Fixing $file
2641 sed -e '/VOIDFUNCPTR/i\
2642 #ifndef __gcc_VOIDFUNCPTR_defined\
2643 #ifdef __cplusplus\
2644 typedef void (*__gcc_VOIDFUNCPTR) (...);\
2645 #else\
2646 typedef void (*__gcc_VOIDFUNCPTR) ();\
2647 #endif\
2648 #define __gcc_VOIDFUNCPTR_defined\
2649 #endif
2651 -e 's/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g' \
2652 ${LIB}/$file > ${LIB}/${file}.sed
2653 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2656 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2657 rm -f ${LIB}/$file
2658 else
2659 # Find any include directives that use "file".
2660 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2661 dir=`echo $file | sed -e s'|/[^/]*$||'`
2662 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2663 done
2667 # This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89; gcc
2668 # doesn't understand it.
2669 file=sys/param.h
2670 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2671 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2672 chmod +w ${LIB}/$file 2>/dev/null
2673 chmod a+r ${LIB}/$file 2>/dev/null
2676 if [ -r ${LIB}/$file ]; then
2677 echo "Fixing __asm directive in sys/param.h"
2678 sed -e 's|#ifndef NOINLINE|#if !defined(NOINLINE) \&\& !defined(__GNUC__)|' \
2679 ${LIB}/$file > ${LIB}/${file}.sed
2680 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2681 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2682 rm -f ${LIB}/$file
2683 else
2684 # Find any include directives that use "file".
2685 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2686 dir=`echo $file | sed -e s'|/[^/]*$||'`
2687 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2688 done
2692 # signal.h on SunOS defines signal using (), which causes trouble when
2693 # compiling with g++ -pedantic.
2694 for file in signal.h sys/signal.h; do
2695 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2696 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2697 chmod +w ${LIB}/$file 2>/dev/null
2698 chmod a+r ${LIB}/$file 2>/dev/null
2701 if [ -r ${LIB}/$file ]; then
2702 echo "Checking for bad C++ prototype in $file"
2703 sed -e '/^void (\*signal())();$/i\
2704 #ifdef __cplusplus\
2705 void (*signal(...))(...);\
2706 #else
2708 -e '/^void (\*signal())();$/a\
2709 #endif
2711 ${LIB}/$file > ${LIB}/${file}.sed
2712 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2713 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2714 rm -f ${LIB}/$file
2715 else
2716 # Find any include directives that use "file".
2717 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2718 dir=`echo $file | sed -e s'|/[^/]*$||'`
2719 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2720 done
2723 done
2725 # sys/signal.h on some versions of AIX uses volatile in the typedef of
2726 # sig_atomic_t, which causes gcc to generate a warning about duplicate
2727 # volatile when a sig_atomic_t variable is declared volatile, as
2728 # required by ANSI C.
2729 file=sys/signal.h
2730 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2731 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2732 chmod +w ${LIB}/$file 2>/dev/null
2733 chmod a+r ${LIB}/$file 2>/dev/null
2736 if [ -r ${LIB}/$file ]; then
2737 echo "Checking for duplicate volatile in sys/signal.h"
2738 sed -e 's/typedef volatile int sig_atomic_t/typedef int sig_atomic_t/' \
2739 ${LIB}/$file > ${LIB}/${file}.sed
2740 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2741 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2742 rm -f ${LIB}/$file
2743 else
2744 # Find any include directives that use "file".
2745 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2746 dir=`echo $file | sed -e s'|/[^/]*$||'`
2747 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2748 done
2752 # Some math.h files define struct exception, which conflicts with
2753 # the class exception defined in the C++ file std/stdexcept.h. We
2754 # redefine it to __math_exception. This is not a great fix, but I
2755 # haven't been able to think of anything better.
2756 file=math.h
2757 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2758 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2759 chmod +w ${LIB}/$file 2>/dev/null
2760 chmod a+r ${LIB}/$file 2>/dev/null
2763 if [ -r ${LIB}/$file ]; then
2764 echo Fixing $file, exception
2765 sed -e '/struct exception/i\
2766 #ifdef __cplusplus\
2767 #define exception __math_exception\
2768 #endif'\
2769 -e '/struct exception/a\
2770 #ifdef __cplusplus\
2771 #undef exception\
2772 #endif' ${LIB}/$file > ${LIB}/${file}.sed
2773 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2774 if egrep 'matherr()' ${LIB}/$file >/dev/null 2>&1; then
2775 sed -e '/matherr/i\
2776 #ifdef __cplusplus\
2777 #define exception __math_exception\
2778 #endif'\
2779 -e '/matherr/a\
2780 #ifdef __cplusplus\
2781 #undef exception\
2782 #endif' ${LIB}/$file > ${LIB}/${file}.sed
2783 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2785 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2786 rm -f ${LIB}/$file
2787 else
2788 # Find any include directives that use "file".
2789 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2790 dir=`echo $file | sed -e s'|/[^/]*$||'`
2791 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2792 done
2796 # rpc/xdr.h on SunOS needs prototypes for its XDR->xdr_ops function pointers.
2797 file=rpc/xdr.h
2798 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2799 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2800 chmod +w ${LIB}/$file 2>/dev/null
2801 chmod a+r ${LIB}/$file 2>/dev/null
2804 if [ -r ${LIB}/$file ]; then
2805 echo "Checking for needed C++ prototype in $file"
2806 sed -e 's/^\(.*\)\*\(x_.*\)();\(.*\)/\
2807 #ifdef __cplusplus\
2808 \1*\2(...);\3\
2809 #else\
2810 \1*\2();\3\
2811 #endif/g' \
2812 $LIB/$file > ${LIB}/${file}.sed
2814 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2815 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2816 rm -f ${LIB}/$file
2817 else
2818 # Find any include directives that use "file".
2819 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2820 dir=`echo $file | sed -e s'|/[^/]*$||'`
2821 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2822 done
2826 # sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
2827 # defining regex.h related types. This causes libg++ build and usage failures.
2828 # Fixing this correctly requires checking and modifying 3 files.
2829 for file in reg_types.h regex.h sys/lc_core.h; do
2830 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2831 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2832 chmod +w ${LIB}/$file 2>/dev/null
2833 chmod a+r ${LIB}/$file 2>/dev/null
2835 done
2836 if [ -r ${LIB}/reg_types.h ]; then
2837 if egrep '} regex_t;' ${LIB}/reg_types.h >/dev/null 2>&1; then
2838 if [ -r ${LIB}/sys/lc_core.h ]; then
2839 if egrep ' regex_t ' ${LIB}/sys/lc_core.h >/dev/null 2>&1; then
2840 if [ -r ${LIB}/regex.h ]; then
2841 if egrep '__regex_t' ${LIB}/regex.h >/dev/null 2>&1; then
2842 true;
2843 else
2844 echo Fixing reg_types.h, regex.h, sys/lc_core.h
2845 for file in reg_types.h sys/lc_core.h; do
2846 sed -e 's/regex_t/__regex_t/g' \
2847 -e 's/regoff_t/__regoff_t/g' \
2848 -e 's/regmatch_t/__regmatch_t/g' \
2849 ${LIB}/$file > ${LIB}/${file}.sed
2850 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2851 done
2852 sed -e '/#include <reg_types.h>/a\
2853 typedef __regex_t regex_t;\
2854 typedef __regoff_t regoff_t;\
2855 typedef __regmatch_t regmatch_t;\
2857 ${LIB}/regex.h > ${LIB}/regex.h.sed
2858 rm -f ${LIB}/regex.h; mv ${LIB}/regex.h.sed ${LIB}/regex.h
2865 for file in reg_types.h regex.h sys/lc_core.h; do
2866 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2867 rm -f ${LIB}/$file
2868 else
2869 # Find any include directives that use "file".
2870 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2871 dir=`echo $file | sed -e s'|/[^/]*$||'`
2872 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2873 done
2875 done
2877 # AIX headers define NULL to be cast to a void pointer, which is illegal
2878 # in ANSI C++.
2879 for file in curses.h dbm.h locale.h stdio.h stdlib.h string.h time.h unistd.h sys/dir.h sys/param.h sys/types.h ; do
2880 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2881 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2882 chmod +w ${LIB}/$file 2>/dev/null
2883 chmod a+r ${LIB}/$file 2>/dev/null
2886 if [ -r ${LIB}/$file ]; then
2887 if egrep '#.*define.*NULL.*void' ${LIB}/$file >/dev/null 2>&1; then
2888 echo "Fixing $file, bad NULL macro"
2889 sed -e 's/^#[ ]*define[ ]*NULL[ ]*((void[ ]*\*)0)/#define NULL 0/' \
2890 ${LIB}/$file > ${LIB}/${file}.sed
2891 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2892 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2893 rm -f ${LIB}/$file
2894 else
2895 # Find any include directives that use "file".
2896 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2897 dir=`echo $file | sed -e s'|/[^/]*$||'`
2898 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2899 done
2903 done
2905 # HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
2906 file=sys/param.h
2907 base=`basename $file`
2908 if [ -r ${LIB}/$file ]; then
2909 file_to_fix=${LIB}/$file
2910 else
2911 if [ -r ${INPUT}/$file ]; then
2912 file_to_fix=${INPUT}/$file
2913 else
2914 file_to_fix=""
2917 if [ \! -z "$file_to_fix" ]; then
2918 echo Checking $file_to_fix
2919 sed -e '/^#[ ]*define[ ]*MAXINT[ ]/i\
2920 #ifndef MAXINT
2922 -e '/^#[ ]*define[ ]*MAXINT[ ]/a\
2923 #endif
2924 ' $file_to_fix > /tmp/$base
2925 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
2926 true
2927 else
2928 echo Fixed $file_to_fix
2929 rm -f ${LIB}/$file
2930 cp /tmp/$base ${LIB}/$file
2931 chmod a+r ${LIB}/$file
2932 # Find any include directives that use "file".
2933 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2934 dir=`echo $file | sed -e s'|/[^/]*$||'`
2935 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2936 done
2938 rm -f /tmp/$base
2942 # This loop does not appear to do anything, because it uses file
2943 # rather than $file when setting target. It also appears to be
2944 # unnecessary, since the main loop processes symbolic links.
2945 #if $LINKS; then
2946 # echo 'Making internal symbolic non-directory links'
2947 # cd ${INPUT}
2948 # files=`find . -type l -print`
2949 # for file in $files; do
2950 # dest=`ls -ld $file | sed -n 's/.*-> //p'`
2951 # if expr "$dest" : '[^/].*' > /dev/null; then
2952 # target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
2953 # if [ -f $target ]; then
2954 # ln -s $dest ${LIB}/$file >/dev/null 2>&1
2955 # fi
2956 # fi
2957 # done
2960 # Make sure that any include files referenced using double quotes
2961 # exist in the fixed directory. This comes last since otherwise
2962 # we might end up deleting some of these files "because they don't
2963 # need any change."
2964 set x $required
2965 shift
2966 while [ $# != 0 ]; do
2967 newreq=
2968 while [ $# != 0 ]; do
2969 # $1 is the directory to copy from, $2 is the unfixed file,
2970 # $3 is the fixed file name.
2971 cd ${INPUT}
2972 cd $1
2973 if [ -r $2 ] && [ ! -r $3 ]; then
2974 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
2975 chmod +w $3 2>/dev/null
2976 chmod a+r $3 2>/dev/null
2977 echo Copied $2
2978 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2979 dir=`echo $2 | sed -e s'|/[^/]*$||'`
2980 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
2981 newreq="$newreq $1 $dir/$include $dir2/$include"
2982 done
2984 shift; shift; shift
2985 done
2986 set x $newreq
2987 shift
2988 done
2990 echo 'Cleaning up DONE files.'
2991 cd $LIB
2992 find . -name DONE -exec rm -f '{}' ';'
2994 echo 'Removing unneeded directories:'
2995 cd $LIB
2996 files=`find . -type d -print | sort -r`
2997 for file in $files; do
2998 rmdir $LIB/$file > /dev/null 2>&1
2999 done
3002 exit 0