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