OSDN Git Service

(ieeefp.h): Delete definitions of __mips and __m68k.
[pf3gnuchains/gcc-fork.git] / gcc / fixinc.svr4
1 #! /bin/sh
2 #
3 #   fixinc.svr4  --  Install modified versions of certain ANSI-incompatible
4 #   native System V Release 4 system include files.
5 #
6 #   Written by Ron Guilmette (rfg@ncd.com).
7 #
8 # This file is part of GNU CC.
9
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)
13 # any later version.
14
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.
19
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.
23 #
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.
31 #
32 #       See README-fixinc for more information.
33
34 # Directory where gcc sources (and sometimes special include files) live.
35 SRCDIR=${3-${SRCDIR-.}}
36
37 # Directory containing the original header files.
38 INPUT=${2-${INPUT-/usr/include}}
39
40 # Fail if no arg to specify a directory for the output.
41 if [ x$1 = x ]
42 then echo fixincludes: no output directory specified
43 exit 1
44 fi
45
46 # Directory in which to store the results.
47 LIB=${1?"fixincludes: output directory not specified"}
48
49 # Make sure it exists.
50 if [ ! -d $LIB ]; then
51   mkdir $LIB || exit 1
52 fi
53
54 ORIG_DIR=`pwd`
55
56 # Make LIB absolute if it is relative.
57 # Don't do this if not necessary, since may screw up automounters.
58 case $LIB in
59 /*)
60         ;;
61 *)
62         cd $LIB; LIB=`${PWDCMD-pwd}`
63         ;;
64 esac
65
66 echo 'Building fixincludes in ' ${LIB}
67
68 # Determine whether this filesystem has symbolic links.
69 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
70   rm -f $LIB/ShouldNotExist
71   LINKS=true
72 else
73   LINKS=false
74 fi
75
76 echo 'Making directories:'
77 cd ${INPUT}
78 if $LINKS; then
79   files=`ls -LR | sed -n s/:$//p`
80 else
81   files=`find . -type d -print | sed '/^.$/d'`
82 fi
83 for file in $files; do
84   rm -rf $LIB/$file
85   if [ ! -d $LIB/$file ]
86   then mkdir $LIB/$file
87   fi
88 done
89
90 # treetops gets an alternating list
91 # of old directories to copy
92 # and the new directories to copy to.
93 treetops="${INPUT} ${LIB}"
94
95 if $LINKS; then
96   echo 'Making internal symbolic directory links'
97   for file in $files; do
98     dest=`ls -ld $file | sed -n 's/.*-> //p'`
99     if [ "$dest" ]; then    
100       cwd=`pwd`
101       # In case $dest is relative, get to $file's dir first.
102       cd ${INPUT}
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
107       if [ $? = 0 ]; then
108         cd $dest
109         # X gets the dir that the link actually leads to.
110         x=`pwd`
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
119         else
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"
126         fi
127       fi
128       cd $cwd
129     fi
130   done
131 fi
132
133 set - $treetops
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:"
137   cd ${INPUT}
138   cd $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"
144         chmod +w $2/$file
145         chmod a+r $2/$file
146
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.
151 #         /^[   ]*#[    ]*ident/d
152
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/
161
162 # The change of u_char, etc, to u_int
163 # applies to bit fields.
164         sed -e '
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
189            rm $2/$file
190         else
191            echo Fixed $file
192         fi
193       fi
194   done
195   shift; shift
196 done
197
198 # Fix first broken decl of getcwd present on some svr4 systems.
199
200 file=stdlib.h
201 base=`basename $file`
202 if [ -r ${LIB}/$file ]; then
203   file_to_fix=${LIB}/$file
204 else
205   if [ -r ${INPUT}/$file ]; then
206     file_to_fix=${INPUT}/$file
207   else
208     file_to_fix=""
209   fi
210 fi
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 \
215     true
216   else
217     echo Fixed $file_to_fix
218     rm -f ${LIB}/$file
219     cp /tmp/$base ${LIB}/$file
220     chmod a+r ${LIB}/$file
221   fi
222   rm -f /tmp/$base
223 fi
224
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.
227
228 file=unistd.h
229 base=`basename $file`
230 if [ -r ${LIB}/$file ]; then
231   file_to_fix=${LIB}/$file
232 else
233   if [ -r ${INPUT}/$file ]; then
234     file_to_fix=${INPUT}/$file
235   else
236     file_to_fix=""
237   fi
238 fi
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 \
244     true
245   else
246     echo Fixed $file_to_fix
247     rm -f ${LIB}/$file
248     cp /tmp/$base ${LIB}/$file
249     chmod a+r ${LIB}/$file
250   fi
251   rm -f /tmp/$base
252 fi
253
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++.
256
257 file=sys/param.h
258 base=`basename $file`
259 if [ -r ${LIB}/$file ]; then
260   file_to_fix=${LIB}/$file
261 else
262   if [ -r ${INPUT}/$file ]; then
263     file_to_fix=${INPUT}/$file
264   else
265     file_to_fix=""
266   fi
267 fi
268 if [ \! -z "$file_to_fix" ]; then
269   echo Checking $file_to_fix
270   cp $file_to_fix /tmp/$base
271   chmod +w /tmp/$base
272   chmod a+r /tmp/$base
273   sed -e '/^#define[    ]*NULL[         ]*0$/c\
274 #ifndef NULL\
275 #ifdef __cplusplus\
276 #define __NULL_TYPE\
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 \
283     true
284   else
285     echo Fixed $file_to_fix
286     rm -f ${LIB}/$file
287     cp /tmp/$base.sed ${LIB}/$file
288     chmod a+r ${LIB}/$file
289   fi
290   rm -f /tmp/$base /tmp/$base.sed
291 fi
292
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++.
295
296 file=stdio.h
297 base=`basename $file`
298 if [ -r ${LIB}/$file ]; then
299   file_to_fix=${LIB}/$file
300 else
301   if [ -r ${INPUT}/$file ]; then
302     file_to_fix=${INPUT}/$file
303   else
304     file_to_fix=""
305   fi
306 fi
307 if [ \! -z "$file_to_fix" ]; then
308   echo Checking $file_to_fix
309   cp $file_to_fix /tmp/$base
310   chmod +w /tmp/$base
311   sed -e '/^#define[    ]*NULL[         ]*0$/c\
312 #ifdef __cplusplus\
313 #define __NULL_TYPE\
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 \
319     true
320   else
321     echo Fixed $file_to_fix
322     rm -f ${LIB}/$file
323     cp /tmp/$base.sed ${LIB}/$file
324     chmod a+r ${LIB}/$file
325   fi
326   rm -f /tmp/$base /tmp/$base.sed
327 fi
328
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++.
331
332 file=dbm.h
333 base=`basename $file`
334 if [ -r ${LIB}/$file ]; then
335   file_to_fix=${LIB}/$file
336 else
337   if [ -r ${INPUT}/$file ]; then
338     file_to_fix=${INPUT}/$file
339   else
340     file_to_fix=""
341   fi
342 fi
343 if [ \! -z "$file_to_fix" ]; then
344   echo Checking $file_to_fix
345   cp $file_to_fix /tmp/$base
346   chmod +w /tmp/$base
347   sed -e '/^#define[    ]*NULL[         ]*((char \*) 0)$/c\
348 #ifndef NULL\
349 #ifdef __cplusplus\
350 #define __NULL_TYPE\
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 \
357     true
358   else
359     echo Fixed $file_to_fix
360     rm -f ${LIB}/$file
361     cp /tmp/$base.sed ${LIB}/$file
362     chmod a+r ${LIB}/$file
363   fi
364   rm -f /tmp/$base /tmp/$base.sed
365 fi
366
367 # Add a prototyped declaration of mmap to <sys/mman.h>.
368
369 file=sys/mman.h
370 base=`basename $file`
371 if [ -r ${LIB}/$file ]; then
372   file_to_fix=${LIB}/$file
373 else
374   if [ -r ${INPUT}/$file ]; then
375     file_to_fix=${INPUT}/$file
376   else
377     file_to_fix=""
378   fi
379 fi
380 if [ \! -z "$file_to_fix" ]; then
381   echo Checking $file_to_fix
382   cp $file_to_fix /tmp/$base
383   chmod +w /tmp/$base
384   sed -e '/^extern caddr_t mmap();$/c\
385 #ifdef __STDC__\
386 extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,\
387                      int fd, off_t off);\
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 \
392     true
393   else
394     echo Fixed $file_to_fix
395     rm -f ${LIB}/$file
396     cp /tmp/$base.sed ${LIB}/$file
397     chmod a+r ${LIB}/$file
398   fi
399   rm -f /tmp/$base /tmp/$base.sed
400 fi
401
402 # Fix declarations of `ftw' and `nftw' in <ftw.h>.
403
404 file=ftw.h
405 base=`basename $file`
406 if [ -r ${LIB}/$file ]; then
407   file_to_fix=${LIB}/$file
408 else
409   if [ -r ${INPUT}/$file ]; then
410     file_to_fix=${INPUT}/$file
411   else
412     file_to_fix=""
413   fi
414 fi
415 if [ \! -z "$file_to_fix" ]; then
416   echo Checking $file_to_fix
417   cp $file_to_fix /tmp/$base
418   chmod +w /tmp/$base
419   sed -e '/^extern int ftw(const/c\
420 #if !defined(_STYPES)\
421 static\
422 #else\
423 extern\
424 #endif\
425   int ftw(const char *, int (*)(const char *, const struct stat *, int), int);' \
426   -e '/^extern int nftw/c\
427 #if defined(_STYPES)\
428 static\
429 #else\
430 extern\
431 #endif\
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)\
435 static\
436 #else\
437 extern\
438 #endif\
439   int ftw();\
440 #if defined(_STYPES)\
441 static\
442 #else\
443 extern\
444 #endif\
445   int nftw();' /tmp/$base > /tmp/$base.sed
446   if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
447     true
448   else
449     echo Fixed $file_to_fix
450     rm -f ${LIB}/$file
451     cp /tmp/$base.sed ${LIB}/$file
452     chmod a+r ${LIB}/$file
453   fi
454   rm -f /tmp/$base /tmp/$base.sed
455 fi
456
457 # Add a `static' declaration of `getrnge' into <regexp.h>.
458
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.
462
463 file=regexp.h
464 base=`basename $file`
465 if [ -r ${LIB}/$file ]; then
466   file_to_fix=${LIB}/$file
467 else
468   if [ -r ${INPUT}/$file ]; then
469     file_to_fix=${INPUT}/$file
470   else
471     file_to_fix=""
472   fi
473 fi
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
477     true
478   else
479     cp $file_to_fix /tmp/$base
480     chmod +w /tmp/$base
481     sed -e '/^static int[       ]*size;/c\
482 static int      size ;\
483 \
484 static int getrnge ();' /tmp/$base > /tmp/$base.sed
485     if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
486       true
487     else
488       echo Fixed $file_to_fix
489       rm -f ${LIB}/$file
490       cp /tmp/$base.sed ${LIB}/$file
491       chmod a+r ${LIB}/$file
492     fi
493   fi
494   rm -f /tmp/$base /tmp/$base.sed
495 fi
496
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 that #define some string functions to internal forms.
500
501 file=string.h
502 base=`basename $file`
503 if [ -r ${LIB}/$file ]; then
504   file_to_fix=${LIB}/$file
505 else
506   if [ -r ${INPUT}/$file ]; then
507     file_to_fix=${INPUT}/$file
508   else
509     file_to_fix=""
510   fi
511 fi
512 if [ \! -z "$file_to_fix" ]; then
513   echo Checking $file_to_fix
514   cp $file_to_fix /tmp/$base
515   chmod +w /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 \
518     true
519   else
520     echo Fixed $file_to_fix
521     rm -f ${LIB}/$file
522     cp /tmp/$base.sed ${LIB}/$file
523     chmod a+r ${LIB}/$file
524   fi
525   rm -f /tmp/$base /tmp/$base.sed
526 fi
527
528 # Delete any #defines of `__i386' which may be present in <ieeefp.h>.  They
529 # tend to conflict with the compiler's own definition of this symbol.  (We
530 # will use the compiler's definition.)
531 # Likewise __sparc, for Solaris, and __i860, and a few others
532 # (guessing it is necessary for all of them).
533
534 file=ieeefp.h
535 base=`basename $file`
536 if [ -r ${LIB}/$file ]; then
537   file_to_fix=${LIB}/$file
538 else
539   if [ -r ${INPUT}/$file ]; then
540     file_to_fix=${INPUT}/$file
541   else
542     file_to_fix=""
543   fi
544 fi
545 if [ \! -z "$file_to_fix" ]; then
546   echo Checking $file_to_fix
547   cp $file_to_fix /tmp/$base
548   chmod +w /tmp/$base
549   sed -e '/#define[     ]*__i386 /d' -e '/#define[      ]*__sparc /d' \
550       -e '/#define[     ]*__i860 /d' -e '/#define[      ]*__m88k /d' \
551       -e '/#define[     ]*__mips /d' -e '/#define[      ]*__m68k /d' \
552      /tmp/$base > /tmp/$base.sed
553   if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
554     true
555   else
556     echo Fixed $file_to_fix 
557     rm -f ${LIB}/$file
558     cp /tmp/$base.sed ${LIB}/$file 
559     chmod a+r ${LIB}/$file
560   fi
561   rm -f /tmp/$base /tmp/$base.sed 
562 fi 
563
564 # Add a #define of _SIGACTION_ into <sys/signal.h>.
565 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
566
567 file=sys/signal.h
568 base=`basename $file`
569 if [ -r ${LIB}/$file ]; then
570   file_to_fix=${LIB}/$file
571 else
572   if [ -r ${INPUT}/$file ]; then
573     file_to_fix=${INPUT}/$file
574   else
575     file_to_fix=""
576   fi
577 fi
578 if [ \! -z "$file_to_fix" ]; then
579   echo Checking $file_to_fix
580   cp $file_to_fix /tmp/$base
581   chmod +w /tmp/$base
582   sed -e '/^struct sigaction {/c\
583 #define _SIGACTION_\
584 struct  sigaction  {' \
585   -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
586   if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
587     true
588   else
589     echo Fixed $file_to_fix
590     rm -f ${LIB}/$file
591     cp /tmp/$base.sed ${LIB}/$file
592     chmod a+r ${LIB}/$file
593   fi
594   rm -f /tmp/$base /tmp/$base.sed
595 fi
596
597 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
598
599 file=sys/mkdev.h
600 base=`basename $file`
601 if [ -r ${LIB}/$file ]; then
602   file_to_fix=${LIB}/$file
603 else
604   if [ -r ${INPUT}/$file ]; then
605     file_to_fix=${INPUT}/$file
606   else
607     file_to_fix=""
608   fi
609 fi
610 if [ \! -z "$file_to_fix" ]; then
611   echo Checking $file_to_fix
612   cp $file_to_fix /tmp/$base
613   chmod +w /tmp/$base
614   sed -e '/^dev_t makedev(const/c\
615 static dev_t makedev(const major_t, const minor_t);' \
616   -e '/^dev_t makedev()/c\
617 static dev_t makedev();' \
618   -e '/^major_t major(const/c\
619 static major_t major(const dev_t);' \
620   -e '/^major_t major()/c\
621 static major_t major();' \
622   -e '/^minor_t minor(const/c\
623 static minor_t minor(const dev_t);' \
624   -e '/^minor_t minor()/c\
625 static minor_t minor();' /tmp/$base > /tmp/$base.sed
626   if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
627     true
628   else
629     echo Fixed $file_to_fix
630     rm -f ${LIB}/$file
631     cp /tmp/$base.sed ${LIB}/$file
632     chmod a+r ${LIB}/$file
633   fi
634   rm -f /tmp/$base /tmp/$base.sed
635 fi
636
637 # Fix reference to NMSZ in <sys/adv.h>.
638
639 file=sys/adv.h
640 base=`basename $file`
641 if [ -r ${LIB}/$file ]; then
642   file_to_fix=${LIB}/$file
643 else
644   if [ -r ${INPUT}/$file ]; then
645     file_to_fix=${INPUT}/$file
646   else
647     file_to_fix=""
648   fi
649 fi
650 if [ \! -z "$file_to_fix" ]; then
651   echo Checking $file_to_fix
652   sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
653   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
654     true
655   else
656     echo Fixed $file_to_fix
657     rm -f ${LIB}/$file
658     cp /tmp/$base ${LIB}/$file
659     chmod a+r ${LIB}/$file
660   fi
661   rm -f /tmp/$base
662 fi
663
664 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>.  Also fix types of
665 # array initializers.
666
667 file=sys/netcspace.h
668 base=`basename $file`
669 if [ -r ${LIB}/$file ]; then
670   file_to_fix=${LIB}/$file
671 else
672   if [ -r ${INPUT}/$file ]; then
673     file_to_fix=${INPUT}/$file
674   else
675     file_to_fix=""
676   fi
677 fi
678 if [ \! -z "$file_to_fix" ]; then
679   echo Checking $file_to_fix
680   sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
681     | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
682   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
683     true
684   else
685     echo Fixed $file_to_fix
686     rm -f ${LIB}/$file
687     cp /tmp/$base ${LIB}/$file
688     chmod a+r ${LIB}/$file
689   fi
690   rm -f /tmp/$base
691 fi
692
693 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
694
695 file=fs/rfs/rf_cache.h
696 base=`basename $file`
697 if [ -r ${LIB}/$file ]; then
698   file_to_fix=${LIB}/$file
699 else
700   if [ -r ${INPUT}/$file ]; then
701     file_to_fix=${INPUT}/$file
702   else
703     file_to_fix=""
704   fi
705 fi
706 if [ \! -z "$file_to_fix" ]; then
707   echo Checking $file_to_fix
708   if grep _KERNEL $file_to_fix > /dev/null; then
709     true
710   else
711     echo '#ifdef _KERNEL' > /tmp/$base
712     cat $file_to_fix >> /tmp/$base
713     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
714     echo Fixed $file_to_fix
715     rm -f ${LIB}/$file
716     cp /tmp/$base ${LIB}/$file
717     chmod a+r ${LIB}/$file
718     rm -f /tmp/$base
719   fi
720 fi
721
722 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
723
724 file=sys/erec.h
725 base=`basename $file`
726 if [ -r ${LIB}/$file ]; then
727   file_to_fix=${LIB}/$file
728 else
729   if [ -r ${INPUT}/$file ]; then
730     file_to_fix=${INPUT}/$file
731   else
732     file_to_fix=""
733   fi
734 fi
735 if [ \! -z "$file_to_fix" ]; then
736   echo Checking $file_to_fix
737   if grep _KERNEL $file_to_fix > /dev/null; then
738     true
739   else
740     echo '#ifdef _KERNEL' > /tmp/$base
741     cat $file_to_fix >> /tmp/$base
742     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
743     echo Fixed $file_to_fix
744     rm -f ${LIB}/$file
745     cp /tmp/$base ${LIB}/$file
746     chmod a+r ${LIB}/$file
747     rm -f /tmp/$base
748   fi
749 fi
750
751 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
752
753 file=sys/err.h
754 base=`basename $file`
755 if [ -r ${LIB}/$file ]; then
756   file_to_fix=${LIB}/$file
757 else
758   if [ -r ${INPUT}/$file ]; then
759     file_to_fix=${INPUT}/$file
760   else
761     file_to_fix=""
762   fi
763 fi
764 if [ \! -z "$file_to_fix" ]; then
765   echo Checking $file_to_fix
766   if grep _KERNEL $file_to_fix > /dev/null; then
767     true
768   else
769     echo '#ifdef _KERNEL' > /tmp/$base
770     cat $file_to_fix >> /tmp/$base
771     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
772     echo Fixed $file_to_fix
773     rm -f ${LIB}/$file
774     cp /tmp/$base ${LIB}/$file
775     chmod a+r ${LIB}/$file
776     rm -f /tmp/$base
777   fi
778 fi
779
780 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
781
782 file=sys/char.h
783 base=`basename $file`
784 if [ -r ${LIB}/$file ]; then
785   file_to_fix=${LIB}/$file
786 else
787   if [ -r ${INPUT}/$file ]; then
788     file_to_fix=${INPUT}/$file
789   else
790     file_to_fix=""
791   fi
792 fi
793 if [ \! -z "$file_to_fix" ]; then
794   echo Checking $file_to_fix
795   if grep _KERNEL $file_to_fix > /dev/null; then
796     true
797   else
798     echo '#ifdef _KERNEL' > /tmp/$base
799     cat $file_to_fix >> /tmp/$base
800     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
801     echo Fixed $file_to_fix
802     rm -f ${LIB}/$file
803     cp /tmp/$base ${LIB}/$file
804     chmod a+r ${LIB}/$file
805     rm -f /tmp/$base
806   fi
807 fi
808
809 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
810
811 file=sys/getpages.h
812 base=`basename $file`
813 if [ -r ${LIB}/$file ]; then
814   file_to_fix=${LIB}/$file
815 else
816   if [ -r ${INPUT}/$file ]; then
817     file_to_fix=${INPUT}/$file
818   else
819     file_to_fix=""
820   fi
821 fi
822 if [ \! -z "$file_to_fix" ]; then
823   echo Checking $file_to_fix
824   if grep _KERNEL $file_to_fix > /dev/null; then
825     true
826   else
827     echo '#ifdef _KERNEL' > /tmp/$base
828     cat $file_to_fix >> /tmp/$base
829     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
830     echo Fixed $file_to_fix
831     rm -f ${LIB}/$file
832     cp /tmp/$base ${LIB}/$file
833     chmod a+r ${LIB}/$file
834     rm -f /tmp/$base
835   fi
836 fi
837
838 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
839
840 file=sys/map.h
841 base=`basename $file`
842 if [ -r ${LIB}/$file ]; then
843   file_to_fix=${LIB}/$file
844 else
845   if [ -r ${INPUT}/$file ]; then
846     file_to_fix=${INPUT}/$file
847   else
848     file_to_fix=""
849   fi
850 fi
851 if [ \! -z "$file_to_fix" ]; then
852   echo Checking $file_to_fix
853   if grep _KERNEL $file_to_fix > /dev/null; then
854     true
855   else
856     echo '#ifdef _KERNEL' > /tmp/$base
857     cat $file_to_fix >> /tmp/$base
858     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
859     echo Fixed $file_to_fix
860     rm -f ${LIB}/$file
861     cp /tmp/$base ${LIB}/$file
862     chmod a+r ${LIB}/$file
863     rm -f /tmp/$base
864   fi
865 fi
866
867 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
868
869 file=sys/cmn_err.h
870 base=`basename $file`
871 if [ -r ${LIB}/$file ]; then
872   file_to_fix=${LIB}/$file
873 else
874   if [ -r ${INPUT}/$file ]; then
875     file_to_fix=${INPUT}/$file
876   else
877     file_to_fix=""
878   fi
879 fi
880 if [ \! -z "$file_to_fix" ]; then
881   echo Checking $file_to_fix
882   if grep _KERNEL $file_to_fix > /dev/null; then
883     true
884   else
885     echo '#ifdef _KERNEL' > /tmp/$base
886     cat $file_to_fix >> /tmp/$base
887     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
888     echo Fixed $file_to_fix
889     rm -f ${LIB}/$file
890     cp /tmp/$base ${LIB}/$file
891     chmod a+r ${LIB}/$file
892     rm -f /tmp/$base
893   fi
894 fi
895
896 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
897
898 file=sys/kdebugger.h
899 base=`basename $file`
900 if [ -r ${LIB}/$file ]; then
901   file_to_fix=${LIB}/$file
902 else
903   if [ -r ${INPUT}/$file ]; then
904     file_to_fix=${INPUT}/$file
905   else
906     file_to_fix=""
907   fi
908 fi
909 if [ \! -z "$file_to_fix" ]; then
910   echo Checking $file_to_fix
911   if grep _KERNEL $file_to_fix > /dev/null; then
912     true
913   else
914     echo '#ifdef _KERNEL' > /tmp/$base
915     cat $file_to_fix >> /tmp/$base
916     echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
917     echo Fixed $file_to_fix
918     rm -f ${LIB}/$file
919     cp /tmp/$base ${LIB}/$file
920     chmod a+r ${LIB}/$file
921     rm -f /tmp/$base
922   fi
923 fi
924
925 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
926
927 file=netinet/in.h
928 base=`basename $file`
929 if [ -r ${LIB}/$file ]; then
930   file_to_fix=${LIB}/$file
931 else
932   if [ -r ${INPUT}/$file ]; then
933     file_to_fix=${INPUT}/$file
934   else
935     file_to_fix=""
936   fi
937 fi
938 if [ \! -z "$file_to_fix" ]; then
939   echo Checking $file_to_fix
940   if grep _KERNEL $file_to_fix > /dev/null; then
941     true
942   else
943     sed -e '/#ifdef INKERNEL/i\
944 #ifdef _KERNEL' \
945     -e '/#endif[        ]*\/\* INKERNEL \*\//a\
946 #endif /* _KERNEL */' \
947     $file_to_fix > ${LIB}/${file}.sed
948     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
949     echo Fixed $file_to_fix
950   fi
951 fi
952
953 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
954
955 file=sys/endian.h
956 base=`basename $file`
957 if [ -r ${LIB}/$file ]; then
958   file_to_fix=${LIB}/$file
959 else
960   if [ -r ${INPUT}/$file ]; then
961     file_to_fix=${INPUT}/$file
962   else
963     file_to_fix=""
964   fi
965 fi
966 if [ \! -z "$file_to_fix" ]; then
967   echo Checking $file_to_fix
968   if grep __GNUC__ $file_to_fix > /dev/null; then
969     true
970   else
971     sed -e '/#  ifdef   __STDC__/i\
972 #   if !defined (__GNUC__) && !defined (__GNUG__)' \
973     -e '/#              include <sys\/byteorder.h>/s/           /   /'\
974     -e '/#   include    <sys\/byteorder.h>/i\
975 #   endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
976     $file_to_fix > ${LIB}/${file}.sed
977     rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
978     echo Fixed $file_to_fix
979   fi
980 fi
981
982 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
983 # and the text in types.h is not erroneous.
984 ## In sys/types.h, don't name the enum for booleans.
985 #
986 #file=sys/types.h
987 #base=`basename $file`
988 #if [ -r ${LIB}/$file ]; then
989 #  file_to_fix=${LIB}/$file
990 #else
991 #  if [ -r ${INPUT}/$file ]; then
992 #    file_to_fix=${INPUT}/$file
993 #  else
994 #    file_to_fix=""
995 #  fi
996 #fi
997 #if [ \! -z "$file_to_fix" ]; then
998 #  echo Checking $file_to_fix
999 #  if grep "enum boolean" $file_to_fix > /dev/null; then
1000 #    sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1001 #    rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1002 #    echo Fixed $file_to_fix
1003 #  else
1004 #    true
1005 #  fi
1006 #fi
1007
1008 # Remove useless extern keyword from struct forward declarations in
1009 # <sys/stream.h> and <sys/strsubr.h>
1010
1011 file=sys/stream.h
1012 base=`basename $file`
1013 if [ -r ${LIB}/$file ]; then
1014   file_to_fix=${LIB}/$file
1015 else
1016   if [ -r ${INPUT}/$file ]; then
1017     file_to_fix=${INPUT}/$file
1018   else
1019     file_to_fix=""
1020   fi
1021 fi
1022 if [ \! -z "$file_to_fix" ]; then
1023   echo Checking $file_to_fix
1024   sed -e '
1025     s/extern struct stdata;/struct stdata;/g
1026     s/extern struct strevent;/struct strevent;/g
1027   ' $file_to_fix > /tmp/$base 
1028   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1029     true
1030   else
1031     echo Fixed $file_to_fix
1032     rm -f ${LIB}/$file
1033     cp /tmp/$base ${LIB}/$file
1034     chmod a+r ${LIB}/$file
1035   fi
1036   rm -f /tmp/$base
1037 fi
1038
1039 file=sys/strsubr.h
1040 base=`basename $file`
1041 if [ -r ${LIB}/$file ]; then
1042   file_to_fix=${LIB}/$file
1043 else
1044   if [ -r ${INPUT}/$file ]; then
1045     file_to_fix=${INPUT}/$file
1046   else
1047     file_to_fix=""
1048   fi
1049 fi
1050 if [ \! -z "$file_to_fix" ]; then
1051   echo Checking $file_to_fix
1052   sed -e '
1053     s/extern struct strbuf;/struct strbuf;/g
1054     s/extern struct uio;/struct uio;/g
1055     s/extern struct thread;/struct thread;/g
1056     s/extern struct proc;/struct proc;/g
1057   ' $file_to_fix > /tmp/$base 
1058   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1059     true
1060   else
1061     echo Fixed $file_to_fix
1062     rm -f ${LIB}/$file
1063     cp /tmp/$base ${LIB}/$file
1064     chmod a+r ${LIB}/$file
1065   fi
1066   rm -f /tmp/$base
1067 fi
1068
1069 # Put storage class at start of decl, to avoid warning.
1070 file=rpc/types.h
1071 base=`basename $file`
1072 if [ -r ${LIB}/$file ]; then
1073   file_to_fix=${LIB}/$file
1074 else
1075   if [ -r ${INPUT}/$file ]; then
1076     file_to_fix=${INPUT}/$file
1077   else
1078     file_to_fix=""
1079   fi
1080 fi
1081 if [ \! -z "$file_to_fix" ]; then
1082   echo Checking $file_to_fix
1083   sed -e '
1084     s/const extern/extern const/g
1085   ' $file_to_fix > /tmp/$base 
1086   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1087     true
1088   else
1089     echo Fixed $file_to_fix
1090     rm -f ${LIB}/$file
1091     cp /tmp/$base ${LIB}/$file
1092     chmod a+r ${LIB}/$file
1093   fi
1094   rm -f /tmp/$base
1095 fi
1096
1097 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1098
1099 file=sys/stat.h
1100 base=`basename $file`
1101 if [ -r ${LIB}/$file ]; then
1102   file_to_fix=${LIB}/$file
1103 else
1104   if [ -r ${INPUT}/$file ]; then
1105     file_to_fix=${INPUT}/$file
1106   else
1107     file_to_fix=""
1108   fi
1109 fi
1110 if [ \! -z "$file_to_fix" ]; then
1111   echo Checking $file_to_fix
1112   cp $file_to_fix /tmp/$base
1113   chmod +w /tmp/$base
1114   sed -e '/^stat(/{
1115 N
1116 N
1117 s/(.*)\n/( /
1118 s/;\n/, /
1119 s/;$/)/
1120 }' \
1121   -e '/^lstat(/{
1122 N
1123 N
1124 s/(.*)\n/( /
1125 s/;\n/, /
1126 s/;$/)/
1127 }' \
1128   -e '/^fstat(/{
1129 N
1130 N
1131 s/(.*)\n/( /
1132 s/;\n/, /
1133 s/;$/)/
1134 }' \
1135   -e '/^mknod(/{
1136 N
1137 N
1138 N
1139 s/(.*)\n/( /
1140 s/;\n/, /g
1141 s/;$/)/
1142 }' \
1143   -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1144   -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1145   -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1146   -e '1,$s/ret\([^u]\)/__ret\1/g' \
1147   -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1148   -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1149   if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1150     true
1151   else
1152     echo Fixed $file_to_fix
1153     rm -f ${LIB}/$file
1154     cp /tmp/$base.sed ${LIB}/$file
1155     chmod a+r ${LIB}/$file
1156   fi
1157   rm -f /tmp/$base /tmp/$base.sed
1158 fi
1159
1160 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1161
1162 if [ -x /bin/sony ]; then
1163   if /bin/sony; then
1164
1165     # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1166
1167     file=stdio.h
1168     base=`basename $file`
1169     if [ -r ${LIB}/$file ]; then
1170       file_to_fix=${LIB}/$file
1171     else
1172       if [ -r ${INPUT}/$file ]; then
1173         file_to_fix=${INPUT}/$file
1174       else
1175         file_to_fix=""
1176       fi
1177     fi
1178     if [ \! -z "$file_to_fix" ]; then
1179       echo Checking $file_to_fix
1180       cp $file_to_fix /tmp/$base
1181       chmod +w /tmp/$base
1182       sed -e '
1183         s/__filbuf/_filbuf/g
1184         s/__flsbuf/_flsbuf/g
1185         s/__iob/_iob/g
1186       ' /tmp/$base > /tmp/$base.sed
1187       mv /tmp/$base.sed /tmp/$base
1188       if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1189         true
1190       else
1191         echo Fixed $file_to_fix
1192         rm -f ${LIB}/$file
1193         cp /tmp/$base ${LIB}/$file
1194         chmod a+r ${LIB}/$file
1195       fi
1196       rm -f /tmp/$base
1197     fi
1198
1199     # Change <ctype.h> to not define __ctype
1200
1201     file=ctype.h
1202     base=`basename $file`
1203     if [ -r ${LIB}/$file ]; then
1204       file_to_fix=${LIB}/$file
1205     else
1206       if [ -r ${INPUT}/$file ]; then
1207         file_to_fix=${INPUT}/$file
1208       else
1209         file_to_fix=""
1210       fi
1211     fi
1212     if [ \! -z "$file_to_fix" ]; then
1213       echo Checking $file_to_fix
1214       cp $file_to_fix /tmp/$base
1215       chmod +w /tmp/$base
1216       sed -e '
1217         s/__ctype/_ctype/g
1218       ' /tmp/$base > /tmp/$base.sed
1219       mv /tmp/$base.sed /tmp/$base
1220       if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1221         true
1222       else
1223         echo Fixed $file_to_fix
1224         rm -f ${LIB}/$file
1225         cp /tmp/$base ${LIB}/$file
1226         chmod a+r ${LIB}/$file
1227       fi
1228       rm -f /tmp/$base
1229     fi
1230   fi
1231 fi
1232
1233 # In limits.h, put #ifndefs around things that are supposed to be defined
1234 # in float.h to avoid redefinition errors if float.h is included first.
1235 # Solaris 2.1 has this problem.
1236
1237 file=limits.h
1238 base=`basename $file`
1239 if [ -r ${LIB}/$file ]; then
1240   file_to_fix=${LIB}/$file
1241 else
1242   if [ -r ${INPUT}/$file ]; then
1243     file_to_fix=${INPUT}/$file
1244   else
1245     file_to_fix=""
1246   fi
1247 fi
1248 if [ \! -z "$file_to_fix" ]; then
1249   echo Checking $file_to_fix
1250   sed -e '/[    ]FLT_MIN[       ]/i\
1251 #ifndef FLT_MIN'\
1252       -e '/[    ]FLT_MIN[       ]/a\
1253 #endif'\
1254       -e '/[    ]FLT_MAX[       ]/i\
1255 #ifndef FLT_MAX'\
1256       -e '/[    ]FLT_MAX[       ]/a\
1257 #endif'\
1258       -e '/[    ]FLT_DIG[       ]/i\
1259 #ifndef FLT_DIG'\
1260       -e '/[    ]FLT_DIG[       ]/a\
1261 #endif'\
1262       -e '/[    ]DBL_MIN[       ]/i\
1263 #ifndef DBL_MIN'\
1264       -e '/[    ]DBL_MIN[       ]/a\
1265 #endif'\
1266       -e '/[    ]DBL_MAX[       ]/i\
1267 #ifndef DBL_MAX'\
1268       -e '/[    ]DBL_MAX[       ]/a\
1269 #endif'\
1270       -e '/[    ]DBL_DIG[       ]/i\
1271 #ifndef DBL_DIG'\
1272       -e '/[    ]DBL_DIG[       ]/a\
1273 #endif' $file_to_fix > /tmp/$base
1274   if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1275     true
1276   else
1277     echo Fixed $file_to_fix
1278     rm -f ${LIB}/$file
1279     cp /tmp/$base ${LIB}/$file
1280     chmod a+r ${LIB}/$file
1281   fi
1282   rm -f /tmp/$base
1283 fi
1284
1285 # Completely replace <sys/varargs.h> with a file that includes gcc's
1286 # stdarg.h or varargs.h files as appropriate.
1287
1288 file=sys/varargs.h
1289 if [ -r ${INPUT}/$file ]; then
1290   echo Replacing $file
1291   cat > ${LIB}/$file << EOF
1292 /* This file was generated by fixincludes.  */
1293 #ifndef _SYS_VARARGS_H
1294 #define _SYS_VARARGS_H
1295
1296 #ifdef __STDC__
1297 #include <stdarg.h>
1298 #else
1299 #include <varargs.h>
1300 #endif
1301
1302 #endif  /* _SYS_VARARGS_H */
1303 EOF
1304   chmod a+r ${LIB}/$file
1305 fi
1306
1307 echo 'Removing unneeded directories:'
1308 cd $LIB
1309 files=`find . -type d -print | sort -r`
1310 for file in $files; do
1311   rmdir $LIB/$file > /dev/null 2>&1
1312 done
1313
1314 if $LINKS; then
1315   echo 'Making internal symbolic non-directory links'
1316   cd ${INPUT}
1317   files=`find . -type l -print`
1318   for file in $files; do
1319     dest=`ls -ld $file | sed -n 's/.*-> //p'`
1320     if expr "$dest" : '[^/].*' > /dev/null; then    
1321       target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1322       if [ -f $target ]; then
1323         ln -s $dest ${LIB}/$file >/dev/null 2>&1
1324       fi
1325     fi
1326   done
1327 fi
1328
1329 cd ${ORIG_DIR}
1330
1331 echo 'Replacing <sys/byteorder.h>'
1332 rm -f ${LIB}/sys/byteorder.h
1333 cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h
1334
1335 exit 0
1336