3 # fixinc.svr4 -- Install modified versions of certain ANSI-incompatible
4 # native System V Release 4 system include files.
6 # Written by Ron Guilmette (rfg@ncd.com).
8 # This file is part of GNU CC.
10 # GNU CC is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
15 # GNU CC is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with GNU CC; see the file COPYING. If not, write to
22 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 # This script munges the native include files provided with System V
25 # Release 4 systems so as to remove things which are violations of the
26 # ANSI C standard. Once munged, the resulting new system include files
27 # are placed in a directory that GNU C will search *before* searching
28 # the /usr/include directory. This script should work properly for most
29 # System V Release 4 systems. For other types of systems, you should
30 # use the `fixincludes' script instead.
32 # See README-fixinc for more information.
34 # Directory where gcc sources (and sometimes special include files) live.
35 SRCDIR
=${3-${SRCDIR-.}}
37 # Directory containing the original header files.
38 INPUT
=${2-${INPUT-/usr/include}}
40 # Fail if no arg to specify a directory for the output.
42 then echo fixincludes
: no output directory specified
46 # Directory in which to store the results.
47 LIB
=${1?"fixincludes: output directory not specified"}
49 # Make sure it exists.
50 if [ ! -d $LIB ]; then
59 # This prevents /bin/ex from failing if the current terminal type is
63 # This prevents /bin/ex from failing if the EXINIT environment variable
64 # was set to something invalid.
68 echo 'Building fixincludes in ' ${LIB}
70 # Determine whether this filesystem has symbolic links.
71 if ln -s X
$LIB/ShouldNotExist
2>/dev
/null
; then
72 rm -f $LIB/ShouldNotExist
78 echo 'Making directories:'
81 files
=`ls -LR | sed -n s/:$//p`
83 files
=`find . -type d -print | sed '/^.$/d'`
85 for file in $files; do
87 if [ ! -d $LIB/$file ]
92 # treetops gets an alternating list
93 # of old directories to copy
94 # and the new directories to copy to.
95 treetops
="${INPUT} ${LIB}"
98 echo 'Making internal symbolic directory links'
99 for file in $files; do
100 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
103 # In case $dest is relative, get to $file's dir first.
105 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
106 # Check that the target directory exists.
107 # Redirections changed to avoid bug in sh on Ultrix.
108 (cd $dest) > /dev
/null
2>&1
111 # X gets the dir that the link actually leads to.
113 # If link leads back into ${INPUT},
114 # make a similar link here.
115 if expr $x : "${INPUT}/.*" > /dev
/null
; then
116 # Y gets the actual target dir name, relative to ${INPUT}.
117 y
=`echo $x | sed -n "s&${INPUT}/&&p"`
118 echo $file '->' $y ': Making link'
119 rm -fr ${LIB}/$file > /dev
/null
2>&1
120 ln -s ${LIB}/$y ${LIB}/$file > /dev
/null
2>&1
122 # If the link is to outside ${INPUT},
123 # treat this directory as if it actually contained the files.
124 # This line used to have $dest instead of $x.
125 # $dest seemed to be wrong for links found in subdirectories
126 # of ${INPUT}. Does this change break anything?
127 treetops
="$treetops $x ${LIB}/$file"
136 while [ $# != 0 ]; do
137 # $1 is an old directory to copy, and $2 is the new directory to copy to.
138 echo "Finding header files in $1:"
141 files
=`find . -name '*.h' -type f -print`
142 echo 'Checking header files:'
143 for file in $files; do
145 if [ -r $file ]; then
146 cp $file $2/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
149 # The following have been removed from the sed command below
150 # because it is more useful to leave these things in.
151 # The only reason to remove them was for -pedantic,
152 # which isn't much of a reason. -- rms.
155 # The change of u_char, etc, to u_int
156 # applies to bit fields.
158 s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
159 s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
160 s/#lint(on)/defined(lint)/g
161 s/#lint(off)/!defined(lint)/g
162 s/#machine(\([^)]*\))/defined(__\1__)/g
163 s/#system(\([^)]*\))/defined(__\1__)/g
164 s/#cpu(\([^)]*\))/defined(__\1__)/g
165 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
166 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
167 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
168 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
169 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
170 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
171 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
172 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
173 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
174 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
175 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
176 s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
177 s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
178 s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
179 s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
180 s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
181 s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
182 s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
183 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
184 ' $2/$file > $2/$file.
sed
185 mv $2/$file.
sed $2/$file
186 if cmp $file $2/$file >/dev
/null
2>&1; then
187 echo Deleting
$2/$file\
; no fixes were needed.
195 # Fix first broken decl of getcwd present on some svr4 systems.
198 base
=`basename $file`
199 if [ -r ${LIB}/$file ]; then
200 file_to_fix
=${LIB}/$file
202 if [ -r ${INPUT}/$file ]; then
203 file_to_fix
=${INPUT}/$file
208 if [ \
! -z "$file_to_fix" ]; then
209 echo Checking
$file_to_fix
210 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp
/$base
211 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
212 echo No change needed
in $file_to_fix
214 echo Fixed
$file_to_fix
216 cp /tmp
/$base ${LIB}/$file
221 # Fix second broken decl of getcwd present on some svr4 systems. Also
222 # fix the incorrect decl of profil present on some svr4 systems.
225 base
=`basename $file`
226 if [ -r ${LIB}/$file ]; then
227 file_to_fix
=${LIB}/$file
229 if [ -r ${INPUT}/$file ]; then
230 file_to_fix
=${INPUT}/$file
235 if [ \
! -z "$file_to_fix" ]; then
236 echo Checking
$file_to_fix
237 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
238 |
sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp
/$base
239 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
240 echo No change needed
in $file_to_fix
242 echo Fixed
$file_to_fix
244 cp /tmp
/$base ${LIB}/$file
249 # Fix the definition of NULL in <sys/param.h> so that it is conditional
250 # and so that it is correct for both C and C++.
253 base
=`basename $file`
254 if [ -r ${LIB}/$file ]; then
255 file_to_fix
=${LIB}/$file
257 if [ -r ${INPUT}/$file ]; then
258 file_to_fix
=${INPUT}/$file
263 if [ \
! -z "$file_to_fix" ]; then
264 echo Checking
$file_to_fix
265 cp $file_to_fix /tmp
/$base
268 /^#define[ ]*NULL[ ]*0$/c
272 #else /* !defined(__cplusplus) */
273 #define __NULL_TYPE (void *)
274 #endif /* !defined(__cplusplus) */
275 #define NULL (__NULL_TYPE 0)
276 #endif /* !defined(NULL) */
280 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
281 echo No change needed
in $file_to_fix
283 echo Fixed
$file_to_fix
285 cp /tmp
/$base ${LIB}/$file
290 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
291 # and so that it is correct for both C and C++.
294 base
=`basename $file`
295 if [ -r ${LIB}/$file ]; then
296 file_to_fix
=${LIB}/$file
298 if [ -r ${INPUT}/$file ]; then
299 file_to_fix
=${INPUT}/$file
304 if [ \
! -z "$file_to_fix" ]; then
305 echo Checking
$file_to_fix
306 cp $file_to_fix /tmp
/$base
309 /^#define[ ]*NULL[ ]*0$/c
312 #else /* !defined(__cplusplus) */
313 #define __NULL_TYPE (void *)
314 #endif /* !defined(__cplusplus) */
315 #define NULL (__NULL_TYPE 0)
319 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
320 echo No change needed
in $file_to_fix
322 echo Fixed
$file_to_fix
324 cp /tmp
/$base ${LIB}/$file
329 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
330 # and so that it is correct for both C and C++.
333 base
=`basename $file`
334 if [ -r ${LIB}/$file ]; then
335 file_to_fix
=${LIB}/$file
337 if [ -r ${INPUT}/$file ]; then
338 file_to_fix
=${INPUT}/$file
343 if [ \
! -z "$file_to_fix" ]; then
344 echo Checking
$file_to_fix
345 cp $file_to_fix /tmp
/$base
348 /^#define[ ]*NULL[ ]*((char \*) 0)$/c
352 #else /* !defined(__cplusplus) */
353 #define __NULL_TYPE (void *)
354 #endif /* !defined(__cplusplus) */
355 #define NULL (__NULL_TYPE 0)
356 #endif /* !defined(NULL) */
360 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
361 echo No change needed
in $file_to_fix
363 echo Fixed
$file_to_fix
365 cp /tmp
/$base ${LIB}/$file
370 # Add a prototyped declaration of mmap to <sys/mman.h>.
373 base
=`basename $file`
374 if [ -r ${LIB}/$file ]; then
375 file_to_fix
=${LIB}/$file
377 if [ -r ${INPUT}/$file ]; then
378 file_to_fix
=${INPUT}/$file
383 if [ \
! -z "$file_to_fix" ]; then
384 echo Checking
$file_to_fix
385 cp $file_to_fix /tmp
/$base
388 /^extern caddr_t mmap();$/c
390 extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,
392 #else /* !defined(__STDC__) */
393 extern caddr_t mmap ();
394 #endif /* !defined(__STDC__) */
398 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
399 echo No changed needed
in $file_to_fix
401 echo Fixed
$file_to_fix
403 cp /tmp
/$base ${LIB}/$file
408 # Fix declarations of `ftw' and `nftw' in <ftw.h>.
411 base
=`basename $file`
412 if [ -r ${LIB}/$file ]; then
413 file_to_fix
=${LIB}/$file
415 if [ -r ${INPUT}/$file ]; then
416 file_to_fix
=${INPUT}/$file
421 if [ \
! -z "$file_to_fix" ]; then
422 echo Checking
$file_to_fix
423 cp $file_to_fix /tmp
/$base
426 /^extern int ftw(const/c
427 #if !defined(_STYPES)
432 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
440 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);
442 /^extern int ftw(),/c
443 #if !defined(_STYPES)
458 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
459 echo No change needed
in $file_to_fix
461 echo Fixed
$file_to_fix
463 cp /tmp
/$base ${LIB}/$file
468 # Add a `static' declaration of `getrnge' into <regexp.h>.
471 base
=`basename $file`
472 if [ -r ${LIB}/$file ]; then
473 file_to_fix
=${LIB}/$file
475 if [ -r ${INPUT}/$file ]; then
476 file_to_fix
=${INPUT}/$file
481 if [ \
! -z "$file_to_fix" ]; then
482 echo Checking
$file_to_fix
483 cp $file_to_fix /tmp
/$base
486 /^static int[ ]*size;/c
489 static int getrnge ();
493 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
494 echo No change needed
in $file_to_fix
496 echo Fixed
$file_to_fix
498 cp /tmp
/$base ${LIB}/$file
503 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
504 # that is visible to any ANSI compiler using this include. Simply
505 # delete the lines the #define some string functions to internal forms.
508 base
=`basename $file`
509 if [ -r ${LIB}/$file ]; then
510 file_to_fix
=${LIB}/$file
512 if [ -r ${INPUT}/$file ]; then
513 file_to_fix
=${INPUT}/$file
518 if [ \
! -z "$file_to_fix" ]; then
519 echo Checking
$file_to_fix
520 cp $file_to_fix /tmp
/$base
523 g/#define.*__std_hdr_/d
526 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
527 echo No change needed
in $file_to_fix
529 echo Fixed
$file_to_fix
531 cp /tmp
/$base ${LIB}/$file
536 # Add a #define of _SIGACTION_ into <sys/signal.h>.
537 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
540 base
=`basename $file`
541 if [ -r ${LIB}/$file ]; then
542 file_to_fix
=${LIB}/$file
544 if [ -r ${INPUT}/$file ]; then
545 file_to_fix
=${INPUT}/$file
550 if [ \
! -z "$file_to_fix" ]; then
551 echo Checking
$file_to_fix
552 cp $file_to_fix /tmp
/$base
555 /^struct sigaction {/c
559 1,\$s/(void *(\*)())/(void (*)(int))/
562 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
563 echo No change needed
in $file_to_fix
565 echo Fixed
$file_to_fix
567 cp /tmp
/$base ${LIB}/$file
572 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
575 base
=`basename $file`
576 if [ -r ${LIB}/$file ]; then
577 file_to_fix
=${LIB}/$file
579 if [ -r ${INPUT}/$file ]; then
580 file_to_fix
=${INPUT}/$file
585 if [ \
! -z "$file_to_fix" ]; then
586 echo Checking
$file_to_fix
587 cp $file_to_fix /tmp
/$base
590 /^dev_t makedev(const/c
591 static dev_t makedev(const major_t, const minor_t);
594 static dev_t makedev();
596 /^major_t major(const/c
597 static major_t major(const dev_t);
600 static major_t major();
602 /^minor_t minor(const/c
603 static minor_t minor(const dev_t);
606 static minor_t minor();
610 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
611 echo No change needed
in $file_to_fix
613 echo Fixed
$file_to_fix
615 cp /tmp
/$base ${LIB}/$file
620 # Fix reference to NMSZ in <sys/adv.h>.
623 base
=`basename $file`
624 if [ -r ${LIB}/$file ]; then
625 file_to_fix
=${LIB}/$file
627 if [ -r ${INPUT}/$file ]; then
628 file_to_fix
=${INPUT}/$file
633 if [ \
! -z "$file_to_fix" ]; then
634 echo Checking
$file_to_fix
635 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp
/$base
636 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
637 echo No change needed
in $file_to_fix
639 echo Fixed
$file_to_fix
641 cp /tmp
/$base ${LIB}/$file
646 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
647 # array initializers.
650 base
=`basename $file`
651 if [ -r ${LIB}/$file ]; then
652 file_to_fix
=${LIB}/$file
654 if [ -r ${INPUT}/$file ]; then
655 file_to_fix
=${INPUT}/$file
660 if [ \
! -z "$file_to_fix" ]; then
661 echo Checking
$file_to_fix
662 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
663 |
sed 's/NC_/(unsigned long) NC_/' > /tmp
/$base
664 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
665 echo No change needed
in $file_to_fix
667 echo Fixed
$file_to_fix
669 cp /tmp
/$base ${LIB}/$file
674 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
676 file=fs
/rfs
/rf_cache.h
677 base
=`basename $file`
678 if [ -r ${LIB}/$file ]; then
679 file_to_fix
=${LIB}/$file
681 if [ -r ${INPUT}/$file ]; then
682 file_to_fix
=${INPUT}/$file
687 if [ \
! -z "$file_to_fix" ]; then
688 echo Checking
$file_to_fix
689 if grep _KERNEL
$file_to_fix > /dev
/null
; then
690 echo No change needed
in $file_to_fix
692 echo '#ifdef _KERNEL' > /tmp
/$base
693 cat $file_to_fix >> /tmp
/$base
694 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
695 echo Fixed
$file_to_fix
697 cp /tmp
/$base ${LIB}/$file
702 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
705 base
=`basename $file`
706 if [ -r ${LIB}/$file ]; then
707 file_to_fix
=${LIB}/$file
709 if [ -r ${INPUT}/$file ]; then
710 file_to_fix
=${INPUT}/$file
715 if [ \
! -z "$file_to_fix" ]; then
716 echo Checking
$file_to_fix
717 if grep _KERNEL
$file_to_fix > /dev
/null
; then
718 echo No change needed
in $file_to_fix
720 echo '#ifdef _KERNEL' > /tmp
/$base
721 cat $file_to_fix >> /tmp
/$base
722 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
723 echo Fixed
$file_to_fix
725 cp /tmp
/$base ${LIB}/$file
730 # Conditionalize all of <sys/err.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
758 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
761 base
=`basename $file`
762 if [ -r ${LIB}/$file ]; then
763 file_to_fix
=${LIB}/$file
765 if [ -r ${INPUT}/$file ]; then
766 file_to_fix
=${INPUT}/$file
771 if [ \
! -z "$file_to_fix" ]; then
772 echo Checking
$file_to_fix
773 if grep _KERNEL
$file_to_fix > /dev
/null
; then
774 echo No change needed
in $file_to_fix
776 echo '#ifdef _KERNEL' > /tmp
/$base
777 cat $file_to_fix >> /tmp
/$base
778 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
779 echo Fixed
$file_to_fix
781 cp /tmp
/$base ${LIB}/$file
786 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
789 base
=`basename $file`
790 if [ -r ${LIB}/$file ]; then
791 file_to_fix
=${LIB}/$file
793 if [ -r ${INPUT}/$file ]; then
794 file_to_fix
=${INPUT}/$file
799 if [ \
! -z "$file_to_fix" ]; then
800 echo Checking
$file_to_fix
801 if grep _KERNEL
$file_to_fix > /dev
/null
; then
802 echo No change needed
in $file_to_fix
804 echo '#ifdef _KERNEL' > /tmp
/$base
805 cat $file_to_fix >> /tmp
/$base
806 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
807 echo Fixed
$file_to_fix
809 cp /tmp
/$base ${LIB}/$file
814 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
817 base
=`basename $file`
818 if [ -r ${LIB}/$file ]; then
819 file_to_fix
=${LIB}/$file
821 if [ -r ${INPUT}/$file ]; then
822 file_to_fix
=${INPUT}/$file
827 if [ \
! -z "$file_to_fix" ]; then
828 echo Checking
$file_to_fix
829 if grep _KERNEL
$file_to_fix > /dev
/null
; then
830 echo No change needed
in $file_to_fix
832 echo '#ifdef _KERNEL' > /tmp
/$base
833 cat $file_to_fix >> /tmp
/$base
834 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
835 echo Fixed
$file_to_fix
837 cp /tmp
/$base ${LIB}/$file
842 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
845 base
=`basename $file`
846 if [ -r ${LIB}/$file ]; then
847 file_to_fix
=${LIB}/$file
849 if [ -r ${INPUT}/$file ]; then
850 file_to_fix
=${INPUT}/$file
855 if [ \
! -z "$file_to_fix" ]; then
856 echo Checking
$file_to_fix
857 if grep _KERNEL
$file_to_fix > /dev
/null
; then
858 echo No change needed
in $file_to_fix
860 echo '#ifdef _KERNEL' > /tmp
/$base
861 cat $file_to_fix >> /tmp
/$base
862 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
863 echo Fixed
$file_to_fix
865 cp /tmp
/$base ${LIB}/$file
870 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
873 base
=`basename $file`
874 if [ -r ${LIB}/$file ]; then
875 file_to_fix
=${LIB}/$file
877 if [ -r ${INPUT}/$file ]; then
878 file_to_fix
=${INPUT}/$file
883 if [ \
! -z "$file_to_fix" ]; then
884 echo Checking
$file_to_fix
885 if grep _KERNEL
$file_to_fix > /dev
/null
; then
886 echo No change needed
in $file_to_fix
888 echo '#ifdef _KERNEL' > /tmp
/$base
889 cat $file_to_fix >> /tmp
/$base
890 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
891 echo Fixed
$file_to_fix
893 cp /tmp
/$base ${LIB}/$file
898 # Remove useless extern keyword from struct forward declarations in
899 # <sys/stream.h> and <sys/strsubr.h>
902 base
=`basename $file`
903 if [ -r ${LIB}/$file ]; then
904 file_to_fix
=${LIB}/$file
906 if [ -r ${INPUT}/$file ]; then
907 file_to_fix
=${INPUT}/$file
912 if [ \
! -z "$file_to_fix" ]; then
913 echo Checking
$file_to_fix
915 s/extern struct stdata;/struct stdata;/g
916 s/extern struct strevent;/struct strevent;/g
917 ' $file_to_fix > /tmp
/$base
918 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
919 echo No change needed
in $file_to_fix
921 echo Fixed
$file_to_fix
923 cp /tmp
/$base ${LIB}/$file
929 base
=`basename $file`
930 if [ -r ${LIB}/$file ]; then
931 file_to_fix
=${LIB}/$file
933 if [ -r ${INPUT}/$file ]; then
934 file_to_fix
=${INPUT}/$file
939 if [ \
! -z "$file_to_fix" ]; then
940 echo Checking
$file_to_fix
942 s/extern struct strbuf;/struct strbuf;/g
943 s/extern struct uio;/struct uio;/g
944 s/extern struct thread;/struct thread;/g
945 s/extern struct proc;/struct proc;/g
946 ' $file_to_fix > /tmp
/$base
947 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
948 echo No change needed
in $file_to_fix
950 echo Fixed
$file_to_fix
952 cp /tmp
/$base ${LIB}/$file
957 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
960 base
=`basename $file`
961 if [ -r ${LIB}/$file ]; then
962 file_to_fix
=${LIB}/$file
964 if [ -r ${INPUT}/$file ]; then
965 file_to_fix
=${INPUT}/$file
970 if [ \
! -z "$file_to_fix" ]; then
971 echo Checking
$file_to_fix
972 cp $file_to_fix /tmp
/$base
979 stat (const char *path, struct stat *buf)
985 lstat (const char *path, struct stat *buf)
991 fstat (int fd, struct stat *buf)
993 /^mknod(path, mode, dev)/j
997 /^mknod(path, mode, dev)/c
998 mknod (const char *path, mode_t mode, dev_t dev)
1003 1,\$s/ret\\([^u]\\)/__ret\1/g
1004 1,\$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g
1005 1,\$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g
1008 echo Fixed
$file_to_fix
1010 cp /tmp
/$base ${LIB}/$file
1014 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1016 if [ -x /bin
/sony
]; then
1019 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1022 base
=`basename $file`
1023 if [ -r ${LIB}/$file ]; then
1024 file_to_fix
=${LIB}/$file
1026 if [ -r ${INPUT}/$file ]; then
1027 file_to_fix
=${INPUT}/$file
1032 if [ \
! -z "$file_to_fix" ]; then
1033 echo Checking
$file_to_fix
1034 cp $file_to_fix /tmp
/$base
1037 s/__filbuf/_filbuf/g
1038 s/__flsbuf/_flsbuf/g
1040 ' /tmp
/$base > /tmp
/$base.
sed
1041 mv /tmp
/$base.
sed /tmp
/$base
1042 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1043 echo No change needed
in $file_to_fix
1045 echo Fixed
$file_to_fix
1047 cp /tmp
/$base ${LIB}/$file
1052 # Change <ctype.h> to not define __ctype
1055 base
=`basename $file`
1056 if [ -r ${LIB}/$file ]; then
1057 file_to_fix
=${LIB}/$file
1059 if [ -r ${INPUT}/$file ]; then
1060 file_to_fix
=${INPUT}/$file
1065 if [ \
! -z "$file_to_fix" ]; then
1066 echo Checking
$file_to_fix
1067 cp $file_to_fix /tmp
/$base
1071 ' /tmp
/$base > /tmp
/$base.
sed
1072 mv /tmp
/$base.
sed /tmp
/$base
1073 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1074 echo No change needed
in $file_to_fix
1076 echo Fixed
$file_to_fix
1078 cp /tmp
/$base ${LIB}/$file
1085 echo 'Removing unneeded directories:'
1087 files
=`find . -type d -print | sort -r`
1088 for file in $files; do
1089 rmdir $LIB/$file > /dev
/null
2>&1
1093 echo 'Making internal symbolic non-directory links'
1095 files
=`find . -type l -print`
1096 for file in $files; do
1097 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1098 if expr "$dest" : '[^/].*' > /dev
/null
; then
1099 target
=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1100 if [ -f $target ]; then
1101 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1109 echo 'Replacing <sys/byteorder.h>'
1110 rm -f ${LIB}/sys
/byteorder.h
1111 cp ${SRCDIR}/byteorder.h
${LIB}/sys
/byteorder.h