3 # fixinc.svr4 -- Install modified versions of certain ANSI-incompatible
4 # native System V Release 4 system include files.
6 # Written by Ron Guilmette (rfg@ncd.com).
8 # This file is part of GNU CC.
10 # GNU CC is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
15 # GNU CC is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with GNU CC; see the file COPYING. If not, write to
22 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 # This script munges the native include files provided with System V
25 # Release 4 systems so as to remove things which are violations of the
26 # ANSI C standard. Once munged, the resulting new system include files
27 # are placed in a directory that GNU C will search *before* searching
28 # the /usr/include directory. This script should work properly for most
29 # System V Release 4 systems. For other types of systems, you should
30 # use the `fixincludes' script instead.
32 # See README-fixinc for more information.
34 # Directory where gcc sources (and sometimes special include files) live.
35 SRCDIR
=${3-${SRCDIR-.}}
37 # Directory containing the original header files.
38 INPUT
=${2-${INPUT-/usr/include}}
40 # Fail if no arg to specify a directory for the output.
42 then echo fixincludes
: no output directory specified
46 # Directory in which to store the results.
47 LIB
=${1?"fixincludes: output directory not specified"}
49 # Make sure it exists.
50 if [ ! -d $LIB ]; then
59 # This prevents /bin/ex from failing if the current terminal type is
63 # This prevents /bin/ex from failing if the EXINIT environment variable
64 # was set to something invalid.
68 echo 'Building fixincludes in ' ${LIB}
70 # Determine whether this filesystem has symbolic links.
71 if ln -s X
$LIB/ShouldNotExist
2>/dev
/null
; then
72 rm -f $LIB/ShouldNotExist
78 echo 'Making directories:'
81 files
=`ls -LR | sed -n s/:$//p`
83 files
=`find . -type d -print | sed '/^.$/d'`
85 for file in $files; do
87 if [ ! -d $LIB/$file ]
92 # treetops gets an alternating list
93 # of old directories to copy
94 # and the new directories to copy to.
95 treetops
="${INPUT} ${LIB}"
98 echo 'Making internal symbolic directory links'
99 for file in $files; do
100 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
103 # In case $dest is relative, get to $file's dir first.
105 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
106 # Check that the target directory exists.
107 # Redirections changed to avoid bug in sh on Ultrix.
108 (cd $dest) > /dev
/null
2>&1
111 # X gets the dir that the link actually leads to.
113 # If link leads back into ${INPUT},
114 # make a similar link here.
115 if expr $x : "${INPUT}/.*" > /dev
/null
; then
116 # Y gets the actual target dir name, relative to ${INPUT}.
117 y
=`echo $x | sed -n "s&${INPUT}/&&p"`
118 echo $file '->' $y ': Making link'
119 rm -fr ${LIB}/$file > /dev
/null
2>&1
120 ln -s ${LIB}/$y ${LIB}/$file > /dev
/null
2>&1
122 # If the link is to outside ${INPUT},
123 # treat this directory as if it actually contained the files.
124 # This line used to have $dest instead of $x.
125 # $dest seemed to be wrong for links found in subdirectories
126 # of ${INPUT}. Does this change break anything?
127 treetops
="$treetops $x ${LIB}/$file"
136 while [ $# != 0 ]; do
137 # $1 is an old directory to copy, and $2 is the new directory to copy to.
138 echo "Finding header files in $1:"
141 files
=`find . -name '*.h' -type f -print`
142 echo 'Checking header files:'
143 for file in $files; do
145 if [ -r $file ]; then
146 cp $file $2/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
149 # The following have been removed from the sed command below
150 # because it is more useful to leave these things in.
151 # The only reason to remove them was for -pedantic,
152 # which isn't much of a reason. -- rms.
155 # The change of u_char, etc, to u_int
156 # applies to bit fields.
158 s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
159 s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
160 s/#lint(on)/defined(lint)/g
161 s/#lint(off)/!defined(lint)/g
162 s/#machine(\([^)]*\))/defined(__\1__)/g
163 s/#system(\([^)]*\))/defined(__\1__)/g
164 s/#cpu(\([^)]*\))/defined(__\1__)/g
165 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
166 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
167 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
168 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
169 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
170 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
171 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
172 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
173 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
174 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
175 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
176 s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
177 s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
178 s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
179 s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
180 s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
181 s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
182 s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
183 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
184 ' $2/$file > $2/$file.
sed
185 mv $2/$file.
sed $2/$file
186 if cmp $file $2/$file >/dev
/null
2>&1; then
187 echo Deleting
$2/$file\
; no fixes were needed.
195 # Fix first broken decl of getcwd present on some svr4 systems.
198 base
=`basename $file`
199 if [ -r ${LIB}/$file ]; then
200 file_to_fix
=${LIB}/$file
202 if [ -r ${INPUT}/$file ]; then
203 file_to_fix
=${INPUT}/$file
208 if [ \
! -z "$file_to_fix" ]; then
209 echo Checking
$file_to_fix
210 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp
/$base
211 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
212 echo No change needed
in $file_to_fix
214 echo Fixed
$file_to_fix
216 cp /tmp
/$base ${LIB}/$file
221 # Fix second broken decl of getcwd present on some svr4 systems. Also
222 # fix the incorrect decl of profil present on some svr4 systems.
225 base
=`basename $file`
226 if [ -r ${LIB}/$file ]; then
227 file_to_fix
=${LIB}/$file
229 if [ -r ${INPUT}/$file ]; then
230 file_to_fix
=${INPUT}/$file
235 if [ \
! -z "$file_to_fix" ]; then
236 echo Checking
$file_to_fix
237 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
238 |
sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp
/$base
239 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
240 echo No change needed
in $file_to_fix
242 echo Fixed
$file_to_fix
244 cp /tmp
/$base ${LIB}/$file
249 # Fix the definition of NULL in <sys/param.h> so that it is conditional
250 # and so that it is correct for both C and C++.
253 base
=`basename $file`
254 if [ -r ${LIB}/$file ]; then
255 file_to_fix
=${LIB}/$file
257 if [ -r ${INPUT}/$file ]; then
258 file_to_fix
=${INPUT}/$file
263 if [ \
! -z "$file_to_fix" ]; then
264 echo Checking
$file_to_fix
265 cp $file_to_fix /tmp
/$base
268 /^#define[ ]*NULL[ ]*0$/c
272 #else /* !defined(__cplusplus) */
273 #define __NULL_TYPE (void *)
274 #endif /* !defined(__cplusplus) */
275 #define NULL (__NULL_TYPE 0)
276 #endif /* !defined(NULL) */
280 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
281 echo No change needed
in $file_to_fix
283 echo Fixed
$file_to_fix
285 cp /tmp
/$base ${LIB}/$file
290 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
291 # and so that it is correct for both C and C++.
294 base
=`basename $file`
295 if [ -r ${LIB}/$file ]; then
296 file_to_fix
=${LIB}/$file
298 if [ -r ${INPUT}/$file ]; then
299 file_to_fix
=${INPUT}/$file
304 if [ \
! -z "$file_to_fix" ]; then
305 echo Checking
$file_to_fix
306 cp $file_to_fix /tmp
/$base
309 /^#define[ ]*NULL[ ]*0$/c
312 #else /* !defined(__cplusplus) */
313 #define __NULL_TYPE (void *)
314 #endif /* !defined(__cplusplus) */
315 #define NULL (__NULL_TYPE 0)
319 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
320 echo No change needed
in $file_to_fix
322 echo Fixed
$file_to_fix
324 cp /tmp
/$base ${LIB}/$file
329 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
330 # and so that it is correct for both C and C++.
333 base
=`basename $file`
334 if [ -r ${LIB}/$file ]; then
335 file_to_fix
=${LIB}/$file
337 if [ -r ${INPUT}/$file ]; then
338 file_to_fix
=${INPUT}/$file
343 if [ \
! -z "$file_to_fix" ]; then
344 echo Checking
$file_to_fix
345 cp $file_to_fix /tmp
/$base
348 /^#define[ ]*NULL[ ]*((char \*) 0)$/c
352 #else /* !defined(__cplusplus) */
353 #define __NULL_TYPE (void *)
354 #endif /* !defined(__cplusplus) */
355 #define NULL (__NULL_TYPE 0)
356 #endif /* !defined(NULL) */
360 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
361 echo No change needed
in $file_to_fix
363 echo Fixed
$file_to_fix
365 cp /tmp
/$base ${LIB}/$file
370 # Add a prototyped declaration of mmap to <sys/mman.h>.
373 base
=`basename $file`
374 if [ -r ${LIB}/$file ]; then
375 file_to_fix
=${LIB}/$file
377 if [ -r ${INPUT}/$file ]; then
378 file_to_fix
=${INPUT}/$file
383 if [ \
! -z "$file_to_fix" ]; then
384 echo Checking
$file_to_fix
385 cp $file_to_fix /tmp
/$base
388 /^extern caddr_t mmap();$/c
390 extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,
392 #else /* !defined(__STDC__) */
393 extern caddr_t mmap ();
394 #endif /* !defined(__STDC__) */
398 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
399 echo No changed needed
in $file_to_fix
401 echo Fixed
$file_to_fix
403 cp /tmp
/$base ${LIB}/$file
408 # Fix declarations of `ftw' and `nftw' in <ftw.h>.
411 base
=`basename $file`
412 if [ -r ${LIB}/$file ]; then
413 file_to_fix
=${LIB}/$file
415 if [ -r ${INPUT}/$file ]; then
416 file_to_fix
=${INPUT}/$file
421 if [ \
! -z "$file_to_fix" ]; then
422 echo Checking
$file_to_fix
423 cp $file_to_fix /tmp
/$base
426 /^extern int ftw(const/c
427 #if !defined(_STYPES)
432 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
440 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);
442 /^extern int ftw(),/c
443 #if !defined(_STYPES)
458 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
459 echo No change needed
in $file_to_fix
461 echo Fixed
$file_to_fix
463 cp /tmp
/$base ${LIB}/$file
468 # Add a `static' declaration of `getrnge' into <regexp.h>.
471 base
=`basename $file`
472 if [ -r ${LIB}/$file ]; then
473 file_to_fix
=${LIB}/$file
475 if [ -r ${INPUT}/$file ]; then
476 file_to_fix
=${INPUT}/$file
481 if [ \
! -z "$file_to_fix" ]; then
482 echo Checking
$file_to_fix
483 cp $file_to_fix /tmp
/$base
486 /^static int[ ]*size;/c
489 static int getrnge ();
493 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
494 echo No change needed
in $file_to_fix
496 echo Fixed
$file_to_fix
498 cp /tmp
/$base ${LIB}/$file
503 # Add a #define of _SIGACTION_ into <sys/signal.h>.
504 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
507 base
=`basename $file`
508 if [ -r ${LIB}/$file ]; then
509 file_to_fix
=${LIB}/$file
511 if [ -r ${INPUT}/$file ]; then
512 file_to_fix
=${INPUT}/$file
517 if [ \
! -z "$file_to_fix" ]; then
518 echo Checking
$file_to_fix
519 cp $file_to_fix /tmp
/$base
522 /^struct sigaction {/c
526 1,\$s/(void *(\*)())/(void (*)(int))/
529 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
530 echo No change needed
in $file_to_fix
532 echo Fixed
$file_to_fix
534 cp /tmp
/$base ${LIB}/$file
539 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
542 base
=`basename $file`
543 if [ -r ${LIB}/$file ]; then
544 file_to_fix
=${LIB}/$file
546 if [ -r ${INPUT}/$file ]; then
547 file_to_fix
=${INPUT}/$file
552 if [ \
! -z "$file_to_fix" ]; then
553 echo Checking
$file_to_fix
554 cp $file_to_fix /tmp
/$base
557 /^dev_t makedev(const/c
558 static dev_t makedev(const major_t, const minor_t);
561 static dev_t makedev();
563 /^major_t major(const/c
564 static major_t major(const dev_t);
567 static major_t major();
569 /^minor_t minor(const/c
570 static minor_t minor(const dev_t);
573 static minor_t minor();
577 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
578 echo No change needed
in $file_to_fix
580 echo Fixed
$file_to_fix
582 cp /tmp
/$base ${LIB}/$file
587 # Fix reference to NMSZ in <sys/adv.h>.
590 base
=`basename $file`
591 if [ -r ${LIB}/$file ]; then
592 file_to_fix
=${LIB}/$file
594 if [ -r ${INPUT}/$file ]; then
595 file_to_fix
=${INPUT}/$file
600 if [ \
! -z "$file_to_fix" ]; then
601 echo Checking
$file_to_fix
602 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp
/$base
603 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
604 echo No change needed
in $file_to_fix
606 echo Fixed
$file_to_fix
608 cp /tmp
/$base ${LIB}/$file
613 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
614 # array initializers.
617 base
=`basename $file`
618 if [ -r ${LIB}/$file ]; then
619 file_to_fix
=${LIB}/$file
621 if [ -r ${INPUT}/$file ]; then
622 file_to_fix
=${INPUT}/$file
627 if [ \
! -z "$file_to_fix" ]; then
628 echo Checking
$file_to_fix
629 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
630 |
sed 's/NC_/(unsigned long) NC_/' > /tmp
/$base
631 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
632 echo No change needed
in $file_to_fix
634 echo Fixed
$file_to_fix
636 cp /tmp
/$base ${LIB}/$file
641 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
643 file=fs
/rfs
/rf_cache.h
644 base
=`basename $file`
645 if [ -r ${LIB}/$file ]; then
646 file_to_fix
=${LIB}/$file
648 if [ -r ${INPUT}/$file ]; then
649 file_to_fix
=${INPUT}/$file
654 if [ \
! -z "$file_to_fix" ]; then
655 echo Checking
$file_to_fix
656 if grep _KERNEL
$file_to_fix > /dev
/null
; then
657 echo No change needed
in $file_to_fix
659 echo '#ifdef _KERNEL' > /tmp
/$base
660 cat $file_to_fix >> /tmp
/$base
661 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
662 echo Fixed
$file_to_fix
664 cp /tmp
/$base ${LIB}/$file
669 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
672 base
=`basename $file`
673 if [ -r ${LIB}/$file ]; then
674 file_to_fix
=${LIB}/$file
676 if [ -r ${INPUT}/$file ]; then
677 file_to_fix
=${INPUT}/$file
682 if [ \
! -z "$file_to_fix" ]; then
683 echo Checking
$file_to_fix
684 if grep _KERNEL
$file_to_fix > /dev
/null
; then
685 echo No change needed
in $file_to_fix
687 echo '#ifdef _KERNEL' > /tmp
/$base
688 cat $file_to_fix >> /tmp
/$base
689 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
690 echo Fixed
$file_to_fix
692 cp /tmp
/$base ${LIB}/$file
697 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
700 base
=`basename $file`
701 if [ -r ${LIB}/$file ]; then
702 file_to_fix
=${LIB}/$file
704 if [ -r ${INPUT}/$file ]; then
705 file_to_fix
=${INPUT}/$file
710 if [ \
! -z "$file_to_fix" ]; then
711 echo Checking
$file_to_fix
712 if grep _KERNEL
$file_to_fix > /dev
/null
; then
713 echo No change needed
in $file_to_fix
715 echo '#ifdef _KERNEL' > /tmp
/$base
716 cat $file_to_fix >> /tmp
/$base
717 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
718 echo Fixed
$file_to_fix
720 cp /tmp
/$base ${LIB}/$file
725 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
728 base
=`basename $file`
729 if [ -r ${LIB}/$file ]; then
730 file_to_fix
=${LIB}/$file
732 if [ -r ${INPUT}/$file ]; then
733 file_to_fix
=${INPUT}/$file
738 if [ \
! -z "$file_to_fix" ]; then
739 echo Checking
$file_to_fix
740 if grep _KERNEL
$file_to_fix > /dev
/null
; then
741 echo No change needed
in $file_to_fix
743 echo '#ifdef _KERNEL' > /tmp
/$base
744 cat $file_to_fix >> /tmp
/$base
745 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
746 echo Fixed
$file_to_fix
748 cp /tmp
/$base ${LIB}/$file
753 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
756 base
=`basename $file`
757 if [ -r ${LIB}/$file ]; then
758 file_to_fix
=${LIB}/$file
760 if [ -r ${INPUT}/$file ]; then
761 file_to_fix
=${INPUT}/$file
766 if [ \
! -z "$file_to_fix" ]; then
767 echo Checking
$file_to_fix
768 if grep _KERNEL
$file_to_fix > /dev
/null
; then
769 echo No change needed
in $file_to_fix
771 echo '#ifdef _KERNEL' > /tmp
/$base
772 cat $file_to_fix >> /tmp
/$base
773 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
774 echo Fixed
$file_to_fix
776 cp /tmp
/$base ${LIB}/$file
781 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
784 base
=`basename $file`
785 if [ -r ${LIB}/$file ]; then
786 file_to_fix
=${LIB}/$file
788 if [ -r ${INPUT}/$file ]; then
789 file_to_fix
=${INPUT}/$file
794 if [ \
! -z "$file_to_fix" ]; then
795 echo Checking
$file_to_fix
796 if grep _KERNEL
$file_to_fix > /dev
/null
; then
797 echo No change needed
in $file_to_fix
799 echo '#ifdef _KERNEL' > /tmp
/$base
800 cat $file_to_fix >> /tmp
/$base
801 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
802 echo Fixed
$file_to_fix
804 cp /tmp
/$base ${LIB}/$file
809 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
812 base
=`basename $file`
813 if [ -r ${LIB}/$file ]; then
814 file_to_fix
=${LIB}/$file
816 if [ -r ${INPUT}/$file ]; then
817 file_to_fix
=${INPUT}/$file
822 if [ \
! -z "$file_to_fix" ]; then
823 echo Checking
$file_to_fix
824 if grep _KERNEL
$file_to_fix > /dev
/null
; then
825 echo No change needed
in $file_to_fix
827 echo '#ifdef _KERNEL' > /tmp
/$base
828 cat $file_to_fix >> /tmp
/$base
829 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
830 echo Fixed
$file_to_fix
832 cp /tmp
/$base ${LIB}/$file
837 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
840 base
=`basename $file`
841 if [ -r ${LIB}/$file ]; then
842 file_to_fix
=${LIB}/$file
844 if [ -r ${INPUT}/$file ]; then
845 file_to_fix
=${INPUT}/$file
850 if [ \
! -z "$file_to_fix" ]; then
851 echo Checking
$file_to_fix
852 if grep _KERNEL
$file_to_fix > /dev
/null
; then
853 echo No change needed
in $file_to_fix
855 echo '#ifdef _KERNEL' > /tmp
/$base
856 cat $file_to_fix >> /tmp
/$base
857 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
858 echo Fixed
$file_to_fix
860 cp /tmp
/$base ${LIB}/$file
865 # Remove useless extern keyword from struct forward declarations in
866 # <sys/stream.h> and <sys/strsubr.h>
869 base
=`basename $file`
870 if [ -r ${LIB}/$file ]; then
871 file_to_fix
=${LIB}/$file
873 if [ -r ${INPUT}/$file ]; then
874 file_to_fix
=${INPUT}/$file
879 if [ \
! -z "$file_to_fix" ]; then
880 echo Checking
$file_to_fix
881 sed -e 's/extern struct \(stdata\|strevent\);/struct \1;/' $file_to_fix > /tmp
/$base
882 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
883 echo No change needed
in $file_to_fix
885 echo Fixed
$file_to_fix
887 cp /tmp
/$base ${LIB}/$file
893 base
=`basename $file`
894 if [ -r ${LIB}/$file ]; then
895 file_to_fix
=${LIB}/$file
897 if [ -r ${INPUT}/$file ]; then
898 file_to_fix
=${INPUT}/$file
903 if [ \
! -z "$file_to_fix" ]; then
904 echo Checking
$file_to_fix
905 sed -e 's/extern struct \(strbuf\|uio\|thread\|proc\);/struct \1;/' $file_to_fix > /tmp
/$base
906 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
907 echo No change needed
in $file_to_fix
909 echo Fixed
$file_to_fix
911 cp /tmp
/$base ${LIB}/$file
916 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
919 base
=`basename $file`
920 if [ -r ${LIB}/$file ]; then
921 file_to_fix
=${LIB}/$file
923 if [ -r ${INPUT}/$file ]; then
924 file_to_fix
=${INPUT}/$file
929 if [ \
! -z "$file_to_fix" ]; then
930 echo Checking
$file_to_fix
931 cp $file_to_fix /tmp
/$base
938 stat (const char *path, struct stat *buf)
944 lstat (const char *path, struct stat *buf)
950 fstat (int fd, struct stat *buf)
952 /^mknod(path, mode, dev)/j
956 /^mknod(path, mode, dev)/c
957 mknod (const char *path, mode_t mode, dev_t dev)
962 1,\$s/ret\\([^u]\\)/__ret\1/g
963 1,\$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g
964 1,\$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g
967 echo Fixed
$file_to_fix
969 cp /tmp
/$base ${LIB}/$file
973 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
975 if [ -x /bin
/sony
]; then
978 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
981 base
=`basename $file`
982 if [ -r ${LIB}/$file ]; then
983 file_to_fix
=${LIB}/$file
985 if [ -r ${INPUT}/$file ]; then
986 file_to_fix
=${INPUT}/$file
991 if [ \
! -z "$file_to_fix" ]; then
992 echo Checking
$file_to_fix
993 cp $file_to_fix /tmp
/$base
999 ' /tmp
/$base > /tmp
/$base.
sed
1000 mv /tmp
/$base.
sed /tmp
/$base
1001 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1002 echo No change needed
in $file_to_fix
1004 echo Fixed
$file_to_fix
1006 cp /tmp
/$base ${LIB}/$file
1011 # Change <ctype.h> to not define __ctype
1014 base
=`basename $file`
1015 if [ -r ${LIB}/$file ]; then
1016 file_to_fix
=${LIB}/$file
1018 if [ -r ${INPUT}/$file ]; then
1019 file_to_fix
=${INPUT}/$file
1024 if [ \
! -z "$file_to_fix" ]; then
1025 echo Checking
$file_to_fix
1026 cp $file_to_fix /tmp
/$base
1030 ' /tmp
/$base > /tmp
/$base.
sed
1031 mv /tmp
/$base.
sed /tmp
/$base
1032 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1033 echo No change needed
in $file_to_fix
1035 echo Fixed
$file_to_fix
1037 cp /tmp
/$base ${LIB}/$file
1044 echo 'Removing unneeded directories:'
1046 files
=`find . -type d -print | sort -r`
1047 for file in $files; do
1048 rmdir $LIB/$file > /dev
/null
2>&1
1052 echo 'Making internal symbolic non-directory links'
1054 files
=`find . -type l -print`
1055 for file in $files; do
1056 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1057 if expr "$dest" : '[^/].*' > /dev
/null
; then
1058 target
=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1059 if [ -f $target ]; then
1060 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1068 echo 'Replacing <sys/byteorder.h>'
1069 rm -f ${LIB}/sys
/byteorder.h
1070 cp ${SRCDIR}/byteorder.h
${LIB}/sys
/byteorder.h