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