2 # Install modified versions of certain ANSI-incompatible system header files
3 # which are fixed to work correctly with ANSI C
4 # and placed in a directory that GNU C will search.
6 # See README-fixinc for more information.
8 # Directory where gcc sources (and sometimes special include files) live.
9 # fixincludes doesn't use this, but fixinc.svr4 does, and I want to make
10 # sure somebody doesn't try to use arg3 for something incompatible. -- gumby
11 SRCDIR=${3-${SRCDIR-.}}
13 # Directory containing the original header files.
14 # (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
15 INPUT=${2-${INPUT-/usr/include}}
17 # Directory in which to store the results.
18 LIB=${1?"fixincludes: output directory not specified"}
20 # Define PWDCMD as a command to use to get the working dir
21 # in the form that we want.
25 # On an Apollo, discard everything before `/usr'.
26 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
30 # Make sure it exists.
31 if [ ! -d $LIB ]; then
36 cd $LIB; LIB=`${PWDCMD}`
38 # Fail if no arg to specify a directory for the output.
40 then echo fixincludes: no output directory specified
44 echo Building fixed headers in ${LIB}
46 # Determine whether this system has symbolic links.
47 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
48 rm -f $LIB/ShouldNotExist
54 echo Finding directories and links to directories
56 # Find all directories and all symlinks that point to directories.
57 # Put the list in $files.
58 # Each time we find a symlink, add it to newdirs
59 # so that we do another find within the dir the link points to.
60 # Note that $files may have duplicates in it;
61 # later parts of this file are supposed to ignore them.
64 while [ -n "$dirs" ] && [ $levels -gt 0 ]
66 levels=`expr $levels - 1`
70 echo " Searching $INPUT/$d"
76 # Find all directories under $d, relative to $d, excluding $d itself.
77 files="$files `find $d -type d -print | \
78 sed -e '/\/\.$/d' -e '/^\.$/d'`"
79 # Find all links to directories.
80 # Using `-exec test -d' in find fails on some systems,
81 # and trying to run test via sh fails on others,
82 # so this is the simplest alternative left.
83 # First find all the links, then test each one.
86 theselinks=`find $d -type l -print`
87 for d1 in $theselinks --dummy--
89 # If the link points to a directory,
90 # add that dir to $newdirs
93 newdirs="$newdirs $d1"
98 files="$files $newdirs"
103 echo "All directories (including links to directories):"
106 for file in $files; do
108 if [ ! -d $LIB/$file ]
109 then mkdir $LIB/$file
114 # treetops gets an alternating list
115 # of old directories to copy
116 # and the new directories to copy to.
117 treetops="${INPUT} ${LIB}"
120 echo 'Making symbolic directory links'
121 for file in $files; do
122 dest=`ls -ld $file | sed -n 's/.*-> //p'`
125 # In case $dest is relative, get to $file's dir first.
127 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
128 # Check that the target directory exists.
129 # Redirections changed to avoid bug in sh on Ultrix.
130 (cd $dest) > /dev/null 2>&1
133 # X gets the dir that the link actually leads to.
135 # If a link points to ., make a similar link to .
136 if [ $x = $INPUT ]; then
137 echo $file '->' . ': Making link'
138 rm -fr ${LIB}/$file > /dev/null 2>&1
139 ln -s . ${LIB}/$file > /dev/null 2>&1
140 # If link leads back into ${INPUT},
141 # make a similar link here.
142 elif expr $x : "${INPUT}/.*" > /dev/null; then
143 # Y gets the actual target dir name, relative to ${INPUT}.
144 y=`echo $x | sed -n "s&${INPUT}/&&p"`
145 echo $file '->' $y ': Making link'
146 rm -fr ${LIB}/$file > /dev/null 2>&1
147 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
149 # If the link is to a dir $target outside ${INPUT},
150 # repoint the link at ${INPUT}/root$target
151 # and process $target into ${INPUT}/root$target
152 # treat this directory as if it actually contained the files.
153 echo $file '->' root$x ': Making link'
154 if [ -d $LIB/root$x ]
160 while [ x$dirname != x ]; do
161 component=`echo $dirname | sed -e 's|/.*$||'`
162 mkdir $component >/dev/null 2>&1
164 dirmade=$dirmade/$component
165 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
168 rm -fr ${LIB}/$file > /dev/null 2>&1
169 ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1
170 treetops="$treetops $x ${LIB}/root$x"
179 while [ $# != 0 ]; do
180 # $1 is an old directory to copy, and $2 is the new directory to copy to.
183 # The same dir can appear more than once in treetops.
184 # There's no need to scan it more than once.
190 echo Fixing directory $1 into $2
191 # Check .h files which are symlinks as well as those which are files.
192 # A link to a header file will not be processed by anything but this.
194 files=`find . -name '*.h' \( -type f -o -type l \) -print`
196 files=`find . -name '*.h' -type f -print`
198 echo Checking header files
200 # Note that BSD43_* are used on recent MIPS systems.
201 for file in $files; do
202 # This call to egrep is essential, since checking a file with egrep
203 # is much faster than actually trying to fix it.
204 # It is also essential that most files *not* match!
205 # Thus, matching every #endif is unacceptable.
206 # But the argument to egrep must be kept small, or many versions of egrep
207 # won't be able to handle it.
208 # rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail.
209 if egrep '//|[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
211 if [ -r $file ]; then
212 cp $file $2/$file >/dev/null 2>&1 \
213 || echo "Can't copy $file"
216 # Following two lines removed.
217 # s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
218 # s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
224 /\/\// s|//\(.*\)$|/*\1*/|
225 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
226 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
227 /#define._IO/ s/'\''x'\''/x/g
228 /#define.BSD43__IO/ s/'\''x'\''/x/g
229 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
230 /#define.CTRL/ s/'\''c'\''/c/g
231 /#define._CTRL/ s/'\''c'\''/c/g
232 /#define.BSD43_CTRL/ s/'\''c'\''/c/g
233 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
234 /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g
235 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
236 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
237 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
238 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
239 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
240 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
241 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
242 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
243 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
244 /^#define.NULL[ ]/ i\
246 ' $2/$file > $2/$file.sed
247 mv $2/$file.sed $2/$file
248 if cmp $file $2/$file >/dev/null 2>&1; then
259 # Fix one other error in this file: a mismatched quote not inside a C comment.
260 file=sundev/vuid_event.h
261 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
262 mkdir ${LIB}/sundev 2>/dev/null
263 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
264 chmod +w ${LIB}/$file 2>/dev/null
265 chmod a+r ${LIB}/$file 2>/dev/null
268 if [ -r ${LIB}/$file ]; then
269 echo Fixing $file comment
270 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
271 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
272 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
277 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
278 file=sunwindow/win_cursor.h
279 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
280 # mkdir ${LIB}/sunwindow 2>/dev/null
281 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
282 chmod +w ${LIB}/$file 2>/dev/null
284 if [ -r ${LIB}/$file ]; then
286 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
287 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
288 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
292 file=sunwindow/win_lock.h
293 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
294 # mkdir ${LIB}/sunwindow 2>/dev/null
295 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
296 chmod +w ${LIB}/$file 2>/dev/null
298 if [ -r ${LIB}/$file ]; then
300 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
301 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
302 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
307 # Fix this Sun file to avoid interfering with stddef.h.
309 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
310 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
311 chmod +w ${LIB}/$file 2>/dev/null
312 chmod a+r ${LIB}/$file 2>/dev/null
315 if [ -r ${LIB}/$file ]; then
317 sed -e '/size_t.*;/i\
319 #define _GCC_SIZE_T' \
323 #ifndef _GCC_PTRDIFF_T\
324 #define _GCC_PTRDIFF_T' \
328 #ifndef _GCC_WCHAR_T\
329 #define _GCC_WCHAR_T' \
331 #endif' ${LIB}/$file > ${LIB}/${file}.sed
332 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
333 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
338 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
339 # match e.g. ssize_t present in AIX for the ps/2.
341 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
342 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
343 chmod +w ${LIB}/$file 2>/dev/null
344 chmod a+r ${LIB}/$file 2>/dev/null
347 if [ -r ${LIB}/$file ]; then
349 sed -e '/size_t.*;/i\
351 #define _GCC_SIZE_T' \
353 #endif' ${LIB}/$file > ${LIB}/${file}.sed
354 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
355 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
360 # Fix an error in this file: the #if says _cplusplus, not the double
361 # underscore __cplusplus that it should be
363 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
364 mkdir ${LIB}/rpcsvc 2>/dev/null
365 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
366 chmod +w ${LIB}/$file 2>/dev/null
367 chmod a+r ${LIB}/$file 2>/dev/null
370 if [ -r ${LIB}/$file ]; then
371 echo Fixing $file, __cplusplus macro
372 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
373 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
374 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
379 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
380 # structure definition.
382 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
383 mkdir ${LIB}/rpcsvc 2>/dev/null
384 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
385 chmod +w ${LIB}/$file 2>/dev/null
386 chmod a+r ${LIB}/$file 2>/dev/null
389 if [ -r ${LIB}/$file ]; then
390 echo Fixing $file, definition of statsswtch
391 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
392 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
393 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
398 # Fix an error in this file: a missing semi-colon at the end of the nodeent
399 # structure definition.
400 file=netdnet/dnetdb.h
401 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
402 mkdir ${LIB}/netdnet 2>/dev/null
403 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
404 chmod +w ${LIB}/$file 2>/dev/null
405 chmod a+r ${LIB}/$file 2>/dev/null
408 if [ -r ${LIB}/$file ]; then
409 echo Fixing $file, definition of nodeent
410 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
411 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
412 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
417 # Check for bad #ifdef line (in Ultrix 4.1)
419 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
420 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
421 chmod +w ${LIB}/$file 2>/dev/null
422 chmod a+r ${LIB}/$file 2>/dev/null
425 if [ -r ${LIB}/$file ]; then
426 echo Fixing $file, bad \#ifdef line
427 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
428 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
429 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
434 # Remove nested comments created by #endifs in a comment (Ultrix 4.1)
435 # Only needed if commenting out junk after #endif.
437 #if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
438 # cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
439 # chmod +w ${LIB}/$file 2>/dev/null
440 # chmod a+r ${LIB}/$file 2>/dev/null
443 #if [ -r ${LIB}/$file ]; then
444 # echo Fixing $file, nested comments
445 # sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
446 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
447 # if cmp $file ${LIB}/$file >/dev/null 2>&1; then
452 # Check for superfluous `static' (in Ultrix 4.2)
454 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
455 mkdir ${LIB}/machine 2>/dev/null
456 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
457 chmod +w ${LIB}/$file 2>/dev/null
458 chmod a+r ${LIB}/$file 2>/dev/null
461 if [ -r ${LIB}/$file ]; then
462 echo Fixing $file, superfluous static
463 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed
464 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
465 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
468 # This file has an alternative name, mips/cpu.h. Fix that name, too.
469 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
470 mkdir ${LIB}/mips 2>&-
471 ln ${LIB}/$file ${LIB}/mips/cpu.h
476 # Incorrect sprintf declaration in X11/Xmu.h
478 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
479 mkdir ${LIB}/X11 2>/dev/null
480 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
481 chmod +w ${LIB}/$file 2>/dev/null
482 chmod a+r ${LIB}/$file 2>/dev/null
485 if [ -r ${LIB}/$file ]; then
486 echo Fixing $file sprintf declaration
487 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
488 extern char * sprintf();\
489 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${file}.sed
490 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
491 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
496 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
497 # (It's not clear whether the right file name is this or X11/Xmu.h.)
499 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
500 mkdir ${LIB}/X11/Xmu 2>/dev/null
501 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
502 chmod +w ${LIB}/$file 2>/dev/null
503 chmod a+r ${LIB}/$file 2>/dev/null
506 if [ -r ${LIB}/$file ]; then
507 echo Fixing $file sprintf declaration
508 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
509 extern char * sprintf();\
510 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${file}.sed
511 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
512 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
517 # Check for missing ';' in struct
519 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
520 mkdir ${LIB}/netinet 2>/dev/null
521 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
522 chmod +w ${LIB}/$file 2>/dev/null
523 chmod a+r ${LIB}/$file 2>/dev/null
526 if [ -r ${LIB}/$file ]; then
528 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
529 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
530 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
535 # Fix the CAT macro in SunOS memvar.h.
536 file=pixrect/memvar.h
537 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
538 mkdir ${LIB}/pixrect 2>/dev/null
539 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
540 chmod +w ${LIB}/$file 2>/dev/null
541 chmod a+r ${LIB}/$file 2>/dev/null
544 if [ -r ${LIB}/$file ]; then
546 sed -e '/^#define.CAT(a,b)/ i\
548 #define CAT(a,b) a##b\
550 /^#define.CAT(a,b)/ a\
552 ' ${LIB}/$file > ${LIB}/${file}.sed
553 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
554 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
559 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
561 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
562 mkdir ${LIB}/rpcsvc 2>/dev/null
563 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
564 chmod +w ${LIB}/$file 2>/dev/null
565 chmod a+r ${LIB}/$file 2>/dev/null
568 if [ -r ${LIB}/$file ]; then
570 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
571 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
572 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
577 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
579 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
580 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
581 chmod +w ${LIB}/$file 2>/dev/null
582 chmod a+r ${LIB}/$file 2>/dev/null
585 if [ -r ${LIB}/$file ]; then
587 sed -e 's/int abort/void abort/g' \
588 -e 's/int free/void free/g' \
589 -e 's/char \* calloc/void \* calloc/g' \
590 -e 's/char \* malloc/void \* malloc/g' \
591 -e 's/char \* realloc/void \* realloc/g' \
592 -e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.sed
593 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
594 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
599 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
601 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
602 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
603 chmod +w ${LIB}/$file 2>/dev/null
604 chmod a+r ${LIB}/$file 2>/dev/null
607 if [ -r ${LIB}/$file ]; then
609 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
610 -e 's/int[ ][ ]*free/void free/g' \
611 ${LIB}/$file > ${LIB}/${file}.sed
612 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
613 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
619 # Fix bogus comment in <locale.h> on SunOS 4.1.
621 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
622 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
623 chmod +w ${LIB}/$file 2>/dev/null
624 chmod a+r ${LIB}/$file 2>/dev/null
627 if [ -r ${LIB}/$file ]; then
629 sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
630 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
631 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
636 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
637 file=hsfs/hsfs_spec.h
638 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
639 mkdir ${LIB}/hsfs 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
645 if [ -r ${LIB}/$file ]; then
647 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
648 ${LIB}/$file > ${LIB}/${file}.sed
649 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
650 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
655 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
657 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
658 mkdir ${LIB}/hsfs 2>/dev/null
659 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
660 chmod +w ${LIB}/$file 2>/dev/null
661 chmod a+r ${LIB}/$file 2>/dev/null
664 if [ -r ${LIB}/$file ]; then
666 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
667 ${LIB}/$file > ${LIB}/${file}.sed
668 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
669 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
674 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
676 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
677 mkdir ${LIB}/hsfs 2>/dev/null
678 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
679 chmod +w ${LIB}/$file 2>/dev/null
680 chmod a+r ${LIB}/$file 2>/dev/null
683 if [ -r ${LIB}/$file ]; then
685 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
686 ${LIB}/$file > ${LIB}/${file}.sed
687 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
688 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
693 # Incorrect #include in Sony News-OS 3.2.
694 file=machine/machparam.h
695 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
696 mkdir ${LIB}/machine 2>/dev/null
697 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
698 chmod +w ${LIB}/$file 2>/dev/null
699 chmod a+r ${LIB}/$file 2>/dev/null
702 if [ -r ${LIB}/$file ]; then
703 echo Fixing $file, incorrect \#include
704 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
705 ${LIB}/$file > ${LIB}/${file}.sed
706 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
707 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
712 # Multiline comment after typedef on IRIX 4.0.1.
714 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
715 mkdir ${LIB}/sys 2>/dev/null
716 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
717 chmod +w ${LIB}/$file 2>/dev/null
718 chmod a+r ${LIB}/$file 2>/dev/null
721 if [ -r ${LIB}/$file ]; then
722 echo Fixing $file, comment in the middle of \#ifdef
723 sed -e 's@type of the result@type of the result */@' \
724 -e 's@of the sizeof@/* of the sizeof@' \
725 ${LIB}/$file > ${LIB}/${file}.sed
726 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
727 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
732 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
733 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
734 # many other systems have similar text but correct versions of the file.
735 # To ensure only Sun's is fixed, we grep for a likely unique string.
737 if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
738 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
739 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
740 chmod +w ${LIB}/$file 2>/dev/null
741 chmod a+r ${LIB}/$file 2>/dev/null
743 if [ -r ${LIB}/$file ]; then
745 cat > ${LIB}/$file << EOF
746 /* This file was generated by fixincludes */
751 extern void *memccpy();
752 extern void *memchr();
753 extern void *memcpy();
754 extern void *memset();
756 extern char *memccpy();
757 extern char *memchr();
758 extern char *memcpy();
759 extern char *memset();
760 #endif /* __STDC__ */
769 # parameters not const on DECstation Ultrix V4.0.
771 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
772 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
773 chmod +w ${LIB}/$file 2>/dev/null
774 chmod a+r ${LIB}/$file 2>/dev/null
777 if [ -r ${LIB}/$file ]; then
778 echo Fixing $file, non-const arg
779 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
780 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
781 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
782 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
783 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
784 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
785 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
786 ${LIB}/$file > ${LIB}/${file}.sed
787 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
788 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
793 # Don't use or define the name va_list in stdio.h.
794 # This is for ANSI and also to interoperate properly with gvarargs.h.
796 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
797 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
798 chmod +w ${LIB}/$file 2>/dev/null
799 chmod a+r ${LIB}/$file 2>/dev/null
802 if [ -r ${LIB}/$file ]; then
803 echo Fixing $file, use of va_list
804 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
805 (echo "#define __need___va_list"
806 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
807 # Use __gnuc_va_list in arg types in place of va_list.
808 # Define __va_list__ (something harmless and unused) instead of va_list.
809 # Don't claim to have defined va_list.
810 sed -e 's@ va_list @ __gnuc_va_list @' \
811 -e 's@ va_list@ __va_list__@' \
812 -e 's@\*va_list@*__va_list__@' \
813 -e 's@VA_LIST@DUMMY_VA_LIST@' \
814 ${LIB}/$file >> ${LIB}/${file}.sed
816 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
817 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
822 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
824 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
825 if grep -s ULTRIX $file; then
826 echo "/* This file intentionally left blank. */" > $LIB/$file
830 # parameter to atof not const on DECstation Ultrix V4.0.
831 # also get rid of bogus inline definitions in HP-UX 8.0
833 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
834 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
835 chmod +w ${LIB}/$file 2>/dev/null
836 chmod a+r ${LIB}/$file 2>/dev/null
839 if [ -r ${LIB}/$file ]; then
840 echo Fixing $file, non-const arg
841 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
842 -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \
843 -e 's@inline double abs(double d) { return fabs(d); }@@' \
844 ${LIB}/$file > ${LIB}/${file}.sed
845 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
846 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
851 # These two files on SunOS 4 are included by other files
852 # in the same directory, using "...". So we must make sure they exist
853 # in the same directory as the other fixed files.
854 if [ -r ${INPUT}/multimedia/audio_errno.h ]
856 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
858 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
860 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
863 echo 'Removing unneeded directories:'
865 files=`find . -type d -print | sort -r`
866 for file in $files; do
867 rmdir $LIB/$file > /dev/null 2>&1
871 echo 'Making internal symbolic non-directory links'
873 files=`find . -type l -print`
874 for file in $files; do
875 dest=`ls -ld $file | sed -n 's/.*-> //p'`
876 if expr "$dest" : '[^/].*' > /dev/null; then
877 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
878 if [ -f $target ]; then
879 ln -s $dest ${LIB}/$file >/dev/null 2>&1