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
56 # Make LIB absolute if it is relative.
57 # Don't do this if not necessary, since may screw up automounters.
62 cd $LIB; LIB
=`${PWDCMD-pwd}`
66 # This prevents /bin/ex from failing if the current terminal type is
70 # This prevents /bin/ex from failing if the EXINIT environment variable
71 # was set to something invalid.
75 echo 'Building fixincludes in ' ${LIB}
77 # Determine whether this filesystem has symbolic links.
78 if ln -s X
$LIB/ShouldNotExist
2>/dev
/null
; then
79 rm -f $LIB/ShouldNotExist
85 echo 'Making directories:'
88 files
=`ls -LR | sed -n s/:$//p`
90 files
=`find . -type d -print | sed '/^.$/d'`
92 for file in $files; do
94 if [ ! -d $LIB/$file ]
99 # treetops gets an alternating list
100 # of old directories to copy
101 # and the new directories to copy to.
102 treetops
="${INPUT} ${LIB}"
105 echo 'Making internal symbolic directory links'
106 for file in $files; do
107 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
110 # In case $dest is relative, get to $file's dir first.
112 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
113 # Check that the target directory exists.
114 # Redirections changed to avoid bug in sh on Ultrix.
115 (cd $dest) > /dev
/null
2>&1
118 # X gets the dir that the link actually leads to.
120 # If link leads back into ${INPUT},
121 # make a similar link here.
122 if expr $x : "${INPUT}/.*" > /dev
/null
; then
123 # Y gets the actual target dir name, relative to ${INPUT}.
124 y
=`echo $x | sed -n "s&${INPUT}/&&p"`
125 echo $file '->' $y ': Making link'
126 rm -fr ${LIB}/$file > /dev
/null
2>&1
127 ln -s ${LIB}/$y ${LIB}/$file > /dev
/null
2>&1
129 # If the link is to outside ${INPUT},
130 # treat this directory as if it actually contained the files.
131 # This line used to have $dest instead of $x.
132 # $dest seemed to be wrong for links found in subdirectories
133 # of ${INPUT}. Does this change break anything?
134 treetops
="$treetops $x ${LIB}/$file"
143 while [ $# != 0 ]; do
144 # $1 is an old directory to copy, and $2 is the new directory to copy to.
145 echo "Finding header files in $1:"
148 files
=`find . -name '*.h' -type f -print`
149 echo 'Checking header files:'
150 for file in $files; do
151 if [ -r $file ]; then
152 cp $file $2/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
156 # The following have been removed from the sed command below
157 # because it is more useful to leave these things in.
158 # The only reason to remove them was for -pedantic,
159 # which isn't much of a reason. -- rms.
162 # This code makes Solaris SCSI fail, because it changes the
163 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
164 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
165 # Disable these also, since they probably aren't safe either.
166 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
167 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
168 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
169 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
171 # The change of u_char, etc, to u_int
172 # applies to bit fields.
174 s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
175 s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
176 s/#lint(on)/defined(lint)/g
177 s/#lint(off)/!defined(lint)/g
178 s/#machine(\([^)]*\))/defined(__\1__)/g
179 s/#system(\([^)]*\))/defined(__\1__)/g
180 s/#cpu(\([^)]*\))/defined(__\1__)/g
181 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
182 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
183 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
184 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
185 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
186 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
187 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
188 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
189 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
190 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
191 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
192 s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
193 s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
194 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
195 ' $2/$file > $2/$file.
sed
196 mv $2/$file.
sed $2/$file
197 if cmp $file $2/$file >/dev
/null
2>&1; then
207 # Fix first broken decl of getcwd present on some svr4 systems.
210 base
=`basename $file`
211 if [ -r ${LIB}/$file ]; then
212 file_to_fix
=${LIB}/$file
214 if [ -r ${INPUT}/$file ]; then
215 file_to_fix
=${INPUT}/$file
220 if [ \
! -z "$file_to_fix" ]; then
221 echo Checking
$file_to_fix
222 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp
/$base
223 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
226 echo Fixed
$file_to_fix
228 cp /tmp
/$base ${LIB}/$file
229 chmod a
+r
${LIB}/$file
234 # Fix second broken decl of getcwd present on some svr4 systems. Also
235 # fix the incorrect decl of profil present on some svr4 systems.
238 base
=`basename $file`
239 if [ -r ${LIB}/$file ]; then
240 file_to_fix
=${LIB}/$file
242 if [ -r ${INPUT}/$file ]; then
243 file_to_fix
=${INPUT}/$file
248 if [ \
! -z "$file_to_fix" ]; then
249 echo Checking
$file_to_fix
250 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
251 |
sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp
/$base
252 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
255 echo Fixed
$file_to_fix
257 cp /tmp
/$base ${LIB}/$file
258 chmod a
+r
${LIB}/$file
263 # Fix the definition of NULL in <sys/param.h> so that it is conditional
264 # and so that it is correct for both C and C++.
267 base
=`basename $file`
268 if [ -r ${LIB}/$file ]; then
269 file_to_fix
=${LIB}/$file
271 if [ -r ${INPUT}/$file ]; then
272 file_to_fix
=${INPUT}/$file
277 if [ \
! -z "$file_to_fix" ]; then
278 echo Checking
$file_to_fix
279 cp $file_to_fix /tmp
/$base
283 /^#define[ ]*NULL[ ]*0$/c
287 #else /* !defined(__cplusplus) */
288 #define __NULL_TYPE (void *)
289 #endif /* !defined(__cplusplus) */
290 #define NULL (__NULL_TYPE 0)
291 #endif /* !defined(NULL) */
295 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
298 echo Fixed
$file_to_fix
300 cp /tmp
/$base ${LIB}/$file
301 chmod a
+r
${LIB}/$file
306 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
307 # and so that it is correct for both C and C++.
310 base
=`basename $file`
311 if [ -r ${LIB}/$file ]; then
312 file_to_fix
=${LIB}/$file
314 if [ -r ${INPUT}/$file ]; then
315 file_to_fix
=${INPUT}/$file
320 if [ \
! -z "$file_to_fix" ]; then
321 echo Checking
$file_to_fix
322 cp $file_to_fix /tmp
/$base
325 /^#define[ ]*NULL[ ]*0$/c
328 #else /* !defined(__cplusplus) */
329 #define __NULL_TYPE (void *)
330 #endif /* !defined(__cplusplus) */
331 #define NULL (__NULL_TYPE 0)
335 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
338 echo Fixed
$file_to_fix
340 cp /tmp
/$base ${LIB}/$file
341 chmod a
+r
${LIB}/$file
346 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
347 # and so that it is correct for both C and C++.
350 base
=`basename $file`
351 if [ -r ${LIB}/$file ]; then
352 file_to_fix
=${LIB}/$file
354 if [ -r ${INPUT}/$file ]; then
355 file_to_fix
=${INPUT}/$file
360 if [ \
! -z "$file_to_fix" ]; then
361 echo Checking
$file_to_fix
362 cp $file_to_fix /tmp
/$base
365 /^#define[ ]*NULL[ ]*((char \*) 0)$/c
369 #else /* !defined(__cplusplus) */
370 #define __NULL_TYPE (void *)
371 #endif /* !defined(__cplusplus) */
372 #define NULL (__NULL_TYPE 0)
373 #endif /* !defined(NULL) */
377 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
380 echo Fixed
$file_to_fix
382 cp /tmp
/$base ${LIB}/$file
383 chmod a
+r
${LIB}/$file
388 # Add a prototyped declaration of mmap to <sys/mman.h>.
391 base
=`basename $file`
392 if [ -r ${LIB}/$file ]; then
393 file_to_fix
=${LIB}/$file
395 if [ -r ${INPUT}/$file ]; then
396 file_to_fix
=${INPUT}/$file
401 if [ \
! -z "$file_to_fix" ]; then
402 echo Checking
$file_to_fix
403 cp $file_to_fix /tmp
/$base
406 /^extern caddr_t mmap();$/c
408 extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,
410 #else /* !defined(__STDC__) */
411 extern caddr_t mmap ();
412 #endif /* !defined(__STDC__) */
416 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
419 echo Fixed
$file_to_fix
421 cp /tmp
/$base ${LIB}/$file
422 chmod a
+r
${LIB}/$file
427 # Fix declarations of `ftw' and `nftw' in <ftw.h>.
430 base
=`basename $file`
431 if [ -r ${LIB}/$file ]; then
432 file_to_fix
=${LIB}/$file
434 if [ -r ${INPUT}/$file ]; then
435 file_to_fix
=${INPUT}/$file
440 if [ \
! -z "$file_to_fix" ]; then
441 echo Checking
$file_to_fix
442 cp $file_to_fix /tmp
/$base
445 /^extern int ftw(const/c
446 #if !defined(_STYPES)
451 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
459 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);
461 /^extern int ftw(),/c
462 #if !defined(_STYPES)
477 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
480 echo Fixed
$file_to_fix
482 cp /tmp
/$base ${LIB}/$file
483 chmod a
+r
${LIB}/$file
488 # Add a `static' declaration of `getrnge' into <regexp.h>.
490 # Don't do this if there is already a `static void getrnge' declaration
491 # present, since this would cause a redeclaration error. Solaris 2.x has
492 # such a declaration.
495 base
=`basename $file`
496 if [ -r ${LIB}/$file ]; then
497 file_to_fix
=${LIB}/$file
499 if [ -r ${INPUT}/$file ]; then
500 file_to_fix
=${INPUT}/$file
505 if [ \
! -z "$file_to_fix" ]; then
506 echo Checking
$file_to_fix
507 if grep "static void getrnge" $file_to_fix > /dev
/null
; then
510 cp $file_to_fix /tmp
/$base
513 /^static int[ ]*size;/c
516 static int getrnge ();
520 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
523 echo Fixed
$file_to_fix
525 cp /tmp
/$base ${LIB}/$file
526 chmod a
+r
${LIB}/$file
532 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
533 # that is visible to any ANSI compiler using this include. Simply
534 # delete the lines the #define some string functions to internal forms.
537 base
=`basename $file`
538 if [ -r ${LIB}/$file ]; then
539 file_to_fix
=${LIB}/$file
541 if [ -r ${INPUT}/$file ]; then
542 file_to_fix
=${INPUT}/$file
547 if [ \
! -z "$file_to_fix" ]; then
548 echo Checking
$file_to_fix
549 cp $file_to_fix /tmp
/$base
552 g/#define.*__std_hdr_/d
555 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
558 echo Fixed
$file_to_fix
560 cp /tmp
/$base ${LIB}/$file
561 chmod a
+r
${LIB}/$file
566 # Add a #define of _SIGACTION_ into <sys/signal.h>.
567 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
570 base
=`basename $file`
571 if [ -r ${LIB}/$file ]; then
572 file_to_fix
=${LIB}/$file
574 if [ -r ${INPUT}/$file ]; then
575 file_to_fix
=${INPUT}/$file
580 if [ \
! -z "$file_to_fix" ]; then
581 echo Checking
$file_to_fix
582 cp $file_to_fix /tmp
/$base
585 /^struct sigaction {/c
589 1,\$s/(void *(\*)())/(void (*)(int))/
592 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
595 echo Fixed
$file_to_fix
597 cp /tmp
/$base ${LIB}/$file
598 chmod a
+r
${LIB}/$file
603 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
606 base
=`basename $file`
607 if [ -r ${LIB}/$file ]; then
608 file_to_fix
=${LIB}/$file
610 if [ -r ${INPUT}/$file ]; then
611 file_to_fix
=${INPUT}/$file
616 if [ \
! -z "$file_to_fix" ]; then
617 echo Checking
$file_to_fix
618 cp $file_to_fix /tmp
/$base
621 /^dev_t makedev(const/c
622 static dev_t makedev(const major_t, const minor_t);
625 static dev_t makedev();
627 /^major_t major(const/c
628 static major_t major(const dev_t);
631 static major_t major();
633 /^minor_t minor(const/c
634 static minor_t minor(const dev_t);
637 static minor_t minor();
641 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
644 echo Fixed
$file_to_fix
646 cp /tmp
/$base ${LIB}/$file
647 chmod a
+r
${LIB}/$file
652 # Fix reference to NMSZ in <sys/adv.h>.
655 base
=`basename $file`
656 if [ -r ${LIB}/$file ]; then
657 file_to_fix
=${LIB}/$file
659 if [ -r ${INPUT}/$file ]; then
660 file_to_fix
=${INPUT}/$file
665 if [ \
! -z "$file_to_fix" ]; then
666 echo Checking
$file_to_fix
667 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp
/$base
668 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
671 echo Fixed
$file_to_fix
673 cp /tmp
/$base ${LIB}/$file
674 chmod a
+r
${LIB}/$file
679 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
680 # array initializers.
683 base
=`basename $file`
684 if [ -r ${LIB}/$file ]; then
685 file_to_fix
=${LIB}/$file
687 if [ -r ${INPUT}/$file ]; then
688 file_to_fix
=${INPUT}/$file
693 if [ \
! -z "$file_to_fix" ]; then
694 echo Checking
$file_to_fix
695 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
696 |
sed 's/NC_/(unsigned long) NC_/' > /tmp
/$base
697 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
700 echo Fixed
$file_to_fix
702 cp /tmp
/$base ${LIB}/$file
703 chmod a
+r
${LIB}/$file
708 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
710 file=fs
/rfs
/rf_cache.h
711 base
=`basename $file`
712 if [ -r ${LIB}/$file ]; then
713 file_to_fix
=${LIB}/$file
715 if [ -r ${INPUT}/$file ]; then
716 file_to_fix
=${INPUT}/$file
721 if [ \
! -z "$file_to_fix" ]; then
722 echo Checking
$file_to_fix
723 if grep _KERNEL
$file_to_fix > /dev
/null
; then
726 echo '#ifdef _KERNEL' > /tmp
/$base
727 cat $file_to_fix >> /tmp
/$base
728 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
729 echo Fixed
$file_to_fix
731 cp /tmp
/$base ${LIB}/$file
732 chmod a
+r
${LIB}/$file
737 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
740 base
=`basename $file`
741 if [ -r ${LIB}/$file ]; then
742 file_to_fix
=${LIB}/$file
744 if [ -r ${INPUT}/$file ]; then
745 file_to_fix
=${INPUT}/$file
750 if [ \
! -z "$file_to_fix" ]; then
751 echo Checking
$file_to_fix
752 if grep _KERNEL
$file_to_fix > /dev
/null
; then
755 echo '#ifdef _KERNEL' > /tmp
/$base
756 cat $file_to_fix >> /tmp
/$base
757 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
758 echo Fixed
$file_to_fix
760 cp /tmp
/$base ${LIB}/$file
761 chmod a
+r
${LIB}/$file
766 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
769 base
=`basename $file`
770 if [ -r ${LIB}/$file ]; then
771 file_to_fix
=${LIB}/$file
773 if [ -r ${INPUT}/$file ]; then
774 file_to_fix
=${INPUT}/$file
779 if [ \
! -z "$file_to_fix" ]; then
780 echo Checking
$file_to_fix
781 if grep _KERNEL
$file_to_fix > /dev
/null
; then
784 echo '#ifdef _KERNEL' > /tmp
/$base
785 cat $file_to_fix >> /tmp
/$base
786 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
787 echo Fixed
$file_to_fix
789 cp /tmp
/$base ${LIB}/$file
790 chmod a
+r
${LIB}/$file
795 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
798 base
=`basename $file`
799 if [ -r ${LIB}/$file ]; then
800 file_to_fix
=${LIB}/$file
802 if [ -r ${INPUT}/$file ]; then
803 file_to_fix
=${INPUT}/$file
808 if [ \
! -z "$file_to_fix" ]; then
809 echo Checking
$file_to_fix
810 if grep _KERNEL
$file_to_fix > /dev
/null
; then
813 echo '#ifdef _KERNEL' > /tmp
/$base
814 cat $file_to_fix >> /tmp
/$base
815 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
816 echo Fixed
$file_to_fix
818 cp /tmp
/$base ${LIB}/$file
819 chmod a
+r
${LIB}/$file
824 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
827 base
=`basename $file`
828 if [ -r ${LIB}/$file ]; then
829 file_to_fix
=${LIB}/$file
831 if [ -r ${INPUT}/$file ]; then
832 file_to_fix
=${INPUT}/$file
837 if [ \
! -z "$file_to_fix" ]; then
838 echo Checking
$file_to_fix
839 if grep _KERNEL
$file_to_fix > /dev
/null
; then
842 echo '#ifdef _KERNEL' > /tmp
/$base
843 cat $file_to_fix >> /tmp
/$base
844 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
845 echo Fixed
$file_to_fix
847 cp /tmp
/$base ${LIB}/$file
848 chmod a
+r
${LIB}/$file
853 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
856 base
=`basename $file`
857 if [ -r ${LIB}/$file ]; then
858 file_to_fix
=${LIB}/$file
860 if [ -r ${INPUT}/$file ]; then
861 file_to_fix
=${INPUT}/$file
866 if [ \
! -z "$file_to_fix" ]; then
867 echo Checking
$file_to_fix
868 if grep _KERNEL
$file_to_fix > /dev
/null
; then
871 echo '#ifdef _KERNEL' > /tmp
/$base
872 cat $file_to_fix >> /tmp
/$base
873 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
874 echo Fixed
$file_to_fix
876 cp /tmp
/$base ${LIB}/$file
877 chmod a
+r
${LIB}/$file
882 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
885 base
=`basename $file`
886 if [ -r ${LIB}/$file ]; then
887 file_to_fix
=${LIB}/$file
889 if [ -r ${INPUT}/$file ]; then
890 file_to_fix
=${INPUT}/$file
895 if [ \
! -z "$file_to_fix" ]; then
896 echo Checking
$file_to_fix
897 if grep _KERNEL
$file_to_fix > /dev
/null
; then
900 echo '#ifdef _KERNEL' > /tmp
/$base
901 cat $file_to_fix >> /tmp
/$base
902 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
903 echo Fixed
$file_to_fix
905 cp /tmp
/$base ${LIB}/$file
906 chmod a
+r
${LIB}/$file
911 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
914 base
=`basename $file`
915 if [ -r ${LIB}/$file ]; then
916 file_to_fix
=${LIB}/$file
918 if [ -r ${INPUT}/$file ]; then
919 file_to_fix
=${INPUT}/$file
924 if [ \
! -z "$file_to_fix" ]; then
925 echo Checking
$file_to_fix
926 if grep _KERNEL
$file_to_fix > /dev
/null
; then
929 echo '#ifdef _KERNEL' > /tmp
/$base
930 cat $file_to_fix >> /tmp
/$base
931 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
932 echo Fixed
$file_to_fix
934 cp /tmp
/$base ${LIB}/$file
935 chmod a
+r
${LIB}/$file
940 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
943 base
=`basename $file`
944 if [ -r ${LIB}/$file ]; then
945 file_to_fix
=${LIB}/$file
947 if [ -r ${INPUT}/$file ]; then
948 file_to_fix
=${INPUT}/$file
953 if [ \
! -z "$file_to_fix" ]; then
954 echo Checking
$file_to_fix
955 if grep _KERNEL
$file_to_fix > /dev
/null
; then
958 sed -e '/#ifdef INKERNEL/i\
960 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
961 #endif /* _KERNEL */' \
962 $file_to_fix > ${LIB}/${file}.
sed
963 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
964 echo Fixed
$file_to_fix
968 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
971 base
=`basename $file`
972 if [ -r ${LIB}/$file ]; then
973 file_to_fix
=${LIB}/$file
975 if [ -r ${INPUT}/$file ]; then
976 file_to_fix
=${INPUT}/$file
981 if [ \
! -z "$file_to_fix" ]; then
982 echo Checking
$file_to_fix
983 if grep __GNUC__
$file_to_fix > /dev
/null
; then
986 sed -e '/# ifdef __STDC__/i\
987 # if !defined (__GNUC__) && !defined (__GNUG__)' \
988 -e '/# include <sys\/byteorder.h>/s/ / /'\
989 -e '/# include <sys\/byteorder.h>/i\
990 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
991 $file_to_fix > ${LIB}/${file}.
sed
992 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
993 echo Fixed
$file_to_fix
997 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
998 # and the text in types.h is not erroneous.
999 ## In sys/types.h, don't name the enum for booleans.
1002 #base=`basename $file`
1003 #if [ -r ${LIB}/$file ]; then
1004 # file_to_fix=${LIB}/$file
1006 # if [ -r ${INPUT}/$file ]; then
1007 # file_to_fix=${INPUT}/$file
1012 #if [ \! -z "$file_to_fix" ]; then
1013 # echo Checking $file_to_fix
1014 # if grep "enum boolean" $file_to_fix > /dev/null; then
1015 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1016 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1017 # echo Fixed $file_to_fix
1023 # Remove useless extern keyword from struct forward declarations in
1024 # <sys/stream.h> and <sys/strsubr.h>
1027 base
=`basename $file`
1028 if [ -r ${LIB}/$file ]; then
1029 file_to_fix
=${LIB}/$file
1031 if [ -r ${INPUT}/$file ]; then
1032 file_to_fix
=${INPUT}/$file
1037 if [ \
! -z "$file_to_fix" ]; then
1038 echo Checking
$file_to_fix
1040 s/extern struct stdata;/struct stdata;/g
1041 s/extern struct strevent;/struct strevent;/g
1042 ' $file_to_fix > /tmp
/$base
1043 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1046 echo Fixed
$file_to_fix
1048 cp /tmp
/$base ${LIB}/$file
1049 chmod a
+r
${LIB}/$file
1055 base
=`basename $file`
1056 if [ -r ${LIB}/$file ]; then
1057 file_to_fix
=${LIB}/$file
1059 if [ -r ${INPUT}/$file ]; then
1060 file_to_fix
=${INPUT}/$file
1065 if [ \
! -z "$file_to_fix" ]; then
1066 echo Checking
$file_to_fix
1068 s/extern struct strbuf;/struct strbuf;/g
1069 s/extern struct uio;/struct uio;/g
1070 s/extern struct thread;/struct thread;/g
1071 s/extern struct proc;/struct proc;/g
1072 ' $file_to_fix > /tmp
/$base
1073 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1076 echo Fixed
$file_to_fix
1078 cp /tmp
/$base ${LIB}/$file
1079 chmod a
+r
${LIB}/$file
1084 # Put storage class at start of decl, to avoid warning.
1086 base
=`basename $file`
1087 if [ -r ${LIB}/$file ]; then
1088 file_to_fix
=${LIB}/$file
1090 if [ -r ${INPUT}/$file ]; then
1091 file_to_fix
=${INPUT}/$file
1096 if [ \
! -z "$file_to_fix" ]; then
1097 echo Checking
$file_to_fix
1099 s/const extern/extern const/g
1100 ' $file_to_fix > /tmp
/$base
1101 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1104 echo Fixed
$file_to_fix
1106 cp /tmp
/$base ${LIB}/$file
1107 chmod a
+r
${LIB}/$file
1112 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1115 base
=`basename $file`
1116 if [ -r ${LIB}/$file ]; then
1117 file_to_fix
=${LIB}/$file
1119 if [ -r ${INPUT}/$file ]; then
1120 file_to_fix
=${INPUT}/$file
1125 if [ \
! -z "$file_to_fix" ]; then
1126 echo Checking
$file_to_fix
1127 cp $file_to_fix /tmp
/$base
1156 1,\$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g
1157 1,\$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g
1158 1,\$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g
1159 1,\$s/ret\([^u]\)/__ret\1/g
1160 1,\$s/\([^_]\)mode\([^_]\)/\1__mode\2/g
1161 1,\$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g
1164 echo Fixed
$file_to_fix
1166 cp /tmp
/$base ${LIB}/$file
1167 chmod a
+r
${LIB}/$file
1171 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1173 if [ -x /bin
/sony
]; then
1176 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1179 base
=`basename $file`
1180 if [ -r ${LIB}/$file ]; then
1181 file_to_fix
=${LIB}/$file
1183 if [ -r ${INPUT}/$file ]; then
1184 file_to_fix
=${INPUT}/$file
1189 if [ \
! -z "$file_to_fix" ]; then
1190 echo Checking
$file_to_fix
1191 cp $file_to_fix /tmp
/$base
1194 s/__filbuf/_filbuf/g
1195 s/__flsbuf/_flsbuf/g
1197 ' /tmp
/$base > /tmp
/$base.
sed
1198 mv /tmp
/$base.
sed /tmp
/$base
1199 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1202 echo Fixed
$file_to_fix
1204 cp /tmp
/$base ${LIB}/$file
1205 chmod a
+r
${LIB}/$file
1210 # Change <ctype.h> to not define __ctype
1213 base
=`basename $file`
1214 if [ -r ${LIB}/$file ]; then
1215 file_to_fix
=${LIB}/$file
1217 if [ -r ${INPUT}/$file ]; then
1218 file_to_fix
=${INPUT}/$file
1223 if [ \
! -z "$file_to_fix" ]; then
1224 echo Checking
$file_to_fix
1225 cp $file_to_fix /tmp
/$base
1229 ' /tmp
/$base > /tmp
/$base.
sed
1230 mv /tmp
/$base.
sed /tmp
/$base
1231 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1234 echo Fixed
$file_to_fix
1236 cp /tmp
/$base ${LIB}/$file
1237 chmod a
+r
${LIB}/$file
1244 # In limits.h, put #ifndefs around things that are supposed to be defined
1245 # in float.h to avoid redefinition errors if float.h is included first.
1246 # Solaris 2.1 has this problem.
1249 base
=`basename $file`
1250 if [ -r ${LIB}/$file ]; then
1251 file_to_fix
=${LIB}/$file
1253 if [ -r ${INPUT}/$file ]; then
1254 file_to_fix
=${INPUT}/$file
1259 if [ \
! -z "$file_to_fix" ]; then
1260 echo Checking
$file_to_fix
1261 sed -e '/[ ]FLT_MIN[ ]/i\
1263 -e '/[ ]FLT_MIN[ ]/a\
1265 -e '/[ ]FLT_MAX[ ]/i\
1267 -e '/[ ]FLT_MAX[ ]/a\
1269 -e '/[ ]FLT_DIG[ ]/i\
1271 -e '/[ ]FLT_DIG[ ]/a\
1273 -e '/[ ]DBL_MIN[ ]/i\
1275 -e '/[ ]DBL_MIN[ ]/a\
1277 -e '/[ ]DBL_MAX[ ]/i\
1279 -e '/[ ]DBL_MAX[ ]/a\
1281 -e '/[ ]DBL_DIG[ ]/i\
1283 -e '/[ ]DBL_DIG[ ]/a\
1284 #endif' $file_to_fix > /tmp
/$base
1285 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1288 echo Fixed
$file_to_fix
1290 cp /tmp
/$base ${LIB}/$file
1291 chmod a
+r
${LIB}/$file
1296 echo 'Removing unneeded directories:'
1298 files
=`find . -type d -print | sort -r`
1299 for file in $files; do
1300 rmdir $LIB/$file > /dev
/null
2>&1
1304 echo 'Making internal symbolic non-directory links'
1306 files
=`find . -type l -print`
1307 for file in $files; do
1308 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1309 if expr "$dest" : '[^/].*' > /dev
/null
; then
1310 target
=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1311 if [ -f $target ]; then
1312 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1320 echo 'Replacing <sys/byteorder.h>'
1321 rm -f ${LIB}/sys
/byteorder.h
1322 cp ${SRCDIR}/byteorder.h
${LIB}/sys
/byteorder.h