* error.c (dump_function_name): Don't crash if given a friend
[official-gcc.git] / gcc / fixincludes
blob8c5843ae20b4c328d47f2581e9a28c8236e5bb45
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 if [ "x$1" = "x" ]
11 then echo fixincludes: no output directory specified
12 exit 1
15 LIB=${1}
16 shift
18 # Make sure it exists.
19 if [ ! -d $LIB ]; then
20 mkdir $LIB || {
21 echo fixincludes: output dir '`'$LIB"' cannot be created"
22 exit 1
24 else
25 ( \cd $LIB && touch DONE && rm DONE ) || {
26 echo fixincludes: output dir '`'$LIB"' is an invalid directory"
27 exit 1
31 # Define what target system we're fixing.
33 if test -r ./Makefile; then
34 target_canonical="`sed -n -e 's,^target[ ]*=[ ]*\(.*\)$,\1,p' < Makefile`"
37 # If not from the Makefile, then try config.guess
39 if test -z "${target_canonical}" ; then
40 if test -x ./config.guess ; then
41 target_canonical="`config.guess`" ; fi
42 test -z "${target_canonical}" && target_canonical=unknown
44 export target_canonical
46 # # # # # # # # # # # # # # # # # # # # #
48 # Define PWDCMD as a command to use to get the working dir
49 # in the form that we want.
50 PWDCMD=pwd
52 case "`$PWDCMD`" in
53 //*)
54 # On an Apollo, discard everything before `/usr'.
55 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
57 esac
59 # Original directory.
60 ORIGDIR=`${PWDCMD}`
62 # Make LIB absolute only if needed to avoid problems with the amd.
63 case $LIB in
64 /*)
67 cd $LIB; LIB=`${PWDCMD}`
69 esac
71 echo Fixing headers into ${LIB} for ${target_canonical} target
73 # Determine whether this system has symbolic links.
74 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
75 rm -f $LIB/ShouldNotExist
76 LINKS=true
77 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
78 rm -f /tmp/ShouldNotExist
79 LINKS=true
80 else
81 LINKS=false
84 # # # # # # # # # # # # # # # # # # # # #
86 # Search each input directory for broken header files.
87 # This loop ends near the end of the file.
89 if test $# -eq 0
90 then
91 INPUTLIST="/usr/include"
92 else
93 INPUTLIST="$@"
96 for INPUT in ${INPUTLIST} ; do
98 cd ${ORIGDIR}
100 cd ${INPUT} || continue
101 INPUT=`${PWDCMD}`
104 # # # # # # # # # # # # # # # # # # # # #
106 echo Finding directories and links to directories
108 # Find all directories and all symlinks that point to directories.
109 # Put the list in $files.
110 # Each time we find a symlink, add it to newdirs
111 # so that we do another find within the dir the link points to.
112 # Note that $files may have duplicates in it;
113 # later parts of this file are supposed to ignore them.
114 dirs="."
115 levels=2
116 while [ -n "$dirs" ] && [ $levels -gt 0 ]
118 levels=`expr $levels - 1`
119 newdirs=
120 for d in $dirs
122 echo " Searching $INPUT/$d"
124 # Find all directories under $d, relative to $d, excluding $d itself.
125 # (The /. is needed after $d in case $d is a symlink.)
126 files="$files `find $d/. -type d -print | \
127 sed -e '/\/\.$/d' -e 's@/./@/@g'`"
128 # Find all links to directories.
129 # Using `-exec test -d' in find fails on some systems,
130 # and trying to run test via sh fails on others,
131 # so this is the simplest alternative left.
132 # First find all the links, then test each one.
133 theselinks=
134 $LINKS && \
135 theselinks=`find $d/. -type l -print | sed -e 's@/./@/@g'`
136 for d1 in $theselinks --dummy--
138 # If the link points to a directory,
139 # add that dir to $newdirs
140 if [ -d $d1 ]
141 then
142 files="$files $d1"
143 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
144 then
145 newdirs="$newdirs $d1"
148 done
149 done
151 dirs="$newdirs"
152 done
154 dirs=
155 echo "All directories (including links to directories):"
156 echo $files
158 for file in $files; do
159 rm -rf $LIB/$file
160 if [ ! -d $LIB/$file ]
161 then mkdir $LIB/$file
163 done
164 mkdir $LIB/root
166 # treetops gets an alternating list
167 # of old directories to copy
168 # and the new directories to copy to.
169 treetops="${INPUT} ${LIB}"
171 if $LINKS; then
172 echo 'Making symbolic directory links'
173 for file in $files; do
174 dest=`ls -ld $file | sed -n 's/.*-> //p'`
175 if [ "$dest" ]; then
176 cwd=`${PWDCMD}`
177 # In case $dest is relative, get to $file's dir first.
178 cd ${INPUT}
179 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
180 # Check that the target directory exists.
181 # Redirections changed to avoid bug in sh on Ultrix.
182 (cd $dest) > /dev/null 2>&1
183 if [ $? = 0 ]; then
184 cd $dest
185 # X gets the dir that the link actually leads to.
186 x=`${PWDCMD}`
187 # Canonicalize ${INPUT} now to minimize the time an
188 # automounter has to change the result of ${PWDCMD}.
189 cinput=`cd ${INPUT}; ${PWDCMD}`
190 # If a link points to ., make a similar link to .
191 if [ $x = ${cinput} ]; then
192 echo $file '->' . ': Making link'
193 rm -fr ${LIB}/$file > /dev/null 2>&1
194 ln -s . ${LIB}/$file > /dev/null 2>&1
195 # If link leads back into ${INPUT},
196 # make a similar link here.
197 elif expr $x : "${cinput}/.*" > /dev/null; then
198 # Y gets the actual target dir name, relative to ${INPUT}.
199 y=`echo $x | sed -n "s&${cinput}/&&p"`
200 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
201 dots=`echo "$file" |
202 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
203 echo $file '->' $dots$y ': Making link'
204 rm -fr ${LIB}/$file > /dev/null 2>&1
205 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
206 else
207 # If the link is to a dir $target outside ${INPUT},
208 # repoint the link at ${INPUT}/root$target
209 # and process $target into ${INPUT}/root$target
210 # treat this directory as if it actually contained the files.
211 echo $file '->' root$x ': Making link'
212 if [ -d $LIB/root$x ]
213 then true
214 else
215 dirname=root$x/
216 dirmade=.
217 cd $LIB
218 while [ x$dirname != x ]; do
219 component=`echo $dirname | sed -e 's|/.*$||'`
220 mkdir $component >/dev/null 2>&1
221 cd $component
222 dirmade=$dirmade/$component
223 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
224 done
226 # Duplicate directory structure created in ${LIB}/$file in new
227 # root area.
228 for file2 in $files; do
229 case $file2 in
230 $file/*)
231 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
232 echo "Duplicating ${file}'s ${dupdir}"
233 if [ -d ${dupdir} ]
234 then true
235 else
236 mkdir ${dupdir}
241 esac
242 done
243 # Get the path from ${LIB} to $file, accounting for symlinks.
244 parent=`echo "$file" | sed -e 's@/[^/]*$@@'`
245 libabs=`cd ${LIB}; ${PWDCMD}`
246 file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"`
247 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
248 dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'`
249 rm -fr ${LIB}/$file > /dev/null 2>&1
250 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
251 treetops="$treetops $x ${LIB}/root$x"
254 cd $cwd
256 done
259 required=
260 set x $treetops
261 shift
262 while [ $# != 0 ]; do
263 # $1 is an old directory to copy, and $2 is the new directory to copy to.
264 cd ${INPUT}
265 cd $1
266 # The same dir can appear more than once in treetops.
267 # There's no need to scan it more than once.
268 if [ -f $2/DONE ]
269 then
270 files=
271 else
272 touch $2/DONE
273 echo Fixing directory $1 into $2
274 # Check .h files which are symlinks as well as those which are files.
275 # A link to a header file will not be processed by anything but this.
276 if $LINKS; then
277 files=`find . -name '*.h' \( -type f -o -type l \) -print`
278 else
279 files=`find . -name '*.h' -type f -print`
281 echo Checking header files
283 # Note that BSD43_* are used on recent MIPS systems.
284 for file in $files; do
285 # This call to egrep is essential, since checking a file with egrep
286 # is much faster than actually trying to fix it.
287 # It is also essential that most files *not* match!
288 # Thus, matching every #endif is unacceptable.
289 # But the argument to egrep must be kept small, or many versions of egrep
290 # won't be able to handle it.
292 # We use the pattern [!-.0-z{|}~] instead of [^/ ] to match a noncomment
293 # following #else or #endif because some buggy egreps think [^/] matches
294 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
295 # [!-.0-~] does not work properly on AIX 4.1.
297 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
298 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
299 # in this pattern lacks `d' and `l'; this means we don't worry about
300 # identifiers starting with `d' or `l'. This is OK, since none of the
301 # identifiers below start with `d' or `l'. It also greatly improves
302 # performance, since many files contain lines of the form `#if ... defined ...'
303 # or `#if lint'.
304 if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-z\{\|\}\~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-zA-Z][a-zA-Z0-9]' $file >/dev/null; then
305 if [ -r $file ]; then
306 cp $file $2/$file >/dev/null 2>&1 \
307 || echo "Can't copy $file"
308 chmod +w $2/$file
309 chmod a+r $2/$file
310 # The fixinc_eol stuff is to work around a bug in the sed
311 # program on HP/UX 10.20.
312 # Here is how the sed commands in braces work.
313 # (It doesn't work to put the comments inside the sed commands.)
314 # Surround each word with spaces, to simplify matching below.
315 # ANSIfy each pre-ANSI machine-dependent symbol
316 # by surrounding it with __ __.
317 # Remove the spaces that we inserted around each word.
318 sed -e '
319 :loop
320 /\\$/ N
321 s/\\$/\\*fixinc_eol*/
322 /\\$/ b loop
323 s/\\\*fixinc_eol\*/\\/g
324 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
325 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
326 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
327 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
328 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
329 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
330 /^[ ]*\/\/[ ]*/s///
331 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
332 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
333 /#[ ]*define[ ]*[ ]_IO/ s/'\''\([cgxtf]\)'\''/\1/g
334 /#[ ]*define[ ]*[ ]BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
335 /#[ ]*define[ ]*[ ]DESIOC/ s/'\''\([cdgx]\)'\''/\1/g
336 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
337 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
338 /#[ ]*define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
339 /#[ ]*define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
340 /#[ ]*define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
341 /#[ ]*define[ ]*[ ][_]*ISCTRL/ s/'\''\([cgx]\)'\''/\1/g
342 /#[ ]*[el]*if/{
343 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
345 s/ bsd4\([0-9]\) / __bsd4\1__ /g
346 s/ _*host_mips / __host_mips__ /g
347 s/ _*i386 / __i386__ /g
348 s/ M32 / __M32__ /g
349 s/ is68k / __is68k__ /g
350 s/ m68k / __m68k__ /g
351 s/ mc680\([0-9]\)0 / __mc680\10__ /g
352 s/ m88k / __m88k__ /g
353 s/ _*mips / __mips__ /g
354 s/ news\([0-9]*\) / __news\1__ /g
355 s/ ns32000 / __ns32000__ /g
356 s/ pdp11 / __pdp11__ /g
357 s/ pyr / __pyr__ /g
358 s/ sel / __sel__ /g
359 s/ sony_news / __sony_news__ /g
360 s/ sparc / __sparc__ /g
361 s/ sun\([a-z0-9]*\) / __sun\1__ /g
362 s/ tahoe / __tahoe__ /g
363 s/ tower\([_0-9]*\) / __tower\1__ /g
364 s/ u370 / __u370__ /g
365 s/ u3b\([0-9]*\) / __u3b\1__ /g
366 s/ unix / __unix__ /g
367 s/ vax / __vax__ /g
368 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
369 s/ _*\([Rr][34]\)000 / __\1000__ /g
370 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
372 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
374 /^#define.NULL[ ]/ i\
375 #undef NULL
376 ' $2/$file > $2/$file.
377 mv $2/$file. $2/$file
378 if cmp $file $2/$file >/dev/null 2>&1 \
379 || egrep 'This file is part of the GNU C Library' $2/$file >/dev/null 2>&1; then
380 rm $2/$file
381 else
382 echo Fixed $file
383 # Find any include directives that use "file".
384 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
385 dir=`echo $file | sed -e s'|/[^/]*$||'`
386 required="$required $1 $dir/$include $2/$dir/$include"
387 done
391 done
392 shift; shift
393 done
395 cd ${INPUT}
397 # Install the proper definition of the three standard types in header files
398 # that they come from.
399 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
400 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
401 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
402 chmod +w ${LIB}/$file 2>/dev/null
403 chmod a+r ${LIB}/$file 2>/dev/null
406 if [ -r ${LIB}/$file ]; then
407 echo Fixing size_t, ptrdiff_t and wchar_t in $file
408 sed \
409 -e '/^[ ]*\*[ ]*typedef unsigned int size_t;/N' \
410 -e 's/^\([ ]*\*[ ]*typedef unsigned int size_t;\n[ ]*\*\/\)/\1\
411 #ifndef __SIZE_TYPE__\
412 #define __SIZE_TYPE__ long unsigned int\
413 #endif\
414 typedef __SIZE_TYPE__ size_t;\
415 /' \
416 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
417 #ifndef __SIZE_TYPE__\
418 #define __SIZE_TYPE__ long unsigned int\
419 #endif
421 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
422 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
423 #ifndef __PTRDIFF_TYPE__\
424 #define __PTRDIFF_TYPE__ long int\
425 #endif
427 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
428 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
429 #ifndef __WCHAR_TYPE__\
430 #define __WCHAR_TYPE__ int\
431 #endif\
432 #ifndef __cplusplus
434 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/a\
435 #endif
437 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
438 ${LIB}/$file > ${LIB}/${file}.sed
439 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
440 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
441 rm ${LIB}/$file
442 else
443 # Find any include directives that use "file".
444 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
445 dir=`echo $file | sed -e s'|/[^/]*$||'`
446 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
447 done
450 done
452 # Fix #defines under Alpha OSF/1:
453 # The following files contain '#pragma extern_prefix "_FOO"' followed by
454 # a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
455 # statements is to reduce namespace pollution. While these macros work
456 # properly in most cases, they don't allow you to take a pointer to the
457 # "something" being modified. To get around this limitation, change these
458 # statements to be of the form '#define something _FOOsomething'.
459 for file in libgen.h dirent.h ftw.h grp.h ndbm.h pthread.h pwd.h signal.h standards.h stdlib.h string.h stropts.h time.h unistd.h
461 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
462 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
463 chmod +w ${LIB}/$file 2>/dev/null
464 chmod a+r ${LIB}/$file 2>/dev/null
467 if [ -r ${LIB}/$file ]; then
468 echo Fixing $file extern_prefix
469 sed -e 's/^[ ]*#[ ]*define[ ]*\([^(]*\)\(([^)]*)\)[ ]*\(_.\)\1\2[ ]*$/#define \1 \3\1/' ${LIB}/$file > ${LIB}/${file}.sed
470 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
471 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
472 rm ${LIB}/$file
473 else
474 # Find any include directives that use "file".
475 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
476 dir=`echo $file | sed -e s'|/[^/]*$||'`
477 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
478 done
481 done
483 # Fix one other error in this file: a mismatched quote not inside a C comment.
484 file=sundev/vuid_event.h
485 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
486 mkdir ${LIB}/sundev 2>/dev/null
487 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
488 chmod +w ${LIB}/$file 2>/dev/null
489 chmod a+r ${LIB}/$file 2>/dev/null
492 if [ -r ${LIB}/$file ]; then
493 echo Fixing $file comment
494 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
495 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
496 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
497 rm ${LIB}/$file
498 else
499 # Find any include directives that use "file".
500 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
501 dir=`echo $file | sed -e s'|/[^/]*$||'`
502 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
503 done
507 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
508 file=sunwindow/win_cursor.h
509 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
510 # mkdir ${LIB}/sunwindow 2>/dev/null
511 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
512 chmod +w ${LIB}/$file 2>/dev/null
514 if [ -r ${LIB}/$file ]; then
515 echo Fixing $file
516 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
517 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
518 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
519 rm ${LIB}/$file
520 else
521 # Find any include directives that use "file".
522 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
523 dir=`echo $file | sed -e s'|/[^/]*$||'`
524 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
525 done
528 file=sunwindow/win_lock.h
529 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
530 # mkdir ${LIB}/sunwindow 2>/dev/null
531 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
532 chmod +w ${LIB}/$file 2>/dev/null
534 if [ -r ${LIB}/$file ]; then
535 echo Fixing $file
536 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
537 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
538 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
539 rm ${LIB}/$file
540 else
541 # Find any include directives that use "file".
542 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
543 dir=`echo $file | sed -e s'|/[^/]*$||'`
544 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
545 done
549 # Fix this Sun file to avoid interfering with stddef.h.
550 file=sys/stdtypes.h
551 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
552 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
553 chmod +w ${LIB}/$file 2>/dev/null
554 chmod a+r ${LIB}/$file 2>/dev/null
557 if [ -r ${LIB}/$file ]; then
558 echo Fixing $file
559 sed -e '/[ ]size_t.*;/i\
560 #ifndef _GCC_SIZE_T\
561 #define _GCC_SIZE_T
563 -e '/[ ]size_t.*;/a\
564 #endif
566 -e '/[ ]ptrdiff_t.*;/i\
567 #ifndef _GCC_PTRDIFF_T\
568 #define _GCC_PTRDIFF_T
570 -e '/[ ]ptrdiff_t.*;/a\
571 #endif
573 -e '/[ ]wchar_t.*;/i\
574 #ifndef _GCC_WCHAR_T\
575 #define _GCC_WCHAR_T
577 -e '/[ ]wchar_t.*;/a\
578 #endif
579 ' ${LIB}/$file > ${LIB}/${file}.sed
580 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
581 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
582 rm ${LIB}/$file
583 else
584 # Find any include directives that use "file".
585 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
586 dir=`echo $file | sed -e s'|/[^/]*$||'`
587 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
588 done
592 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
593 # in cc1plus.
594 file=stdlib.h
595 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
596 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
597 chmod +w ${LIB}/$file 2>/dev/null
598 chmod a+r ${LIB}/$file 2>/dev/null
601 if [ -r ${LIB}/$file ]; then
602 echo Fixing $file
603 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
604 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
605 ${LIB}/$file > ${LIB}/${file}.sed
606 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
607 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
608 rm ${LIB}/$file
609 else
610 # Find any include directives that use "file".
611 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
612 dir=`echo $file | sed -e s'|/[^/]*$||'`
613 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
614 done
618 # Fix this ARM/RISCiX file where ___type is a Compiler hint that is specific to
619 # the Norcroft compiler.
620 file=X11/Intrinsic.h
621 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
622 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
623 chmod +w ${LIB}/$file 2>/dev/null
624 chmod a+r ${LIB}/$file 2>/dev/null
627 if [ -r ${LIB}/$file ]; then
628 echo Fixing $file
629 sed -e "s/___type p_type/p_type/" \
630 ${LIB}/$file > ${LIB}/${file}.sed
631 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
632 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
633 rm ${LIB}/$file
634 else
635 # Find any include directives that use "file".
636 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
637 dir=`echo $file | sed -e s'|/[^/]*$||'`
638 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
639 done
643 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
644 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
645 # set) size_t.
646 file=sys/types.h
647 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
648 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
649 chmod +w ${LIB}/$file 2>/dev/null
650 chmod a+r ${LIB}/$file 2>/dev/null
653 if [ -r ${LIB}/$file ]; then
654 echo Fixing $file
655 sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
656 #ifndef _GCC_SIZE_T\
657 #define _GCC_SIZE_T
659 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
660 #endif
661 ' ${LIB}/$file > ${LIB}/${file}.sed
662 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
663 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
664 rm ${LIB}/$file
665 else
666 # Find any include directives that use "file".
667 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
668 dir=`echo $file | sed -e s'|/[^/]*$||'`
669 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
670 done
674 # Fix HP's use of ../machine/inline.h to refer to
675 # /usr/include/machine/inline.h
676 file=sys/spinlock.h
677 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
678 cp $file ${LIB}/$file
680 if [ -r ${LIB}/$file ] ; then
681 echo Fixing $file
682 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
683 -e 's,"../machine/psl.h",<machine/psl.h>,' \
684 ${LIB}/$file > ${LIB}/${file}.sed
685 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
686 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
687 rm ${LIB}/$file
688 else
689 # Find any include directives that use "file".
690 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
691 dir=`echo $file | sed -e s'|/[^/]*$||'`
692 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
693 done
697 # Fix an error in this file: the #if says _cplusplus, not the double
698 # underscore __cplusplus that it should be
699 file=tinfo.h
700 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
701 mkdir ${LIB}/rpcsvc 2>/dev/null
702 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
703 chmod +w ${LIB}/$file 2>/dev/null
704 chmod a+r ${LIB}/$file 2>/dev/null
707 if [ -r ${LIB}/$file ]; then
708 echo Fixing $file, __cplusplus macro
709 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
710 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
711 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
712 rm ${LIB}/$file
713 else
714 # Find any include directives that use "file".
715 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
716 dir=`echo $file | sed -e s'|/[^/]*$||'`
717 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
718 done
722 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
723 # structure definition.
724 file=rpcsvc/rstat.h
725 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
726 mkdir ${LIB}/rpcsvc 2>/dev/null
727 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
728 chmod +w ${LIB}/$file 2>/dev/null
729 chmod a+r ${LIB}/$file 2>/dev/null
732 if [ -r ${LIB}/$file ]; then
733 echo Fixing $file, definition of statsswtch
734 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
735 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
736 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
737 rm ${LIB}/$file
738 else
739 # Find any include directives that use "file".
740 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
741 dir=`echo $file | sed -e s'|/[^/]*$||'`
742 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
743 done
747 # Fix an error in this file: a missing semi-colon at the end of the nodeent
748 # structure definition.
749 file=netdnet/dnetdb.h
750 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
751 mkdir ${LIB}/netdnet 2>/dev/null
752 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
753 chmod +w ${LIB}/$file 2>/dev/null
754 chmod a+r ${LIB}/$file 2>/dev/null
757 if [ -r ${LIB}/$file ]; then
758 echo Fixing $file, definition of nodeent
759 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
760 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
761 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
762 rm ${LIB}/$file
763 else
764 # Find any include directives that use "file".
765 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
766 dir=`echo $file | sed -e s'|/[^/]*$||'`
767 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
768 done
772 # Check for bad #ifdef line (in Ultrix 4.1)
773 file=sys/file.h
774 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
775 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
776 chmod +w ${LIB}/$file 2>/dev/null
777 chmod a+r ${LIB}/$file 2>/dev/null
780 if [ -r ${LIB}/$file ]; then
781 echo Fixing $file, bad \#ifdef line
782 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
783 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
784 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
785 rm ${LIB}/$file
786 else
787 # Find any include directives that use "file".
788 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
789 dir=`echo $file | sed -e s'|/[^/]*$||'`
790 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
791 done
795 # Check for (...) in C++ code in HP/UX sys/file.h.
796 file=sys/file.h
797 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
798 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
799 chmod +w ${LIB}/$file 2>/dev/null
800 chmod a+r ${LIB}/$file 2>/dev/null
803 if [ -r ${LIB}/$file ]; then
804 if egrep HPUX_SOURCE ${LIB}/$file > /dev/null; then
805 echo Fixing $file, use of '(...)'
806 sed -e 's/(\.\.\.)/(struct file * ...)/' ${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
820 # Check for superfluous `static' (in Ultrix 4.2)
821 # On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
822 file=machine/cpu.h
823 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
824 mkdir ${LIB}/machine 2>/dev/null
825 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
826 chmod +w ${LIB}/$file 2>/dev/null
827 chmod a+r ${LIB}/$file 2>/dev/null
830 if [ -r ${LIB}/$file ]; then
831 echo Fixing $file, superfluous static and broken includes of other files.
832 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
833 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
834 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
835 ${LIB}/$file > ${LIB}/${file}.sed
836 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
837 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
838 rm ${LIB}/$file
839 else
840 # Find any include directives that use "file".
841 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
842 dir=`echo $file | sed -e s'|/[^/]*$||'`
843 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
844 done
845 # This file has an alternative name, mips/cpu.h. Fix that name, too.
846 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
847 mkdir ${LIB}/mips 2>&-
848 # Don't remove the file first, they may be the same file!
849 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
854 # Incorrect sprintf declaration in X11/Xmu.h
855 file=X11/Xmu.h
856 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
857 mkdir ${LIB}/X11 2>/dev/null
858 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
859 chmod +w ${LIB}/$file 2>/dev/null
860 chmod a+r ${LIB}/$file 2>/dev/null
863 if [ -r ${LIB}/$file ]; then
864 echo Fixing $file sprintf declaration
865 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
866 extern char * sprintf();\
867 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
868 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
869 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
870 rm ${LIB}/$file
871 else
872 # Find any include directives that use "file".
873 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
874 dir=`echo $file | sed -e s'|/[^/]*$||'`
875 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
876 done
880 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
881 # (It's not clear whether the right file name is this or X11/Xmu.h.)
882 file=X11/Xmu/Xmu.h
883 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
884 mkdir ${LIB}/X11/Xmu 2>/dev/null
885 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
886 chmod +w ${LIB}/$file 2>/dev/null
887 chmod a+r ${LIB}/$file 2>/dev/null
890 if [ -r ${LIB}/$file ]; then
891 echo Fixing $file sprintf declaration
892 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
893 extern char * sprintf();\
894 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
895 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
896 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
897 rm ${LIB}/$file
898 else
899 # Find any include directives that use "file".
900 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
901 dir=`echo $file | sed -e s'|/[^/]*$||'`
902 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
903 done
907 # Check for missing ';' in struct
908 file=netinet/ip.h
909 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
910 mkdir ${LIB}/netinet 2>/dev/null
911 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
912 chmod +w ${LIB}/$file 2>/dev/null
913 chmod a+r ${LIB}/$file 2>/dev/null
916 if [ -r ${LIB}/$file ]; then
917 echo Fixing $file
918 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
919 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
920 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
921 rm -f ${LIB}/$file
922 else
923 # Find any include directives that use "file".
924 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
925 dir=`echo $file | sed -e s'|/[^/]*$||'`
926 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
927 done
931 # Fix the CAT macro in SunOS memvar.h.
932 file=pixrect/memvar.h
933 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
934 mkdir ${LIB}/pixrect 2>/dev/null
935 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
936 chmod +w ${LIB}/$file 2>/dev/null
937 chmod a+r ${LIB}/$file 2>/dev/null
940 if [ -r ${LIB}/$file ]; then
941 echo Fixing $file
942 sed -e '/^#define.CAT(a,b)/ i\
943 #ifdef __STDC__ \
944 #define CAT(a,b) a##b\
945 #else
946 /^#define.CAT(a,b)/ a\
947 #endif
948 ' ${LIB}/$file > ${LIB}/${file}.sed
949 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
950 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
951 rm -f ${LIB}/$file
952 else
953 # Find any include directives that use "file".
954 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
955 dir=`echo $file | sed -e s'|/[^/]*$||'`
956 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
957 done
961 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
962 file=rpcsvc/rusers.h
963 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
964 mkdir ${LIB}/rpcsvc 2>/dev/null
965 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
966 chmod +w ${LIB}/$file 2>/dev/null
967 chmod a+r ${LIB}/$file 2>/dev/null
970 if [ -r ${LIB}/$file ]; then
971 echo Fixing $file
972 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
973 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
974 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
975 rm -f ${LIB}/$file
976 else
977 # Find any include directives that use "file".
978 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
979 dir=`echo $file | sed -e s'|/[^/]*$||'`
980 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
981 done
985 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
986 # Also wrap protection around size_t for m88k-sysv3 systems.
987 file=stdlib.h
988 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
989 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
990 chmod +w ${LIB}/$file 2>/dev/null
991 chmod a+r ${LIB}/$file 2>/dev/null
994 if [ -r ${LIB}/$file ]; then
995 echo Fixing $file
996 if grep _GCC_SIZE_T ${LIB}/$file >/dev/null
997 then size_t_pattern='<<< do not double-wrap the size_t typedef >>>'
998 else size_t_pattern='typedef[ a-zA-Z_]*[ ]size_t[ ]*;'
1000 sed -e 's/int abort/void abort/g' \
1001 -e 's/int free/void free/g' \
1002 -e 's/char[ ]*\*[ ]*calloc/void \* calloc/g' \
1003 -e 's/char[ ]*\*[ ]*malloc/void \* malloc/g' \
1004 -e 's/char[ ]*\*[ ]*realloc/void \* realloc/g' \
1005 -e 's/char[ ]*\*[ ]*bsearch/void \* bsearch/g' \
1006 -e 's/int[ ][ ]*exit/void exit/g' \
1007 -e "/$size_t_pattern/"'i\
1008 #ifndef _GCC_SIZE_T\
1009 #define _GCC_SIZE_T
1011 -e "/$size_t_pattern/"'a\
1012 #endif
1014 ${LIB}/$file > ${LIB}/${file}.sed
1015 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1016 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1017 rm -f ${LIB}/$file
1018 else
1019 # Find any include directives that use "file".
1020 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1021 dir=`echo $file | sed -e s'|/[^/]*$||'`
1022 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1023 done
1027 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
1028 # Also fix return type of {m,re}alloc in <malloc.h> on sysV68
1029 file=malloc.h
1030 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1031 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1032 chmod +w ${LIB}/$file 2>/dev/null
1033 chmod a+r ${LIB}/$file 2>/dev/null
1036 if [ -r ${LIB}/$file ]; then
1037 echo Fixing $file
1038 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
1039 -e 's/int[ ][ ]*free/void free/g' \
1040 -e 's/char\([ ]*\*[ ]*malloc\)/void\1/g' \
1041 -e 's/char\([ ]*\*[ ]*realloc\)/void\1/g' \
1042 ${LIB}/$file > ${LIB}/${file}.sed
1043 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1044 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1045 rm -f ${LIB}/$file
1046 else
1047 # Find any include directives that use "file".
1048 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1049 dir=`echo $file | sed -e s'|/[^/]*$||'`
1050 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1051 done
1055 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
1056 file=hsfs/hsfs_spec.h
1057 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1058 mkdir ${LIB}/hsfs 2>/dev/null
1059 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1060 chmod +w ${LIB}/$file 2>/dev/null
1061 chmod a+r ${LIB}/$file 2>/dev/null
1064 if [ -r ${LIB}/$file ]; then
1065 echo Fixing $file
1066 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
1067 ${LIB}/$file > ${LIB}/${file}.
1068 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
1069 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1070 rm -f ${LIB}/$file
1071 else
1072 # Find any include directives that use "file".
1073 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1074 dir=`echo $file | sed -e s'|/[^/]*$||'`
1075 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1076 done
1080 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
1081 file=hsfs/hsnode.h
1082 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1083 mkdir ${LIB}/hsfs 2>/dev/null
1084 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1085 chmod +w ${LIB}/$file 2>/dev/null
1086 chmod a+r ${LIB}/$file 2>/dev/null
1089 if [ -r ${LIB}/$file ]; then
1090 echo Fixing $file
1091 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
1092 ${LIB}/$file > ${LIB}/${file}.sed
1093 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1094 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1095 rm -f ${LIB}/$file
1096 else
1097 # Find any include directives that use "file".
1098 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1099 dir=`echo $file | sed -e s'|/[^/]*$||'`
1100 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1101 done
1105 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
1106 file=hsfs/iso_spec.h
1107 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1108 mkdir ${LIB}/hsfs 2>/dev/null
1109 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1110 chmod +w ${LIB}/$file 2>/dev/null
1111 chmod a+r ${LIB}/$file 2>/dev/null
1114 if [ -r ${LIB}/$file ]; then
1115 echo Fixing $file
1116 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
1117 ${LIB}/$file > ${LIB}/${file}.sed
1118 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1119 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1120 rm -f ${LIB}/$file
1121 else
1122 # Find any include directives that use "file".
1123 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1124 dir=`echo $file | sed -e s'|/[^/]*$||'`
1125 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1126 done
1130 # Incorrect #include in Sony News-OS 3.2.
1131 file=machine/machparam.h
1132 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1133 mkdir ${LIB}/machine 2>/dev/null
1134 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1135 chmod +w ${LIB}/$file 2>/dev/null
1136 chmod a+r ${LIB}/$file 2>/dev/null
1139 if [ -r ${LIB}/$file ]; then
1140 echo Fixing $file, incorrect \#include
1141 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
1142 ${LIB}/$file > ${LIB}/${file}.
1143 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
1144 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1145 rm -f ${LIB}/$file
1146 else
1147 # Find any include directives that use "file".
1148 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1149 dir=`echo $file | sed -e s'|/[^/]*$||'`
1150 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1151 done
1155 # Multiline comment after typedef on IRIX 4.0.1.
1156 file=sys/types.h
1157 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1158 mkdir ${LIB}/sys 2>/dev/null
1159 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1160 chmod +w ${LIB}/$file 2>/dev/null
1161 chmod a+r ${LIB}/$file 2>/dev/null
1164 if [ -r ${LIB}/$file ]; then
1165 echo Fixing $file, comment in the middle of \#ifdef
1166 sed -e 's@type of the result@type of the result */@' \
1167 -e 's@of the sizeof@/* of the sizeof@' \
1168 ${LIB}/$file > ${LIB}/${file}.sed
1169 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1170 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1171 rm -f ${LIB}/$file
1172 else
1173 # Find any include directives that use "file".
1174 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1175 dir=`echo $file | sed -e s'|/[^/]*$||'`
1176 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1177 done
1181 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
1182 # header file, which embeds // comments inside multi-line /* */
1183 # comments. If this looks like the IRIX header file, we refix it by
1184 # just throwing away the // comments.
1185 file=fam.h
1186 if [ -r ${LIB}/$file ]; then
1187 if egrep indigo.esd ${LIB}/$file > /dev/null; then
1188 echo Fixing $file, overeager sed script
1189 rm ${LIB}/$file
1190 sed -e 's|//.*$||g' $file > ${LIB}/$file
1191 chmod +w ${LIB}/$file 2>/dev/null
1192 chmod a+r ${LIB}/$file 2>/dev/null
1196 # There is a similar problem with the VxWorks drv/netif/if_med.h file.
1197 file=drv/netif/if_med.h
1198 if [ -r ${LIB}/$file ]; then
1199 if egrep 'Wind River' ${LIB}/$file > /dev/null; then
1200 echo Fixing $file, overeager sed script
1201 rm ${LIB}/$file
1202 sed -e 's|//.*$||g' $file > ${LIB}/$file
1203 chmod +w ${LIB}/$file 2>/dev/null
1204 chmod a+r ${LIB}/$file 2>/dev/null
1208 # And also with the HP-UX 10 and HP-UX 11 sys/pci.h file
1209 file=sys/pci.h
1210 if [ -r ${LIB}/$file ]; then
1211 if egrep 'System Private Structures' ${LIB}/$file > /dev/null; then
1212 echo Fixing $file, overeager sed script
1213 rm ${LIB}/$file
1214 sed -e 's|//.*$||g' $file > ${LIB}/$file
1215 chmod +w ${LIB}/$file 2>/dev/null
1216 chmod a+r ${LIB}/$file 2>/dev/null
1220 # And also with a few more HP-UX 11 headers which are only broken
1221 # after they are "fixed".
1222 file=sys/ki_iface.h
1223 if [ -r ${LIB}/$file ]; then
1224 if egrep 'These definitions are for HP Internal developers' ${LIB}/$file > /dev/null; then
1225 echo Fixing $file, overeager sed script
1226 rm ${LIB}/$file
1230 file=sys/ki.h
1231 if [ -r ${LIB}/$file ]; then
1232 if egrep '11.00 HP-UX LP64' ${LIB}/$file > /dev/null; then
1233 echo Fixing $file, overeager sed script
1234 rm ${LIB}/$file
1238 file=sys/ki_calls.h
1239 if [ -r ${LIB}/$file ]; then
1240 if egrep 'KI_MAX_PROCS is an arbitrary number' ${LIB}/$file > /dev/null; then
1241 echo Fixing $file, overeager sed script
1242 rm ${LIB}/$file
1246 file=sys/ki_defs.h
1247 if [ -r ${LIB}/$file ] ; then
1248 if egrep 'Kernel Instrumentation Definitions' ${LIB}/$file > /dev/null; then
1249 echo Fixing $file, overeager sed script
1250 rm ${LIB}/$file
1254 file=sys/time.h
1255 if [ -r ${LIB}/$file ] ; then
1256 if egrep 'For CASPEC, look in' ${LIB}/$file > /dev/null; then
1257 echo Fixing $file, overeager sed script
1258 rm ${LIB}/$file
1262 # Some IRIX header files contains the string "//"
1263 for file in elf_abi.h elf.h; do
1264 if [ -r ${LIB}/$file ]; then
1265 echo Fixing $file, overeager sed script
1266 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
1267 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1268 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1269 rm -f ${LIB}/$file
1270 else
1271 # Find any include directives that use "file".
1272 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1273 dir=`echo $file | sed -e s'|/[^/]*$||'`
1274 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1275 done
1278 done
1280 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
1281 # previous definition.
1282 file=rpc/auth.h
1283 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1284 mkdir ${LIB}/rpc 2>/dev/null
1285 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1286 chmod +w ${LIB}/$file 2>/dev/null
1287 chmod a+r ${LIB}/$file 2>/dev/null
1290 if [ -r ${LIB}/$file ]; then
1291 echo Fixing $file, undefined type
1292 sed -e '/authdes_create.*struct sockaddr/i\
1293 struct sockaddr;
1295 ${LIB}/$file > ${LIB}/$file.sed
1296 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1297 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1298 rm -f ${LIB}/$file
1299 else
1300 # Find any include directives that use "file".
1301 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1302 dir=`echo $file | sed -e s'|/[^/]*$||'`
1303 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1304 done
1308 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
1309 # definition.
1310 file=rpc/xdr.h
1311 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1312 mkdir ${LIB}/rpc 2>/dev/null
1313 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1314 chmod +w ${LIB}/$file 2>/dev/null
1315 chmod a+r ${LIB}/$file 2>/dev/null
1318 if [ -r ${LIB}/$file ]; then
1319 echo Fixing $file, undefined type
1320 sed -e '/xdrstdio_create.*struct __file_s/i\
1321 struct __file_s;
1323 ${LIB}/$file > ${LIB}/$file.sed
1324 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1325 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1326 rm -f ${LIB}/$file
1327 else
1328 # Find any include directives that use "file".
1329 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1330 dir=`echo $file | sed -e s'|/[^/]*$||'`
1331 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1332 done
1336 # Same problem with a file from SunOS 4.1.3 : a header file containing
1337 # the string "//" embedded in "/**/"
1338 file=sbusdev/audiovar.h
1339 if [ -r ${LIB}/$file ]; then
1340 echo Fixing $file, overeager sed script
1341 rm ${LIB}/$file
1342 sed -e 's|//.*$||g' $file > ${LIB}/$file
1343 chmod +w ${LIB}/$file 2>/dev/null
1344 chmod a+r ${LIB}/$file 2>/dev/null
1347 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
1348 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
1349 # many other systems have similar text but correct versions of the file.
1350 # To ensure only Sun's is fixed, we grep for a likely unique string.
1351 # Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
1352 file=memory.h
1353 if [ -r $file ] && egrep '/\* @\(#\)(head/memory.h 50.1 |memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 )\*/' $file > /dev/null; then
1354 if [ ! -r ${LIB}/$file ]; then
1355 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1356 chmod +w ${LIB}/$file 2>/dev/null
1357 chmod a+r ${LIB}/$file 2>/dev/null
1359 if [ -r ${LIB}/$file ]; then
1360 echo Replacing $file
1361 cat > ${LIB}/$file << EOF
1362 /* This file was generated by fixincludes */
1363 #ifndef __memory_h__
1364 #define __memory_h__
1366 #ifdef __STDC__
1367 extern void *memccpy();
1368 extern void *memchr();
1369 extern void *memcpy();
1370 extern void *memset();
1371 #else
1372 extern char *memccpy();
1373 extern char *memchr();
1374 extern char *memcpy();
1375 extern char *memset();
1376 #endif /* __STDC__ */
1378 extern int memcmp();
1380 #endif /* __memory_h__ */
1385 # Fix return type of fread and fwrite on sysV68
1386 file=stdio.h
1387 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1388 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1389 chmod +w ${LIB}/$file 2>/dev/null
1390 chmod a+r ${LIB}/$file 2>/dev/null
1393 if [ -r ${LIB}/$file ]; then
1394 echo Fixing $file, fread and fwrite return type
1395 sed -e 's/^\(extern int fclose(), fflush()\), \(fread(), fwrite()\)\(.*\)$/extern unsigned int \2;\
1396 \1\3/' \
1397 ${LIB}/$file > ${LIB}/${file}.sed
1398 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1399 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1400 rm -f ${LIB}/$file
1401 else
1402 # Find any include directives that use "file".
1403 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1404 dir=`echo $file | sed -e s'|/[^/]*$||'`
1405 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1406 done
1410 # parameters not const on DECstation Ultrix V4.0 and OSF/1.
1411 file=stdio.h
1412 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1413 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1414 chmod +w ${LIB}/$file 2>/dev/null
1415 chmod a+r ${LIB}/$file 2>/dev/null
1418 if [ -r ${LIB}/$file ]; then
1419 echo Fixing $file, non-const arg
1420 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1421 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1422 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1423 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1424 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1425 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1426 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1427 -e 's@popen(char \*, char \*);@popen(const char *, const char *);@' \
1428 -e 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@' \
1429 ${LIB}/$file > ${LIB}/${file}.sed
1430 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1431 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1432 rm -f ${LIB}/$file
1433 else
1434 # Find any include directives that use "file".
1435 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1436 dir=`echo $file | sed -e s'|/[^/]*$||'`
1437 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1438 done
1442 # parameters conflict with C++ new on rs/6000
1443 for file in stdio.h unistd.h ; do
1444 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1445 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1446 chmod +w ${LIB}/$file 2>/dev/null
1449 if [ -r ${LIB}/$file ]; then
1450 echo Fixing $file, parameter name conflicts
1451 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1452 ${LIB}/$file > ${LIB}/${file}.sed
1453 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1454 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1455 rm -f ${LIB}/$file
1456 else
1457 # Find any include directives that use "file".
1458 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1459 dir=`echo $file | sed -e s'|/[^/]*$||'`
1460 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1461 done
1464 done
1466 # function class(double x) conflicts with C++ keyword on rs/6000
1467 file=math.h
1468 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1469 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1470 chmod +w ${LIB}/$file 2>/dev/null
1471 chmod a+r ${LIB}/$file 2>/dev/null
1474 if [ -r ${LIB}/$file ]; then
1475 if grep '[^a-zA-Z_]class[(]' ${LIB}/$file >/dev/null; then
1476 echo Fixing $file
1477 sed -e '/class[(]/i\
1478 #ifndef __cplusplus
1480 -e '/class[(]/a\
1481 #endif
1482 ' ${LIB}/$file > ${LIB}/${file}.sed
1483 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1484 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1485 rm ${LIB}/$file
1486 else
1487 # Find any include directives that use "file".
1488 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1489 dir=`echo $file | sed -e s'|/[^/]*$||'`
1490 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1491 done
1496 # Wrong fchmod prototype on RS/6000.
1497 file=sys/stat.h
1498 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1499 mkdir ${LIB}/sys 2>/dev/null
1500 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1501 chmod +w ${LIB}/$file 2>/dev/null
1502 chmod a+r ${LIB}/$file 2>/dev/null
1505 if [ -r ${LIB}/$file ]; then
1506 echo Fixing $file, fchmod prototype
1507 sed -e 's/fchmod(char \*/fchmod(int/' \
1508 ${LIB}/$file > ${LIB}/$file.sed
1509 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1510 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1511 rm -f ${LIB}/$file
1512 else
1513 # Find any include directives that use "file".
1514 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1515 dir=`echo $file | sed -e s'|/[^/]*$||'`
1516 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1517 done
1521 # There are several name conflicts with C++ reserved words in X11
1522 # header files. These are fixed in some versions, so don't do the
1523 # fixes if we find __cplusplus in the file. These were found on the
1524 # RS/6000.
1526 # class in X11/ShellP.h
1527 file=X11/ShellP.h
1528 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1529 mkdir ${LIB}/sys 2>/dev/null
1530 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1531 chmod +w ${LIB}/$file 2>/dev/null
1532 chmod a+r ${LIB}/$file 2>/dev/null
1535 if [ -r ${LIB}/$file ]; then
1536 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1537 true;
1538 else
1539 echo Fixing $file, field class
1540 sed -e '/char [*]class;/i\
1541 #ifdef __cplusplus\
1542 char *c_class;\
1543 #else
1545 -e '/char [*]class;/a\
1546 #endif
1547 ' ${LIB}/$file > ${LIB}/${file}.sed
1548 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1550 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1551 rm -f ${LIB}/$file
1552 else
1553 # Find any include directives that use "file".
1554 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1555 dir=`echo $file | sed -e s'|/[^/]*$||'`
1556 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1557 done
1560 # new in Xm/Traversal.h
1561 file=Xm/Traversal.h
1562 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1563 mkdir ${LIB}/sys 2>/dev/null
1564 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1565 chmod +w ${LIB}/$file 2>/dev/null
1566 chmod a+r ${LIB}/$file 2>/dev/null
1569 if [ -r ${LIB}/$file ]; then
1570 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1571 true;
1572 else
1573 echo Fixing $file, uses of new
1574 sed -e '/Widget old, new;/i\
1575 #ifdef __cplusplus\
1576 Widget old, c_new;\
1577 #else
1579 -e '/Widget old, new;/a\
1580 #endif
1582 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1583 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1585 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1586 rm -f ${LIB}/$file
1587 else
1588 # Find any include directives that use "file".
1589 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1590 dir=`echo $file | sed -e s'|/[^/]*$||'`
1591 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1592 done
1595 # class in Xm/BaseClassI.h
1596 file=Xm/BaseClassI.h
1597 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1598 mkdir ${LIB}/sys 2>/dev/null
1599 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1600 chmod +w ${LIB}/$file 2>/dev/null
1601 chmod a+r ${LIB}/$file 2>/dev/null
1604 if [ -r ${LIB}/$file ]; then
1605 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1606 true;
1607 else
1608 echo Fixing $file, prototype parameter name
1609 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1610 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1612 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1613 rm -f ${LIB}/$file
1614 else
1615 # Find any include directives that use "file".
1616 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1617 dir=`echo $file | sed -e s'|/[^/]*$||'`
1618 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1619 done
1623 # NeXT 3.2 adds const prefix to some math functions. These conflict
1624 # with the built-in functions.
1625 file=ansi/math.h
1626 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1627 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1628 chmod +w ${LIB}/$file 2>/dev/null
1630 if [ -r ${LIB}/$file ]; then
1631 echo Fixing $file
1632 sed -e '/^extern.*double.*__const__.*sqrt(/s/__const__//' \
1633 -e '/^extern.*double.*__const__.*fabs(/s/__const__//' \
1634 -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
1635 -e '/^extern.*double.*__const__.*hypot(/s/__const__//' \
1636 -e '/^extern.*double.*__const__.*sin(/s/__const__//' ${LIB}/$file > ${LIB}/${file}.sed
1637 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1638 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1639 rm -f ${LIB}/$file
1640 else
1641 # Find any include directives that use "file".
1642 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1643 dir=`echo $file | sed -e s'|/[^/]*$||'`
1644 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1645 done
1649 # NeXT 3.2 uses the word "template" as a parameter for some
1650 # functions. GCC reports an invalid use of a reserved key word
1651 # with the built-in functions. NeXT 3.2 includes the keyword
1652 # volatile in the prototype for abort(). This conflicts with
1653 # the built-in definition.
1654 file=bsd/libc.h
1655 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1656 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1657 chmod +w ${LIB}/$file 2>/dev/null
1659 if [ -r ${LIB}/$file ]; then
1660 echo Fixing $file
1661 sed -e '/\(.*template\)/s/template//' \
1662 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1663 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1664 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1665 rm -f ${LIB}/$file
1666 else
1667 # Find any include directives that use "file".
1668 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1669 dir=`echo $file | sed -e s'|/[^/]*$||'`
1670 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1671 done
1675 # NeXT 3.2 includes the keyword volatile in the abort() and
1676 # exit() function prototypes. That conflicts with the
1677 # built-in functions.
1678 file=ansi/stdlib.h
1679 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1680 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1681 chmod +w ${LIB}/$file 2>/dev/null
1683 if [ -r ${LIB}/$file ]; then
1684 echo Fixing $file
1685 sed -e '/extern.*volatile.*void.*exit/s/volatile//' \
1686 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1687 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1688 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1689 rm -f ${LIB}/$file
1690 else
1691 # Find any include directives that use "file".
1692 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1693 dir=`echo $file | sed -e s'|/[^/]*$||'`
1694 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1695 done
1699 # sys/utsname.h on Ultrix V4.[35] puts the declaration of uname before the
1700 # definition of struct utsname, so the prototype (added by fixproto) causes
1701 # havoc.
1702 file=sys/utsname.h
1703 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1704 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1705 chmod +w ${LIB}/$file 2>/dev/null
1708 if [ -r ${LIB}/$file ] \
1709 && grep 'ULTRIX' ${LIB}/$file >/dev/null; then
1710 echo Fixing $file, uname declaration
1711 sed -e '/^[ ]*extern[ ]*int[ ]*uname();$/i\
1712 struct utsname;
1714 ${LIB}/$file > ${LIB}/${file}.sed
1715 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1716 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1717 rm -f ${LIB}/$file
1718 else
1719 # Find any include directives that use "file".
1720 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1721 dir=`echo $file | sed -e s'|/[^/]*$||'`
1722 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1723 done
1727 # sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition
1728 # of struct rusage, so the prototype (added by fixproto) causes havoc.
1729 file=sys/wait.h
1730 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1731 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1732 chmod +w ${LIB}/$file 2>/dev/null
1735 if [ -r ${LIB}/$file ] \
1736 && grep 'bos325,' ${LIB}/$file >/dev/null; then
1737 echo Fixing $file, wait3 declaration
1738 sed -e '/^extern pid_t wait3();$/i\
1739 struct rusage;
1741 ${LIB}/$file > ${LIB}/${file}.sed
1742 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1743 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1744 rm -f ${LIB}/$file
1745 else
1746 # Find any include directives that use "file".
1747 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1748 dir=`echo $file | sed -e s'|/[^/]*$||'`
1749 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1750 done
1754 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1755 # Note that version 3 of the NeXT system has wait.h in a different directory,
1756 # so that this code won't do anything. But wait.h in version 3 has a
1757 # conditional, so it doesn't need this fix. So everything is okay.
1758 file=sys/wait.h
1759 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1760 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1761 chmod +w ${LIB}/$file 2>/dev/null
1764 if [ -r ${LIB}/$file ] \
1765 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1766 echo Fixing $file, bad wait formal
1767 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1768 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1769 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1770 rm -f ${LIB}/$file
1771 else
1772 # Find any include directives that use "file".
1773 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1774 dir=`echo $file | sed -e s'|/[^/]*$||'`
1775 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1776 done
1780 # Don't use or define the name va_list in stdio.h.
1781 # This is for ANSI and also to interoperate properly with gcc's varargs.h.
1782 file=stdio.h
1783 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1784 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1785 chmod +w ${LIB}/$file 2>/dev/null
1786 chmod a+r ${LIB}/$file 2>/dev/null
1789 if [ -r ${LIB}/$file ]; then
1790 echo Fixing $file, use of va_list
1791 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1792 if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
1793 touch ${LIB}/${file}.sed
1794 else
1795 (echo "#define __need___va_list"
1796 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1798 # Use __gnuc_va_list in arg types in place of va_list.
1799 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1800 # trailing parentheses and semicolon save all other systems from this.
1801 # Define __va_list__ (something harmless and unused) instead of va_list.
1802 # Don't claim to have defined va_list.
1803 sed -e 's@ va_list @ __gnuc_va_list @' \
1804 -e 's@ va_list)@ __gnuc_va_list)@' \
1805 -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \
1806 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1807 -e 's@ va_list@ __va_list__@' \
1808 -e 's@\*va_list@*__va_list__@' \
1809 -e 's@ __va_list)@ __gnuc_va_list)@' \
1810 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
1811 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1812 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1813 -e 's@_Va_LIST@_VA_LIST@' \
1814 ${LIB}/$file >> ${LIB}/${file}.sed
1816 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1817 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1818 rm -f ${LIB}/$file
1819 else
1820 # Find any include directives that use "file".
1821 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1822 dir=`echo $file | sed -e s'|/[^/]*$||'`
1823 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1824 done
1828 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1829 file=ansi_compat.h
1830 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1831 if grep -s ULTRIX $file; then
1832 echo "/* This file intentionally left blank. */" > $LIB/$file
1836 # parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
1837 # also get rid of bogus inline definitions in HP-UX 8.0
1838 file=math.h
1839 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1840 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1841 chmod +w ${LIB}/$file 2>/dev/null
1842 chmod a+r ${LIB}/$file 2>/dev/null
1845 if [ -r ${LIB}/$file ]; then
1846 echo Fixing $file, non-const arg
1847 sed -e 's@atof(\([ ]*char[ ]*\*[^)]*\))@atof(const \1)@' \
1848 -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \
1849 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1850 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1851 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1852 ${LIB}/$file > ${LIB}/${file}.sed
1853 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1854 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1855 rm -f ${LIB}/$file
1856 else
1857 # Find any include directives that use "file".
1858 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1859 dir=`echo $file | sed -e s'|/[^/]*$||'`
1860 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1861 done
1865 # fix bogus recursive stdlib.h in NEWS-OS 4.0C
1866 file=stdlib.h
1867 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1868 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1869 chmod +w ${LIB}/$file 2>/dev/null
1870 chmod a+r ${LIB}/$file 2>/dev/null
1873 if [ -r ${LIB}/$file ]; then
1874 echo Fixing $file, recursive inclusion
1875 sed -e '/^#include <stdlib.h>/i\
1876 #if 0
1878 -e '/^#include <stdlib.h>/a\
1879 #endif
1881 ${LIB}/$file > ${LIB}/${file}.sed
1882 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1883 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1884 rm -f ${LIB}/$file
1885 else
1886 # Find any include directives that use "file".
1887 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1888 dir=`echo $file | sed -e s'|/[^/]*$||'`
1889 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1890 done
1894 # Avoid nested comments on Ultrix 4.3.
1895 file=rpc/svc.h
1896 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1897 mkdir ${LIB}/rpc 2>/dev/null
1898 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1899 chmod +w ${LIB}/$file 2>/dev/null
1900 chmod a+r ${LIB}/$file 2>/dev/null
1903 if [ -r ${LIB}/$file ]; then
1904 echo Fixing $file, nested comment
1905 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1906 ${LIB}/$file > ${LIB}/$file.sed
1907 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1908 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1909 rm -f ${LIB}/$file
1910 else
1911 # Find any include directives that use "file".
1912 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1913 dir=`echo $file | sed -e s'|/[^/]*$||'`
1914 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1915 done
1919 # This file in RISC/os uses /**/ to concatenate two tokens.
1920 file=bsd43/bsd43_.h
1921 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1922 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1923 chmod +w ${LIB}/$file 2>/dev/null
1924 chmod a+r ${LIB}/$file 2>/dev/null
1926 if [ -r ${LIB}/$file ]; then
1927 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1928 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1929 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
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 file=rpc/rpc.h
1941 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1942 mkdir ${LIB}/rpc 2>/dev/null
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, nested comment
1950 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
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 # rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C
1965 # is defined for the alpha. The problem is the declaration of malloc.
1966 file=rpc/types.h
1967 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1968 mkdir ${LIB}/rpc 2>/dev/null
1969 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1970 chmod +w ${LIB}/$file 2>/dev/null
1971 chmod a+r ${LIB}/$file 2>/dev/null
1973 if [ -r ${LIB}/$file ]; then
1974 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1; then
1975 true
1976 else
1977 echo Fixing $file
1978 echo '#ifdef __cplusplus
1979 extern "C" {
1980 #endif' > ${LIB}/${file}.sed
1981 cat ${LIB}/${file} >> ${LIB}/${file}.sed
1982 echo '#ifdef __cplusplus
1984 #endif' >> ${LIB}/${file}.sed
1985 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1986 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1987 rm -f ${LIB}/$file
1988 else
1989 # Find any include directives that use "file".
1990 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1991 dir=`echo $file | sed -e s'|/[^/]*$||'`
1992 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1993 done
1998 # In limits.h, put #ifndefs around things that are supposed to be defined
1999 # in float.h to avoid redefinition errors if float.h is included first.
2000 # On HP/UX this patch does not work, because on HP/UX limits.h uses
2001 # multi line comments and the inserted #endif winds up inside the
2002 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
2003 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
2004 # are there, and we do not add them ourselves.
2005 # Also fix a nested comment problem in sys/limits.h on Motorola sysV68 R3V7.1
2006 for file in limits.h sys/limits.h; do
2007 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2008 mkdir ${LIB}/sys 2>/dev/null
2009 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2010 chmod +w ${LIB}/$file 2>/dev/null
2011 chmod a+r ${LIB}/$file 2>/dev/null
2014 if [ -r ${LIB}/$file ]; then
2015 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
2016 true
2017 else
2018 echo Fixing $file
2019 sed -e '/[ ]FLT_MIN[ ]/i\
2020 #ifndef FLT_MIN
2022 -e '/[ ]FLT_MIN[ ]/a\
2023 #endif
2025 -e '/[ ]FLT_MAX[ ]/i\
2026 #ifndef FLT_MAX
2028 -e '/[ ]FLT_MAX[ ]/a\
2029 #endif
2031 -e '/[ ]FLT_DIG[ ]/i\
2032 #ifndef FLT_DIG
2034 -e '/[ ]FLT_DIG[ ]/a\
2035 #endif
2037 -e '/[ ]DBL_MIN[ ]/i\
2038 #ifndef DBL_MIN
2040 -e '/[ ]DBL_MIN[ ]/a\
2041 #endif
2043 -e '/[ ]DBL_MAX[ ]/i\
2044 #ifndef DBL_MAX
2046 -e '/[ ]DBL_MAX[ ]/a\
2047 #endif
2049 -e '/[ ]DBL_DIG[ ]/i\
2050 #ifndef DBL_DIG
2052 -e '/[ ]DBL_DIG[ ]/a\
2053 #endif
2055 -e '/^\(\/\*#define HUGE_VAL 3\.[0-9e+]* *\)\/\*/s//\1/'\
2056 ${LIB}/$file > ${LIB}/${file}.sed
2057 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2059 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2060 echo Deleting ${LIB}/$file\; no fixes were needed.
2061 rm -f ${LIB}/$file
2062 else
2063 # Find any include directives that use "file".
2064 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2065 dir=`echo $file | sed -e s'|/[^/]*$||'`
2066 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2067 done
2070 done
2072 # In math.h, put #ifndefs around things that might be defined in a gcc
2073 # specific math-*.h file.
2074 file=math.h
2075 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2076 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2077 chmod +w ${LIB}/$file 2>/dev/null
2078 chmod a+r ${LIB}/$file 2>/dev/null
2081 if [ -r ${LIB}/$file ]; then
2082 echo Fixing $file
2083 sed -e '/define[ ]HUGE_VAL[ ]/i\
2084 #ifndef HUGE_VAL
2086 -e '/define[ ]HUGE_VAL[ ]/a\
2087 #endif
2089 ${LIB}/$file > ${LIB}/${file}.sed
2090 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2092 # In addition, copy the definition of DBL_MAX from float.h
2093 # if math.h requires one. The Lynx math.h requires it.
2094 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
2095 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
2096 true;
2097 else
2098 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
2099 if [ "$dbl_max_def" != "" ]; then
2100 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
2101 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
2102 ${LIB}/$file > ${LIB}/${file}.sed
2103 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2108 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2109 echo Deleting ${LIB}/$file\; no fixes were needed.
2110 rm -f ${LIB}/$file
2111 else
2112 # Find any include directives that use "file".
2113 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2114 dir=`echo $file | sed -e s'|/[^/]*$||'`
2115 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2116 done
2120 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
2121 file=sym.h
2122 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2123 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2124 chmod +w ${LIB}/$file 2>/dev/null
2125 chmod a+r ${LIB}/$file 2>/dev/null
2128 if [ -r ${LIB}/$file ]; then
2129 echo Fixing $file
2130 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
2131 ${LIB}/$file > ${LIB}/${file}.sed
2132 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2133 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2134 rm -f ${LIB}/$file
2135 else
2136 # Find any include directives that use "file".
2137 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2138 dir=`echo $file | sed -e s'|/[^/]*$||'`
2139 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2140 done
2144 # Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
2145 # in string.h on sysV68
2146 # Correct the return type for strlen in string.h on Lynx.
2147 # Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
2148 # Add missing const for strdup on OSF/1 V3.0.
2149 # On sysV88 layout is slightly different.
2150 file=string.h
2151 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2152 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2153 chmod +w ${LIB}/$file 2>/dev/null
2154 chmod a+r ${LIB}/$file 2>/dev/null
2157 if [ -r ${LIB}/$file ]; then
2158 echo Fixing $file, mem{ccpy,chr,cpy,set} and str{len,spn,cspn} return value
2159 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
2160 -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \
2161 -e 's/strdup(char \*s1);/strdup(const char *s1);/' \
2162 -e '/^extern char$/N' \
2163 -e 's/^extern char\(\n \*memccpy(),\)$/extern void\1/'\
2164 -e '/^ strncmp(),$/N'\
2165 -e 's/^\( strncmp()\),\n\( strlen(),\)$/\1;\
2166 extern unsigned int\
2167 \2/'\
2168 -e '/^extern int$/N'\
2169 -e 's/^extern int\(\n strlen(),\)/extern size_t\1/' \
2170 ${LIB}/$file > ${LIB}/${file}.sed
2171 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2172 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2173 rm -f ${LIB}/$file
2174 else
2175 # Find any include directives that use "file".
2176 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2177 dir=`echo $file | sed -e s'|/[^/]*$||'`
2178 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2179 done
2183 # Correct the return type for strlen in strings.h in SunOS 4.
2184 file=strings.h
2185 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2186 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2187 chmod +w ${LIB}/$file 2>/dev/null
2188 chmod a+r ${LIB}/$file 2>/dev/null
2191 if [ -r ${LIB}/$file ]; then
2192 echo Fixing $file
2193 sed -e 's/int[ ]*strlen();/__SIZE_TYPE__ strlen();/' \
2194 ${LIB}/$file > ${LIB}/${file}.sed
2195 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2196 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2197 rm -f ${LIB}/$file
2198 else
2199 # Find any include directives that use "file".
2200 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2201 dir=`echo $file | sed -e s'|/[^/]*$||'`
2202 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2203 done
2207 # Delete the '#define void int' line from curses.h on Lynx
2208 file=curses.h
2209 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2210 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2211 chmod +w ${LIB}/$file 2>/dev/null
2212 chmod a+r ${LIB}/$file 2>/dev/null
2215 if [ -r ${LIB}/$file ]; then
2216 echo Fixing $file
2217 sed -e '/#[ ]*define[ ][ ]*void[ ]int/d' \
2218 ${LIB}/$file > ${LIB}/${file}.sed
2219 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2220 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2221 rm -f ${LIB}/$file
2222 else
2223 # Find any include directives that use "file".
2224 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2225 dir=`echo $file | sed -e s'|/[^/]*$||'`
2226 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2227 done
2231 # Fix `typedef struct term;' on hppa1.1-hp-hpux9.
2232 file=curses.h
2233 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2234 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2235 chmod +w ${LIB}/$file 2>/dev/null
2236 chmod a+r ${LIB}/$file 2>/dev/null
2239 if [ -r ${LIB}/$file ]; then
2240 echo Fixing $file
2241 sed -e 's/^[ ]*typedef[ ][ ]*\(struct[ ][ ]*term[ ]*;[ ]*\)$/\1/' \
2242 ${LIB}/$file > ${LIB}/${file}.sed
2243 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2244 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2245 rm -f ${LIB}/$file
2246 else
2247 # Find any include directives that use "file".
2248 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2249 dir=`echo $file | sed -e s'|/[^/]*$||'`
2250 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2251 done
2255 # For C++, avoid any typedef or macro definition of bool, and use the
2256 # built in type instead. HP/UX 10.20, at least, also has it
2257 # in curses_colr/curses.h.
2258 for file in curses.h curses_colr/curses.h ; do
2259 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2260 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2261 chmod +w ${LIB}/$file 2>/dev/null
2262 chmod a+r ${LIB}/$file 2>/dev/null
2264 if [ -r ${LIB}/$file ] && egrep bool ${LIB}/$file >/dev/null 2>&1; then
2265 echo Fixing $file, typedef or macro for bool is invalid in C++
2266 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
2267 #ifndef __cplusplus
2269 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
2270 #endif
2272 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/i\
2273 #ifndef __cplusplus
2275 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/a\
2276 #endif
2278 ${LIB}/$file > ${LIB}/${file}.sed
2279 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2280 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2281 rm -f ${LIB}/$file
2282 else
2283 # Find any include directives that use "file".
2284 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2285 dir=`echo $file | sed -e s'|/[^/]*$||'`
2286 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2287 done
2290 done
2292 # Fix incorrect S_IF* definitions on m88k-sysv3.
2293 file=sys/stat.h
2294 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2295 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2296 chmod +w ${LIB}/$file 2>/dev/null
2297 chmod a+r ${LIB}/$file 2>/dev/null
2300 if [ -r ${LIB}/$file ]; then
2301 echo Fixing $file
2302 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)/' \
2303 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
2304 ${LIB}/$file > ${LIB}/${file}.sed
2305 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2306 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2307 rm -f ${LIB}/$file
2308 else
2309 # Find any include directives that use "file".
2310 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2311 dir=`echo $file | sed -e s'|/[^/]*$||'`
2312 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2313 done
2317 # Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
2318 for file in limits.h sys/limits.h; do
2319 if [ $target_canonical = m88k-motorola-sysv3 -o \
2320 $target_canonical = m68k-motorola-sysv ]; then
2322 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2323 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2324 chmod +w ${LIB}/$file 2>/dev/null
2325 chmod a+r ${LIB}/$file 2>/dev/null
2328 if [ -r ${LIB}/$file ]; then
2329 echo "Fixing nested comments in Motorola's $file"
2330 sed \
2331 -e 's@^\(#undef[ ][ ]*PIPE_BUF[ ]*/\* max # bytes atomic in write to a\)$@\1 */@' \
2332 -e 's@\(/\*#define HUGE_VAL 3.40282346638528860e+38 \)\(/\*error value returned by Math lib\*/\)$@\1*/ \2@' \
2333 < ${LIB}/$file > ${LIB}/${file}.sed
2334 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2335 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2336 rm -f ${LIB}/$file
2340 done
2342 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
2343 for file in stdio.h stdlib.h; do
2344 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2345 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2346 chmod +w ${LIB}/$file 2>/dev/null
2347 chmod a+r ${LIB}/$file 2>/dev/null
2350 if [ -r ${LIB}/$file ]; then
2351 echo Fixing $file, getopt declaration
2352 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
2353 ${LIB}/$file > ${LIB}/${file}.sed
2354 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2355 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2356 rm -f ${LIB}/$file
2357 else
2358 # Find any include directives that use "file".
2359 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2360 dir=`echo $file | sed -e s'|/[^/]*$||'`
2361 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2362 done
2365 done
2367 # Fix __page_size* declarations in pthread.h AIX 4.1.[34].
2368 # The original ones fail if uninitialized externs are not common.
2369 # This is the default for all ANSI standard C++ compilers.
2370 for file in pthread.h; do
2371 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2372 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2373 chmod +w ${LIB}/$file 2>/dev/null
2374 chmod a+r ${LIB}/$file 2>/dev/null
2377 if [ -r ${LIB}/$file ]; then
2378 echo Fixing $file, __page_size* declarations
2379 sed -e 's/^int __page_size/extern int __page_size/' \
2380 ${LIB}/$file > ${LIB}/${file}.sed
2381 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2382 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2383 rm -f ${LIB}/$file
2384 else
2385 # Find any include directives that use "file".
2386 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2387 dir=`echo $file | sed -e s'|/[^/]*$||'`
2388 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2389 done
2392 done
2394 # Determine if we're on Interactive Unix 2.2 or later, in which case we
2395 # need to fix some additional files. This is the same test for ISC that
2396 # Autoconf uses.
2397 if test -d /etc/conf/kconfig.d \
2398 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
2399 echo "Fixing ISC __STDC__ goof in several files..."
2400 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
2401 echo $name
2402 if test -r ${LIB}/$name; then
2403 file=${LIB}/$name
2404 else
2405 file=${INPUT}/$name
2407 # On Interactive 2.2, certain traditional Unix definitions
2408 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
2409 # defined, not just if _POSIX_SOURCE is defined. This makes it
2410 # impossible to compile any nontrivial program except with -posix.
2411 sed \
2412 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
2413 < $file > ${LIB}/$name.
2414 mv ${LIB}/$name. ${LIB}/$name
2415 done
2417 echo "Fixing ISC fmod declaration"
2418 # This one's already been fixed for other things.
2419 file=${LIB}/math.h
2420 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
2421 mv $file. $file
2423 echo "Fixing nested comments in ISC <sys/limits.h>"
2424 file=sys/limits.h
2425 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
2426 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
2429 # These files in Sun OS 4.x use /**/ to concatenate tokens.
2430 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
2431 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
2432 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
2434 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2435 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2436 chmod +w ${LIB}/$file 2>/dev/null
2437 chmod a+r ${LIB}/$file 2>/dev/null
2440 if [ -r ${LIB}/$file ]; then
2441 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2442 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2443 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2444 rm -f ${LIB}/$file
2445 else
2446 # Find any include directives that use "file".
2447 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2448 dir=`echo $file | sed -e s'|/[^/]*$||'`
2449 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2450 done
2453 done
2455 # These files in ARM/RISCiX use /**/ to concatenate tokens.
2456 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
2457 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
2459 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2460 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2461 chmod +w ${LIB}/$file 2>/dev/null
2462 chmod a+r ${LIB}/$file 2>/dev/null
2465 if [ -r ${LIB}/$file ]; then
2466 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2467 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2468 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2469 rm -f ${LIB}/$file
2470 else
2471 # Find any include directives that use "file".
2472 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2473 dir=`echo $file | sed -e s'|/[^/]*$||'`
2474 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2475 done
2478 done
2480 # libm.a on m88k-motorola-sysv3 contains a stupid optimization for function
2481 # hypot(), which returns the second argument without even looking at its value
2482 # if the other is 0.0
2483 # Another drawback is that fix-header doesn't fix fabs' prototype, and I have
2484 # no idea why.
2485 file=math.h
2486 if [ $target_canonical = m88k-motorola-sysv3 ]; then
2487 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2488 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2489 chmod +w ${LIB}/$file 2>/dev/null
2490 chmod a+r ${LIB}/$file 2>/dev/null
2493 if [ -r ${LIB}/$file ]; then
2494 echo Fixing $file, fabs/hypot definition
2495 sed \
2496 -e 's/extern double floor(), ceil(), fmod(), fabs();/extern double floor(), ceil(), fmod(), fabs _PARAMS((double));/' \
2497 -e '/^extern double hypot();$/a\
2498 \/* Workaround a stupid Motorola optimization if one\
2499 of x or y is 0.0 and the other is negative! *\/\
2500 #ifdef __STDC__\
2501 static __inline__ double fake_hypot (double x, double y)\
2502 #else\
2503 static __inline__ double fake_hypot (x, y)\
2504 double x, y;\
2505 #endif\
2507 return fabs (hypot (x, y));\
2509 #define hypot fake_hypot
2511 ${LIB}/$file > ${LIB}/${file}.sed
2512 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2513 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2514 rm -f ${LIB}/$file
2519 # math.h on SunOS 4 puts the declaration of matherr before the definition
2520 # of struct exception, so the prototype (added by fixproto) causes havoc.
2521 file=math.h
2522 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2523 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2524 chmod +w ${LIB}/$file 2>/dev/null
2525 chmod a+r ${LIB}/$file 2>/dev/null
2528 if [ -r ${LIB}/$file ]; then
2529 echo Fixing $file, matherr declaration
2530 sed -e '/^struct exception/,$b' \
2531 -e '/matherr/i\
2532 struct exception;
2534 ${LIB}/$file > ${LIB}/${file}.sed
2535 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2536 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2537 rm -f ${LIB}/$file
2538 else
2539 # Find any include directives that use "file".
2540 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2541 dir=`echo $file | sed -e s'|/[^/]*$||'`
2542 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2543 done
2547 # sys/mman.h on HP/UX is not C++ ready, even though
2548 # NO_IMPLICIT_EXTERN_C is defined on HP/UX.
2549 for file in sys/mman.h; do
2550 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2551 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2552 chmod +w ${LIB}/$file 2>/dev/null
2553 chmod a+r ${LIB}/$file 2>/dev/null
2556 if [ -r ${LIB}/$file ]; then
2557 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
2558 || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
2559 true
2560 else
2561 echo Fixing $file
2562 echo '#ifdef __cplusplus
2563 extern "C" {
2564 #endif' > ${LIB}/${file}.sed
2565 cat ${LIB}/${file} >> ${LIB}/${file}.sed
2566 echo '#ifdef __cplusplus
2568 #endif' >> ${LIB}/${file}.sed
2569 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2571 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2572 rm -f ${LIB}/$file
2573 else
2574 # Find any include directives that use "file".
2575 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2576 dir=`echo $file | sed -e s'|/[^/]*$||'`
2577 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2578 done
2581 done
2583 # Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
2584 file=unistd.h
2585 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2586 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2587 chmod +w ${LIB}/$file 2>/dev/null
2588 chmod a+r ${LIB}/$file 2>/dev/null
2591 if [ -r ${LIB}/$file ]; then
2592 echo Fixing $file, sbrk declaration
2593 sed -e 's/char\([ ]*\*[ ]*sbrk[ ]*(\)/void\1/' \
2594 ${LIB}/$file > ${LIB}/${file}.sed
2595 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2596 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2597 rm -f ${LIB}/$file
2598 else
2599 # Find any include directives that use "file".
2600 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2601 dir=`echo $file | sed -e s'|/[^/]*$||'`
2602 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2603 done
2607 # Fix <c_asm.h> on Digital UNIX V4.0:
2608 # It contains a prototype for a DEC C internal asm() function, clashing with
2609 # gcc's asm keyword. So protect this with __DECC.
2610 file=c_asm.h
2611 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2612 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2613 chmod +w ${LIB}/$file 2>/dev/null
2614 chmod a+r ${LIB}/$file 2>/dev/null
2617 if [ -r ${LIB}/$file ]; then
2618 echo Fixing $file
2619 sed -e '/^[ ]*float[ ]*fasm/i\
2620 #ifdef __DECC
2622 -e '/^[ ]*#[ ]*pragma[ ]*intrinsic([ ]*dasm/a\
2623 #endif
2624 ' ${LIB}/$file > ${LIB}/${file}.sed
2625 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2626 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2627 rm ${LIB}/$file
2628 else
2629 # Find any include directives that use "file".
2630 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2631 dir=`echo $file | sed -e s'|/[^/]*$||'`
2632 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2633 done
2637 # This file on SunOS 4 has a very large macro. When the sed loop
2638 # tries pull it in, it overflows the pattern space size of the SunOS
2639 # sed (GNU sed does not have this problem). Since the file does not
2640 # require fixing, we remove it from the fixed directory.
2641 file=sundev/ipi_error.h
2642 if [ -r ${LIB}/$file ]; then
2643 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
2644 rm -f ${LIB}/$file
2647 # Put cpp wrappers around these include files to avoid redeclaration
2648 # errors during multiple inclusion on m88k-tektronix-sysv3.
2649 for file in time.h sys/time.h ; do
2650 if egrep '#ifndef' $file >/dev/null 2>&1; then
2651 true
2652 else
2653 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2654 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2655 chmod +w ${LIB}/$file 2>/dev/null
2657 if [ -r ${LIB}/$file ]; then
2658 echo Fixing $file, to protect against multiple inclusion.
2659 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
2660 (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
2661 echo "#define __GCC_GOT_${cpp_wrapper}_"
2662 cat ${LIB}/${file}
2663 echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */') > ${LIB}/${file}.new
2664 rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
2667 done
2669 # Fix fcntl prototype in fcntl.h on LynxOS.
2670 file=fcntl.h
2671 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2672 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2673 chmod +w ${LIB}/$file 2>/dev/null
2674 chmod a+r ${LIB}/$file 2>/dev/null
2677 if [ -r ${LIB}/$file ]; then
2678 echo Fixing $file, fcntl declaration
2679 sed -e 's/\(fcntl.*(int, int, \)int)/\1...)/' \
2680 ${LIB}/$file > ${LIB}/${file}.sed
2681 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2682 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2683 rm -f ${LIB}/$file
2684 else
2685 # Find any include directives that use "file".
2686 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2687 dir=`echo $file | sed -e s'|/[^/]*$||'`
2688 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2689 done
2693 # Fix definitions of macros used by va-i960.h in VxWorks header file.
2694 file=arch/i960/archI960.h
2695 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2696 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2697 chmod +w ${LIB}/$file 2>/dev/null
2698 chmod a+r ${LIB}/$file 2>/dev/null
2701 if [ -r ${LIB}/$file ]; then
2702 echo Fixing $file
2703 sed -e 's/__vsiz/__vxvsiz/' -e 's/__vali/__vxvali/' \
2704 -e s'/__vpad/__vxvpad/' -e 's/__alignof__/__vxalignof__/' \
2705 ${LIB}/$file > ${LIB}/${file}.sed
2706 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2707 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2708 rm -f ${LIB}/$file
2709 else
2710 # Find any include directives that use "file".
2711 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2712 dir=`echo $file | sed -e s'|/[^/]*$||'`
2713 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2714 done
2718 # Make VxWorks header which is almost gcc ready fully gcc ready.
2719 file=types/vxTypesBase.h
2720 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2721 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2722 chmod +w ${LIB}/$file 2>/dev/null
2723 chmod a+r ${LIB}/$file 2>/dev/null
2726 if [ -r ${LIB}/$file ]; then
2727 echo Fixing $file
2728 sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \
2729 -e '/[ ]size_t/i\
2730 #ifndef _GCC_SIZE_T\
2731 #define _GCC_SIZE_T
2733 -e '/[ ]size_t/a\
2734 #endif
2736 -e '/[ ]ptrdiff_t/i\
2737 #ifndef _GCC_PTRDIFF_T\
2738 #define _GCC_PTRDIFF_T
2740 -e '/[ ]ptrdiff_t/a\
2741 #endif
2743 -e '/[ ]wchar_t/i\
2744 #ifndef _GCC_WCHAR_T\
2745 #define _GCC_WCHAR_T
2747 -e '/[ ]wchar_t/a\
2748 #endif
2750 ${LIB}/$file > ${LIB}/${file}.sed
2751 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2752 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2753 rm -f ${LIB}/$file
2754 else
2755 # Find any include directives that use "file".
2756 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2757 dir=`echo $file | sed -e s'|/[^/]*$||'`
2758 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2759 done
2763 # Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
2764 file=sys/stat.h
2765 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2766 mkdir ${LIB}/sys 2>/dev/null
2767 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2768 chmod +w ${LIB}/$file 2>/dev/null
2769 chmod a+r ${LIB}/$file 2>/dev/null
2772 if [ -r ${LIB}/$file ]; then
2773 if egrep '#include' ${LIB}/$file >/dev/null 2>&1; then
2775 else
2776 if egrep 'ULONG' ${LIB}/$file >/dev/null 2>&1 \
2777 && [ -r types/vxTypesOld.h ]; then
2778 echo Fixing $file
2779 sed -e '/#define[ ][ ]*__INCstath/a\
2780 #include <types/vxTypesOld.h>
2782 ${LIB}/$file > ${LIB}/${file}.sed
2783 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2786 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2787 rm -f ${LIB}/$file
2788 else
2789 # Find any include directives that use "file".
2790 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2791 dir=`echo $file | sed -e s'|/[^/]*$||'`
2792 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2793 done
2797 # Fix VxWorks <time.h> to not require including <vxTypes.h>.
2798 file=time.h
2799 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2800 mkdir ${LIB}/sys 2>/dev/null
2801 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2802 chmod +w ${LIB}/$file 2>/dev/null
2803 chmod a+r ${LIB}/$file 2>/dev/null
2806 if [ -r ${LIB}/$file ]; then
2807 if egrep 'uint_t[ ][ ]*_clocks_per_sec' ${LIB}/$file >/dev/null 2>&1; then
2808 echo Fixing $file
2809 sed -e 's/uint_t/unsigned int/' ${LIB}/$file > ${LIB}/${file}.sed
2810 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2812 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2813 rm -f ${LIB}/$file
2814 else
2815 # Find any include directives that use "file".
2816 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2817 dir=`echo $file | sed -e s'|/[^/]*$||'`
2818 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2819 done
2823 # Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2824 file=sys/time.h
2825 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2826 mkdir ${LIB}/sys 2>/dev/null
2827 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2828 chmod +w ${LIB}/$file 2>/dev/null
2829 chmod a+r ${LIB}/$file 2>/dev/null
2832 if [ -r ${LIB}/$file ]; then
2833 if egrep '^extern struct sigevent;' ${LIB}/$file >/dev/null 2>&1; then
2834 echo Fixing $file
2835 sed -e 's/^extern struct sigevent;/struct sigevent;/' ${LIB}/$file > ${LIB}/${file}.sed
2836 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2838 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2839 rm -f ${LIB}/$file
2840 else
2841 # Find any include directives that use "file".
2842 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2843 dir=`echo $file | sed -e s'|/[^/]*$||'`
2844 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2845 done
2849 # Another bad dependency in VxWorks 5.2 <time.h>.
2850 file=time.h
2851 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2852 mkdir ${LIB}/sys 2>/dev/null
2853 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2854 chmod +w ${LIB}/$file 2>/dev/null
2855 chmod a+r ${LIB}/$file 2>/dev/null
2858 if [ -r ${LIB}/$file ]; then
2859 if egrep VOIDFUNCPTR ${LIB}/$file >/dev/null 2>&1; then
2860 if [ -r vxWorks.h ]; then
2861 echo Fixing $file
2862 sed -e '/VOIDFUNCPTR/i\
2863 #ifndef __gcc_VOIDFUNCPTR_defined\
2864 #ifdef __cplusplus\
2865 typedef void (*__gcc_VOIDFUNCPTR) (...);\
2866 #else\
2867 typedef void (*__gcc_VOIDFUNCPTR) ();\
2868 #endif\
2869 #define __gcc_VOIDFUNCPTR_defined\
2870 #endif
2872 -e 's/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g' \
2873 ${LIB}/$file > ${LIB}/${file}.sed
2874 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2877 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2878 rm -f ${LIB}/$file
2879 else
2880 # Find any include directives that use "file".
2881 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2882 dir=`echo $file | sed -e s'|/[^/]*$||'`
2883 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2884 done
2888 # This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89; gcc
2889 # doesn't understand it.
2890 file=sys/param.h
2891 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2892 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2893 chmod +w ${LIB}/$file 2>/dev/null
2894 chmod a+r ${LIB}/$file 2>/dev/null
2897 if [ -r ${LIB}/$file ]; then
2898 echo "Fixing __asm directive in sys/param.h"
2899 sed -e 's|#ifndef NOINLINE|#if !defined(NOINLINE) \&\& !defined(__GNUC__)|' \
2900 ${LIB}/$file > ${LIB}/${file}.sed
2901 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2902 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2903 rm -f ${LIB}/$file
2904 else
2905 # Find any include directives that use "file".
2906 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2907 dir=`echo $file | sed -e s'|/[^/]*$||'`
2908 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2909 done
2913 # signal.h on SunOS defines signal using (), which causes trouble when
2914 # compiling with g++ -pedantic.
2915 for file in signal.h sys/signal.h; do
2916 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2917 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2918 chmod +w ${LIB}/$file 2>/dev/null
2919 chmod a+r ${LIB}/$file 2>/dev/null
2922 if [ -r ${LIB}/$file ]; then
2923 echo "Checking for bad C++ prototype in $file"
2924 sed -e '/^void (\*signal())();$/i\
2925 #ifdef __cplusplus\
2926 void (*signal(...))(...);\
2927 #else
2929 -e '/^void (\*signal())();$/a\
2930 #endif
2932 ${LIB}/$file > ${LIB}/${file}.sed
2933 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2934 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2935 rm -f ${LIB}/$file
2936 else
2937 # Find any include directives that use "file".
2938 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2939 dir=`echo $file | sed -e s'|/[^/]*$||'`
2940 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2941 done
2944 done
2946 # sys/signal.h on some versions of AIX uses volatile in the typedef of
2947 # sig_atomic_t, which causes gcc to generate a warning about duplicate
2948 # volatile when a sig_atomic_t variable is declared volatile, as
2949 # required by ANSI C.
2950 file=sys/signal.h
2951 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2952 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2953 chmod +w ${LIB}/$file 2>/dev/null
2954 chmod a+r ${LIB}/$file 2>/dev/null
2957 if [ -r ${LIB}/$file ]; then
2958 echo "Checking for duplicate volatile in sys/signal.h"
2959 sed -e 's/typedef volatile int sig_atomic_t/typedef int sig_atomic_t/' \
2960 ${LIB}/$file > ${LIB}/${file}.sed
2961 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2962 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2963 rm -f ${LIB}/$file
2964 else
2965 # Find any include directives that use "file".
2966 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2967 dir=`echo $file | sed -e s'|/[^/]*$||'`
2968 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2969 done
2973 # In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
2974 # of UINT32_C has undefined behavior according to ISO/ANSI:
2975 # the arguments to __CONCAT__ are not macro expanded before the
2976 # concatination happens so the trailing ')' in the first argument
2977 # is concatinated with the 'l' in the second argument creating an
2978 # invalid pp token. The behavior of invalid pp tokens is undefined.
2979 # GCC does not handle these invalid tokens the way the HP compiler does.
2980 # This problem will potentially occur anytime macros are used in the
2981 # arguments to __CONCAT__. A general solution to this problem would be to
2982 # insert another layer of macro between __CONCAT__ and its use
2983 # in UINT32_C. An example of this solution can be found in the C standard.
2984 # A more specific solution, the one used here, is to change the UINT32_C
2985 # macro to not used macros in the arguments to __CONCAT__.
2986 file=inttypes.h
2987 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2988 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2989 chmod +w ${LIB}/$file 2>/dev/null
2990 chmod a+r ${LIB}/$file 2>/dev/null
2993 if [ -r ${LIB}/$file ]; then
2994 echo "Fixing use of __CONCAT__ in $file"
2995 sed -e 's/^#define UINT32_C(__c)\([ ]*\)__CONCAT__(__CONCAT_U__(__c),l)/#define UINT32_C(__c)\1__CONCAT__(__c,ul)/' \
2996 ${LIB}/$file > ${LIB}/${file}.sed
2997 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2998 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2999 rm -f ${LIB}/$file
3000 else
3001 # Find any include directives that use "file".
3002 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3003 dir=`echo $file | sed -e s'|/[^/]*$||'`
3004 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3005 done
3009 # Some math.h files define struct exception, which conflicts with
3010 # the class exception defined in the C++ file std/stdexcept.h. We
3011 # redefine it to __math_exception. This is not a great fix, but I
3012 # haven't been able to think of anything better.
3013 file=math.h
3014 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
3015 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
3016 chmod +w ${LIB}/$file 2>/dev/null
3017 chmod a+r ${LIB}/$file 2>/dev/null
3020 if [ -r ${LIB}/$file ]; then
3021 echo Fixing $file, exception
3022 sed -e '/struct exception/i\
3023 #ifdef __cplusplus\
3024 #define exception __math_exception\
3025 #endif
3027 -e '/struct exception/a\
3028 #ifdef __cplusplus\
3029 #undef exception\
3030 #endif
3031 ' ${LIB}/$file > ${LIB}/${file}.sed
3032 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3033 if egrep 'matherr()' ${LIB}/$file >/dev/null 2>&1; then
3034 sed -e '/matherr/i\
3035 #ifdef __cplusplus\
3036 #define exception __math_exception\
3037 #endif
3039 -e '/matherr/a\
3040 #ifdef __cplusplus\
3041 #undef exception\
3042 #endif
3043 ' ${LIB}/$file > ${LIB}/${file}.sed
3044 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3046 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
3047 rm -f ${LIB}/$file
3048 else
3049 # Find any include directives that use "file".
3050 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3051 dir=`echo $file | sed -e s'|/[^/]*$||'`
3052 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3053 done
3057 # rpc/auth.h on SunOS needs prototypes for its AUTH->auth_ops function pointers
3058 # Similarly for
3059 # rpc/clnt.h CLIENT->clnt_ops
3060 # rpc/svc.h SVCXPRT->xp_ops
3061 # rpc/xdr.h XDR->xdr_ops
3062 for file in rpc/auth.h rpc/clnt.h rpc/svc.h rpc/xdr.h; do
3063 # each file has a different name to replace, so if you add a file to
3064 # that list please update the following case statement.
3065 case "$file" in
3066 rpc/auth.h)
3067 prefix="ah_"
3069 rpc/clnt.h)
3070 prefix="cl_"
3072 rpc/svc.h)
3073 prefix="xp_"
3075 rpc/xdr.h)
3076 prefix="x_"
3079 # Oh Oh, we shouldn't be here
3080 exit 1;
3082 esac
3084 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
3085 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
3086 chmod +w ${LIB}/$file 2>/dev/null
3087 chmod a+r ${LIB}/$file 2>/dev/null
3090 if [ -r ${LIB}/$file ]; then
3091 echo "Checking for needed C++ prototype in $file"
3092 sed -e 's/^\(.*\)\*\('$prefix'.*\)();\(.*\)/\
3093 #ifdef __cplusplus\
3094 \1*\2(...);\3\
3095 #else\
3096 \1*\2();\3\
3097 #endif/g' \
3098 $LIB/$file > ${LIB}/${file}.sed
3100 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3101 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
3102 rm -f ${LIB}/$file
3103 else
3104 # Find any include directives that use "file".
3105 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3106 dir=`echo $file | sed -e s'|/[^/]*$||'`
3107 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3108 done
3111 done
3113 # sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
3114 # defining regex.h types. This causes C++ library build and usage failures.
3115 # Fixing this correctly requires checking and modifying 3 files.
3116 for file in reg_types.h regex.h sys/lc_core.h; do
3117 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
3118 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
3119 chmod +w ${LIB}/$file 2>/dev/null
3120 chmod a+r ${LIB}/$file 2>/dev/null
3122 done
3123 if [ -r ${LIB}/reg_types.h ]; then
3124 if egrep '} regex_t;' ${LIB}/reg_types.h >/dev/null 2>&1; then
3125 if [ -r ${LIB}/sys/lc_core.h ]; then
3126 if egrep ' regex_t ' ${LIB}/sys/lc_core.h >/dev/null 2>&1; then
3127 if [ -r ${LIB}/regex.h ]; then
3128 if egrep '__regex_t' ${LIB}/regex.h >/dev/null 2>&1; then
3129 true;
3130 else
3131 echo Fixing reg_types.h, regex.h, sys/lc_core.h
3132 for file in reg_types.h sys/lc_core.h; do
3133 sed -e 's/regex_t/__regex_t/g' \
3134 -e 's/regoff_t/__regoff_t/g' \
3135 -e 's/regmatch_t/__regmatch_t/g' \
3136 ${LIB}/$file > ${LIB}/${file}.sed
3137 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3138 done
3139 sed -e '/#include <reg_types.h>/a\
3140 typedef __regex_t regex_t;\
3141 typedef __regoff_t regoff_t;\
3142 typedef __regmatch_t regmatch_t;\
3144 ${LIB}/regex.h > ${LIB}/regex.h.sed
3145 rm -f ${LIB}/regex.h; mv ${LIB}/regex.h.sed ${LIB}/regex.h
3152 for file in reg_types.h regex.h sys/lc_core.h; do
3153 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
3154 rm -f ${LIB}/$file
3155 else
3156 # Find any include directives that use "file".
3157 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3158 dir=`echo $file | sed -e s'|/[^/]*$||'`
3159 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3160 done
3162 done
3164 # AIX headers define NULL to be cast to a void pointer, which is illegal
3165 # in ANSI C++.
3166 for file in curses.h dbm.h locale.h stdio.h stdlib.h string.h time.h unistd.h sys/dir.h sys/param.h sys/types.h ; do
3167 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
3168 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
3169 chmod +w ${LIB}/$file 2>/dev/null
3170 chmod a+r ${LIB}/$file 2>/dev/null
3173 if [ -r ${LIB}/$file ]; then
3174 if egrep '#.*define.*NULL.*void' ${LIB}/$file >/dev/null 2>&1; then
3175 echo "Fixing $file, bad NULL macro"
3176 sed -e 's/^#[ ]*define[ ]*NULL[ ]*((void[ ]*\*)0)/#define NULL 0/' \
3177 ${LIB}/$file > ${LIB}/${file}.sed
3178 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3179 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
3180 rm -f ${LIB}/$file
3181 else
3182 # Find any include directives that use "file".
3183 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3184 dir=`echo $file | sed -e s'|/[^/]*$||'`
3185 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3186 done
3190 done
3192 # HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
3193 file=sys/param.h
3194 base=`basename $file`
3195 if [ -r ${LIB}/$file ]; then
3196 file_to_fix=${LIB}/$file
3197 else
3198 if [ -r ${INPUT}/$file ]; then
3199 file_to_fix=${INPUT}/$file
3200 else
3201 file_to_fix=""
3204 if [ \! -z "$file_to_fix" ]; then
3205 echo Checking $file_to_fix
3206 sed -e '/^#[ ]*define[ ]*MAXINT[ ]/i\
3207 #ifndef MAXINT
3209 -e '/^#[ ]*define[ ]*MAXINT[ ]/a\
3210 #endif
3211 ' $file_to_fix > /tmp/$base
3212 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
3213 true
3214 else
3215 echo Fixed $file_to_fix
3216 rm -f ${LIB}/$file
3217 cp /tmp/$base ${LIB}/$file
3218 chmod a+r ${LIB}/$file
3219 # Find any include directives that use "file".
3220 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3221 dir=`echo $file | sed -e s'|/[^/]*$||'`
3222 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3223 done
3225 rm -f /tmp/$base
3229 # This loop does not appear to do anything, because it uses file
3230 # rather than $file when setting target. It also appears to be
3231 # unnecessary, since the main loop processes symbolic links.
3232 #if $LINKS; then
3233 # echo 'Making internal symbolic non-directory links'
3234 # cd ${INPUT}
3235 # files=`find . -type l -print`
3236 # for file in $files; do
3237 # dest=`ls -ld $file | sed -n 's/.*-> //p'`
3238 # if expr "$dest" : '[^/].*' > /dev/null; then
3239 # target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
3240 # if [ -f $target ]; then
3241 # ln -s $dest ${LIB}/$file >/dev/null 2>&1
3242 # fi
3243 # fi
3244 # done
3247 # Make sure that any include files referenced using double quotes
3248 # exist in the fixed directory. This comes last since otherwise
3249 # we might end up deleting some of these files "because they don't
3250 # need any change."
3251 set x $required
3252 shift
3253 while [ $# != 0 ]; do
3254 newreq=
3255 while [ $# != 0 ]; do
3256 # $1 is the directory to copy from, $2 is the unfixed file,
3257 # $3 is the fixed file name.
3258 cd ${INPUT}
3259 cd $1
3260 if [ -r $2 ] && [ ! -r $3 ]; then
3261 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
3262 chmod +w $3 2>/dev/null
3263 chmod a+r $3 2>/dev/null
3264 echo Copied $2
3265 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3266 dir=`echo $2 | sed -e s'|/[^/]*$||'`
3267 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
3268 newreq="$newreq $1 $dir/$include $dir2/$include"
3269 done
3271 shift; shift; shift
3272 done
3273 set x $newreq
3274 shift
3275 done
3277 echo 'Cleaning up DONE files.'
3278 cd $LIB
3279 find . -name DONE -exec rm -f '{}' ';'
3281 echo 'Removing unneeded directories:'
3282 cd $LIB
3283 files=`find . -type d \! -name '.' -print | sort -r`
3284 for file in $files; do
3285 rmdir $LIB/$file > /dev/null 2>&1
3286 done
3288 # # # # # # # # # # # # # # # # # # # # #
3290 # End of for INPUT directories
3292 done
3294 # # # # # # # # # # # # # # # # # # # # #
3296 cd $ORIGDIR
3297 rm -f include/assert.h
3298 cp ${srcdir}/assert.h include/assert.h || exit 1
3299 chmod a+r include/assert.h
3301 exit 0