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}`
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
152 if [ -r $file ]; then
153 cp $file $2/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
157 # The following have been removed from the sed command below
158 # because it is more useful to leave these things in.
159 # The only reason to remove them was for -pedantic,
160 # which isn't much of a reason. -- rms.
163 # This code makes Solaris SCSI fail, because it changes the
164 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
165 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
166 # Disable these also, since they probably aren't safe either.
167 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
168 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
169 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
170 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
172 # The change of u_char, etc, to u_int
173 # applies to bit fields.
175 s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
176 s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
177 s/#lint(on)/defined(lint)/g
178 s/#lint(off)/!defined(lint)/g
179 s/#machine(\([^)]*\))/defined(__\1__)/g
180 s/#system(\([^)]*\))/defined(__\1__)/g
181 s/#cpu(\([^)]*\))/defined(__\1__)/g
182 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
183 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
184 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
185 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
186 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
187 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
188 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
189 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
190 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
191 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
192 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
193 s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
194 s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
195 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
196 ' $2/$file > $2/$file.
sed
197 mv $2/$file.
sed $2/$file
198 if cmp $file $2/$file >/dev
/null
2>&1; then
206 # Fix first broken decl of getcwd present on some svr4 systems.
209 base
=`basename $file`
210 if [ -r ${LIB}/$file ]; then
211 file_to_fix
=${LIB}/$file
213 if [ -r ${INPUT}/$file ]; then
214 file_to_fix
=${INPUT}/$file
219 if [ \
! -z "$file_to_fix" ]; then
220 echo Checking
$file_to_fix
221 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp
/$base
222 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
225 echo Fixed
$file_to_fix
227 cp /tmp
/$base ${LIB}/$file
228 chmod a
+r
${LIB}/$file
233 # Fix second broken decl of getcwd present on some svr4 systems. Also
234 # fix the incorrect decl of profil present on some svr4 systems.
237 base
=`basename $file`
238 if [ -r ${LIB}/$file ]; then
239 file_to_fix
=${LIB}/$file
241 if [ -r ${INPUT}/$file ]; then
242 file_to_fix
=${INPUT}/$file
247 if [ \
! -z "$file_to_fix" ]; then
248 echo Checking
$file_to_fix
249 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
250 |
sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp
/$base
251 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
254 echo Fixed
$file_to_fix
256 cp /tmp
/$base ${LIB}/$file
257 chmod a
+r
${LIB}/$file
262 # Fix the definition of NULL in <sys/param.h> so that it is conditional
263 # and so that it is correct for both C and C++.
266 base
=`basename $file`
267 if [ -r ${LIB}/$file ]; then
268 file_to_fix
=${LIB}/$file
270 if [ -r ${INPUT}/$file ]; then
271 file_to_fix
=${INPUT}/$file
276 if [ \
! -z "$file_to_fix" ]; then
277 echo Checking
$file_to_fix
278 cp $file_to_fix /tmp
/$base
282 /^#define[ ]*NULL[ ]*0$/c
286 #else /* !defined(__cplusplus) */
287 #define __NULL_TYPE (void *)
288 #endif /* !defined(__cplusplus) */
289 #define NULL (__NULL_TYPE 0)
290 #endif /* !defined(NULL) */
294 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
297 echo Fixed
$file_to_fix
299 cp /tmp
/$base ${LIB}/$file
300 chmod a
+r
${LIB}/$file
305 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
306 # and so that it is correct for both C and C++.
309 base
=`basename $file`
310 if [ -r ${LIB}/$file ]; then
311 file_to_fix
=${LIB}/$file
313 if [ -r ${INPUT}/$file ]; then
314 file_to_fix
=${INPUT}/$file
319 if [ \
! -z "$file_to_fix" ]; then
320 echo Checking
$file_to_fix
321 cp $file_to_fix /tmp
/$base
324 /^#define[ ]*NULL[ ]*0$/c
327 #else /* !defined(__cplusplus) */
328 #define __NULL_TYPE (void *)
329 #endif /* !defined(__cplusplus) */
330 #define NULL (__NULL_TYPE 0)
334 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
337 echo Fixed
$file_to_fix
339 cp /tmp
/$base ${LIB}/$file
340 chmod a
+r
${LIB}/$file
345 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
346 # and so that it is correct for both C and C++.
349 base
=`basename $file`
350 if [ -r ${LIB}/$file ]; then
351 file_to_fix
=${LIB}/$file
353 if [ -r ${INPUT}/$file ]; then
354 file_to_fix
=${INPUT}/$file
359 if [ \
! -z "$file_to_fix" ]; then
360 echo Checking
$file_to_fix
361 cp $file_to_fix /tmp
/$base
364 /^#define[ ]*NULL[ ]*((char \*) 0)$/c
368 #else /* !defined(__cplusplus) */
369 #define __NULL_TYPE (void *)
370 #endif /* !defined(__cplusplus) */
371 #define NULL (__NULL_TYPE 0)
372 #endif /* !defined(NULL) */
376 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
379 echo Fixed
$file_to_fix
381 cp /tmp
/$base ${LIB}/$file
382 chmod a
+r
${LIB}/$file
387 # Add a prototyped declaration of mmap to <sys/mman.h>.
390 base
=`basename $file`
391 if [ -r ${LIB}/$file ]; then
392 file_to_fix
=${LIB}/$file
394 if [ -r ${INPUT}/$file ]; then
395 file_to_fix
=${INPUT}/$file
400 if [ \
! -z "$file_to_fix" ]; then
401 echo Checking
$file_to_fix
402 cp $file_to_fix /tmp
/$base
405 /^extern caddr_t mmap();$/c
407 extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,
409 #else /* !defined(__STDC__) */
410 extern caddr_t mmap ();
411 #endif /* !defined(__STDC__) */
415 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
418 echo Fixed
$file_to_fix
420 cp /tmp
/$base ${LIB}/$file
421 chmod a
+r
${LIB}/$file
426 # Fix declarations of `ftw' and `nftw' in <ftw.h>.
429 base
=`basename $file`
430 if [ -r ${LIB}/$file ]; then
431 file_to_fix
=${LIB}/$file
433 if [ -r ${INPUT}/$file ]; then
434 file_to_fix
=${INPUT}/$file
439 if [ \
! -z "$file_to_fix" ]; then
440 echo Checking
$file_to_fix
441 cp $file_to_fix /tmp
/$base
444 /^extern int ftw(const/c
445 #if !defined(_STYPES)
450 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
458 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);
460 /^extern int ftw(),/c
461 #if !defined(_STYPES)
476 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
479 echo Fixed
$file_to_fix
481 cp /tmp
/$base ${LIB}/$file
482 chmod a
+r
${LIB}/$file
487 # Add a `static' declaration of `getrnge' into <regexp.h>.
489 # Don't do this if there is already a `static void getrnge' declaration
490 # present, since this would cause a redeclaration error. Solaris 2.x has
491 # such a declaration.
494 base
=`basename $file`
495 if [ -r ${LIB}/$file ]; then
496 file_to_fix
=${LIB}/$file
498 if [ -r ${INPUT}/$file ]; then
499 file_to_fix
=${INPUT}/$file
504 if [ \
! -z "$file_to_fix" ]; then
505 echo Checking
$file_to_fix
506 if grep "static void getrnge" $file_to_fix > /dev
/null
; then
509 cp $file_to_fix /tmp
/$base
512 /^static int[ ]*size;/c
515 static int getrnge ();
519 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
522 echo Fixed
$file_to_fix
524 cp /tmp
/$base ${LIB}/$file
525 chmod a
+r
${LIB}/$file
531 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
532 # that is visible to any ANSI compiler using this include. Simply
533 # delete the lines the #define some string functions to internal forms.
536 base
=`basename $file`
537 if [ -r ${LIB}/$file ]; then
538 file_to_fix
=${LIB}/$file
540 if [ -r ${INPUT}/$file ]; then
541 file_to_fix
=${INPUT}/$file
546 if [ \
! -z "$file_to_fix" ]; then
547 echo Checking
$file_to_fix
548 cp $file_to_fix /tmp
/$base
551 g/#define.*__std_hdr_/d
554 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
557 echo Fixed
$file_to_fix
559 cp /tmp
/$base ${LIB}/$file
560 chmod a
+r
${LIB}/$file
565 # Add a #define of _SIGACTION_ into <sys/signal.h>.
566 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
569 base
=`basename $file`
570 if [ -r ${LIB}/$file ]; then
571 file_to_fix
=${LIB}/$file
573 if [ -r ${INPUT}/$file ]; then
574 file_to_fix
=${INPUT}/$file
579 if [ \
! -z "$file_to_fix" ]; then
580 echo Checking
$file_to_fix
581 cp $file_to_fix /tmp
/$base
584 /^struct sigaction {/c
588 1,\$s/(void *(\*)())/(void (*)(int))/
591 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
594 echo Fixed
$file_to_fix
596 cp /tmp
/$base ${LIB}/$file
597 chmod a
+r
${LIB}/$file
602 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
605 base
=`basename $file`
606 if [ -r ${LIB}/$file ]; then
607 file_to_fix
=${LIB}/$file
609 if [ -r ${INPUT}/$file ]; then
610 file_to_fix
=${INPUT}/$file
615 if [ \
! -z "$file_to_fix" ]; then
616 echo Checking
$file_to_fix
617 cp $file_to_fix /tmp
/$base
620 /^dev_t makedev(const/c
621 static dev_t makedev(const major_t, const minor_t);
624 static dev_t makedev();
626 /^major_t major(const/c
627 static major_t major(const dev_t);
630 static major_t major();
632 /^minor_t minor(const/c
633 static minor_t minor(const dev_t);
636 static minor_t minor();
640 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
643 echo Fixed
$file_to_fix
645 cp /tmp
/$base ${LIB}/$file
646 chmod a
+r
${LIB}/$file
651 # Fix reference to NMSZ in <sys/adv.h>.
654 base
=`basename $file`
655 if [ -r ${LIB}/$file ]; then
656 file_to_fix
=${LIB}/$file
658 if [ -r ${INPUT}/$file ]; then
659 file_to_fix
=${INPUT}/$file
664 if [ \
! -z "$file_to_fix" ]; then
665 echo Checking
$file_to_fix
666 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp
/$base
667 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
670 echo Fixed
$file_to_fix
672 cp /tmp
/$base ${LIB}/$file
673 chmod a
+r
${LIB}/$file
678 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
679 # array initializers.
682 base
=`basename $file`
683 if [ -r ${LIB}/$file ]; then
684 file_to_fix
=${LIB}/$file
686 if [ -r ${INPUT}/$file ]; then
687 file_to_fix
=${INPUT}/$file
692 if [ \
! -z "$file_to_fix" ]; then
693 echo Checking
$file_to_fix
694 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
695 |
sed 's/NC_/(unsigned long) NC_/' > /tmp
/$base
696 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
699 echo Fixed
$file_to_fix
701 cp /tmp
/$base ${LIB}/$file
702 chmod a
+r
${LIB}/$file
707 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
709 file=fs
/rfs
/rf_cache.h
710 base
=`basename $file`
711 if [ -r ${LIB}/$file ]; then
712 file_to_fix
=${LIB}/$file
714 if [ -r ${INPUT}/$file ]; then
715 file_to_fix
=${INPUT}/$file
720 if [ \
! -z "$file_to_fix" ]; then
721 echo Checking
$file_to_fix
722 if grep _KERNEL
$file_to_fix > /dev
/null
; then
725 echo '#ifdef _KERNEL' > /tmp
/$base
726 cat $file_to_fix >> /tmp
/$base
727 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
728 echo Fixed
$file_to_fix
730 cp /tmp
/$base ${LIB}/$file
731 chmod a
+r
${LIB}/$file
736 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
739 base
=`basename $file`
740 if [ -r ${LIB}/$file ]; then
741 file_to_fix
=${LIB}/$file
743 if [ -r ${INPUT}/$file ]; then
744 file_to_fix
=${INPUT}/$file
749 if [ \
! -z "$file_to_fix" ]; then
750 echo Checking
$file_to_fix
751 if grep _KERNEL
$file_to_fix > /dev
/null
; then
754 echo '#ifdef _KERNEL' > /tmp
/$base
755 cat $file_to_fix >> /tmp
/$base
756 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
757 echo Fixed
$file_to_fix
759 cp /tmp
/$base ${LIB}/$file
760 chmod a
+r
${LIB}/$file
765 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
768 base
=`basename $file`
769 if [ -r ${LIB}/$file ]; then
770 file_to_fix
=${LIB}/$file
772 if [ -r ${INPUT}/$file ]; then
773 file_to_fix
=${INPUT}/$file
778 if [ \
! -z "$file_to_fix" ]; then
779 echo Checking
$file_to_fix
780 if grep _KERNEL
$file_to_fix > /dev
/null
; then
783 echo '#ifdef _KERNEL' > /tmp
/$base
784 cat $file_to_fix >> /tmp
/$base
785 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
786 echo Fixed
$file_to_fix
788 cp /tmp
/$base ${LIB}/$file
789 chmod a
+r
${LIB}/$file
794 # Conditionalize all of <sys/char.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
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
818 chmod a
+r
${LIB}/$file
823 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
826 base
=`basename $file`
827 if [ -r ${LIB}/$file ]; then
828 file_to_fix
=${LIB}/$file
830 if [ -r ${INPUT}/$file ]; then
831 file_to_fix
=${INPUT}/$file
836 if [ \
! -z "$file_to_fix" ]; then
837 echo Checking
$file_to_fix
838 if grep _KERNEL
$file_to_fix > /dev
/null
; then
841 echo '#ifdef _KERNEL' > /tmp
/$base
842 cat $file_to_fix >> /tmp
/$base
843 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
844 echo Fixed
$file_to_fix
846 cp /tmp
/$base ${LIB}/$file
847 chmod a
+r
${LIB}/$file
852 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
855 base
=`basename $file`
856 if [ -r ${LIB}/$file ]; then
857 file_to_fix
=${LIB}/$file
859 if [ -r ${INPUT}/$file ]; then
860 file_to_fix
=${INPUT}/$file
865 if [ \
! -z "$file_to_fix" ]; then
866 echo Checking
$file_to_fix
867 if grep _KERNEL
$file_to_fix > /dev
/null
; then
870 echo '#ifdef _KERNEL' > /tmp
/$base
871 cat $file_to_fix >> /tmp
/$base
872 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
873 echo Fixed
$file_to_fix
875 cp /tmp
/$base ${LIB}/$file
876 chmod a
+r
${LIB}/$file
881 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
884 base
=`basename $file`
885 if [ -r ${LIB}/$file ]; then
886 file_to_fix
=${LIB}/$file
888 if [ -r ${INPUT}/$file ]; then
889 file_to_fix
=${INPUT}/$file
894 if [ \
! -z "$file_to_fix" ]; then
895 echo Checking
$file_to_fix
896 if grep _KERNEL
$file_to_fix > /dev
/null
; then
899 echo '#ifdef _KERNEL' > /tmp
/$base
900 cat $file_to_fix >> /tmp
/$base
901 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
902 echo Fixed
$file_to_fix
904 cp /tmp
/$base ${LIB}/$file
905 chmod a
+r
${LIB}/$file
910 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
913 base
=`basename $file`
914 if [ -r ${LIB}/$file ]; then
915 file_to_fix
=${LIB}/$file
917 if [ -r ${INPUT}/$file ]; then
918 file_to_fix
=${INPUT}/$file
923 if [ \
! -z "$file_to_fix" ]; then
924 echo Checking
$file_to_fix
925 if grep _KERNEL
$file_to_fix > /dev
/null
; then
928 echo '#ifdef _KERNEL' > /tmp
/$base
929 cat $file_to_fix >> /tmp
/$base
930 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
931 echo Fixed
$file_to_fix
933 cp /tmp
/$base ${LIB}/$file
934 chmod a
+r
${LIB}/$file
939 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
942 base
=`basename $file`
943 if [ -r ${LIB}/$file ]; then
944 file_to_fix
=${LIB}/$file
946 if [ -r ${INPUT}/$file ]; then
947 file_to_fix
=${INPUT}/$file
952 if [ \
! -z "$file_to_fix" ]; then
953 echo Checking
$file_to_fix
954 if grep _KERNEL
$file_to_fix > /dev
/null
; then
957 sed -e '/#ifdef INKERNEL/i\
959 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
960 #endif /* _KERNEL */' \
961 $file_to_fix > ${LIB}/${file}.
sed
962 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
963 echo Fixed
$file_to_fix
967 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
970 base
=`basename $file`
971 if [ -r ${LIB}/$file ]; then
972 file_to_fix
=${LIB}/$file
974 if [ -r ${INPUT}/$file ]; then
975 file_to_fix
=${INPUT}/$file
980 if [ \
! -z "$file_to_fix" ]; then
981 echo Checking
$file_to_fix
982 if grep __GNUC__
$file_to_fix > /dev
/null
; then
985 sed -e '/# ifdef __STDC__/i\
986 # if !defined (__GNUC__) && !defined (__GNUG__)' \
987 -e '/# include <sys\/byteorder.h>/s/ / /'\
988 -e '/# include <sys\/byteorder.h>/i\
989 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
990 $file_to_fix > ${LIB}/${file}.
sed
991 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
992 echo Fixed
$file_to_fix
996 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
997 # and the text in types.h is not erroneous.
998 ## In sys/types.h, don't name the enum for booleans.
1001 #base=`basename $file`
1002 #if [ -r ${LIB}/$file ]; then
1003 # file_to_fix=${LIB}/$file
1005 # if [ -r ${INPUT}/$file ]; then
1006 # file_to_fix=${INPUT}/$file
1011 #if [ \! -z "$file_to_fix" ]; then
1012 # echo Checking $file_to_fix
1013 # if grep "enum boolean" $file_to_fix > /dev/null; then
1014 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1015 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1016 # echo Fixed $file_to_fix
1022 # Remove useless extern keyword from struct forward declarations in
1023 # <sys/stream.h> and <sys/strsubr.h>
1026 base
=`basename $file`
1027 if [ -r ${LIB}/$file ]; then
1028 file_to_fix
=${LIB}/$file
1030 if [ -r ${INPUT}/$file ]; then
1031 file_to_fix
=${INPUT}/$file
1036 if [ \
! -z "$file_to_fix" ]; then
1037 echo Checking
$file_to_fix
1039 s/extern struct stdata;/struct stdata;/g
1040 s/extern struct strevent;/struct strevent;/g
1041 ' $file_to_fix > /tmp
/$base
1042 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1045 echo Fixed
$file_to_fix
1047 cp /tmp
/$base ${LIB}/$file
1048 chmod a
+r
${LIB}/$file
1054 base
=`basename $file`
1055 if [ -r ${LIB}/$file ]; then
1056 file_to_fix
=${LIB}/$file
1058 if [ -r ${INPUT}/$file ]; then
1059 file_to_fix
=${INPUT}/$file
1064 if [ \
! -z "$file_to_fix" ]; then
1065 echo Checking
$file_to_fix
1067 s/extern struct strbuf;/struct strbuf;/g
1068 s/extern struct uio;/struct uio;/g
1069 s/extern struct thread;/struct thread;/g
1070 s/extern struct proc;/struct proc;/g
1071 ' $file_to_fix > /tmp
/$base
1072 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1075 echo Fixed
$file_to_fix
1077 cp /tmp
/$base ${LIB}/$file
1078 chmod a
+r
${LIB}/$file
1083 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
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
1098 cp $file_to_fix /tmp
/$base
1127 1,\$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g
1128 1,\$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g
1129 1,\$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g
1130 1,\$s/ret\([^u]\)/__ret\1/g
1131 1,\$s/\([^_]\)mode\([^_]\)/\1__mode\2/g
1132 1,\$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g
1135 echo Fixed
$file_to_fix
1137 cp /tmp
/$base ${LIB}/$file
1138 chmod a
+r
${LIB}/$file
1142 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1144 if [ -x /bin
/sony
]; then
1147 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1150 base
=`basename $file`
1151 if [ -r ${LIB}/$file ]; then
1152 file_to_fix
=${LIB}/$file
1154 if [ -r ${INPUT}/$file ]; then
1155 file_to_fix
=${INPUT}/$file
1160 if [ \
! -z "$file_to_fix" ]; then
1161 echo Checking
$file_to_fix
1162 cp $file_to_fix /tmp
/$base
1165 s/__filbuf/_filbuf/g
1166 s/__flsbuf/_flsbuf/g
1168 ' /tmp
/$base > /tmp
/$base.
sed
1169 mv /tmp
/$base.
sed /tmp
/$base
1170 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1173 echo Fixed
$file_to_fix
1175 cp /tmp
/$base ${LIB}/$file
1176 chmod a
+r
${LIB}/$file
1181 # Change <ctype.h> to not define __ctype
1184 base
=`basename $file`
1185 if [ -r ${LIB}/$file ]; then
1186 file_to_fix
=${LIB}/$file
1188 if [ -r ${INPUT}/$file ]; then
1189 file_to_fix
=${INPUT}/$file
1194 if [ \
! -z "$file_to_fix" ]; then
1195 echo Checking
$file_to_fix
1196 cp $file_to_fix /tmp
/$base
1200 ' /tmp
/$base > /tmp
/$base.
sed
1201 mv /tmp
/$base.
sed /tmp
/$base
1202 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1205 echo Fixed
$file_to_fix
1207 cp /tmp
/$base ${LIB}/$file
1208 chmod a
+r
${LIB}/$file
1215 # In limits.h, put #ifndefs around things that are supposed to be defined
1216 # in float.h to avoid redefinition errors if float.h is included first.
1217 # Solaris 2.1 has this problem.
1220 base
=`basename $file`
1221 if [ -r ${LIB}/$file ]; then
1222 file_to_fix
=${LIB}/$file
1224 if [ -r ${INPUT}/$file ]; then
1225 file_to_fix
=${INPUT}/$file
1230 if [ \
! -z "$file_to_fix" ]; then
1231 echo Checking
$file_to_fix
1232 sed -e '/[ ]FLT_MIN[ ]/i\
1234 -e '/[ ]FLT_MIN[ ]/a\
1236 -e '/[ ]FLT_MAX[ ]/i\
1238 -e '/[ ]FLT_MAX[ ]/a\
1240 -e '/[ ]FLT_DIG[ ]/i\
1242 -e '/[ ]FLT_DIG[ ]/a\
1244 -e '/[ ]DBL_MIN[ ]/i\
1246 -e '/[ ]DBL_MIN[ ]/a\
1248 -e '/[ ]DBL_MAX[ ]/i\
1250 -e '/[ ]DBL_MAX[ ]/a\
1252 -e '/[ ]DBL_DIG[ ]/i\
1254 -e '/[ ]DBL_DIG[ ]/a\
1255 #endif' $file_to_fix > /tmp
/$base
1256 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1259 echo Fixed
$file_to_fix
1261 cp /tmp
/$base ${LIB}/$file
1262 chmod a
+r
${LIB}/$file
1267 echo 'Removing unneeded directories:'
1269 files
=`find . -type d -print | sort -r`
1270 for file in $files; do
1271 rmdir $LIB/$file > /dev
/null
2>&1
1275 echo 'Making internal symbolic non-directory links'
1277 files
=`find . -type l -print`
1278 for file in $files; do
1279 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1280 if expr "$dest" : '[^/].*' > /dev
/null
; then
1281 target
=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1282 if [ -f $target ]; then
1283 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1291 echo 'Replacing <sys/byteorder.h>'
1292 rm -f ${LIB}/sys
/byteorder.h
1293 cp ${SRCDIR}/byteorder.h
${LIB}/sys
/byteorder.h