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>.
470 # Don't do this if there is already a `static void getrnge' declaration
471 # present, since this would cause a redeclaration error. Solaris 2.x has
472 # such a declaration.
475 base
=`basename $file`
476 if [ -r ${LIB}/$file ]; then
477 file_to_fix
=${LIB}/$file
479 if [ -r ${INPUT}/$file ]; then
480 file_to_fix
=${INPUT}/$file
485 if [ \
! -z "$file_to_fix" ]; then
486 echo Checking
$file_to_fix
487 if grep "static void getrnge" $file_to_fix > /dev
/null
; then
490 cp $file_to_fix /tmp
/$base
493 /^static int[ ]*size;/c
496 static int getrnge ();
500 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
501 No change needed
in $file_to_fix
503 echo Fixed
$file_to_fix
505 cp /tmp
/$base ${LIB}/$file
511 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
512 # that is visible to any ANSI compiler using this include. Simply
513 # delete the lines the #define some string functions to internal forms.
516 base
=`basename $file`
517 if [ -r ${LIB}/$file ]; then
518 file_to_fix
=${LIB}/$file
520 if [ -r ${INPUT}/$file ]; then
521 file_to_fix
=${INPUT}/$file
526 if [ \
! -z "$file_to_fix" ]; then
527 echo Checking
$file_to_fix
528 cp $file_to_fix /tmp
/$base
531 g/#define.*__std_hdr_/d
534 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
535 echo No change needed
in $file_to_fix
537 echo Fixed
$file_to_fix
539 cp /tmp
/$base ${LIB}/$file
544 # Add a #define of _SIGACTION_ into <sys/signal.h>.
545 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
548 base
=`basename $file`
549 if [ -r ${LIB}/$file ]; then
550 file_to_fix
=${LIB}/$file
552 if [ -r ${INPUT}/$file ]; then
553 file_to_fix
=${INPUT}/$file
558 if [ \
! -z "$file_to_fix" ]; then
559 echo Checking
$file_to_fix
560 cp $file_to_fix /tmp
/$base
563 /^struct sigaction {/c
567 1,\$s/(void *(\*)())/(void (*)(int))/
570 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
571 echo No change needed
in $file_to_fix
573 echo Fixed
$file_to_fix
575 cp /tmp
/$base ${LIB}/$file
580 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
583 base
=`basename $file`
584 if [ -r ${LIB}/$file ]; then
585 file_to_fix
=${LIB}/$file
587 if [ -r ${INPUT}/$file ]; then
588 file_to_fix
=${INPUT}/$file
593 if [ \
! -z "$file_to_fix" ]; then
594 echo Checking
$file_to_fix
595 cp $file_to_fix /tmp
/$base
598 /^dev_t makedev(const/c
599 static dev_t makedev(const major_t, const minor_t);
602 static dev_t makedev();
604 /^major_t major(const/c
605 static major_t major(const dev_t);
608 static major_t major();
610 /^minor_t minor(const/c
611 static minor_t minor(const dev_t);
614 static minor_t minor();
618 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
619 echo No change needed
in $file_to_fix
621 echo Fixed
$file_to_fix
623 cp /tmp
/$base ${LIB}/$file
628 # Fix reference to NMSZ in <sys/adv.h>.
631 base
=`basename $file`
632 if [ -r ${LIB}/$file ]; then
633 file_to_fix
=${LIB}/$file
635 if [ -r ${INPUT}/$file ]; then
636 file_to_fix
=${INPUT}/$file
641 if [ \
! -z "$file_to_fix" ]; then
642 echo Checking
$file_to_fix
643 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp
/$base
644 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
645 echo No change needed
in $file_to_fix
647 echo Fixed
$file_to_fix
649 cp /tmp
/$base ${LIB}/$file
654 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
655 # array initializers.
658 base
=`basename $file`
659 if [ -r ${LIB}/$file ]; then
660 file_to_fix
=${LIB}/$file
662 if [ -r ${INPUT}/$file ]; then
663 file_to_fix
=${INPUT}/$file
668 if [ \
! -z "$file_to_fix" ]; then
669 echo Checking
$file_to_fix
670 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
671 |
sed 's/NC_/(unsigned long) NC_/' > /tmp
/$base
672 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
673 echo No change needed
in $file_to_fix
675 echo Fixed
$file_to_fix
677 cp /tmp
/$base ${LIB}/$file
682 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
684 file=fs
/rfs
/rf_cache.h
685 base
=`basename $file`
686 if [ -r ${LIB}/$file ]; then
687 file_to_fix
=${LIB}/$file
689 if [ -r ${INPUT}/$file ]; then
690 file_to_fix
=${INPUT}/$file
695 if [ \
! -z "$file_to_fix" ]; then
696 echo Checking
$file_to_fix
697 if grep _KERNEL
$file_to_fix > /dev
/null
; then
698 echo No change needed
in $file_to_fix
700 echo '#ifdef _KERNEL' > /tmp
/$base
701 cat $file_to_fix >> /tmp
/$base
702 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
703 echo Fixed
$file_to_fix
705 cp /tmp
/$base ${LIB}/$file
710 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
713 base
=`basename $file`
714 if [ -r ${LIB}/$file ]; then
715 file_to_fix
=${LIB}/$file
717 if [ -r ${INPUT}/$file ]; then
718 file_to_fix
=${INPUT}/$file
723 if [ \
! -z "$file_to_fix" ]; then
724 echo Checking
$file_to_fix
725 if grep _KERNEL
$file_to_fix > /dev
/null
; then
726 echo No change needed
in $file_to_fix
728 echo '#ifdef _KERNEL' > /tmp
/$base
729 cat $file_to_fix >> /tmp
/$base
730 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
731 echo Fixed
$file_to_fix
733 cp /tmp
/$base ${LIB}/$file
738 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
741 base
=`basename $file`
742 if [ -r ${LIB}/$file ]; then
743 file_to_fix
=${LIB}/$file
745 if [ -r ${INPUT}/$file ]; then
746 file_to_fix
=${INPUT}/$file
751 if [ \
! -z "$file_to_fix" ]; then
752 echo Checking
$file_to_fix
753 if grep _KERNEL
$file_to_fix > /dev
/null
; then
754 echo No change needed
in $file_to_fix
756 echo '#ifdef _KERNEL' > /tmp
/$base
757 cat $file_to_fix >> /tmp
/$base
758 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
759 echo Fixed
$file_to_fix
761 cp /tmp
/$base ${LIB}/$file
766 # Conditionalize all of <sys/char.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
782 echo No change needed
in $file_to_fix
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
794 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
797 base
=`basename $file`
798 if [ -r ${LIB}/$file ]; then
799 file_to_fix
=${LIB}/$file
801 if [ -r ${INPUT}/$file ]; then
802 file_to_fix
=${INPUT}/$file
807 if [ \
! -z "$file_to_fix" ]; then
808 echo Checking
$file_to_fix
809 if grep _KERNEL
$file_to_fix > /dev
/null
; then
810 echo No change needed
in $file_to_fix
812 echo '#ifdef _KERNEL' > /tmp
/$base
813 cat $file_to_fix >> /tmp
/$base
814 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
815 echo Fixed
$file_to_fix
817 cp /tmp
/$base ${LIB}/$file
822 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
825 base
=`basename $file`
826 if [ -r ${LIB}/$file ]; then
827 file_to_fix
=${LIB}/$file
829 if [ -r ${INPUT}/$file ]; then
830 file_to_fix
=${INPUT}/$file
835 if [ \
! -z "$file_to_fix" ]; then
836 echo Checking
$file_to_fix
837 if grep _KERNEL
$file_to_fix > /dev
/null
; then
838 echo No change needed
in $file_to_fix
840 echo '#ifdef _KERNEL' > /tmp
/$base
841 cat $file_to_fix >> /tmp
/$base
842 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
843 echo Fixed
$file_to_fix
845 cp /tmp
/$base ${LIB}/$file
850 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
853 base
=`basename $file`
854 if [ -r ${LIB}/$file ]; then
855 file_to_fix
=${LIB}/$file
857 if [ -r ${INPUT}/$file ]; then
858 file_to_fix
=${INPUT}/$file
863 if [ \
! -z "$file_to_fix" ]; then
864 echo Checking
$file_to_fix
865 if grep _KERNEL
$file_to_fix > /dev
/null
; then
866 echo No change needed
in $file_to_fix
868 echo '#ifdef _KERNEL' > /tmp
/$base
869 cat $file_to_fix >> /tmp
/$base
870 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
871 echo Fixed
$file_to_fix
873 cp /tmp
/$base ${LIB}/$file
878 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
881 base
=`basename $file`
882 if [ -r ${LIB}/$file ]; then
883 file_to_fix
=${LIB}/$file
885 if [ -r ${INPUT}/$file ]; then
886 file_to_fix
=${INPUT}/$file
891 if [ \
! -z "$file_to_fix" ]; then
892 echo Checking
$file_to_fix
893 if grep _KERNEL
$file_to_fix > /dev
/null
; then
894 echo No change needed
in $file_to_fix
896 echo '#ifdef _KERNEL' > /tmp
/$base
897 cat $file_to_fix >> /tmp
/$base
898 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
899 echo Fixed
$file_to_fix
901 cp /tmp
/$base ${LIB}/$file
906 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
909 base
=`basename $file`
910 if [ -r ${LIB}/$file ]; then
911 file_to_fix
=${LIB}/$file
913 if [ -r ${INPUT}/$file ]; then
914 file_to_fix
=${INPUT}/$file
919 if [ \
! -z "$file_to_fix" ]; then
920 echo Checking
$file_to_fix
921 if grep _KERNEL
$file_to_fix > /dev
/null
; then
922 echo No change needed
in $file_to_fix
924 sed -e '/#ifdef INKERNEL/i\
926 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
927 #endif /* _KERNEL */' \
928 $file_to_fix > ${LIB}/${file}.
sed
929 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
930 echo Fixed
$file_to_fix
934 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
937 base
=`basename $file`
938 if [ -r ${LIB}/$file ]; then
939 file_to_fix
=${LIB}/$file
941 if [ -r ${INPUT}/$file ]; then
942 file_to_fix
=${INPUT}/$file
947 if [ \
! -z "$file_to_fix" ]; then
948 echo Checking
$file_to_fix
949 if grep __GNUC__
$file_to_fix > /dev
/null
; then
950 echo No change needed
in $file_to_fix
952 sed -e '/# ifdef __STDC__/i\
953 # if !defined (__GNUC__) && !defined (__GNUG__)' \
954 -e '/# include <sys\/byteorder.h>/s/ / /'\
955 -e '/# include <sys\/byteorder.h>/i\
956 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
957 $file_to_fix > ${LIB}/${file}.
sed
958 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
959 echo Fixed
$file_to_fix
963 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
964 # and the text in types.h is not erroneous.
965 ## In sys/types.h, don't name the enum for booleans.
968 #base=`basename $file`
969 #if [ -r ${LIB}/$file ]; then
970 # file_to_fix=${LIB}/$file
972 # if [ -r ${INPUT}/$file ]; then
973 # file_to_fix=${INPUT}/$file
978 #if [ \! -z "$file_to_fix" ]; then
979 # echo Checking $file_to_fix
980 # if grep "enum boolean" $file_to_fix > /dev/null; then
981 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
982 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
983 # echo Fixed $file_to_fix
985 # echo No change needed in $file_to_fix
989 # Remove useless extern keyword from struct forward declarations in
990 # <sys/stream.h> and <sys/strsubr.h>
993 base
=`basename $file`
994 if [ -r ${LIB}/$file ]; then
995 file_to_fix
=${LIB}/$file
997 if [ -r ${INPUT}/$file ]; then
998 file_to_fix
=${INPUT}/$file
1003 if [ \
! -z "$file_to_fix" ]; then
1004 echo Checking
$file_to_fix
1006 s/extern struct stdata;/struct stdata;/g
1007 s/extern struct strevent;/struct strevent;/g
1008 ' $file_to_fix > /tmp
/$base
1009 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1010 echo No change needed
in $file_to_fix
1012 echo Fixed
$file_to_fix
1014 cp /tmp
/$base ${LIB}/$file
1020 base
=`basename $file`
1021 if [ -r ${LIB}/$file ]; then
1022 file_to_fix
=${LIB}/$file
1024 if [ -r ${INPUT}/$file ]; then
1025 file_to_fix
=${INPUT}/$file
1030 if [ \
! -z "$file_to_fix" ]; then
1031 echo Checking
$file_to_fix
1033 s/extern struct strbuf;/struct strbuf;/g
1034 s/extern struct uio;/struct uio;/g
1035 s/extern struct thread;/struct thread;/g
1036 s/extern struct proc;/struct proc;/g
1037 ' $file_to_fix > /tmp
/$base
1038 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1039 echo No change needed
in $file_to_fix
1041 echo Fixed
$file_to_fix
1043 cp /tmp
/$base ${LIB}/$file
1048 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1051 base
=`basename $file`
1052 if [ -r ${LIB}/$file ]; then
1053 file_to_fix
=${LIB}/$file
1055 if [ -r ${INPUT}/$file ]; then
1056 file_to_fix
=${INPUT}/$file
1061 if [ \
! -z "$file_to_fix" ]; then
1062 echo Checking
$file_to_fix
1063 cp $file_to_fix /tmp
/$base
1070 stat (const char *path, struct stat *buf)
1072 /^lstat(path, buf)/j
1075 /^lstat(path, buf)/c
1076 lstat (const char *path, struct stat *buf)
1082 fstat (int fd, struct stat *buf)
1084 /^mknod(path, mode, dev)/j
1088 /^mknod(path, mode, dev)/c
1089 mknod (const char *path, mode_t mode, dev_t dev)
1094 1,\$s/ret\\([^u]\\)/__ret\1/g
1095 1,\$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g
1096 1,\$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g
1099 echo Fixed
$file_to_fix
1101 cp /tmp
/$base ${LIB}/$file
1105 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1107 if [ -x /bin
/sony
]; then
1110 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1113 base
=`basename $file`
1114 if [ -r ${LIB}/$file ]; then
1115 file_to_fix
=${LIB}/$file
1117 if [ -r ${INPUT}/$file ]; then
1118 file_to_fix
=${INPUT}/$file
1123 if [ \
! -z "$file_to_fix" ]; then
1124 echo Checking
$file_to_fix
1125 cp $file_to_fix /tmp
/$base
1128 s/__filbuf/_filbuf/g
1129 s/__flsbuf/_flsbuf/g
1131 ' /tmp
/$base > /tmp
/$base.
sed
1132 mv /tmp
/$base.
sed /tmp
/$base
1133 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1134 echo No change needed
in $file_to_fix
1136 echo Fixed
$file_to_fix
1138 cp /tmp
/$base ${LIB}/$file
1143 # Change <ctype.h> to not define __ctype
1146 base
=`basename $file`
1147 if [ -r ${LIB}/$file ]; then
1148 file_to_fix
=${LIB}/$file
1150 if [ -r ${INPUT}/$file ]; then
1151 file_to_fix
=${INPUT}/$file
1156 if [ \
! -z "$file_to_fix" ]; then
1157 echo Checking
$file_to_fix
1158 cp $file_to_fix /tmp
/$base
1162 ' /tmp
/$base > /tmp
/$base.
sed
1163 mv /tmp
/$base.
sed /tmp
/$base
1164 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1165 echo No change needed
in $file_to_fix
1167 echo Fixed
$file_to_fix
1169 cp /tmp
/$base ${LIB}/$file
1176 # In limits.h, put #ifndefs around things that are supposed to be defined
1177 # in float.h to avoid redefinition errors if float.h is included first.
1178 # Solaris 2.1 has this problem.
1181 base
=`basename $file`
1182 if [ -r ${LIB}/$file ]; then
1183 file_to_fix
=${LIB}/$file
1185 if [ -r ${INPUT}/$file ]; then
1186 file_to_fix
=${INPUT}/$file
1191 if [ \
! -z "$file_to_fix" ]; then
1192 echo Checking
$file_to_fix
1193 sed -e '/[ ]FLT_MIN[ ]/i\
1195 -e '/[ ]FLT_MIN[ ]/a\
1197 -e '/[ ]FLT_MAX[ ]/i\
1199 -e '/[ ]FLT_MAX[ ]/a\
1201 -e '/[ ]FLT_DIG[ ]/i\
1203 -e '/[ ]FLT_DIG[ ]/a\
1205 -e '/[ ]DBL_MIN[ ]/i\
1207 -e '/[ ]DBL_MIN[ ]/a\
1209 -e '/[ ]DBL_MAX[ ]/i\
1211 -e '/[ ]DBL_MAX[ ]/a\
1213 -e '/[ ]DBL_DIG[ ]/i\
1215 -e '/[ ]DBL_DIG[ ]/a\
1216 #endif' $file_to_fix > /tmp
/$base
1217 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1218 echo No change needed
in $file_to_fix
1220 echo Fixed
$file_to_fix
1222 cp /tmp
/$base ${LIB}/$file
1227 echo 'Removing unneeded directories:'
1229 files
=`find . -type d -print | sort -r`
1230 for file in $files; do
1231 rmdir $LIB/$file > /dev
/null
2>&1
1235 echo 'Making internal symbolic non-directory links'
1237 files
=`find . -type l -print`
1238 for file in $files; do
1239 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1240 if expr "$dest" : '[^/].*' > /dev
/null
; then
1241 target
=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1242 if [ -f $target ]; then
1243 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1251 echo 'Replacing <sys/byteorder.h>'
1252 rm -f ${LIB}/sys
/byteorder.h
1253 cp ${SRCDIR}/byteorder.h
${LIB}/sys
/byteorder.h