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 echo $file '->' $y ': Making link'
117 rm -fr ${LIB}/$file > /dev
/null
2>&1
118 ln -s ${LIB}/$y ${LIB}/$file > /dev
/null
2>&1
120 # If the link is to outside ${INPUT},
121 # treat this directory as if it actually contained the files.
122 # This line used to have $dest instead of $x.
123 # $dest seemed to be wrong for links found in subdirectories
124 # of ${INPUT}. Does this change break anything?
125 treetops
="$treetops $x ${LIB}/$file"
134 while [ $# != 0 ]; do
135 # $1 is an old directory to copy, and $2 is the new directory to copy to.
136 echo "Finding header files in $1:"
139 files
=`find . -name '*.h' -type f -print`
140 echo 'Checking header files:'
141 for file in $files; do
142 if [ -r $file ]; then
143 cp $file $2/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
147 # The following have been removed from the sed command below
148 # because it is more useful to leave these things in.
149 # The only reason to remove them was for -pedantic,
150 # which isn't much of a reason. -- rms.
153 # This code makes Solaris SCSI fail, because it changes the
154 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
155 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
156 # Disable these also, since they probably aren't safe either.
157 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
158 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
159 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
160 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
162 # The change of u_char, etc, to u_int
163 # applies to bit fields.
165 s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
166 s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
167 s/#lint(on)/defined(lint)/g
168 s/#lint(off)/!defined(lint)/g
169 s/#machine(\([^)]*\))/defined(__\1__)/g
170 s/#system(\([^)]*\))/defined(__\1__)/g
171 s/#cpu(\([^)]*\))/defined(__\1__)/g
172 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
173 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
174 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
175 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
176 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
177 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
178 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
179 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
180 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
181 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
182 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
183 s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
184 s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
185 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
186 ' $2/$file > $2/$file.
sed
187 mv $2/$file.
sed $2/$file
188 if cmp $file $2/$file >/dev
/null
2>&1; then
198 # Fix first broken decl of getcwd present on some svr4 systems.
201 base
=`basename $file`
202 if [ -r ${LIB}/$file ]; then
203 file_to_fix
=${LIB}/$file
205 if [ -r ${INPUT}/$file ]; then
206 file_to_fix
=${INPUT}/$file
211 if [ \
! -z "$file_to_fix" ]; then
212 echo Checking
$file_to_fix
213 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp
/$base
214 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
217 echo Fixed
$file_to_fix
219 cp /tmp
/$base ${LIB}/$file
220 chmod a
+r
${LIB}/$file
225 # Fix second broken decl of getcwd present on some svr4 systems. Also
226 # fix the incorrect decl of profil present on some svr4 systems.
229 base
=`basename $file`
230 if [ -r ${LIB}/$file ]; then
231 file_to_fix
=${LIB}/$file
233 if [ -r ${INPUT}/$file ]; then
234 file_to_fix
=${INPUT}/$file
239 if [ \
! -z "$file_to_fix" ]; then
240 echo Checking
$file_to_fix
241 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
242 |
sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp
/$base
243 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
246 echo Fixed
$file_to_fix
248 cp /tmp
/$base ${LIB}/$file
249 chmod a
+r
${LIB}/$file
254 # Fix the definition of NULL in <sys/param.h> so that it is conditional
255 # and so that it is correct for both C and C++.
258 base
=`basename $file`
259 if [ -r ${LIB}/$file ]; then
260 file_to_fix
=${LIB}/$file
262 if [ -r ${INPUT}/$file ]; then
263 file_to_fix
=${INPUT}/$file
268 if [ \
! -z "$file_to_fix" ]; then
269 echo Checking
$file_to_fix
270 cp $file_to_fix /tmp
/$base
273 sed -e '/^#define[ ]*NULL[ ]*0$/c\
277 #else /* !defined(__cplusplus) */\
278 #define __NULL_TYPE (void *)\
279 #endif /* !defined(__cplusplus) */\
280 #define NULL (__NULL_TYPE 0)\
281 #endif /* !defined(NULL) */' /tmp
/$base > /tmp
/$base.
sed
282 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
285 echo Fixed
$file_to_fix
287 cp /tmp
/$base.
sed ${LIB}/$file
288 chmod a
+r
${LIB}/$file
290 rm -f /tmp
/$base /tmp
/$base.
sed
293 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
294 # and so that it is correct for both C and C++.
297 base
=`basename $file`
298 if [ -r ${LIB}/$file ]; then
299 file_to_fix
=${LIB}/$file
301 if [ -r ${INPUT}/$file ]; then
302 file_to_fix
=${INPUT}/$file
307 if [ \
! -z "$file_to_fix" ]; then
308 echo Checking
$file_to_fix
309 cp $file_to_fix /tmp
/$base
311 sed -e '/^#define[ ]*NULL[ ]*0$/c\
314 #else /* !defined(__cplusplus) */\
315 #define __NULL_TYPE (void *)\
316 #endif /* !defined(__cplusplus) */\
317 #define NULL (__NULL_TYPE 0)' /tmp
/$base > /tmp
/$base.
sed
318 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
321 echo Fixed
$file_to_fix
323 cp /tmp
/$base.
sed ${LIB}/$file
324 chmod a
+r
${LIB}/$file
326 rm -f /tmp
/$base /tmp
/$base.
sed
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
347 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
351 #else /* !defined(__cplusplus) */\
352 #define __NULL_TYPE (void *)\
353 #endif /* !defined(__cplusplus) */\
354 #define NULL (__NULL_TYPE 0)\
355 #endif /* !defined(NULL) */' /tmp
/$base > /tmp
/$base.
sed
356 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
359 echo Fixed
$file_to_fix
361 cp /tmp
/$base.
sed ${LIB}/$file
362 chmod a
+r
${LIB}/$file
364 rm -f /tmp
/$base /tmp
/$base.
sed
367 # Add a prototyped declaration of mmap to <sys/mman.h>.
370 base
=`basename $file`
371 if [ -r ${LIB}/$file ]; then
372 file_to_fix
=${LIB}/$file
374 if [ -r ${INPUT}/$file ]; then
375 file_to_fix
=${INPUT}/$file
380 if [ \
! -z "$file_to_fix" ]; then
381 echo Checking
$file_to_fix
382 cp $file_to_fix /tmp
/$base
384 sed -e '/^extern caddr_t mmap();$/c\
386 extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,\
388 #else /* !defined(__STDC__) */\
389 extern caddr_t mmap ();\
390 #endif /* !defined(__STDC__) */' /tmp
/$base > /tmp
/$base.
sed
391 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
394 echo Fixed
$file_to_fix
396 cp /tmp
/$base.
sed ${LIB}/$file
397 chmod a
+r
${LIB}/$file
399 rm -f /tmp
/$base /tmp
/$base.
sed
402 # Fix declarations of `ftw' and `nftw' in <ftw.h>.
405 base
=`basename $file`
406 if [ -r ${LIB}/$file ]; then
407 file_to_fix
=${LIB}/$file
409 if [ -r ${INPUT}/$file ]; then
410 file_to_fix
=${INPUT}/$file
415 if [ \
! -z "$file_to_fix" ]; then
416 echo Checking
$file_to_fix
417 cp $file_to_fix /tmp
/$base
419 sed -e '/^extern int ftw(const/c\
420 #if !defined(_STYPES)\
425 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);' \
426 -e '/^extern int nftw/c\
427 #if defined(_STYPES)\
432 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);' \
433 -e '/^extern int ftw(),/c\
434 #if !defined(_STYPES)\
440 #if defined(_STYPES)\
445 int nftw();' /tmp
/$base > /tmp
/$base.
sed
446 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
449 echo Fixed
$file_to_fix
451 cp /tmp
/$base.
sed ${LIB}/$file
452 chmod a
+r
${LIB}/$file
454 rm -f /tmp
/$base /tmp
/$base.
sed
457 # Add a `static' declaration of `getrnge' into <regexp.h>.
459 # Don't do this if there is already a `static void getrnge' declaration
460 # present, since this would cause a redeclaration error. Solaris 2.x has
461 # such a declaration.
464 base
=`basename $file`
465 if [ -r ${LIB}/$file ]; then
466 file_to_fix
=${LIB}/$file
468 if [ -r ${INPUT}/$file ]; then
469 file_to_fix
=${INPUT}/$file
474 if [ \
! -z "$file_to_fix" ]; then
475 echo Checking
$file_to_fix
476 if grep "static void getrnge" $file_to_fix > /dev
/null
; then
479 cp $file_to_fix /tmp
/$base
481 sed -e '/^static int[ ]*size;/c\
484 static int getrnge ();' /tmp
/$base > /tmp
/$base.
sed
485 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
488 echo Fixed
$file_to_fix
490 cp /tmp
/$base.
sed ${LIB}/$file
491 chmod a
+r
${LIB}/$file
494 rm -f /tmp
/$base /tmp
/$base.
sed
497 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
498 # that is visible to any ANSI compiler using this include. Simply
499 # delete the lines the #define some string functions to internal forms.
502 base
=`basename $file`
503 if [ -r ${LIB}/$file ]; then
504 file_to_fix
=${LIB}/$file
506 if [ -r ${INPUT}/$file ]; then
507 file_to_fix
=${INPUT}/$file
512 if [ \
! -z "$file_to_fix" ]; then
513 echo Checking
$file_to_fix
514 cp $file_to_fix /tmp
/$base
516 sed -e '/#define.*__std_hdr_/d' /tmp
/$base > /tmp
/$base.
sed
517 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
520 echo Fixed
$file_to_fix
522 cp /tmp
/$base.
sed ${LIB}/$file
523 chmod a
+r
${LIB}/$file
525 rm -f /tmp
/$base /tmp
/$base.
sed
528 # Add a #define of _SIGACTION_ into <sys/signal.h>.
529 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
532 base
=`basename $file`
533 if [ -r ${LIB}/$file ]; then
534 file_to_fix
=${LIB}/$file
536 if [ -r ${INPUT}/$file ]; then
537 file_to_fix
=${INPUT}/$file
542 if [ \
! -z "$file_to_fix" ]; then
543 echo Checking
$file_to_fix
544 cp $file_to_fix /tmp
/$base
546 sed -e '/^struct sigaction {/c\
548 struct sigaction {' \
549 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp
/$base > /tmp
/$base.
sed
550 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
553 echo Fixed
$file_to_fix
555 cp /tmp
/$base.
sed ${LIB}/$file
556 chmod a
+r
${LIB}/$file
558 rm -f /tmp
/$base /tmp
/$base.
sed
561 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
564 base
=`basename $file`
565 if [ -r ${LIB}/$file ]; then
566 file_to_fix
=${LIB}/$file
568 if [ -r ${INPUT}/$file ]; then
569 file_to_fix
=${INPUT}/$file
574 if [ \
! -z "$file_to_fix" ]; then
575 echo Checking
$file_to_fix
576 cp $file_to_fix /tmp
/$base
578 sed -e '/^dev_t makedev(const/c\
579 static dev_t makedev(const major_t, const minor_t);' \
580 -e '/^dev_t makedev()/c\
581 static dev_t makedev();' \
582 -e '/^major_t major(const/c\
583 static major_t major(const dev_t);' \
584 -e '/^major_t major()/c\
585 static major_t major();' \
586 -e '/^minor_t minor(const/c\
587 static minor_t minor(const dev_t);' \
588 -e '/^minor_t minor()/c\
589 static minor_t minor();' /tmp
/$base > /tmp
/$base.
sed
590 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
593 echo Fixed
$file_to_fix
595 cp /tmp
/$base.
sed ${LIB}/$file
596 chmod a
+r
${LIB}/$file
598 rm -f /tmp
/$base /tmp
/$base.
sed
601 # Fix reference to NMSZ in <sys/adv.h>.
604 base
=`basename $file`
605 if [ -r ${LIB}/$file ]; then
606 file_to_fix
=${LIB}/$file
608 if [ -r ${INPUT}/$file ]; then
609 file_to_fix
=${INPUT}/$file
614 if [ \
! -z "$file_to_fix" ]; then
615 echo Checking
$file_to_fix
616 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp
/$base
617 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
620 echo Fixed
$file_to_fix
622 cp /tmp
/$base ${LIB}/$file
623 chmod a
+r
${LIB}/$file
628 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
629 # array initializers.
632 base
=`basename $file`
633 if [ -r ${LIB}/$file ]; then
634 file_to_fix
=${LIB}/$file
636 if [ -r ${INPUT}/$file ]; then
637 file_to_fix
=${INPUT}/$file
642 if [ \
! -z "$file_to_fix" ]; then
643 echo Checking
$file_to_fix
644 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
645 |
sed 's/NC_/(unsigned long) NC_/' > /tmp
/$base
646 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
649 echo Fixed
$file_to_fix
651 cp /tmp
/$base ${LIB}/$file
652 chmod a
+r
${LIB}/$file
657 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
659 file=fs
/rfs
/rf_cache.h
660 base
=`basename $file`
661 if [ -r ${LIB}/$file ]; then
662 file_to_fix
=${LIB}/$file
664 if [ -r ${INPUT}/$file ]; then
665 file_to_fix
=${INPUT}/$file
670 if [ \
! -z "$file_to_fix" ]; then
671 echo Checking
$file_to_fix
672 if grep _KERNEL
$file_to_fix > /dev
/null
; then
675 echo '#ifdef _KERNEL' > /tmp
/$base
676 cat $file_to_fix >> /tmp
/$base
677 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
678 echo Fixed
$file_to_fix
680 cp /tmp
/$base ${LIB}/$file
681 chmod a
+r
${LIB}/$file
686 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
689 base
=`basename $file`
690 if [ -r ${LIB}/$file ]; then
691 file_to_fix
=${LIB}/$file
693 if [ -r ${INPUT}/$file ]; then
694 file_to_fix
=${INPUT}/$file
699 if [ \
! -z "$file_to_fix" ]; then
700 echo Checking
$file_to_fix
701 if grep _KERNEL
$file_to_fix > /dev
/null
; then
704 echo '#ifdef _KERNEL' > /tmp
/$base
705 cat $file_to_fix >> /tmp
/$base
706 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
707 echo Fixed
$file_to_fix
709 cp /tmp
/$base ${LIB}/$file
710 chmod a
+r
${LIB}/$file
715 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
718 base
=`basename $file`
719 if [ -r ${LIB}/$file ]; then
720 file_to_fix
=${LIB}/$file
722 if [ -r ${INPUT}/$file ]; then
723 file_to_fix
=${INPUT}/$file
728 if [ \
! -z "$file_to_fix" ]; then
729 echo Checking
$file_to_fix
730 if grep _KERNEL
$file_to_fix > /dev
/null
; then
733 echo '#ifdef _KERNEL' > /tmp
/$base
734 cat $file_to_fix >> /tmp
/$base
735 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
736 echo Fixed
$file_to_fix
738 cp /tmp
/$base ${LIB}/$file
739 chmod a
+r
${LIB}/$file
744 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
747 base
=`basename $file`
748 if [ -r ${LIB}/$file ]; then
749 file_to_fix
=${LIB}/$file
751 if [ -r ${INPUT}/$file ]; then
752 file_to_fix
=${INPUT}/$file
757 if [ \
! -z "$file_to_fix" ]; then
758 echo Checking
$file_to_fix
759 if grep _KERNEL
$file_to_fix > /dev
/null
; then
762 echo '#ifdef _KERNEL' > /tmp
/$base
763 cat $file_to_fix >> /tmp
/$base
764 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
765 echo Fixed
$file_to_fix
767 cp /tmp
/$base ${LIB}/$file
768 chmod a
+r
${LIB}/$file
773 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
776 base
=`basename $file`
777 if [ -r ${LIB}/$file ]; then
778 file_to_fix
=${LIB}/$file
780 if [ -r ${INPUT}/$file ]; then
781 file_to_fix
=${INPUT}/$file
786 if [ \
! -z "$file_to_fix" ]; then
787 echo Checking
$file_to_fix
788 if grep _KERNEL
$file_to_fix > /dev
/null
; then
791 echo '#ifdef _KERNEL' > /tmp
/$base
792 cat $file_to_fix >> /tmp
/$base
793 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
794 echo Fixed
$file_to_fix
796 cp /tmp
/$base ${LIB}/$file
797 chmod a
+r
${LIB}/$file
802 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
805 base
=`basename $file`
806 if [ -r ${LIB}/$file ]; then
807 file_to_fix
=${LIB}/$file
809 if [ -r ${INPUT}/$file ]; then
810 file_to_fix
=${INPUT}/$file
815 if [ \
! -z "$file_to_fix" ]; then
816 echo Checking
$file_to_fix
817 if grep _KERNEL
$file_to_fix > /dev
/null
; then
820 echo '#ifdef _KERNEL' > /tmp
/$base
821 cat $file_to_fix >> /tmp
/$base
822 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
823 echo Fixed
$file_to_fix
825 cp /tmp
/$base ${LIB}/$file
826 chmod a
+r
${LIB}/$file
831 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
834 base
=`basename $file`
835 if [ -r ${LIB}/$file ]; then
836 file_to_fix
=${LIB}/$file
838 if [ -r ${INPUT}/$file ]; then
839 file_to_fix
=${INPUT}/$file
844 if [ \
! -z "$file_to_fix" ]; then
845 echo Checking
$file_to_fix
846 if grep _KERNEL
$file_to_fix > /dev
/null
; then
849 echo '#ifdef _KERNEL' > /tmp
/$base
850 cat $file_to_fix >> /tmp
/$base
851 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
852 echo Fixed
$file_to_fix
854 cp /tmp
/$base ${LIB}/$file
855 chmod a
+r
${LIB}/$file
860 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
863 base
=`basename $file`
864 if [ -r ${LIB}/$file ]; then
865 file_to_fix
=${LIB}/$file
867 if [ -r ${INPUT}/$file ]; then
868 file_to_fix
=${INPUT}/$file
873 if [ \
! -z "$file_to_fix" ]; then
874 echo Checking
$file_to_fix
875 if grep _KERNEL
$file_to_fix > /dev
/null
; then
878 echo '#ifdef _KERNEL' > /tmp
/$base
879 cat $file_to_fix >> /tmp
/$base
880 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
881 echo Fixed
$file_to_fix
883 cp /tmp
/$base ${LIB}/$file
884 chmod a
+r
${LIB}/$file
889 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
892 base
=`basename $file`
893 if [ -r ${LIB}/$file ]; then
894 file_to_fix
=${LIB}/$file
896 if [ -r ${INPUT}/$file ]; then
897 file_to_fix
=${INPUT}/$file
902 if [ \
! -z "$file_to_fix" ]; then
903 echo Checking
$file_to_fix
904 if grep _KERNEL
$file_to_fix > /dev
/null
; then
907 sed -e '/#ifdef INKERNEL/i\
909 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
910 #endif /* _KERNEL */' \
911 $file_to_fix > ${LIB}/${file}.
sed
912 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
913 echo Fixed
$file_to_fix
917 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
920 base
=`basename $file`
921 if [ -r ${LIB}/$file ]; then
922 file_to_fix
=${LIB}/$file
924 if [ -r ${INPUT}/$file ]; then
925 file_to_fix
=${INPUT}/$file
930 if [ \
! -z "$file_to_fix" ]; then
931 echo Checking
$file_to_fix
932 if grep __GNUC__
$file_to_fix > /dev
/null
; then
935 sed -e '/# ifdef __STDC__/i\
936 # if !defined (__GNUC__) && !defined (__GNUG__)' \
937 -e '/# include <sys\/byteorder.h>/s/ / /'\
938 -e '/# include <sys\/byteorder.h>/i\
939 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
940 $file_to_fix > ${LIB}/${file}.
sed
941 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
942 echo Fixed
$file_to_fix
946 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
947 # and the text in types.h is not erroneous.
948 ## In sys/types.h, don't name the enum for booleans.
951 #base=`basename $file`
952 #if [ -r ${LIB}/$file ]; then
953 # file_to_fix=${LIB}/$file
955 # if [ -r ${INPUT}/$file ]; then
956 # file_to_fix=${INPUT}/$file
961 #if [ \! -z "$file_to_fix" ]; then
962 # echo Checking $file_to_fix
963 # if grep "enum boolean" $file_to_fix > /dev/null; then
964 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
965 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
966 # echo Fixed $file_to_fix
972 # Remove useless extern keyword from struct forward declarations in
973 # <sys/stream.h> and <sys/strsubr.h>
976 base
=`basename $file`
977 if [ -r ${LIB}/$file ]; then
978 file_to_fix
=${LIB}/$file
980 if [ -r ${INPUT}/$file ]; then
981 file_to_fix
=${INPUT}/$file
986 if [ \
! -z "$file_to_fix" ]; then
987 echo Checking
$file_to_fix
989 s/extern struct stdata;/struct stdata;/g
990 s/extern struct strevent;/struct strevent;/g
991 ' $file_to_fix > /tmp
/$base
992 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
995 echo Fixed
$file_to_fix
997 cp /tmp
/$base ${LIB}/$file
998 chmod a
+r
${LIB}/$file
1004 base
=`basename $file`
1005 if [ -r ${LIB}/$file ]; then
1006 file_to_fix
=${LIB}/$file
1008 if [ -r ${INPUT}/$file ]; then
1009 file_to_fix
=${INPUT}/$file
1014 if [ \
! -z "$file_to_fix" ]; then
1015 echo Checking
$file_to_fix
1017 s/extern struct strbuf;/struct strbuf;/g
1018 s/extern struct uio;/struct uio;/g
1019 s/extern struct thread;/struct thread;/g
1020 s/extern struct proc;/struct proc;/g
1021 ' $file_to_fix > /tmp
/$base
1022 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1025 echo Fixed
$file_to_fix
1027 cp /tmp
/$base ${LIB}/$file
1028 chmod a
+r
${LIB}/$file
1033 # Put storage class at start of decl, to avoid warning.
1035 base
=`basename $file`
1036 if [ -r ${LIB}/$file ]; then
1037 file_to_fix
=${LIB}/$file
1039 if [ -r ${INPUT}/$file ]; then
1040 file_to_fix
=${INPUT}/$file
1045 if [ \
! -z "$file_to_fix" ]; then
1046 echo Checking
$file_to_fix
1048 s/const extern/extern const/g
1049 ' $file_to_fix > /tmp
/$base
1050 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1053 echo Fixed
$file_to_fix
1055 cp /tmp
/$base ${LIB}/$file
1056 chmod a
+r
${LIB}/$file
1061 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1064 base
=`basename $file`
1065 if [ -r ${LIB}/$file ]; then
1066 file_to_fix
=${LIB}/$file
1068 if [ -r ${INPUT}/$file ]; then
1069 file_to_fix
=${INPUT}/$file
1074 if [ \
! -z "$file_to_fix" ]; then
1075 echo Checking
$file_to_fix
1076 cp $file_to_fix /tmp
/$base
1107 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1108 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1109 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1110 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1111 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1112 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp
/$base > /tmp
/$base.
sed
1113 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
1116 echo Fixed
$file_to_fix
1118 cp /tmp
/$base.
sed ${LIB}/$file
1119 chmod a
+r
${LIB}/$file
1121 rm -f /tmp
/$base /tmp
/$base.
sed
1124 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1126 if [ -x /bin
/sony
]; then
1129 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1132 base
=`basename $file`
1133 if [ -r ${LIB}/$file ]; then
1134 file_to_fix
=${LIB}/$file
1136 if [ -r ${INPUT}/$file ]; then
1137 file_to_fix
=${INPUT}/$file
1142 if [ \
! -z "$file_to_fix" ]; then
1143 echo Checking
$file_to_fix
1144 cp $file_to_fix /tmp
/$base
1147 s/__filbuf/_filbuf/g
1148 s/__flsbuf/_flsbuf/g
1150 ' /tmp
/$base > /tmp
/$base.
sed
1151 mv /tmp
/$base.
sed /tmp
/$base
1152 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1155 echo Fixed
$file_to_fix
1157 cp /tmp
/$base ${LIB}/$file
1158 chmod a
+r
${LIB}/$file
1163 # Change <ctype.h> to not define __ctype
1166 base
=`basename $file`
1167 if [ -r ${LIB}/$file ]; then
1168 file_to_fix
=${LIB}/$file
1170 if [ -r ${INPUT}/$file ]; then
1171 file_to_fix
=${INPUT}/$file
1176 if [ \
! -z "$file_to_fix" ]; then
1177 echo Checking
$file_to_fix
1178 cp $file_to_fix /tmp
/$base
1182 ' /tmp
/$base > /tmp
/$base.
sed
1183 mv /tmp
/$base.
sed /tmp
/$base
1184 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1187 echo Fixed
$file_to_fix
1189 cp /tmp
/$base ${LIB}/$file
1190 chmod a
+r
${LIB}/$file
1197 # In limits.h, put #ifndefs around things that are supposed to be defined
1198 # in float.h to avoid redefinition errors if float.h is included first.
1199 # Solaris 2.1 has this problem.
1202 base
=`basename $file`
1203 if [ -r ${LIB}/$file ]; then
1204 file_to_fix
=${LIB}/$file
1206 if [ -r ${INPUT}/$file ]; then
1207 file_to_fix
=${INPUT}/$file
1212 if [ \
! -z "$file_to_fix" ]; then
1213 echo Checking
$file_to_fix
1214 sed -e '/[ ]FLT_MIN[ ]/i\
1216 -e '/[ ]FLT_MIN[ ]/a\
1218 -e '/[ ]FLT_MAX[ ]/i\
1220 -e '/[ ]FLT_MAX[ ]/a\
1222 -e '/[ ]FLT_DIG[ ]/i\
1224 -e '/[ ]FLT_DIG[ ]/a\
1226 -e '/[ ]DBL_MIN[ ]/i\
1228 -e '/[ ]DBL_MIN[ ]/a\
1230 -e '/[ ]DBL_MAX[ ]/i\
1232 -e '/[ ]DBL_MAX[ ]/a\
1234 -e '/[ ]DBL_DIG[ ]/i\
1236 -e '/[ ]DBL_DIG[ ]/a\
1237 #endif' $file_to_fix > /tmp
/$base
1238 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1241 echo Fixed
$file_to_fix
1243 cp /tmp
/$base ${LIB}/$file
1244 chmod a
+r
${LIB}/$file
1249 echo 'Removing unneeded directories:'
1251 files
=`find . -type d -print | sort -r`
1252 for file in $files; do
1253 rmdir $LIB/$file > /dev
/null
2>&1
1257 echo 'Making internal symbolic non-directory links'
1259 files
=`find . -type l -print`
1260 for file in $files; do
1261 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1262 if expr "$dest" : '[^/].*' > /dev
/null
; then
1263 target
=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1264 if [ -f $target ]; then
1265 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1273 echo 'Replacing <sys/byteorder.h>'
1274 rm -f ${LIB}/sys
/byteorder.h
1275 cp ${SRCDIR}/byteorder.h
${LIB}/sys
/byteorder.h