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
64 echo 'Building fixincludes in ' ${LIB}
66 # Determine whether this filesystem has symbolic links.
67 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
68 rm -f $LIB/ShouldNotExist
74 echo 'Making directories:'
77 files=`ls -LR | sed -n s/:$//p`
79 files=`find . -type d -print | sed '/^.$/d'`
81 for file in $files; do
83 if [ ! -d $LIB/$file ]
88 # treetops gets an alternating list
89 # of old directories to copy
90 # and the new directories to copy to.
91 treetops="${INPUT} ${LIB}"
94 echo 'Making internal symbolic directory links'
95 for file in $files; do
96 dest=`ls -ld $file | sed -n 's/.*-> //p'`
99 # In case $dest is relative, get to $file's dir first.
101 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
102 # Check that the target directory exists.
103 # Redirections changed to avoid bug in sh on Ultrix.
104 (cd $dest) > /dev/null 2>&1
107 # X gets the dir that the link actually leads to.
109 # If link leads back into ${INPUT},
110 # make a similar link here.
111 if expr $x : "${INPUT}/.*" > /dev/null; then
112 # Y gets the actual target dir name, relative to ${INPUT}.
113 y=`echo $x | sed -n "s&${INPUT}/&&p"`
114 echo $file '->' $y ': Making link'
115 rm -fr ${LIB}/$file > /dev/null 2>&1
116 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
118 # If the link is to outside ${INPUT},
119 # treat this directory as if it actually contained the files.
120 # This line used to have $dest instead of $x.
121 # $dest seemed to be wrong for links found in subdirectories
122 # of ${INPUT}. Does this change break anything?
123 treetops="$treetops $x ${LIB}/$file"
132 while [ $# != 0 ]; do
133 # $1 is an old directory to copy, and $2 is the new directory to copy to.
134 echo "Finding header files in $1:"
137 files=`find . -name '*.h' -type f -print`
138 echo 'Checking header files:'
139 for file in $files; do
141 if [ -r $file ]; then
142 cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
145 # The following have been removed from the sed command below
146 # because it is more useful to leave these things in.
147 # The only reason to remove them was for -pedantic,
148 # which isn't much of a reason. -- rms.
151 # The change of u_char, etc, to u_int
152 # applies to bit fields.
154 s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
155 s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
156 s/#lint(on)/defined(lint)/g
157 s/#lint(off)/!defined(lint)/g
158 s/#machine(\([^)]*\))/defined(__\1__)/g
159 s/#system(\([^)]*\))/defined(__\1__)/g
160 s/#cpu(\([^)]*\))/defined(__\1__)/g
161 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
162 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
163 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
164 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
165 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
166 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
167 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
168 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
169 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
170 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
171 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
172 s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
173 s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
174 s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
175 s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
176 s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
177 s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
178 s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
179 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
180 ' $2/$file > $2/$file.sed
181 mv $2/$file.sed $2/$file
182 if cmp $file $2/$file >/dev/null 2>&1; then
183 echo Deleting $2/$file\; no fixes were needed.
191 # Fix first broken decl of getcwd present on some svr4 systems.
194 base=`basename $file`
195 if [ -r ${LIB}/$file ]; then
196 file_to_fix=${LIB}/$file
198 if [ -r ${INPUT}/$file ]; then
199 file_to_fix=${INPUT}/$file
204 if [ \! -z "$file_to_fix" ]; then
205 echo Checking $file_to_fix
206 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
207 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
208 echo No change needed in $file_to_fix
210 echo Fixed $file_to_fix
212 cp /tmp/$base ${LIB}/$file
217 # Fix second broken decl of getcwd present on some svr4 systems. Also
218 # fix the incorrect decl of profil present on some svr4 systems.
221 base=`basename $file`
222 if [ -r ${LIB}/$file ]; then
223 file_to_fix=${LIB}/$file
225 if [ -r ${INPUT}/$file ]; then
226 file_to_fix=${INPUT}/$file
231 if [ \! -z "$file_to_fix" ]; then
232 echo Checking $file_to_fix
233 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
234 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
235 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
236 echo No change needed in $file_to_fix
238 echo Fixed $file_to_fix
240 cp /tmp/$base ${LIB}/$file
245 # Fix the definition of NULL in <sys/param.h> so that it is conditional
246 # and so that it is correct for both C and C++.
249 base=`basename $file`
250 if [ -r ${LIB}/$file ]; then
251 file_to_fix=${LIB}/$file
253 if [ -r ${INPUT}/$file ]; then
254 file_to_fix=${INPUT}/$file
259 if [ \! -z "$file_to_fix" ]; then
260 echo Checking $file_to_fix
261 cp $file_to_fix /tmp/$base
264 /^#define[ ]*NULL[ ]*0$/c
268 #else /* !defined(__cplusplus) */
269 #define __NULL_TYPE (void *)
270 #endif /* !defined(__cplusplus) */
271 #define NULL (__NULL_TYPE 0)
272 #endif /* !defined(NULL) */
276 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
277 echo No change needed in $file_to_fix
279 echo Fixed $file_to_fix
281 cp /tmp/$base ${LIB}/$file
286 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
287 # and so that it is correct for both C and C++.
290 base=`basename $file`
291 if [ -r ${LIB}/$file ]; then
292 file_to_fix=${LIB}/$file
294 if [ -r ${INPUT}/$file ]; then
295 file_to_fix=${INPUT}/$file
300 if [ \! -z "$file_to_fix" ]; then
301 echo Checking $file_to_fix
302 cp $file_to_fix /tmp/$base
305 /^#define[ ]*NULL[ ]*0$/c
308 #else /* !defined(__cplusplus) */
309 #define __NULL_TYPE (void *)
310 #endif /* !defined(__cplusplus) */
311 #define NULL (__NULL_TYPE 0)
315 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
316 echo No change needed in $file_to_fix
318 echo Fixed $file_to_fix
320 cp /tmp/$base ${LIB}/$file
325 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
326 # and so that it is correct for both C and C++.
329 base=`basename $file`
330 if [ -r ${LIB}/$file ]; then
331 file_to_fix=${LIB}/$file
333 if [ -r ${INPUT}/$file ]; then
334 file_to_fix=${INPUT}/$file
339 if [ \! -z "$file_to_fix" ]; then
340 echo Checking $file_to_fix
341 cp $file_to_fix /tmp/$base
344 /^#define[ ]*NULL[ ]*((char \*) 0)$/c
348 #else /* !defined(__cplusplus) */
349 #define __NULL_TYPE (void *)
350 #endif /* !defined(__cplusplus) */
351 #define NULL (__NULL_TYPE 0)
352 #endif /* !defined(NULL) */
356 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
357 echo No change needed in $file_to_fix
359 echo Fixed $file_to_fix
361 cp /tmp/$base ${LIB}/$file
366 # Add a prototyped declaration of mmap to <sys/mman.h>.
369 base=`basename $file`
370 if [ -r ${LIB}/$file ]; then
371 file_to_fix=${LIB}/$file
373 if [ -r ${INPUT}/$file ]; then
374 file_to_fix=${INPUT}/$file
379 if [ \! -z "$file_to_fix" ]; then
380 echo Checking $file_to_fix
381 cp $file_to_fix /tmp/$base
384 /^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__) */
394 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
395 echo No changed needed in $file_to_fix
397 echo Fixed $file_to_fix
399 cp /tmp/$base ${LIB}/$file
404 # Fix declarations of `ftw' and `nftw' in <ftw.h>.
407 base=`basename $file`
408 if [ -r ${LIB}/$file ]; then
409 file_to_fix=${LIB}/$file
411 if [ -r ${INPUT}/$file ]; then
412 file_to_fix=${INPUT}/$file
417 if [ \! -z "$file_to_fix" ]; then
418 echo Checking $file_to_fix
419 cp $file_to_fix /tmp/$base
422 /^extern int ftw(const/c
423 #if !defined(_STYPES)
428 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
436 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);
438 /^extern int ftw(),/c
439 #if !defined(_STYPES)
454 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
455 echo No change needed in $file_to_fix
457 echo Fixed $file_to_fix
459 cp /tmp/$base ${LIB}/$file
464 # Add a `static' declaration of `getrnge' into <regexp.h>.
467 base=`basename $file`
468 if [ -r ${LIB}/$file ]; then
469 file_to_fix=${LIB}/$file
471 if [ -r ${INPUT}/$file ]; then
472 file_to_fix=${INPUT}/$file
477 if [ \! -z "$file_to_fix" ]; then
478 echo Checking $file_to_fix
479 cp $file_to_fix /tmp/$base
482 /^static int[ ]*size;/c
485 static int getrnge ();
489 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
490 echo No change needed in $file_to_fix
492 echo Fixed $file_to_fix
494 cp /tmp/$base ${LIB}/$file
499 # Add a #define of _SIGACTION_ into <sys/signal.h>.
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
517 /^struct sigaction {/c
523 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
524 echo No change needed in $file_to_fix
526 echo Fixed $file_to_fix
528 cp /tmp/$base ${LIB}/$file
533 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
536 base=`basename $file`
537 if [ -r ${LIB}/$file ]; then
538 file_to_fix=${LIB}/$file
540 if [ -r ${INPUT}/$file ]; then
541 file_to_fix=${INPUT}/$file
546 if [ \! -z "$file_to_fix" ]; then
547 echo Checking $file_to_fix
548 cp $file_to_fix /tmp/$base
551 /^dev_t makedev(const/c
552 static dev_t makedev(const major_t, const minor_t);
555 static dev_t makedev();
557 /^major_t major(const/c
558 static major_t major(const dev_t);
561 static major_t major();
563 /^minor_t minor(const/c
564 static minor_t minor(const dev_t);
567 static minor_t minor();
571 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
572 echo No change needed in $file_to_fix
574 echo Fixed $file_to_fix
576 cp /tmp/$base ${LIB}/$file
581 # Fix reference to NMSZ in <sys/adv.h>.
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 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
597 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
598 echo No change needed in $file_to_fix
600 echo Fixed $file_to_fix
602 cp /tmp/$base ${LIB}/$file
607 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
608 # array initializers.
611 base=`basename $file`
612 if [ -r ${LIB}/$file ]; then
613 file_to_fix=${LIB}/$file
615 if [ -r ${INPUT}/$file ]; then
616 file_to_fix=${INPUT}/$file
621 if [ \! -z "$file_to_fix" ]; then
622 echo Checking $file_to_fix
623 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
624 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
625 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
626 echo No change needed in $file_to_fix
628 echo Fixed $file_to_fix
630 cp /tmp/$base ${LIB}/$file
635 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
637 file=fs/rfs/rf_cache.h
638 base=`basename $file`
639 if [ -r ${LIB}/$file ]; then
640 file_to_fix=${LIB}/$file
642 if [ -r ${INPUT}/$file ]; then
643 file_to_fix=${INPUT}/$file
648 if [ \! -z "$file_to_fix" ]; then
649 echo Checking $file_to_fix
650 if grep _KERNEL $file_to_fix > /dev/null; then
651 echo No change needed in $file_to_fix
653 echo '#ifdef _KERNEL' > /tmp/$base
654 cat $file_to_fix >> /tmp/$base
655 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
656 echo Fixed $file_to_fix
658 cp /tmp/$base ${LIB}/$file
663 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
666 base=`basename $file`
667 if [ -r ${LIB}/$file ]; then
668 file_to_fix=${LIB}/$file
670 if [ -r ${INPUT}/$file ]; then
671 file_to_fix=${INPUT}/$file
676 if [ \! -z "$file_to_fix" ]; then
677 echo Checking $file_to_fix
678 if grep _KERNEL $file_to_fix > /dev/null; then
679 echo No change needed in $file_to_fix
681 echo '#ifdef _KERNEL' > /tmp/$base
682 cat $file_to_fix >> /tmp/$base
683 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
684 echo Fixed $file_to_fix
686 cp /tmp/$base ${LIB}/$file
691 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
694 base=`basename $file`
695 if [ -r ${LIB}/$file ]; then
696 file_to_fix=${LIB}/$file
698 if [ -r ${INPUT}/$file ]; then
699 file_to_fix=${INPUT}/$file
704 if [ \! -z "$file_to_fix" ]; then
705 echo Checking $file_to_fix
706 if grep _KERNEL $file_to_fix > /dev/null; then
707 echo No change needed in $file_to_fix
709 echo '#ifdef _KERNEL' > /tmp/$base
710 cat $file_to_fix >> /tmp/$base
711 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
712 echo Fixed $file_to_fix
714 cp /tmp/$base ${LIB}/$file
719 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
722 base=`basename $file`
723 if [ -r ${LIB}/$file ]; then
724 file_to_fix=${LIB}/$file
726 if [ -r ${INPUT}/$file ]; then
727 file_to_fix=${INPUT}/$file
732 if [ \! -z "$file_to_fix" ]; then
733 echo Checking $file_to_fix
734 if grep _KERNEL $file_to_fix > /dev/null; then
735 echo No change needed in $file_to_fix
737 echo '#ifdef _KERNEL' > /tmp/$base
738 cat $file_to_fix >> /tmp/$base
739 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
740 echo Fixed $file_to_fix
742 cp /tmp/$base ${LIB}/$file
747 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
750 base=`basename $file`
751 if [ -r ${LIB}/$file ]; then
752 file_to_fix=${LIB}/$file
754 if [ -r ${INPUT}/$file ]; then
755 file_to_fix=${INPUT}/$file
760 if [ \! -z "$file_to_fix" ]; then
761 echo Checking $file_to_fix
762 if grep _KERNEL $file_to_fix > /dev/null; then
763 echo No change needed in $file_to_fix
765 echo '#ifdef _KERNEL' > /tmp/$base
766 cat $file_to_fix >> /tmp/$base
767 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
768 echo Fixed $file_to_fix
770 cp /tmp/$base ${LIB}/$file
775 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
778 base=`basename $file`
779 if [ -r ${LIB}/$file ]; then
780 file_to_fix=${LIB}/$file
782 if [ -r ${INPUT}/$file ]; then
783 file_to_fix=${INPUT}/$file
788 if [ \! -z "$file_to_fix" ]; then
789 echo Checking $file_to_fix
790 if grep _KERNEL $file_to_fix > /dev/null; then
791 echo No change needed in $file_to_fix
793 echo '#ifdef _KERNEL' > /tmp/$base
794 cat $file_to_fix >> /tmp/$base
795 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
796 echo Fixed $file_to_fix
798 cp /tmp/$base ${LIB}/$file
803 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
806 base=`basename $file`
807 if [ -r ${LIB}/$file ]; then
808 file_to_fix=${LIB}/$file
810 if [ -r ${INPUT}/$file ]; then
811 file_to_fix=${INPUT}/$file
816 if [ \! -z "$file_to_fix" ]; then
817 echo Checking $file_to_fix
818 if grep _KERNEL $file_to_fix > /dev/null; then
819 echo No change needed in $file_to_fix
821 echo '#ifdef _KERNEL' > /tmp/$base
822 cat $file_to_fix >> /tmp/$base
823 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
824 echo Fixed $file_to_fix
826 cp /tmp/$base ${LIB}/$file
831 # Conditionalize all of <sys/kdebugger.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
847 echo No change needed in $file_to_fix
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
859 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
861 if [ -x /bin/sony ]; then
864 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
867 base=`basename $file`
868 if [ -r ${LIB}/$file ]; then
869 file_to_fix=${LIB}/$file
871 if [ -r ${INPUT}/$file ]; then
872 file_to_fix=${INPUT}/$file
877 if [ \! -z "$file_to_fix" ]; then
878 echo Checking $file_to_fix
879 cp $file_to_fix /tmp/$base
885 ' /tmp/$base > /tmp/$base.sed
886 mv /tmp/$base.sed /tmp/$base
887 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
888 echo No change needed in $file_to_fix
890 echo Fixed $file_to_fix
892 cp /tmp/$base ${LIB}/$file
897 # Change <ctype.h> to not define __ctype
900 base=`basename $file`
901 if [ -r ${LIB}/$file ]; then
902 file_to_fix=${LIB}/$file
904 if [ -r ${INPUT}/$file ]; then
905 file_to_fix=${INPUT}/$file
910 if [ \! -z "$file_to_fix" ]; then
911 echo Checking $file_to_fix
912 cp $file_to_fix /tmp/$base
916 ' /tmp/$base > /tmp/$base.sed
917 mv /tmp/$base.sed /tmp/$base
918 if cmp $file_to_fix /tmp/$base.sed >/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
930 echo 'Removing unneeded directories:'
932 files=`find . -type d -print | sort -r`
933 for file in $files; do
934 rmdir $LIB/$file > /dev/null 2>&1
938 echo 'Making internal symbolic non-directory links'
940 files=`find . -type l -print`
941 for file in $files; do
942 dest=`ls -ld $file | sed -n 's/.*-> //p'`
943 if expr "$dest" : '[^/].*' > /dev/null; then
944 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
945 if [ -f $target ]; then
946 ln -s $dest ${LIB}/$file >/dev/null 2>&1
954 echo 'Replacing <sys/byteorder.h>'
955 rm -f ${LIB}/sys/byteorder.h
956 cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h