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