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 echo 'Building fixincludes in ' ${LIB}
68 # Determine whether this filesystem has symbolic links.
69 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
70 rm -f $LIB/ShouldNotExist
76 echo 'Making directories:'
79 files=`ls -LR | sed -n s/:$//p`
81 files=`find . -type d -print | sed '/^.$/d'`
83 for file in $files; do
85 if [ ! -d $LIB/$file ]
90 # treetops gets an alternating list
91 # of old directories to copy
92 # and the new directories to copy to.
93 treetops="${INPUT} ${LIB}"
96 echo 'Making internal symbolic directory links'
97 for file in $files; do
98 dest=`ls -ld $file | sed -n 's/.*-> //p'`
101 # In case $dest is relative, get to $file's dir first.
103 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
104 # Check that the target directory exists.
105 # Redirections changed to avoid bug in sh on Ultrix.
106 (cd $dest) > /dev/null 2>&1
109 # X gets the dir that the link actually leads to.
111 # If link leads back into ${INPUT},
112 # make a similar link here.
113 if expr $x : "${INPUT}/.*" > /dev/null; then
114 # Y gets the actual target dir name, relative to ${INPUT}.
115 y=`echo $x | sed -n "s&${INPUT}/&&p"`
116 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
118 sed -e 's@^./@@' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
119 echo $file '->' $dots$y ': Making link'
120 rm -fr ${LIB}/$file > /dev/null 2>&1
121 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
123 # If the link is to outside ${INPUT},
124 # treat this directory as if it actually contained the files.
125 # This line used to have $dest instead of $x.
126 # $dest seemed to be wrong for links found in subdirectories
127 # of ${INPUT}. Does this change break anything?
128 treetops="$treetops $x ${LIB}/$file"
137 while [ $# != 0 ]; do
138 # $1 is an old directory to copy, and $2 is the new directory to copy to.
139 echo "Finding header files in $1:"
142 files=`find . -name '*.h' -type f -print`
143 echo 'Checking header files:'
144 for file in $files; do
145 if [ -r $file ]; then
146 cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
150 # The following have been removed from the sed command below
151 # because it is more useful to leave these things in.
152 # The only reason to remove them was for -pedantic,
153 # which isn't much of a reason. -- rms.
156 # This code makes Solaris SCSI fail, because it changes the
157 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
158 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
159 # Disable these also, since they probably aren't safe either.
160 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
161 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
162 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
163 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
165 # The change of u_char, etc, to u_int
166 # applies to bit fields.
168 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
169 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
170 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
171 s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
172 s/#lint(on)/defined(lint)/g
173 s/#lint(off)/!defined(lint)/g
174 s/#machine(\([^)]*\))/defined(__\1__)/g
175 s/#system(\([^)]*\))/defined(__\1__)/g
176 s/#cpu(\([^)]*\))/defined(__\1__)/g
177 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
178 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
179 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
180 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
181 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
182 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
183 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
184 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
185 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
186 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
187 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
188 s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
189 s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
190 s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
191 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
192 ' $2/$file > $2/$file.sed
193 mv $2/$file.sed $2/$file
194 if cmp $file $2/$file >/dev/null 2>&1; then
204 # Fix first broken decl of getcwd present on some svr4 systems.
207 base=`basename $file`
208 if [ -r ${LIB}/$file ]; then
209 file_to_fix=${LIB}/$file
211 if [ -r ${INPUT}/$file ]; then
212 file_to_fix=${INPUT}/$file
217 if [ \! -z "$file_to_fix" ]; then
218 echo Checking $file_to_fix
219 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
220 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
223 echo Fixed $file_to_fix
225 cp /tmp/$base ${LIB}/$file
226 chmod a+r ${LIB}/$file
231 # Fix second broken decl of getcwd present on some svr4 systems. Also
232 # fix the incorrect decl of profil present on some svr4 systems.
235 base=`basename $file`
236 if [ -r ${LIB}/$file ]; then
237 file_to_fix=${LIB}/$file
239 if [ -r ${INPUT}/$file ]; then
240 file_to_fix=${INPUT}/$file
245 if [ \! -z "$file_to_fix" ]; then
246 echo Checking $file_to_fix
247 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
248 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
249 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
252 echo Fixed $file_to_fix
254 cp /tmp/$base ${LIB}/$file
255 chmod a+r ${LIB}/$file
260 # Fix the definition of NULL in <sys/param.h> so that it is conditional
261 # and so that it is correct for both C and C++.
264 base=`basename $file`
265 if [ -r ${LIB}/$file ]; then
266 file_to_fix=${LIB}/$file
268 if [ -r ${INPUT}/$file ]; then
269 file_to_fix=${INPUT}/$file
274 if [ \! -z "$file_to_fix" ]; then
275 echo Checking $file_to_fix
276 cp $file_to_fix /tmp/$base
279 sed -e '/^#define[ ]*NULL[ ]*0$/c\
283 #else /* !defined(__cplusplus) */\
284 #define __NULL_TYPE (void *)\
285 #endif /* !defined(__cplusplus) */\
286 #define NULL (__NULL_TYPE 0)\
287 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
288 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
291 echo Fixed $file_to_fix
293 cp /tmp/$base.sed ${LIB}/$file
294 chmod a+r ${LIB}/$file
296 rm -f /tmp/$base /tmp/$base.sed
299 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
300 # and so that it is correct for both C and C++.
303 base=`basename $file`
304 if [ -r ${LIB}/$file ]; then
305 file_to_fix=${LIB}/$file
307 if [ -r ${INPUT}/$file ]; then
308 file_to_fix=${INPUT}/$file
313 if [ \! -z "$file_to_fix" ]; then
314 echo Checking $file_to_fix
315 cp $file_to_fix /tmp/$base
317 sed -e '/^#define[ ]*NULL[ ]*0$/c\
320 #else /* !defined(__cplusplus) */\
321 #define __NULL_TYPE (void *)\
322 #endif /* !defined(__cplusplus) */\
323 #define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
324 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
327 echo Fixed $file_to_fix
329 cp /tmp/$base.sed ${LIB}/$file
330 chmod a+r ${LIB}/$file
332 rm -f /tmp/$base /tmp/$base.sed
335 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
336 # and so that it is correct for both C and C++.
339 base=`basename $file`
340 if [ -r ${LIB}/$file ]; then
341 file_to_fix=${LIB}/$file
343 if [ -r ${INPUT}/$file ]; then
344 file_to_fix=${INPUT}/$file
349 if [ \! -z "$file_to_fix" ]; then
350 echo Checking $file_to_fix
351 cp $file_to_fix /tmp/$base
353 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
357 #else /* !defined(__cplusplus) */\
358 #define __NULL_TYPE (void *)\
359 #endif /* !defined(__cplusplus) */\
360 #define NULL (__NULL_TYPE 0)\
361 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
362 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
365 echo Fixed $file_to_fix
367 cp /tmp/$base.sed ${LIB}/$file
368 chmod a+r ${LIB}/$file
370 rm -f /tmp/$base /tmp/$base.sed
373 # Add a prototyped declaration of mmap to <sys/mman.h>.
376 base=`basename $file`
377 if [ -r ${LIB}/$file ]; then
378 file_to_fix=${LIB}/$file
380 if [ -r ${INPUT}/$file ]; then
381 file_to_fix=${INPUT}/$file
386 if [ \! -z "$file_to_fix" ]; then
387 echo Checking $file_to_fix
388 cp $file_to_fix /tmp/$base
390 sed -e '/^extern caddr_t mmap();$/c\
392 extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,\
394 #else /* !defined(__STDC__) */\
395 extern caddr_t mmap ();\
396 #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
397 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
400 echo Fixed $file_to_fix
402 cp /tmp/$base.sed ${LIB}/$file
403 chmod a+r ${LIB}/$file
405 rm -f /tmp/$base /tmp/$base.sed
408 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
409 # the file <ftw.h> contains extern declarations of these functions followed
410 # by explicitly `static' definitions of these functions... and that's not
411 # allowed according to ANSI C. (Note however that on Solaris, this header
412 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
413 # there are no static definitions of any function so we don't need to do
414 # any of this stuff when on Solaris.
417 base=`basename $file`
418 if [ -r ${LIB}/$file ]; then
419 file_to_fix=${LIB}/$file
421 if [ -r ${INPUT}/$file ]; then
422 file_to_fix=${INPUT}/$file
427 if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
428 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
429 # one. Either way, we don't have to do anything.
432 echo Checking $file_to_fix
433 cp $file_to_fix /tmp/$base
435 sed -e '/^extern int ftw(const/i\
436 #if !defined(_STYPES)\
441 -e 's/extern \(int ftw(const.*\)$/\1/' \
442 -e '/^extern int nftw/i\
443 #if defined(_STYPES)\
448 -e 's/extern \(int nftw.*\)$/\1/' \
449 -e '/^extern int ftw(),/c\
450 #if !defined(_STYPES)\
456 #if defined(_STYPES)\
461 int nftw();' /tmp/$base > /tmp/$base.sed
462 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
465 echo Fixed $file_to_fix
467 cp /tmp/$base.sed ${LIB}/$file
468 chmod a+r ${LIB}/$file
470 rm -f /tmp/$base /tmp/$base.sed
473 # Add a `static' declaration of `getrnge' into <regexp.h>.
475 # Don't do this if there is already a `static void getrnge' declaration
476 # present, since this would cause a redeclaration error. Solaris 2.x has
477 # such a declaration.
480 base=`basename $file`
481 if [ -r ${LIB}/$file ]; then
482 file_to_fix=${LIB}/$file
484 if [ -r ${INPUT}/$file ]; then
485 file_to_fix=${INPUT}/$file
490 if [ \! -z "$file_to_fix" ]; then
491 echo Checking $file_to_fix
492 if grep "static void getrnge" $file_to_fix > /dev/null; then
495 cp $file_to_fix /tmp/$base
497 sed -e '/^static int[ ]*size;/c\
500 static int getrnge ();' /tmp/$base > /tmp/$base.sed
501 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
504 echo Fixed $file_to_fix
506 cp /tmp/$base.sed ${LIB}/$file
507 chmod a+r ${LIB}/$file
510 rm -f /tmp/$base /tmp/$base.sed
513 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
514 # that is visible to any ANSI compiler using this include. Simply
515 # delete the lines that #define some string functions to internal forms.
518 base=`basename $file`
519 if [ -r ${LIB}/$file ]; then
520 file_to_fix=${LIB}/$file
522 if [ -r ${INPUT}/$file ]; then
523 file_to_fix=${INPUT}/$file
528 if [ \! -z "$file_to_fix" ]; then
529 echo Checking $file_to_fix
530 cp $file_to_fix /tmp/$base
532 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
533 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
536 echo Fixed $file_to_fix
538 cp /tmp/$base.sed ${LIB}/$file
539 chmod a+r ${LIB}/$file
541 rm -f /tmp/$base /tmp/$base.sed
544 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
545 # tend to conflict with the compiler's own definition of this symbol. (We
546 # will use the compiler's definition.)
547 # Likewise __sparc, for Solaris, and __i860, and a few others
548 # (guessing it is necessary for all of them).
551 base=`basename $file`
552 if [ -r ${LIB}/$file ]; then
553 file_to_fix=${LIB}/$file
555 if [ -r ${INPUT}/$file ]; then
556 file_to_fix=${INPUT}/$file
561 if [ \! -z "$file_to_fix" ]; then
562 echo Checking $file_to_fix
563 cp $file_to_fix /tmp/$base
565 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
566 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
567 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
568 /tmp/$base > /tmp/$base.sed
569 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
572 echo Fixed $file_to_fix
574 cp /tmp/$base.sed ${LIB}/$file
575 chmod a+r ${LIB}/$file
577 rm -f /tmp/$base /tmp/$base.sed
580 # Add a #define of _SIGACTION_ into <sys/signal.h>.
581 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
584 base=`basename $file`
585 if [ -r ${LIB}/$file ]; then
586 file_to_fix=${LIB}/$file
588 if [ -r ${INPUT}/$file ]; then
589 file_to_fix=${INPUT}/$file
594 if [ \! -z "$file_to_fix" ]; then
595 echo Checking $file_to_fix
596 cp $file_to_fix /tmp/$base
598 sed -e '/^struct sigaction {/c\
600 struct sigaction {' \
601 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
602 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
605 echo Fixed $file_to_fix
607 cp /tmp/$base.sed ${LIB}/$file
608 chmod a+r ${LIB}/$file
610 rm -f /tmp/$base /tmp/$base.sed
613 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
616 base=`basename $file`
617 if [ -r ${LIB}/$file ]; then
618 file_to_fix=${LIB}/$file
620 if [ -r ${INPUT}/$file ]; then
621 file_to_fix=${INPUT}/$file
626 if [ \! -z "$file_to_fix" ]; then
627 echo Checking $file_to_fix
628 cp $file_to_fix /tmp/$base
630 sed -e '/^dev_t makedev(const/c\
631 static dev_t makedev(const major_t, const minor_t);' \
632 -e '/^dev_t makedev()/c\
633 static dev_t makedev();' \
634 -e '/^major_t major(const/c\
635 static major_t major(const dev_t);' \
636 -e '/^major_t major()/c\
637 static major_t major();' \
638 -e '/^minor_t minor(const/c\
639 static minor_t minor(const dev_t);' \
640 -e '/^minor_t minor()/c\
641 static minor_t minor();' /tmp/$base > /tmp/$base.sed
642 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
645 echo Fixed $file_to_fix
647 cp /tmp/$base.sed ${LIB}/$file
648 chmod a+r ${LIB}/$file
650 rm -f /tmp/$base /tmp/$base.sed
653 # Fix reference to NMSZ in <sys/adv.h>.
656 base=`basename $file`
657 if [ -r ${LIB}/$file ]; then
658 file_to_fix=${LIB}/$file
660 if [ -r ${INPUT}/$file ]; then
661 file_to_fix=${INPUT}/$file
666 if [ \! -z "$file_to_fix" ]; then
667 echo Checking $file_to_fix
668 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
669 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
672 echo Fixed $file_to_fix
674 cp /tmp/$base ${LIB}/$file
675 chmod a+r ${LIB}/$file
680 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
681 # array initializers.
684 base=`basename $file`
685 if [ -r ${LIB}/$file ]; then
686 file_to_fix=${LIB}/$file
688 if [ -r ${INPUT}/$file ]; then
689 file_to_fix=${INPUT}/$file
694 if [ \! -z "$file_to_fix" ]; then
695 echo Checking $file_to_fix
696 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
697 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
698 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
701 echo Fixed $file_to_fix
703 cp /tmp/$base ${LIB}/$file
704 chmod a+r ${LIB}/$file
709 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
711 file=fs/rfs/rf_cache.h
712 base=`basename $file`
713 if [ -r ${LIB}/$file ]; then
714 file_to_fix=${LIB}/$file
716 if [ -r ${INPUT}/$file ]; then
717 file_to_fix=${INPUT}/$file
722 if [ \! -z "$file_to_fix" ]; then
723 echo Checking $file_to_fix
724 if grep _KERNEL $file_to_fix > /dev/null; then
727 echo '#ifdef _KERNEL' > /tmp/$base
728 cat $file_to_fix >> /tmp/$base
729 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
730 echo Fixed $file_to_fix
732 cp /tmp/$base ${LIB}/$file
733 chmod a+r ${LIB}/$file
738 # Conditionalize all of <sys/erec.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
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
762 chmod a+r ${LIB}/$file
767 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
770 base=`basename $file`
771 if [ -r ${LIB}/$file ]; then
772 file_to_fix=${LIB}/$file
774 if [ -r ${INPUT}/$file ]; then
775 file_to_fix=${INPUT}/$file
780 if [ \! -z "$file_to_fix" ]; then
781 echo Checking $file_to_fix
782 if grep _KERNEL $file_to_fix > /dev/null; then
785 echo '#ifdef _KERNEL' > /tmp/$base
786 cat $file_to_fix >> /tmp/$base
787 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
788 echo Fixed $file_to_fix
790 cp /tmp/$base ${LIB}/$file
791 chmod a+r ${LIB}/$file
796 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
799 base=`basename $file`
800 if [ -r ${LIB}/$file ]; then
801 file_to_fix=${LIB}/$file
803 if [ -r ${INPUT}/$file ]; then
804 file_to_fix=${INPUT}/$file
809 if [ \! -z "$file_to_fix" ]; then
810 echo Checking $file_to_fix
811 if grep _KERNEL $file_to_fix > /dev/null; then
814 echo '#ifdef _KERNEL' > /tmp/$base
815 cat $file_to_fix >> /tmp/$base
816 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
817 echo Fixed $file_to_fix
819 cp /tmp/$base ${LIB}/$file
820 chmod a+r ${LIB}/$file
825 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
828 base=`basename $file`
829 if [ -r ${LIB}/$file ]; then
830 file_to_fix=${LIB}/$file
832 if [ -r ${INPUT}/$file ]; then
833 file_to_fix=${INPUT}/$file
838 if [ \! -z "$file_to_fix" ]; then
839 echo Checking $file_to_fix
840 if grep _KERNEL $file_to_fix > /dev/null; then
843 echo '#ifdef _KERNEL' > /tmp/$base
844 cat $file_to_fix >> /tmp/$base
845 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
846 echo Fixed $file_to_fix
848 cp /tmp/$base ${LIB}/$file
849 chmod a+r ${LIB}/$file
854 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
857 base=`basename $file`
858 if [ -r ${LIB}/$file ]; then
859 file_to_fix=${LIB}/$file
861 if [ -r ${INPUT}/$file ]; then
862 file_to_fix=${INPUT}/$file
867 if [ \! -z "$file_to_fix" ]; then
868 echo Checking $file_to_fix
869 if grep _KERNEL $file_to_fix > /dev/null; then
872 echo '#ifdef _KERNEL' > /tmp/$base
873 cat $file_to_fix >> /tmp/$base
874 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
875 echo Fixed $file_to_fix
877 cp /tmp/$base ${LIB}/$file
878 chmod a+r ${LIB}/$file
883 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
886 base=`basename $file`
887 if [ -r ${LIB}/$file ]; then
888 file_to_fix=${LIB}/$file
890 if [ -r ${INPUT}/$file ]; then
891 file_to_fix=${INPUT}/$file
896 if [ \! -z "$file_to_fix" ]; then
897 echo Checking $file_to_fix
898 if grep _KERNEL $file_to_fix > /dev/null; then
901 echo '#ifdef _KERNEL' > /tmp/$base
902 cat $file_to_fix >> /tmp/$base
903 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
904 echo Fixed $file_to_fix
906 cp /tmp/$base ${LIB}/$file
907 chmod a+r ${LIB}/$file
912 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
915 base=`basename $file`
916 if [ -r ${LIB}/$file ]; then
917 file_to_fix=${LIB}/$file
919 if [ -r ${INPUT}/$file ]; then
920 file_to_fix=${INPUT}/$file
925 if [ \! -z "$file_to_fix" ]; then
926 echo Checking $file_to_fix
927 if grep _KERNEL $file_to_fix > /dev/null; then
930 echo '#ifdef _KERNEL' > /tmp/$base
931 cat $file_to_fix >> /tmp/$base
932 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
933 echo Fixed $file_to_fix
935 cp /tmp/$base ${LIB}/$file
936 chmod a+r ${LIB}/$file
941 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
944 base=`basename $file`
945 if [ -r ${LIB}/$file ]; then
946 file_to_fix=${LIB}/$file
948 if [ -r ${INPUT}/$file ]; then
949 file_to_fix=${INPUT}/$file
954 if [ \! -z "$file_to_fix" ]; then
955 echo Checking $file_to_fix
956 if grep _KERNEL $file_to_fix > /dev/null; then
959 sed -e '/#ifdef INKERNEL/i\
961 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
962 #endif /* _KERNEL */' \
963 $file_to_fix > ${LIB}/${file}.sed
964 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
965 echo Fixed $file_to_fix
969 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
972 base=`basename $file`
973 if [ -r ${LIB}/$file ]; then
974 file_to_fix=${LIB}/$file
976 if [ -r ${INPUT}/$file ]; then
977 file_to_fix=${INPUT}/$file
982 if [ \! -z "$file_to_fix" ]; then
983 echo Checking $file_to_fix
984 if grep __GNUC__ $file_to_fix > /dev/null; then
987 sed -e '/# ifdef __STDC__/i\
988 # if !defined (__GNUC__) && !defined (__GNUG__)' \
989 -e '/# include <sys\/byteorder.h>/s/ / /'\
990 -e '/# include <sys\/byteorder.h>/i\
991 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
992 $file_to_fix > ${LIB}/${file}.sed
993 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
994 echo Fixed $file_to_fix
998 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
999 # and the text in types.h is not erroneous.
1000 ## In sys/types.h, don't name the enum for booleans.
1003 #base=`basename $file`
1004 #if [ -r ${LIB}/$file ]; then
1005 # file_to_fix=${LIB}/$file
1007 # if [ -r ${INPUT}/$file ]; then
1008 # file_to_fix=${INPUT}/$file
1013 #if [ \! -z "$file_to_fix" ]; then
1014 # echo Checking $file_to_fix
1015 # if grep "enum boolean" $file_to_fix > /dev/null; then
1016 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1017 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1018 # echo Fixed $file_to_fix
1024 # Remove useless extern keyword from struct forward declarations in
1025 # <sys/stream.h> and <sys/strsubr.h>
1028 base=`basename $file`
1029 if [ -r ${LIB}/$file ]; then
1030 file_to_fix=${LIB}/$file
1032 if [ -r ${INPUT}/$file ]; then
1033 file_to_fix=${INPUT}/$file
1038 if [ \! -z "$file_to_fix" ]; then
1039 echo Checking $file_to_fix
1041 s/extern struct stdata;/struct stdata;/g
1042 s/extern struct strevent;/struct strevent;/g
1043 ' $file_to_fix > /tmp/$base
1044 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1047 echo Fixed $file_to_fix
1049 cp /tmp/$base ${LIB}/$file
1050 chmod a+r ${LIB}/$file
1056 base=`basename $file`
1057 if [ -r ${LIB}/$file ]; then
1058 file_to_fix=${LIB}/$file
1060 if [ -r ${INPUT}/$file ]; then
1061 file_to_fix=${INPUT}/$file
1066 if [ \! -z "$file_to_fix" ]; then
1067 echo Checking $file_to_fix
1069 s/extern struct strbuf;/struct strbuf;/g
1070 s/extern struct uio;/struct uio;/g
1071 s/extern struct thread;/struct thread;/g
1072 s/extern struct proc;/struct proc;/g
1073 ' $file_to_fix > /tmp/$base
1074 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1077 echo Fixed $file_to_fix
1079 cp /tmp/$base ${LIB}/$file
1080 chmod a+r ${LIB}/$file
1085 # Put storage class at start of decl, to avoid warning.
1087 base=`basename $file`
1088 if [ -r ${LIB}/$file ]; then
1089 file_to_fix=${LIB}/$file
1091 if [ -r ${INPUT}/$file ]; then
1092 file_to_fix=${INPUT}/$file
1097 if [ \! -z "$file_to_fix" ]; then
1098 echo Checking $file_to_fix
1100 s/const extern/extern const/g
1101 ' $file_to_fix > /tmp/$base
1102 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1105 echo Fixed $file_to_fix
1107 cp /tmp/$base ${LIB}/$file
1108 chmod a+r ${LIB}/$file
1113 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1116 base=`basename $file`
1117 if [ -r ${LIB}/$file ]; then
1118 file_to_fix=${LIB}/$file
1120 if [ -r ${INPUT}/$file ]; then
1121 file_to_fix=${INPUT}/$file
1126 if [ \! -z "$file_to_fix" ]; then
1127 echo Checking $file_to_fix
1128 cp $file_to_fix /tmp/$base
1159 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1160 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1161 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1162 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1163 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1164 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1165 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1168 echo Fixed $file_to_fix
1170 cp /tmp/$base.sed ${LIB}/$file
1171 chmod a+r ${LIB}/$file
1173 rm -f /tmp/$base /tmp/$base.sed
1176 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1178 if [ -x /bin/sony ]; then
1181 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
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
1199 s/__filbuf/_filbuf/g
1200 s/__flsbuf/_flsbuf/g
1202 ' /tmp/$base > /tmp/$base.sed
1203 mv /tmp/$base.sed /tmp/$base
1204 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1207 echo Fixed $file_to_fix
1209 cp /tmp/$base ${LIB}/$file
1210 chmod a+r ${LIB}/$file
1215 # Change <ctype.h> to not define __ctype
1218 base=`basename $file`
1219 if [ -r ${LIB}/$file ]; then
1220 file_to_fix=${LIB}/$file
1222 if [ -r ${INPUT}/$file ]; then
1223 file_to_fix=${INPUT}/$file
1228 if [ \! -z "$file_to_fix" ]; then
1229 echo Checking $file_to_fix
1230 cp $file_to_fix /tmp/$base
1234 ' /tmp/$base > /tmp/$base.sed
1235 mv /tmp/$base.sed /tmp/$base
1236 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1239 echo Fixed $file_to_fix
1241 cp /tmp/$base ${LIB}/$file
1242 chmod a+r ${LIB}/$file
1249 # In limits.h, put #ifndefs around things that are supposed to be defined
1250 # in float.h to avoid redefinition errors if float.h is included first.
1251 # Solaris 2.1 has this problem.
1254 base=`basename $file`
1255 if [ -r ${LIB}/$file ]; then
1256 file_to_fix=${LIB}/$file
1258 if [ -r ${INPUT}/$file ]; then
1259 file_to_fix=${INPUT}/$file
1264 if [ \! -z "$file_to_fix" ]; then
1265 echo Checking $file_to_fix
1266 sed -e '/[ ]FLT_MIN[ ]/i\
1268 -e '/[ ]FLT_MIN[ ]/a\
1270 -e '/[ ]FLT_MAX[ ]/i\
1272 -e '/[ ]FLT_MAX[ ]/a\
1274 -e '/[ ]FLT_DIG[ ]/i\
1276 -e '/[ ]FLT_DIG[ ]/a\
1278 -e '/[ ]DBL_MIN[ ]/i\
1280 -e '/[ ]DBL_MIN[ ]/a\
1282 -e '/[ ]DBL_MAX[ ]/i\
1284 -e '/[ ]DBL_MAX[ ]/a\
1286 -e '/[ ]DBL_DIG[ ]/i\
1288 -e '/[ ]DBL_DIG[ ]/a\
1289 #endif' $file_to_fix > /tmp/$base
1290 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1293 echo Fixed $file_to_fix
1295 cp /tmp/$base ${LIB}/$file
1296 chmod a+r ${LIB}/$file
1301 # Completely replace <sys/varargs.h> with a file that includes gcc's
1302 # stdarg.h or varargs.h files as appropriate.
1305 if [ -r ${INPUT}/$file ]; then
1306 echo Replacing $file
1307 cat > ${LIB}/$file << EOF
1308 /* This file was generated by fixincludes. */
1309 #ifndef _SYS_VARARGS_H
1310 #define _SYS_VARARGS_H
1315 #include <varargs.h>
1318 #endif /* _SYS_VARARGS_H */
1320 chmod a+r ${LIB}/$file
1323 echo 'Removing unneeded directories:'
1325 files=`find . -type d -print | sort -r`
1326 for file in $files; do
1327 rmdir $LIB/$file > /dev/null 2>&1
1331 echo 'Making internal symbolic non-directory links'
1333 files=`find . -type l -print`
1334 for file in $files; do
1335 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1336 if expr "$dest" : '[^/].*' > /dev/null; then
1337 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1338 if [ -f $target ]; then
1339 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1347 echo 'Replacing <sys/byteorder.h>'
1348 rm -f ${LIB}/sys/byteorder.h
1349 cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h