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"
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%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
169 s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
170 s/#lint(on)/defined(lint)/g
171 s/#lint(off)/!defined(lint)/g
172 s/#machine(\([^)]*\))/defined(__\1__)/g
173 s/#system(\([^)]*\))/defined(__\1__)/g
174 s/#cpu(\([^)]*\))/defined(__\1__)/g
175 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
176 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
177 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
178 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
179 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
180 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
181 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
182 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
183 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
184 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
185 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
186 s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
187 s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
188 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
189 ' $2/$file > $2/$file.sed
190 mv $2/$file.sed $2/$file
191 if cmp $file $2/$file >/dev/null 2>&1; then
192 echo Deleting $2/$file\; no fixes were needed.
200 # Fix first broken decl of getcwd present on some svr4 systems.
203 base=`basename $file`
204 if [ -r ${LIB}/$file ]; then
205 file_to_fix=${LIB}/$file
207 if [ -r ${INPUT}/$file ]; then
208 file_to_fix=${INPUT}/$file
213 if [ \! -z "$file_to_fix" ]; then
214 echo Checking $file_to_fix
215 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
216 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
217 echo No change needed in $file_to_fix
219 echo Fixed $file_to_fix
221 cp /tmp/$base ${LIB}/$file
222 chmod a+r ${LIB}/$file
227 # Fix second broken decl of getcwd present on some svr4 systems. Also
228 # fix the incorrect decl of profil present on some svr4 systems.
231 base=`basename $file`
232 if [ -r ${LIB}/$file ]; then
233 file_to_fix=${LIB}/$file
235 if [ -r ${INPUT}/$file ]; then
236 file_to_fix=${INPUT}/$file
241 if [ \! -z "$file_to_fix" ]; then
242 echo Checking $file_to_fix
243 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
244 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
245 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
246 echo No change needed in $file_to_fix
248 echo Fixed $file_to_fix
250 cp /tmp/$base ${LIB}/$file
251 chmod a+r ${LIB}/$file
256 # Fix the definition of NULL in <sys/param.h> so that it is conditional
257 # and so that it is correct for both C and C++.
260 base=`basename $file`
261 if [ -r ${LIB}/$file ]; then
262 file_to_fix=${LIB}/$file
264 if [ -r ${INPUT}/$file ]; then
265 file_to_fix=${INPUT}/$file
270 if [ \! -z "$file_to_fix" ]; then
271 echo Checking $file_to_fix
272 cp $file_to_fix /tmp/$base
276 /^#define[ ]*NULL[ ]*0$/c
280 #else /* !defined(__cplusplus) */
281 #define __NULL_TYPE (void *)
282 #endif /* !defined(__cplusplus) */
283 #define NULL (__NULL_TYPE 0)
284 #endif /* !defined(NULL) */
288 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
289 echo No change needed in $file_to_fix
291 echo Fixed $file_to_fix
293 cp /tmp/$base ${LIB}/$file
294 chmod a+r ${LIB}/$file
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
318 /^#define[ ]*NULL[ ]*0$/c
321 #else /* !defined(__cplusplus) */
322 #define __NULL_TYPE (void *)
323 #endif /* !defined(__cplusplus) */
324 #define NULL (__NULL_TYPE 0)
328 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
329 echo No change needed in $file_to_fix
331 echo Fixed $file_to_fix
333 cp /tmp/$base ${LIB}/$file
334 chmod a+r ${LIB}/$file
339 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
340 # and so that it is correct for both C and C++.
343 base=`basename $file`
344 if [ -r ${LIB}/$file ]; then
345 file_to_fix=${LIB}/$file
347 if [ -r ${INPUT}/$file ]; then
348 file_to_fix=${INPUT}/$file
353 if [ \! -z "$file_to_fix" ]; then
354 echo Checking $file_to_fix
355 cp $file_to_fix /tmp/$base
358 /^#define[ ]*NULL[ ]*((char \*) 0)$/c
362 #else /* !defined(__cplusplus) */
363 #define __NULL_TYPE (void *)
364 #endif /* !defined(__cplusplus) */
365 #define NULL (__NULL_TYPE 0)
366 #endif /* !defined(NULL) */
370 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
371 echo No change needed in $file_to_fix
373 echo Fixed $file_to_fix
375 cp /tmp/$base ${LIB}/$file
376 chmod a+r ${LIB}/$file
381 # Add a prototyped declaration of mmap to <sys/mman.h>.
384 base=`basename $file`
385 if [ -r ${LIB}/$file ]; then
386 file_to_fix=${LIB}/$file
388 if [ -r ${INPUT}/$file ]; then
389 file_to_fix=${INPUT}/$file
394 if [ \! -z "$file_to_fix" ]; then
395 echo Checking $file_to_fix
396 cp $file_to_fix /tmp/$base
399 /^extern caddr_t mmap();$/c
401 extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,
403 #else /* !defined(__STDC__) */
404 extern caddr_t mmap ();
405 #endif /* !defined(__STDC__) */
409 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
410 echo No changed needed in $file_to_fix
412 echo Fixed $file_to_fix
414 cp /tmp/$base ${LIB}/$file
415 chmod a+r ${LIB}/$file
420 # Fix declarations of `ftw' and `nftw' in <ftw.h>.
423 base=`basename $file`
424 if [ -r ${LIB}/$file ]; then
425 file_to_fix=${LIB}/$file
427 if [ -r ${INPUT}/$file ]; then
428 file_to_fix=${INPUT}/$file
433 if [ \! -z "$file_to_fix" ]; then
434 echo Checking $file_to_fix
435 cp $file_to_fix /tmp/$base
438 /^extern int ftw(const/c
439 #if !defined(_STYPES)
444 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
452 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);
454 /^extern int ftw(),/c
455 #if !defined(_STYPES)
470 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
471 echo No change needed in $file_to_fix
473 echo Fixed $file_to_fix
475 cp /tmp/$base ${LIB}/$file
476 chmod a+r ${LIB}/$file
481 # Add a `static' declaration of `getrnge' into <regexp.h>.
483 # Don't do this if there is already a `static void getrnge' declaration
484 # present, since this would cause a redeclaration error. Solaris 2.x has
485 # such a declaration.
488 base=`basename $file`
489 if [ -r ${LIB}/$file ]; then
490 file_to_fix=${LIB}/$file
492 if [ -r ${INPUT}/$file ]; then
493 file_to_fix=${INPUT}/$file
498 if [ \! -z "$file_to_fix" ]; then
499 echo Checking $file_to_fix
500 if grep "static void getrnge" $file_to_fix > /dev/null; then
503 cp $file_to_fix /tmp/$base
506 /^static int[ ]*size;/c
509 static int getrnge ();
513 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
514 No change needed in $file_to_fix
516 echo Fixed $file_to_fix
518 cp /tmp/$base ${LIB}/$file
519 chmod a+r ${LIB}/$file
525 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
526 # that is visible to any ANSI compiler using this include. Simply
527 # delete the lines the #define some string functions to internal forms.
530 base=`basename $file`
531 if [ -r ${LIB}/$file ]; then
532 file_to_fix=${LIB}/$file
534 if [ -r ${INPUT}/$file ]; then
535 file_to_fix=${INPUT}/$file
540 if [ \! -z "$file_to_fix" ]; then
541 echo Checking $file_to_fix
542 cp $file_to_fix /tmp/$base
545 g/#define.*__std_hdr_/d
548 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
549 echo No change needed in $file_to_fix
551 echo Fixed $file_to_fix
553 cp /tmp/$base ${LIB}/$file
554 chmod a+r ${LIB}/$file
559 # Add a #define of _SIGACTION_ into <sys/signal.h>.
560 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
563 base=`basename $file`
564 if [ -r ${LIB}/$file ]; then
565 file_to_fix=${LIB}/$file
567 if [ -r ${INPUT}/$file ]; then
568 file_to_fix=${INPUT}/$file
573 if [ \! -z "$file_to_fix" ]; then
574 echo Checking $file_to_fix
575 cp $file_to_fix /tmp/$base
578 /^struct sigaction {/c
582 1,\$s/(void *(\*)())/(void (*)(int))/
585 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
586 echo No change needed in $file_to_fix
588 echo Fixed $file_to_fix
590 cp /tmp/$base ${LIB}/$file
591 chmod a+r ${LIB}/$file
596 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
599 base=`basename $file`
600 if [ -r ${LIB}/$file ]; then
601 file_to_fix=${LIB}/$file
603 if [ -r ${INPUT}/$file ]; then
604 file_to_fix=${INPUT}/$file
609 if [ \! -z "$file_to_fix" ]; then
610 echo Checking $file_to_fix
611 cp $file_to_fix /tmp/$base
614 /^dev_t makedev(const/c
615 static dev_t makedev(const major_t, const minor_t);
618 static dev_t makedev();
620 /^major_t major(const/c
621 static major_t major(const dev_t);
624 static major_t major();
626 /^minor_t minor(const/c
627 static minor_t minor(const dev_t);
630 static minor_t minor();
634 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
635 echo No change needed in $file_to_fix
637 echo Fixed $file_to_fix
639 cp /tmp/$base ${LIB}/$file
640 chmod a+r ${LIB}/$file
645 # Fix reference to NMSZ in <sys/adv.h>.
648 base=`basename $file`
649 if [ -r ${LIB}/$file ]; then
650 file_to_fix=${LIB}/$file
652 if [ -r ${INPUT}/$file ]; then
653 file_to_fix=${INPUT}/$file
658 if [ \! -z "$file_to_fix" ]; then
659 echo Checking $file_to_fix
660 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
661 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
662 echo No change needed in $file_to_fix
664 echo Fixed $file_to_fix
666 cp /tmp/$base ${LIB}/$file
667 chmod a+r ${LIB}/$file
672 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
673 # array initializers.
676 base=`basename $file`
677 if [ -r ${LIB}/$file ]; then
678 file_to_fix=${LIB}/$file
680 if [ -r ${INPUT}/$file ]; then
681 file_to_fix=${INPUT}/$file
686 if [ \! -z "$file_to_fix" ]; then
687 echo Checking $file_to_fix
688 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
689 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
690 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
691 echo No change needed in $file_to_fix
693 echo Fixed $file_to_fix
695 cp /tmp/$base ${LIB}/$file
696 chmod a+r ${LIB}/$file
701 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
703 file=fs/rfs/rf_cache.h
704 base=`basename $file`
705 if [ -r ${LIB}/$file ]; then
706 file_to_fix=${LIB}/$file
708 if [ -r ${INPUT}/$file ]; then
709 file_to_fix=${INPUT}/$file
714 if [ \! -z "$file_to_fix" ]; then
715 echo Checking $file_to_fix
716 if grep _KERNEL $file_to_fix > /dev/null; then
717 echo No change needed in $file_to_fix
719 echo '#ifdef _KERNEL' > /tmp/$base
720 cat $file_to_fix >> /tmp/$base
721 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
722 echo Fixed $file_to_fix
724 cp /tmp/$base ${LIB}/$file
725 chmod a+r ${LIB}/$file
730 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
733 base=`basename $file`
734 if [ -r ${LIB}/$file ]; then
735 file_to_fix=${LIB}/$file
737 if [ -r ${INPUT}/$file ]; then
738 file_to_fix=${INPUT}/$file
743 if [ \! -z "$file_to_fix" ]; then
744 echo Checking $file_to_fix
745 if grep _KERNEL $file_to_fix > /dev/null; then
746 echo No change needed in $file_to_fix
748 echo '#ifdef _KERNEL' > /tmp/$base
749 cat $file_to_fix >> /tmp/$base
750 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
751 echo Fixed $file_to_fix
753 cp /tmp/$base ${LIB}/$file
754 chmod a+r ${LIB}/$file
759 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
762 base=`basename $file`
763 if [ -r ${LIB}/$file ]; then
764 file_to_fix=${LIB}/$file
766 if [ -r ${INPUT}/$file ]; then
767 file_to_fix=${INPUT}/$file
772 if [ \! -z "$file_to_fix" ]; then
773 echo Checking $file_to_fix
774 if grep _KERNEL $file_to_fix > /dev/null; then
775 echo No change needed in $file_to_fix
777 echo '#ifdef _KERNEL' > /tmp/$base
778 cat $file_to_fix >> /tmp/$base
779 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
780 echo Fixed $file_to_fix
782 cp /tmp/$base ${LIB}/$file
783 chmod a+r ${LIB}/$file
788 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
791 base=`basename $file`
792 if [ -r ${LIB}/$file ]; then
793 file_to_fix=${LIB}/$file
795 if [ -r ${INPUT}/$file ]; then
796 file_to_fix=${INPUT}/$file
801 if [ \! -z "$file_to_fix" ]; then
802 echo Checking $file_to_fix
803 if grep _KERNEL $file_to_fix > /dev/null; then
804 echo No change needed in $file_to_fix
806 echo '#ifdef _KERNEL' > /tmp/$base
807 cat $file_to_fix >> /tmp/$base
808 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
809 echo Fixed $file_to_fix
811 cp /tmp/$base ${LIB}/$file
812 chmod a+r ${LIB}/$file
817 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
820 base=`basename $file`
821 if [ -r ${LIB}/$file ]; then
822 file_to_fix=${LIB}/$file
824 if [ -r ${INPUT}/$file ]; then
825 file_to_fix=${INPUT}/$file
830 if [ \! -z "$file_to_fix" ]; then
831 echo Checking $file_to_fix
832 if grep _KERNEL $file_to_fix > /dev/null; then
833 echo No change needed in $file_to_fix
835 echo '#ifdef _KERNEL' > /tmp/$base
836 cat $file_to_fix >> /tmp/$base
837 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
838 echo Fixed $file_to_fix
840 cp /tmp/$base ${LIB}/$file
841 chmod a+r ${LIB}/$file
846 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
849 base=`basename $file`
850 if [ -r ${LIB}/$file ]; then
851 file_to_fix=${LIB}/$file
853 if [ -r ${INPUT}/$file ]; then
854 file_to_fix=${INPUT}/$file
859 if [ \! -z "$file_to_fix" ]; then
860 echo Checking $file_to_fix
861 if grep _KERNEL $file_to_fix > /dev/null; then
862 echo No change needed in $file_to_fix
864 echo '#ifdef _KERNEL' > /tmp/$base
865 cat $file_to_fix >> /tmp/$base
866 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
867 echo Fixed $file_to_fix
869 cp /tmp/$base ${LIB}/$file
870 chmod a+r ${LIB}/$file
875 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
878 base=`basename $file`
879 if [ -r ${LIB}/$file ]; then
880 file_to_fix=${LIB}/$file
882 if [ -r ${INPUT}/$file ]; then
883 file_to_fix=${INPUT}/$file
888 if [ \! -z "$file_to_fix" ]; then
889 echo Checking $file_to_fix
890 if grep _KERNEL $file_to_fix > /dev/null; then
891 echo No change needed in $file_to_fix
893 echo '#ifdef _KERNEL' > /tmp/$base
894 cat $file_to_fix >> /tmp/$base
895 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
896 echo Fixed $file_to_fix
898 cp /tmp/$base ${LIB}/$file
899 chmod a+r ${LIB}/$file
904 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
907 base=`basename $file`
908 if [ -r ${LIB}/$file ]; then
909 file_to_fix=${LIB}/$file
911 if [ -r ${INPUT}/$file ]; then
912 file_to_fix=${INPUT}/$file
917 if [ \! -z "$file_to_fix" ]; then
918 echo Checking $file_to_fix
919 if grep _KERNEL $file_to_fix > /dev/null; then
920 echo No change needed in $file_to_fix
922 echo '#ifdef _KERNEL' > /tmp/$base
923 cat $file_to_fix >> /tmp/$base
924 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
925 echo Fixed $file_to_fix
927 cp /tmp/$base ${LIB}/$file
928 chmod a+r ${LIB}/$file
933 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
936 base=`basename $file`
937 if [ -r ${LIB}/$file ]; then
938 file_to_fix=${LIB}/$file
940 if [ -r ${INPUT}/$file ]; then
941 file_to_fix=${INPUT}/$file
946 if [ \! -z "$file_to_fix" ]; then
947 echo Checking $file_to_fix
948 if grep _KERNEL $file_to_fix > /dev/null; then
949 echo No change needed in $file_to_fix
951 sed -e '/#ifdef INKERNEL/i\
953 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
954 #endif /* _KERNEL */' \
955 $file_to_fix > ${LIB}/${file}.sed
956 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
957 echo Fixed $file_to_fix
961 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
964 base=`basename $file`
965 if [ -r ${LIB}/$file ]; then
966 file_to_fix=${LIB}/$file
968 if [ -r ${INPUT}/$file ]; then
969 file_to_fix=${INPUT}/$file
974 if [ \! -z "$file_to_fix" ]; then
975 echo Checking $file_to_fix
976 if grep __GNUC__ $file_to_fix > /dev/null; then
977 echo No change needed in $file_to_fix
979 sed -e '/# ifdef __STDC__/i\
980 # if !defined (__GNUC__) && !defined (__GNUG__)' \
981 -e '/# include <sys\/byteorder.h>/s/ / /'\
982 -e '/# include <sys\/byteorder.h>/i\
983 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
984 $file_to_fix > ${LIB}/${file}.sed
985 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
986 echo Fixed $file_to_fix
990 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
991 # and the text in types.h is not erroneous.
992 ## In sys/types.h, don't name the enum for booleans.
995 #base=`basename $file`
996 #if [ -r ${LIB}/$file ]; then
997 # file_to_fix=${LIB}/$file
999 # if [ -r ${INPUT}/$file ]; then
1000 # file_to_fix=${INPUT}/$file
1005 #if [ \! -z "$file_to_fix" ]; then
1006 # echo Checking $file_to_fix
1007 # if grep "enum boolean" $file_to_fix > /dev/null; then
1008 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1009 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1010 # echo Fixed $file_to_fix
1012 # echo No change needed in $file_to_fix
1016 # Remove useless extern keyword from struct forward declarations in
1017 # <sys/stream.h> and <sys/strsubr.h>
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 stdata;/struct stdata;/g
1034 s/extern struct strevent;/struct strevent;/g
1035 ' $file_to_fix > /tmp/$base
1036 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1037 echo No change needed in $file_to_fix
1039 echo Fixed $file_to_fix
1041 cp /tmp/$base ${LIB}/$file
1042 chmod a+r ${LIB}/$file
1048 base=`basename $file`
1049 if [ -r ${LIB}/$file ]; then
1050 file_to_fix=${LIB}/$file
1052 if [ -r ${INPUT}/$file ]; then
1053 file_to_fix=${INPUT}/$file
1058 if [ \! -z "$file_to_fix" ]; then
1059 echo Checking $file_to_fix
1061 s/extern struct strbuf;/struct strbuf;/g
1062 s/extern struct uio;/struct uio;/g
1063 s/extern struct thread;/struct thread;/g
1064 s/extern struct proc;/struct proc;/g
1065 ' $file_to_fix > /tmp/$base
1066 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1067 echo No change needed in $file_to_fix
1069 echo Fixed $file_to_fix
1071 cp /tmp/$base ${LIB}/$file
1072 chmod a+r ${LIB}/$file
1077 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1080 base=`basename $file`
1081 if [ -r ${LIB}/$file ]; then
1082 file_to_fix=${LIB}/$file
1084 if [ -r ${INPUT}/$file ]; then
1085 file_to_fix=${INPUT}/$file
1090 if [ \! -z "$file_to_fix" ]; then
1091 echo Checking $file_to_fix
1092 cp $file_to_fix /tmp/$base
1099 stat (const char *path, struct stat *buf)
1101 /^lstat(path, buf)/j
1104 /^lstat(path, buf)/c
1105 lstat (const char *path, struct stat *buf)
1111 fstat (int fd, struct stat *buf)
1113 /^mknod(path, mode, dev)/j
1117 /^mknod(path, mode, dev)/c
1118 mknod (const char *path, mode_t mode, dev_t dev)
1123 1,\$s/ret\\([^u]\\)/__ret\1/g
1124 1,\$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g
1125 1,\$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g
1128 echo Fixed $file_to_fix
1130 cp /tmp/$base ${LIB}/$file
1131 chmod a+r ${LIB}/$file
1135 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1137 if [ -x /bin/sony ]; then
1140 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1143 base=`basename $file`
1144 if [ -r ${LIB}/$file ]; then
1145 file_to_fix=${LIB}/$file
1147 if [ -r ${INPUT}/$file ]; then
1148 file_to_fix=${INPUT}/$file
1153 if [ \! -z "$file_to_fix" ]; then
1154 echo Checking $file_to_fix
1155 cp $file_to_fix /tmp/$base
1158 s/__filbuf/_filbuf/g
1159 s/__flsbuf/_flsbuf/g
1161 ' /tmp/$base > /tmp/$base.sed
1162 mv /tmp/$base.sed /tmp/$base
1163 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1164 echo No change needed in $file_to_fix
1166 echo Fixed $file_to_fix
1168 cp /tmp/$base ${LIB}/$file
1169 chmod a+r ${LIB}/$file
1174 # Change <ctype.h> to not define __ctype
1177 base=`basename $file`
1178 if [ -r ${LIB}/$file ]; then
1179 file_to_fix=${LIB}/$file
1181 if [ -r ${INPUT}/$file ]; then
1182 file_to_fix=${INPUT}/$file
1187 if [ \! -z "$file_to_fix" ]; then
1188 echo Checking $file_to_fix
1189 cp $file_to_fix /tmp/$base
1193 ' /tmp/$base > /tmp/$base.sed
1194 mv /tmp/$base.sed /tmp/$base
1195 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1196 echo No change needed in $file_to_fix
1198 echo Fixed $file_to_fix
1200 cp /tmp/$base ${LIB}/$file
1201 chmod a+r ${LIB}/$file
1208 # In limits.h, put #ifndefs around things that are supposed to be defined
1209 # in float.h to avoid redefinition errors if float.h is included first.
1210 # Solaris 2.1 has this problem.
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 sed -e '/[ ]FLT_MIN[ ]/i\
1227 -e '/[ ]FLT_MIN[ ]/a\
1229 -e '/[ ]FLT_MAX[ ]/i\
1231 -e '/[ ]FLT_MAX[ ]/a\
1233 -e '/[ ]FLT_DIG[ ]/i\
1235 -e '/[ ]FLT_DIG[ ]/a\
1237 -e '/[ ]DBL_MIN[ ]/i\
1239 -e '/[ ]DBL_MIN[ ]/a\
1241 -e '/[ ]DBL_MAX[ ]/i\
1243 -e '/[ ]DBL_MAX[ ]/a\
1245 -e '/[ ]DBL_DIG[ ]/i\
1247 -e '/[ ]DBL_DIG[ ]/a\
1248 #endif' $file_to_fix > /tmp/$base
1249 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1250 echo No change needed in $file_to_fix
1252 echo Fixed $file_to_fix
1254 cp /tmp/$base ${LIB}/$file
1255 chmod a+r ${LIB}/$file
1260 echo 'Removing unneeded directories:'
1262 files=`find . -type d -print | sort -r`
1263 for file in $files; do
1264 rmdir $LIB/$file > /dev/null 2>&1
1268 echo 'Making internal symbolic non-directory links'
1270 files=`find . -type l -print`
1271 for file in $files; do
1272 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1273 if expr "$dest" : '[^/].*' > /dev/null; then
1274 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1275 if [ -f $target ]; then
1276 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1284 echo 'Replacing <sys/byteorder.h>'
1285 rm -f ${LIB}/sys/byteorder.h
1286 cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h