FSF GCC merge 02/23/03
[official-gcc.git] / gcc / fixinc / fixinc.svr4
blob88972f01a1397660ffb9105eab79727d14569a3f
1 #! /bin/sh
2 # Install modified versions of certain ANSI-incompatible
3 # native System V Release 4 system include files.
4 # Copyright (C) 1994, 1996, 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
5 # Contributed by Ron Guilmette (rfg@monkeys.com).
7 # This file is part of GNU CC.
8 #
9 # GNU CC is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
14 # GNU CC is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU CC; see the file COPYING. If not, write to
21 # the Free Software Foundation, 59 Temple Place - Suite 330,
22 # Boston, MA 02111-1307, 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 # Fail if no arg to specify a directory for the output.
35 if [ x$1 = x ]
36 then echo fixincludes: no output directory specified
37 exit 1
40 # Directory in which to store the results.
41 LIB=${1?"fixincludes: output directory not specified"}
43 # Make sure it exists.
44 if [ ! -d $LIB ]; then
45 mkdir $LIB || exit 1
48 ORIG_DIR=`${PWDCMD-pwd}`
50 # Make LIB absolute if it is relative.
51 # Don't do this if not necessary, since may screw up automounters.
52 case $LIB in
53 /*)
56 cd $LIB; LIB=`${PWDCMD-pwd}`
58 esac
60 echo 'Building fixincludes in ' ${LIB}
62 # Determine whether this filesystem has symbolic links.
63 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
64 rm -f $LIB/ShouldNotExist
65 LINKS=true
66 else
67 LINKS=false
70 echo 'Making directories:'
72 # Directory containing the original header files.
73 shift
74 if [ $# -eq 0 ] ; then
75 set /usr/include
78 INLIST="$@"
80 for INPUT in ${INLIST} ; do
81 cd ${ORIG_DIR}
82 cd ${INPUT}
84 if $LINKS; then
85 files=`find . -follow -type d -print 2>/dev/null | sed '/^.$/d'`
86 else
87 files=`find . -type d -print | sed '/^.$/d'`
89 for file in $files; do
90 rm -rf $LIB/$file
91 if [ ! -d $LIB/$file ]
92 then mkdir $LIB/$file
94 done
96 # treetops gets an alternating list
97 # of old directories to copy
98 # and the new directories to copy to.
99 treetops="${INPUT} ${LIB}"
101 if $LINKS; then
102 echo 'Making internal symbolic directory links'
103 for file in $files; do
104 dest=`ls -ld $file | sed -n 's/.*-> //p'`
105 if [ "$dest" ]; then
106 cwd=`${PWDCMD-pwd}`
107 # In case $dest is relative, get to $file's dir first.
108 cd ${INPUT}
109 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
110 rwd=`${PWDCMD-pwd}`
111 # Check that the target directory exists.
112 # Redirections changed to avoid bug in sh on Ultrix.
113 (cd $dest) > /dev/null 2>&1
114 if [ $? = 0 ]; then
115 cd $dest
116 # X gets the dir that the link actually leads to.
117 x=`${PWDCMD-pwd}`
118 # If link leads back into ${INPUT},
119 # make a similar link here.
120 if expr "$dest" : '[^/][^/]*' >/dev/null && [ ! -h $dest ]; then
121 echo $file '->' $dest': Making link'
122 rm -fr ${LIB}/$file > /dev/null 2>&1
123 ln -s $dest ${LIB}/$file > /dev/null 2>&1
124 elif expr $x : "${INPUT}/.*" > /dev/null; then
125 # Y gets the actual target dir name, relative to ${INPUT}.
126 y=`echo $x | sed -n "s&${INPUT}/&&p"`
127 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
128 dots=`echo "$file" |
129 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
130 echo $file '->' $dots$y ': Making link'
131 rm -fr ${LIB}/$file > /dev/null 2>&1
132 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
133 elif expr $x : "${rwd}/.*" > /dev/null; then
134 # Y gets the actual target dir name, relative to the directory where the link is.
135 y=`echo $x | sed -n "s&${rwd}/&&p"`
136 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
137 dots=`echo "$file" |
138 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
139 echo $file '->' $dots$y ': Making link'
140 rm -fr ${LIB}/$file > /dev/null 2>&1
141 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
142 else
143 # If the link is to outside ${INPUT},
144 # treat this directory as if it actually contained the files.
145 # This line used to have $dest instead of $x.
146 # $dest seemed to be wrong for links found in subdirectories
147 # of ${INPUT}. Does this change break anything?
148 treetops="$treetops $x ${LIB}/$file"
151 cd $cwd
153 done
156 set - $treetops
157 while [ $# != 0 ]; do
158 # $1 is an old directory to copy, and $2 is the new directory to copy to.
159 echo "Finding header files in $1:"
160 cd ${INPUT}
161 cd $1
162 files=`find . -name '*.h' -type f -print`
163 echo 'Checking header files:'
164 for file in $files; do
165 if [ -r $file ]; then
166 cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
167 chmod +w $2/$file
168 chmod a+r $2/$file
170 # The following have been removed from the sed command below
171 # because it is more useful to leave these things in.
172 # The only reason to remove them was for -pedantic,
173 # which isn't much of a reason. -- rms.
174 # /^[ ]*#[ ]*ident/d
176 # This code makes Solaris SCSI fail, because it changes the
177 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
178 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
179 # Disable these also, since they probably aren't safe either.
180 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
181 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
182 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
183 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
185 # The change of u_char, etc, to u_int
186 # applies to bit fields.
187 sed -e '
188 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
189 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
190 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
191 s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
192 s/#lint(on)/defined(lint)/g
193 s/#lint(off)/!defined(lint)/g
194 s/#machine(\([^)]*\))/defined(__\1__)/g
195 s/#system(\([^)]*\))/defined(__\1__)/g
196 s/#cpu(\([^)]*\))/defined(__\1__)/g
197 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
198 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
199 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
200 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
201 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
202 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
203 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
204 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
205 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
206 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
207 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
208 s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
209 s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
210 s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
211 s/__STDC__[ ][ ]*!=[ ][ ]*1/!defined (__STRICT_ANSI__)/g
212 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
213 s/__STDC__ - 0 == 1/defined (__STRICT_ANSI__)/g
214 /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
215 ' $2/$file > $2/$file.sed
216 mv $2/$file.sed $2/$file
217 if cmp $file $2/$file >/dev/null 2>&1; then
218 rm $2/$file
219 else
220 echo Fixed $file
223 done
224 shift; shift
225 done
227 # Install the proper definition of the three standard types in header files
228 # that they come from.
229 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
230 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
231 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
232 chmod +w ${LIB}/$file 2>/dev/null
233 chmod a+r ${LIB}/$file 2>/dev/null
236 if [ -r ${LIB}/$file ]; then
237 echo Fixing size_t, ptrdiff_t and wchar_t in $file
238 sed \
239 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
240 #ifndef __SIZE_TYPE__\
241 #define __SIZE_TYPE__ long unsigned int\
242 #endif
244 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
245 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
246 #ifndef __PTRDIFF_TYPE__\
247 #define __PTRDIFF_TYPE__ long int\
248 #endif
250 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
251 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
252 #ifndef __WCHAR_TYPE__\
253 #define __WCHAR_TYPE__ int\
254 #endif
256 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
257 ${LIB}/$file > ${LIB}/${file}.sed
258 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
259 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
260 rm ${LIB}/$file
263 done
265 # Fix first broken decl of getcwd present on some svr4 systems.
267 file=stdlib.h
268 base=`basename $file`.$$
269 if [ -r ${LIB}/$file ]; then
270 file_to_fix=${LIB}/$file
271 else
272 if [ -r ${INPUT}/$file ]; then
273 file_to_fix=${INPUT}/$file
274 else
275 file_to_fix=""
278 if [ \! -z "$file_to_fix" ]; then
279 echo Checking $file_to_fix
280 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
281 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
282 true
283 else
284 echo Fixed $file_to_fix
285 rm -f ${LIB}/$file
286 cp /tmp/$base ${LIB}/$file
287 chmod a+r ${LIB}/$file
289 rm -f /tmp/$base
292 # Fix second broken decl of getcwd present on some svr4 systems. Also
293 # fix the incorrect decl of profil present on some svr4 systems.
295 file=unistd.h
296 base=`basename $file`.$$
297 if [ -r ${LIB}/$file ]; then
298 file_to_fix=${LIB}/$file
299 else
300 if [ -r ${INPUT}/$file ]; then
301 file_to_fix=${INPUT}/$file
302 else
303 file_to_fix=""
306 if [ \! -z "$file_to_fix" ]; then
307 echo Checking $file_to_fix
308 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
309 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
310 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
311 true
312 else
313 echo Fixed $file_to_fix
314 rm -f ${LIB}/$file
315 cp /tmp/$base ${LIB}/$file
316 chmod a+r ${LIB}/$file
318 rm -f /tmp/$base
321 # Fix the definition of NULL in <sys/param.h> so that it is conditional
322 # and so that it is correct for both C and C++.
324 file=sys/param.h
325 base=`basename $file`.$$
326 if [ -r ${LIB}/$file ]; then
327 file_to_fix=${LIB}/$file
328 else
329 if [ -r ${INPUT}/$file ]; then
330 file_to_fix=${INPUT}/$file
331 else
332 file_to_fix=""
335 if [ \! -z "$file_to_fix" ]; then
336 echo Checking $file_to_fix
337 cp $file_to_fix /tmp/$base
338 chmod +w /tmp/$base
339 chmod a+r /tmp/$base
340 sed -e '/^#define[ ]*NULL[ ]*0$/c\
341 #ifndef NULL\
342 #ifdef __cplusplus\
343 #define __NULL_TYPE\
344 #else /* !defined(__cplusplus) */\
345 #define __NULL_TYPE (void *)\
346 #endif /* !defined(__cplusplus) */\
347 #define NULL (__NULL_TYPE 0)\
348 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
349 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
350 true
351 else
352 echo Fixed $file_to_fix
353 rm -f ${LIB}/$file
354 cp /tmp/$base.sed ${LIB}/$file
355 chmod a+r ${LIB}/$file
357 rm -f /tmp/$base /tmp/$base.sed
360 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
361 # and so that it is correct for both C and C++.
363 file=stdio.h
364 base=`basename $file`.$$
365 if [ -r ${LIB}/$file ]; then
366 file_to_fix=${LIB}/$file
367 else
368 if [ -r ${INPUT}/$file ]; then
369 file_to_fix=${INPUT}/$file
370 else
371 file_to_fix=""
374 if [ \! -z "$file_to_fix" ]; then
375 echo Checking $file_to_fix
376 cp $file_to_fix /tmp/$base
377 chmod +w /tmp/$base
378 sed -e '/^#define[ ]*NULL[ ]*0$/c\
379 #ifdef __cplusplus\
380 #define __NULL_TYPE\
381 #else /* !defined(__cplusplus) */\
382 #define __NULL_TYPE (void *)\
383 #endif /* !defined(__cplusplus) */\
384 #define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
385 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
386 true
387 else
388 echo Fixed $file_to_fix
389 rm -f ${LIB}/$file
390 cp /tmp/$base.sed ${LIB}/$file
391 chmod a+r ${LIB}/$file
393 rm -f /tmp/$base /tmp/$base.sed
396 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
397 # and so that it is correct for both C and C++.
399 file=dbm.h
400 base=`basename $file`.$$
401 if [ -r ${LIB}/$file ]; then
402 file_to_fix=${LIB}/$file
403 else
404 if [ -r ${INPUT}/$file ]; then
405 file_to_fix=${INPUT}/$file
406 else
407 file_to_fix=""
410 if [ \! -z "$file_to_fix" ]; then
411 echo Checking $file_to_fix
412 cp $file_to_fix /tmp/$base
413 chmod +w /tmp/$base
414 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
415 #ifndef NULL\
416 #ifdef __cplusplus\
417 #define __NULL_TYPE\
418 #else /* !defined(__cplusplus) */\
419 #define __NULL_TYPE (void *)\
420 #endif /* !defined(__cplusplus) */\
421 #define NULL (__NULL_TYPE 0)\
422 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
423 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
424 true
425 else
426 echo Fixed $file_to_fix
427 rm -f ${LIB}/$file
428 cp /tmp/$base.sed ${LIB}/$file
429 chmod a+r ${LIB}/$file
431 rm -f /tmp/$base /tmp/$base.sed
434 # Add a prototyped declaration of mmap to <sys/mman.h>.
436 file=sys/mman.h
437 base=`basename $file`.$$
438 if [ -r ${LIB}/$file ]; then
439 file_to_fix=${LIB}/$file
440 else
441 if [ -r ${INPUT}/$file ]; then
442 file_to_fix=${INPUT}/$file
443 else
444 file_to_fix=""
447 if [ \! -z "$file_to_fix" ]; then
448 echo Checking $file_to_fix
449 cp $file_to_fix /tmp/$base
450 chmod +w /tmp/$base
451 sed -e '/^extern caddr_t mmap();$/c\
452 #ifdef __STDC__\
453 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
454 #else /* !defined(__STDC__) */\
455 extern caddr_t mmap ();\
456 #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
457 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
458 true
459 else
460 echo Fixed $file_to_fix
461 rm -f ${LIB}/$file
462 cp /tmp/$base.sed ${LIB}/$file
463 chmod a+r ${LIB}/$file
465 rm -f /tmp/$base /tmp/$base.sed
468 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
469 # the file <ftw.h> contains extern declarations of these functions followed
470 # by explicitly `static' definitions of these functions... and that's not
471 # allowed according to ANSI C. (Note however that on Solaris, this header
472 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
473 # there are no static definitions of any function so we don't need to do
474 # any of this stuff when on Solaris.
476 file=ftw.h
477 base=`basename $file`.$$
478 if [ -r ${LIB}/$file ]; then
479 file_to_fix=${LIB}/$file
480 else
481 if [ -r ${INPUT}/$file ]; then
482 file_to_fix=${INPUT}/$file
483 else
484 file_to_fix=""
487 if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
488 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
489 # one. Either way, we don't have to do anything.
490 true
491 else
492 echo Checking $file_to_fix
493 cp $file_to_fix /tmp/$base
494 chmod +w /tmp/$base
495 sed -e '/^extern int ftw(const/i\
496 #if !defined(_STYPES)\
497 static\
498 #else\
499 extern\
500 #endif
502 -e 's/extern \(int ftw(const.*\)$/\1/' \
503 -e '/^extern int nftw/i\
504 #if defined(_STYPES)\
505 static\
506 #else\
507 extern\
508 #endif
510 -e 's/extern \(int nftw.*\)$/\1/' \
511 -e '/^extern int ftw(),/c\
512 #if !defined(_STYPES)\
513 static\
514 #else\
515 extern\
516 #endif\
517 int ftw();\
518 #if defined(_STYPES)\
519 static\
520 #else\
521 extern\
522 #endif\
523 int nftw();' /tmp/$base > /tmp/$base.sed
524 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
525 true
526 else
527 echo Fixed $file_to_fix
528 rm -f ${LIB}/$file
529 cp /tmp/$base.sed ${LIB}/$file
530 chmod a+r ${LIB}/$file
532 rm -f /tmp/$base /tmp/$base.sed
535 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
536 # g++, since it's now an official type in the C++ language.
537 file=curses.h
538 base=`basename $file`.$$
539 if [ -r ${LIB}/$file ]; then
540 file_to_fix=${LIB}/$file
541 else
542 if [ -r ${INPUT}/$file ]; then
543 file_to_fix=${INPUT}/$file
544 else
545 file_to_fix=""
549 if [ \! -z "$file_to_fix" ]; then
550 echo Checking $file_to_fix
551 cp $file_to_fix /tmp/$base
552 chmod +w /tmp/$base
553 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
554 typedef char bool;\
555 #endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed
556 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
557 true
558 else
559 echo Fixed $file_to_fix
560 rm -f ${LIB}/$file
561 cp /tmp/$base.sed ${LIB}/$file
562 chmod a+r ${LIB}/$file
564 rm -f /tmp/$base /tmp/$base.sed
567 # Add a `static' declaration of `getrnge' into <regexp.h>.
569 # Don't do this if there is already a `static void getrnge' declaration
570 # present, since this would cause a redeclaration error. Solaris 2.x has
571 # such a declaration.
573 file=regexp.h
574 base=`basename $file`.$$
575 if [ -r ${LIB}/$file ]; then
576 file_to_fix=${LIB}/$file
577 else
578 if [ -r ${INPUT}/$file ]; then
579 file_to_fix=${INPUT}/$file
580 else
581 file_to_fix=""
584 if [ \! -z "$file_to_fix" ]; then
585 echo Checking $file_to_fix
586 if grep "static void getrnge" $file_to_fix > /dev/null; then
587 true
588 else
589 cp $file_to_fix /tmp/$base
590 chmod +w /tmp/$base
591 sed -e '/^static int[ ]*size;/c\
592 static int size ;\
594 static int getrnge ();' /tmp/$base > /tmp/$base.sed
595 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
596 true
597 else
598 echo Fixed $file_to_fix
599 rm -f ${LIB}/$file
600 cp /tmp/$base.sed ${LIB}/$file
601 chmod a+r ${LIB}/$file
604 rm -f /tmp/$base /tmp/$base.sed
607 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
608 # that is visible to any ANSI compiler using this include. Simply
609 # delete the lines that #define some string functions to internal forms.
611 file=string.h
612 base=`basename $file`.$$
613 if [ -r ${LIB}/$file ]; then
614 file_to_fix=${LIB}/$file
615 else
616 if [ -r ${INPUT}/$file ]; then
617 file_to_fix=${INPUT}/$file
618 else
619 file_to_fix=""
622 if [ \! -z "$file_to_fix" ]; then
623 echo Checking $file_to_fix
624 cp $file_to_fix /tmp/$base
625 chmod +w /tmp/$base
626 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
627 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
628 true
629 else
630 echo Fixed $file_to_fix
631 rm -f ${LIB}/$file
632 cp /tmp/$base.sed ${LIB}/$file
633 chmod a+r ${LIB}/$file
635 rm -f /tmp/$base /tmp/$base.sed
638 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
639 # tend to conflict with the compiler's own definition of this symbol. (We
640 # will use the compiler's definition.)
641 # Likewise __sparc, for Solaris, and __i860, and a few others
642 # (guessing it is necessary for all of them).
644 file=ieeefp.h
645 base=`basename $file`.$$
646 if [ -r ${LIB}/$file ]; then
647 file_to_fix=${LIB}/$file
648 else
649 if [ -r ${INPUT}/$file ]; then
650 file_to_fix=${INPUT}/$file
651 else
652 file_to_fix=""
655 if [ \! -z "$file_to_fix" ]; then
656 echo Checking $file_to_fix
657 cp $file_to_fix /tmp/$base
658 chmod +w /tmp/$base
659 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
660 -e '/#define[ ]*__m88k /d' -e '/#define[ ]*__mips /d' \
661 -e '/#define[ ]*__m68k /d' \
662 /tmp/$base > /tmp/$base.sed
663 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
664 true
665 else
666 echo Fixed $file_to_fix
667 rm -f ${LIB}/$file
668 cp /tmp/$base.sed ${LIB}/$file
669 chmod a+r ${LIB}/$file
671 rm -f /tmp/$base /tmp/$base.sed
674 # Add a #define of _SIGACTION_ into <sys/signal.h>.
675 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
677 file=sys/signal.h
678 base=`basename $file`.$$
679 if [ -r ${LIB}/$file ]; then
680 file_to_fix=${LIB}/$file
681 else
682 if [ -r ${INPUT}/$file ]; then
683 file_to_fix=${INPUT}/$file
684 else
685 file_to_fix=""
688 if [ \! -z "$file_to_fix" ]; then
689 echo Checking $file_to_fix
690 cp $file_to_fix /tmp/$base
691 chmod +w /tmp/$base
692 sed -e '/^struct sigaction {/c\
693 #define _SIGACTION_\
694 struct sigaction {' \
695 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
696 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
697 true
698 else
699 echo Fixed $file_to_fix
700 rm -f ${LIB}/$file
701 cp /tmp/$base.sed ${LIB}/$file
702 chmod a+r ${LIB}/$file
704 rm -f /tmp/$base /tmp/$base.sed
707 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
709 file=sys/mkdev.h
710 base=`basename $file`.$$
711 if [ -r ${LIB}/$file ]; then
712 file_to_fix=${LIB}/$file
713 else
714 if [ -r ${INPUT}/$file ]; then
715 file_to_fix=${INPUT}/$file
716 else
717 file_to_fix=""
720 if [ \! -z "$file_to_fix" ]; then
721 echo Checking $file_to_fix
722 cp $file_to_fix /tmp/$base
723 chmod +w /tmp/$base
724 sed -e '/^dev_t makedev(const/c\
725 static dev_t makedev(const major_t, const minor_t);' \
726 -e '/^dev_t makedev()/c\
727 static dev_t makedev();' \
728 -e '/^major_t major(const/c\
729 static major_t major(const dev_t);' \
730 -e '/^major_t major()/c\
731 static major_t major();' \
732 -e '/^minor_t minor(const/c\
733 static minor_t minor(const dev_t);' \
734 -e '/^minor_t minor()/c\
735 static minor_t minor();' /tmp/$base > /tmp/$base.sed
736 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
737 true
738 else
739 echo Fixed $file_to_fix
740 rm -f ${LIB}/$file
741 cp /tmp/$base.sed ${LIB}/$file
742 chmod a+r ${LIB}/$file
744 rm -f /tmp/$base /tmp/$base.sed
747 # Fix reference to NMSZ in <sys/adv.h>.
749 file=sys/adv.h
750 base=`basename $file`.$$
751 if [ -r ${LIB}/$file ]; then
752 file_to_fix=${LIB}/$file
753 else
754 if [ -r ${INPUT}/$file ]; then
755 file_to_fix=${INPUT}/$file
756 else
757 file_to_fix=""
760 if [ \! -z "$file_to_fix" ]; then
761 echo Checking $file_to_fix
762 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
763 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
764 true
765 else
766 echo Fixed $file_to_fix
767 rm -f ${LIB}/$file
768 cp /tmp/$base ${LIB}/$file
769 chmod a+r ${LIB}/$file
771 rm -f /tmp/$base
774 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
775 # array initializers.
777 file=sys/netcspace.h
778 base=`basename $file`.$$
779 if [ -r ${LIB}/$file ]; then
780 file_to_fix=${LIB}/$file
781 else
782 if [ -r ${INPUT}/$file ]; then
783 file_to_fix=${INPUT}/$file
784 else
785 file_to_fix=""
788 if [ \! -z "$file_to_fix" ]; then
789 echo Checking $file_to_fix
790 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
791 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
792 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
793 true
794 else
795 echo Fixed $file_to_fix
796 rm -f ${LIB}/$file
797 cp /tmp/$base ${LIB}/$file
798 chmod a+r ${LIB}/$file
800 rm -f /tmp/$base
803 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
805 file=fs/rfs/rf_cache.h
806 base=`basename $file`.$$
807 if [ -r ${LIB}/$file ]; then
808 file_to_fix=${LIB}/$file
809 else
810 if [ -r ${INPUT}/$file ]; then
811 file_to_fix=${INPUT}/$file
812 else
813 file_to_fix=""
816 if [ \! -z "$file_to_fix" ]; then
817 echo Checking $file_to_fix
818 if grep _KERNEL $file_to_fix > /dev/null; then
819 true
820 else
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
825 rm -f ${LIB}/$file
826 cp /tmp/$base ${LIB}/$file
827 chmod a+r ${LIB}/$file
828 rm -f /tmp/$base
832 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
834 file=sys/erec.h
835 base=`basename $file`.$$
836 if [ -r ${LIB}/$file ]; then
837 file_to_fix=${LIB}/$file
838 else
839 if [ -r ${INPUT}/$file ]; then
840 file_to_fix=${INPUT}/$file
841 else
842 file_to_fix=""
845 if [ \! -z "$file_to_fix" ]; then
846 echo Checking $file_to_fix
847 if grep _KERNEL $file_to_fix > /dev/null; then
848 true
849 else
850 echo '#ifdef _KERNEL' > /tmp/$base
851 cat $file_to_fix >> /tmp/$base
852 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
853 echo Fixed $file_to_fix
854 rm -f ${LIB}/$file
855 cp /tmp/$base ${LIB}/$file
856 chmod a+r ${LIB}/$file
857 rm -f /tmp/$base
861 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
863 file=sys/err.h
864 base=`basename $file`.$$
865 if [ -r ${LIB}/$file ]; then
866 file_to_fix=${LIB}/$file
867 else
868 if [ -r ${INPUT}/$file ]; then
869 file_to_fix=${INPUT}/$file
870 else
871 file_to_fix=""
874 if [ \! -z "$file_to_fix" ]; then
875 echo Checking $file_to_fix
876 if grep _KERNEL $file_to_fix > /dev/null; then
877 true
878 else
879 echo '#ifdef _KERNEL' > /tmp/$base
880 cat $file_to_fix >> /tmp/$base
881 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
882 echo Fixed $file_to_fix
883 rm -f ${LIB}/$file
884 cp /tmp/$base ${LIB}/$file
885 chmod a+r ${LIB}/$file
886 rm -f /tmp/$base
890 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
892 file=sys/char.h
893 base=`basename $file`.$$
894 if [ -r ${LIB}/$file ]; then
895 file_to_fix=${LIB}/$file
896 else
897 if [ -r ${INPUT}/$file ]; then
898 file_to_fix=${INPUT}/$file
899 else
900 file_to_fix=""
903 if [ \! -z "$file_to_fix" ]; then
904 echo Checking $file_to_fix
905 if grep _KERNEL $file_to_fix > /dev/null; then
906 true
907 else
908 echo '#ifdef _KERNEL' > /tmp/$base
909 cat $file_to_fix >> /tmp/$base
910 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
911 echo Fixed $file_to_fix
912 rm -f ${LIB}/$file
913 cp /tmp/$base ${LIB}/$file
914 chmod a+r ${LIB}/$file
915 rm -f /tmp/$base
919 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
921 file=sys/getpages.h
922 base=`basename $file`.$$
923 if [ -r ${LIB}/$file ]; then
924 file_to_fix=${LIB}/$file
925 else
926 if [ -r ${INPUT}/$file ]; then
927 file_to_fix=${INPUT}/$file
928 else
929 file_to_fix=""
932 if [ \! -z "$file_to_fix" ]; then
933 echo Checking $file_to_fix
934 if grep _KERNEL $file_to_fix > /dev/null; then
935 true
936 else
937 echo '#ifdef _KERNEL' > /tmp/$base
938 cat $file_to_fix >> /tmp/$base
939 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
940 echo Fixed $file_to_fix
941 rm -f ${LIB}/$file
942 cp /tmp/$base ${LIB}/$file
943 chmod a+r ${LIB}/$file
944 rm -f /tmp/$base
948 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
950 file=sys/map.h
951 base=`basename $file`.$$
952 if [ -r ${LIB}/$file ]; then
953 file_to_fix=${LIB}/$file
954 else
955 if [ -r ${INPUT}/$file ]; then
956 file_to_fix=${INPUT}/$file
957 else
958 file_to_fix=""
961 if [ \! -z "$file_to_fix" ]; then
962 echo Checking $file_to_fix
963 if grep _KERNEL $file_to_fix > /dev/null; then
964 true
965 else
966 echo '#ifdef _KERNEL' > /tmp/$base
967 cat $file_to_fix >> /tmp/$base
968 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
969 echo Fixed $file_to_fix
970 rm -f ${LIB}/$file
971 cp /tmp/$base ${LIB}/$file
972 chmod a+r ${LIB}/$file
973 rm -f /tmp/$base
977 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
979 file=sys/cmn_err.h
980 base=`basename $file`.$$
981 if [ -r ${LIB}/$file ]; then
982 file_to_fix=${LIB}/$file
983 else
984 if [ -r ${INPUT}/$file ]; then
985 file_to_fix=${INPUT}/$file
986 else
987 file_to_fix=""
990 if [ \! -z "$file_to_fix" ]; then
991 echo Checking $file_to_fix
992 if grep _KERNEL $file_to_fix > /dev/null; then
993 true
994 else
995 echo '#ifdef _KERNEL' > /tmp/$base
996 cat $file_to_fix >> /tmp/$base
997 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
998 echo Fixed $file_to_fix
999 rm -f ${LIB}/$file
1000 cp /tmp/$base ${LIB}/$file
1001 chmod a+r ${LIB}/$file
1002 rm -f /tmp/$base
1006 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
1008 file=sys/kdebugger.h
1009 base=`basename $file`.$$
1010 if [ -r ${LIB}/$file ]; then
1011 file_to_fix=${LIB}/$file
1012 else
1013 if [ -r ${INPUT}/$file ]; then
1014 file_to_fix=${INPUT}/$file
1015 else
1016 file_to_fix=""
1019 if [ \! -z "$file_to_fix" ]; then
1020 echo Checking $file_to_fix
1021 if grep _KERNEL $file_to_fix > /dev/null; then
1022 true
1023 else
1024 echo '#ifdef _KERNEL' > /tmp/$base
1025 cat $file_to_fix >> /tmp/$base
1026 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
1027 echo Fixed $file_to_fix
1028 rm -f ${LIB}/$file
1029 cp /tmp/$base ${LIB}/$file
1030 chmod a+r ${LIB}/$file
1031 rm -f /tmp/$base
1035 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1036 # This has been taken out because it breaks on some versions of
1037 # DYNIX/ptx, and it does not seem to do much good on any system.
1038 # file=netinet/in.h
1039 # base=`basename $file`.$$
1040 # if [ -r ${LIB}/$file ]; then
1041 # file_to_fix=${LIB}/$file
1042 # else
1043 # if [ -r ${INPUT}/$file ]; then
1044 # file_to_fix=${INPUT}/$file
1045 # else
1046 # file_to_fix=""
1047 # fi
1048 # fi
1049 # if [ \! -z "$file_to_fix" ]; then
1050 # echo Checking $file_to_fix
1051 # if grep _KERNEL $file_to_fix > /dev/null; then
1052 # true
1053 # else
1054 # sed -e '/#ifdef INKERNEL/i\
1055 # #ifdef _KERNEL
1056 # ' \
1057 # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1058 # #endif /* _KERNEL */
1059 # ' \
1060 # $file_to_fix > ${LIB}/${file}.sed
1061 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1062 # echo Fixed $file_to_fix
1063 # fi
1064 # fi
1066 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1068 file=sys/endian.h
1069 base=`basename $file`.$$
1070 if [ -r ${LIB}/$file ]; then
1071 file_to_fix=${LIB}/$file
1072 else
1073 if [ -r ${INPUT}/$file ]; then
1074 file_to_fix=${INPUT}/$file
1075 else
1076 file_to_fix=""
1079 if [ \! -z "$file_to_fix" ]; then
1080 echo Checking $file_to_fix
1081 if grep __GNUC__ $file_to_fix > /dev/null; then
1082 true
1083 else
1084 sed -e '/# ifdef __STDC__/i\
1085 # if !defined (__GNUC__) && !defined (__GNUG__)
1087 -e '/# include <sys\/byteorder.h>/s/ / /'\
1088 -e '/# include <sys\/byteorder.h>/i\
1089 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */
1091 $file_to_fix > ${LIB}/${file}.sed
1092 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1093 echo Fixed $file_to_fix
1097 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1098 # and the text in types.h is not erroneous.
1099 ## In sys/types.h, don't name the enum for booleans.
1101 #file=sys/types.h
1102 #base=`basename $file`.$$
1103 #if [ -r ${LIB}/$file ]; then
1104 # file_to_fix=${LIB}/$file
1105 #else
1106 # if [ -r ${INPUT}/$file ]; then
1107 # file_to_fix=${INPUT}/$file
1108 # else
1109 # file_to_fix=""
1110 # fi
1112 #if [ \! -z "$file_to_fix" ]; then
1113 # echo Checking $file_to_fix
1114 # if grep "enum boolean" $file_to_fix > /dev/null; then
1115 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1116 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1117 # echo Fixed $file_to_fix
1118 # else
1119 # true
1120 # fi
1123 # Remove useless extern keyword from struct forward declarations in
1124 # <sys/stream.h> and <sys/strsubr.h>
1126 file=sys/stream.h
1127 base=`basename $file`.$$
1128 if [ -r ${LIB}/$file ]; then
1129 file_to_fix=${LIB}/$file
1130 else
1131 if [ -r ${INPUT}/$file ]; then
1132 file_to_fix=${INPUT}/$file
1133 else
1134 file_to_fix=""
1137 if [ \! -z "$file_to_fix" ]; then
1138 echo Checking $file_to_fix
1139 sed -e '
1140 s/extern struct stdata;/struct stdata;/g
1141 s/extern struct strevent;/struct strevent;/g
1142 ' $file_to_fix > /tmp/$base
1143 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1144 true
1145 else
1146 echo Fixed $file_to_fix
1147 rm -f ${LIB}/$file
1148 cp /tmp/$base ${LIB}/$file
1149 chmod a+r ${LIB}/$file
1151 rm -f /tmp/$base
1154 file=sys/strsubr.h
1155 base=`basename $file`.$$
1156 if [ -r ${LIB}/$file ]; then
1157 file_to_fix=${LIB}/$file
1158 else
1159 if [ -r ${INPUT}/$file ]; then
1160 file_to_fix=${INPUT}/$file
1161 else
1162 file_to_fix=""
1165 if [ \! -z "$file_to_fix" ]; then
1166 echo Checking $file_to_fix
1167 sed -e '
1168 s/extern struct strbuf;/struct strbuf;/g
1169 s/extern struct uio;/struct uio;/g
1170 s/extern struct thread;/struct thread;/g
1171 s/extern struct proc;/struct proc;/g
1172 ' $file_to_fix > /tmp/$base
1173 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1174 true
1175 else
1176 echo Fixed $file_to_fix
1177 rm -f ${LIB}/$file
1178 cp /tmp/$base ${LIB}/$file
1179 chmod a+r ${LIB}/$file
1181 rm -f /tmp/$base
1184 # Put storage class at start of decl, to avoid warning.
1185 file=rpc/types.h
1186 base=`basename $file`.$$
1187 if [ -r ${LIB}/$file ]; then
1188 file_to_fix=${LIB}/$file
1189 else
1190 if [ -r ${INPUT}/$file ]; then
1191 file_to_fix=${INPUT}/$file
1192 else
1193 file_to_fix=""
1196 if [ \! -z "$file_to_fix" ]; then
1197 echo Checking $file_to_fix
1198 sed -e '
1199 s/const extern/extern const/g
1200 ' $file_to_fix > /tmp/$base
1201 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1202 true
1203 else
1204 echo Fixed $file_to_fix
1205 rm -f ${LIB}/$file
1206 cp /tmp/$base ${LIB}/$file
1207 chmod a+r ${LIB}/$file
1209 rm -f /tmp/$base
1212 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1214 file=sys/stat.h
1215 base=`basename $file`.$$
1216 if [ -r ${LIB}/$file ]; then
1217 file_to_fix=${LIB}/$file
1218 else
1219 if [ -r ${INPUT}/$file ]; then
1220 file_to_fix=${INPUT}/$file
1221 else
1222 file_to_fix=""
1225 if [ \! -z "$file_to_fix" ]; then
1226 echo Checking $file_to_fix
1227 cp $file_to_fix /tmp/$base
1228 chmod +w /tmp/$base
1229 sed -e '/^stat([ ]*[^c]/{
1232 s/(.*)\n/( /
1233 s/;\n/, /
1234 s/;$/)/
1235 }' \
1236 -e '/^lstat([ ]*[^c]/{
1239 s/(.*)\n/( /
1240 s/;\n/, /
1241 s/;$/)/
1242 }' \
1243 -e '/^fstat([ ]*[^i]/{
1246 s/(.*)\n/( /
1247 s/;\n/, /
1248 s/;$/)/
1249 }' \
1250 -e '/^mknod([ ]*[^c]/{
1254 s/(.*)\n/( /
1255 s/;\n/, /g
1256 s/;$/)/
1257 }' \
1258 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1259 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1260 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1261 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1262 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1263 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1264 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1265 true
1266 else
1267 echo Fixed $file_to_fix
1268 rm -f ${LIB}/$file
1269 cp /tmp/$base.sed ${LIB}/$file
1270 chmod a+r ${LIB}/$file
1272 rm -f /tmp/$base /tmp/$base.sed
1275 # In limits.h, put #ifndefs around things that are supposed to be defined
1276 # in float.h to avoid redefinition errors if float.h is included first.
1277 # Solaris 2.1 has this problem.
1279 file=limits.h
1280 base=`basename $file`.$$
1281 if [ -r ${LIB}/$file ]; then
1282 file_to_fix=${LIB}/$file
1283 else
1284 if [ -r ${INPUT}/$file ]; then
1285 file_to_fix=${INPUT}/$file
1286 else
1287 file_to_fix=""
1290 if [ \! -z "$file_to_fix" ]; then
1291 echo Checking $file_to_fix
1292 sed -e '/[ ]FLT_MIN[ ]/i\
1293 #ifndef FLT_MIN
1295 -e '/[ ]FLT_MIN[ ]/a\
1296 #endif
1298 -e '/[ ]FLT_MAX[ ]/i\
1299 #ifndef FLT_MAX
1301 -e '/[ ]FLT_MAX[ ]/a\
1302 #endif
1304 -e '/[ ]FLT_DIG[ ]/i\
1305 #ifndef FLT_DIG
1307 -e '/[ ]FLT_DIG[ ]/a\
1308 #endif
1310 -e '/[ ]DBL_MIN[ ]/i\
1311 #ifndef DBL_MIN
1313 -e '/[ ]DBL_MIN[ ]/a\
1314 #endif
1316 -e '/[ ]DBL_MAX[ ]/i\
1317 #ifndef DBL_MAX
1319 -e '/[ ]DBL_MAX[ ]/a\
1320 #endif
1322 -e '/[ ]DBL_DIG[ ]/i\
1323 #ifndef DBL_DIG
1325 -e '/[ ]DBL_DIG[ ]/a\
1326 #endif
1327 ' $file_to_fix > /tmp/$base
1328 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1329 true
1330 else
1331 echo Fixed $file_to_fix
1332 rm -f ${LIB}/$file
1333 cp /tmp/$base ${LIB}/$file
1334 chmod a+r ${LIB}/$file
1336 rm -f /tmp/$base
1339 # Completely replace <sys/varargs.h> with a file that includes gcc's
1340 # stdarg.h or varargs.h files as appropriate.
1342 file=sys/varargs.h
1343 if [ -r ${INPUT}/$file ]; then
1344 echo Replacing $file
1345 cat > ${LIB}/$file << EOF
1346 /* This file was generated by fixincludes. */
1347 #ifndef _SYS_VARARGS_H
1348 #define _SYS_VARARGS_H
1350 #ifdef __STDC__
1351 #include <stdarg.h>
1352 #else
1353 #include <varargs.h>
1354 #endif
1356 #endif /* _SYS_VARARGS_H */
1358 chmod a+r ${LIB}/$file
1361 # In math.h, put #ifndefs around things that might be defined in a gcc
1362 # specific math-*.h file.
1364 file=math.h
1365 base=`basename $file`.$$
1366 if [ -r ${LIB}/$file ]; then
1367 file_to_fix=${LIB}/$file
1368 else
1369 if [ -r ${INPUT}/$file ]; then
1370 file_to_fix=${INPUT}/$file
1371 else
1372 file_to_fix=""
1375 if [ \! -z "$file_to_fix" ]; then
1376 echo Checking $file_to_fix
1377 sed -e '/define[ ]HUGE_VAL[ ]/i\
1378 #ifndef HUGE_VAL
1380 -e '/define[ ]HUGE_VAL[ ]/a\
1381 #endif
1382 ' $file_to_fix > /tmp/$base
1383 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1384 true
1385 else
1386 echo Fixed $file_to_fix
1387 rm -f ${LIB}/$file
1388 cp /tmp/$base ${LIB}/$file
1389 chmod a+r ${LIB}/$file
1391 rm -f /tmp/$base
1394 # Solaris math.h and floatingpoint.h define __P without protection,
1395 # which conflicts with the fixproto definition. The fixproto
1396 # definition and the Solaris definition are used the same way.
1397 for file in math.h floatingpoint.h; do
1398 base=`basename $file`.$$
1399 if [ -r ${LIB}/$file ]; then
1400 file_to_fix=${LIB}/$file
1401 else
1402 if [ -r ${INPUT}/$file ]; then
1403 file_to_fix=${INPUT}/$file
1404 else
1405 file_to_fix=""
1408 if [ \! -z "$file_to_fix" ]; then
1409 echo Checking $file_to_fix
1410 sed -e '/^#define[ ]*__P/i\
1411 #ifndef __P
1413 -e '/^#define[ ]*__P/a\
1414 #endif
1415 ' $file_to_fix > /tmp/$base
1416 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1417 true
1418 else
1419 echo Fixed $file_to_fix
1420 rm -f ${LIB}/$file
1421 cp /tmp/$base ${LIB}/$file
1422 chmod a+r ${LIB}/$file
1424 rm -f /tmp/$base
1426 done
1428 # The Solaris math.h defines struct exception, which conflicts with
1429 # the class exception defined in the C++ file std/stdexcept.h. We
1430 # redefine it to __math_exception. This is not a great fix, but I
1431 # haven't been able to think of anything better.
1432 file=math.h
1433 base=`basename $file`.$$
1434 if [ -r ${LIB}/$file ]; then
1435 file_to_fix=${LIB}/$file
1436 else
1437 if [ -r ${INPUT}/$file ]; then
1438 file_to_fix=${INPUT}/$file
1439 else
1440 file_to_fix=""
1443 if [ \! -z "$file_to_fix" ]; then
1444 echo Checking $file_to_fix
1445 sed -e '/struct exception/i\
1446 #ifdef __cplusplus\
1447 #define exception __math_exception\
1448 #endif'\
1449 -e '/struct exception/a\
1450 #ifdef __cplusplus\
1451 #undef exception\
1452 #endif' $file_to_fix > /tmp/$base
1453 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1454 true
1455 else
1456 echo Fixed $file_to_fix
1457 rm -f ${LIB}/$file
1458 cp /tmp/$base ${LIB}/$file
1459 chmod a+r ${LIB}/$file
1461 rm -f /tmp/$base
1464 # Similarly for struct queue in sys/stream.h.
1465 file=sys/stream.h
1466 base=`basename $file`.$$
1467 if [ -r ${LIB}/$file ]; then
1468 file_to_fix=${LIB}/$file
1469 else
1470 if [ -r ${INPUT}/$file ]; then
1471 file_to_fix=${INPUT}/$file
1472 else
1473 file_to_fix=""
1476 if [ \! -z "$file_to_fix" ]; then
1477 echo Checking $file_to_fix
1478 sed -e '/struct[ ]*queue/i\
1479 #ifdef __cplusplus\
1480 #define queue __stream_queue\
1481 #endif'\
1482 -e '/struct[ ]*queue/a\
1483 #ifdef __cplusplus\
1484 #undef queue\
1485 #endif' $file_to_fix > /tmp/$base
1486 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1487 true
1488 else
1489 echo Fixed $file_to_fix
1490 mkdir -p $LIB/`dirname $file`
1491 rm -f ${LIB}/$file
1492 cp /tmp/$base ${LIB}/$file
1493 chmod a+r ${LIB}/$file
1495 rm -f /tmp/$base
1498 # If arpa/inet.h prototypes are incompatible with the ones we just
1499 # installed in <sys/byteorder.h>, just remove the protos.
1500 set -x
1501 file=arpa/inet.h
1502 base=`basename $file`.$$
1503 if [ -r ${LIB}/$file ]; then
1504 file_to_fix=${LIB}/$file
1505 else
1506 if [ -r ${INPUT}/$file ]; then
1507 file_to_fix=${INPUT}/$file
1508 else
1509 file_to_fix=""
1512 if [ \! -z "$file_to_fix" ]; then
1513 echo Checking $file_to_fix
1514 sed -e '/^extern.*htons.*(in_port_t)/d' \
1515 -e '/^extern.*ntohs.*(in_port_t)/d' \
1516 $file_to_fix > /tmp/$base
1517 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1518 true
1519 else
1520 echo Fixed $file_to_fix
1521 mkdir -p $LIB/`dirname $file`
1522 rm -f ${LIB}/$file
1523 cp /tmp/$base ${LIB}/$file
1524 chmod a+r ${LIB}/$file
1526 rm -f /tmp/$base
1529 echo 'Removing unneeded directories:'
1530 cd $LIB
1531 files=`find . -type d \! -name '.' -print | sort -r`
1532 for file in $files; do
1533 rmdir $LIB/$file > /dev/null 2>&1
1534 done
1536 if $LINKS; then
1537 echo 'Making internal symbolic non-directory links'
1538 cd ${INPUT}
1539 files=`find . -type l -print`
1540 for file in $files; do
1541 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1542 if expr "$dest" : '[^/].*' > /dev/null; then
1543 target=${LIB}/`echo $file | sed "s|[^/]*\$|$dest|"`
1544 if [ -f $target ]; then
1545 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1548 done
1551 cd ${ORIG_DIR}
1553 echo 'Replacing <sys/byteorder.h>'
1554 if [ \! -d $LIB/sys ]; then
1555 mkdir $LIB/sys
1557 rm -f ${LIB}/sys/byteorder.h
1558 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1559 #ifndef _SYS_BYTEORDER_H
1560 #define _SYS_BYTEORDER_H
1562 /* Functions to convert `short' and `long' quantities from host byte order
1563 to (internet) network byte order (i.e. big-endian).
1565 Written by Ron Guilmette (rfg@ncd.com).
1567 This isn't actually used by GCC. It is installed by fixinc.svr4.
1569 For big-endian machines these functions are essentially no-ops.
1571 For little-endian machines, we define the functions using specialized
1572 asm sequences in cases where doing so yields better code (e.g. i386). */
1574 #if !defined (__GNUC__) && !defined (__GNUG__)
1575 #error You lose! This file is only useful with GNU compilers.
1576 #endif
1578 #ifdef __cplusplus
1579 extern "C" {
1580 #endif
1582 #ifndef __BYTE_ORDER__
1583 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1584 double underscores added at the front and back. */
1585 #define __LITTLE_ENDIAN__ 1234
1586 #define __BIG_ENDIAN__ 4321
1587 #define __PDP_ENDIAN__ 3412
1588 #endif
1590 #ifdef __STDC__
1591 static __inline__ unsigned long htonl (unsigned long);
1592 static __inline__ unsigned short htons (unsigned int);
1593 static __inline__ unsigned long ntohl (unsigned long);
1594 static __inline__ unsigned short ntohs (unsigned int);
1595 #endif /* defined (__STDC__) */
1597 #if defined (__i386__)
1599 #ifndef __BYTE_ORDER__
1600 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1601 #endif
1603 /* Convert a host long to a network long. */
1605 /* We must use a new-style function definition, so that this will also
1606 be valid for C++. */
1607 static __inline__ unsigned long
1608 htonl (unsigned long __arg)
1610 register unsigned long __result;
1612 __asm__ ("xchg%B0 %b0,%h0\n\
1613 ror%L0 $16,%0\n\
1614 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1615 return __result;
1618 /* Convert a host short to a network short. */
1620 static __inline__ unsigned short
1621 htons (unsigned int __arg)
1623 register unsigned short __result;
1625 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1626 return __result;
1629 #elif (defined (__ns32k__) || defined (__vax__) || defined (__arm__))
1631 #ifndef __BYTE_ORDER__
1632 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1633 #endif
1635 /* For other little-endian machines, using C code is just as efficient as
1636 using assembly code. */
1638 /* Convert a host long to a network long. */
1640 static __inline__ unsigned long
1641 htonl (unsigned long __arg)
1643 register unsigned long __result;
1645 __result = (__arg >> 24) & 0x000000ff;
1646 __result |= (__arg >> 8) & 0x0000ff00;
1647 __result |= (__arg << 8) & 0x00ff0000;
1648 __result |= (__arg << 24) & 0xff000000;
1649 return __result;
1652 /* Convert a host short to a network short. */
1654 static __inline__ unsigned short
1655 htons (unsigned int __arg)
1657 register unsigned short __result;
1659 __result = (__arg << 8) & 0xff00;
1660 __result |= (__arg >> 8) & 0x00ff;
1661 return __result;
1664 #else /* must be a big-endian machine */
1666 #ifndef __BYTE_ORDER__
1667 #define __BYTE_ORDER__ __BIG_ENDIAN__
1668 #endif
1670 /* Convert a host long to a network long. */
1672 static __inline__ unsigned long
1673 htonl (unsigned long __arg)
1675 return __arg;
1678 /* Convert a host short to a network short. */
1680 static __inline__ unsigned short
1681 htons (unsigned int __arg)
1683 return __arg;
1686 #endif /* big-endian */
1688 /* Convert a network long to a host long. */
1690 static __inline__ unsigned long
1691 ntohl (unsigned long __arg)
1693 return htonl (__arg);
1696 /* Convert a network short to a host short. */
1698 static __inline__ unsigned short
1699 ntohs (unsigned int __arg)
1701 return htons (__arg);
1704 #ifdef __cplusplus
1705 } /* extern "C" */
1706 #endif
1708 __EOF__
1710 if [ -r ${INPUT}/sys/byteorder.h ]; then
1711 if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
1712 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1713 #ifndef BYTE_ORDER
1714 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1715 #define BIG_ENDIAN __BIG_ENDIAN__
1716 #define PDP_ENDIAN __PDP_ENDIAN__
1717 #define BYTE_ORDER __BYTE_ORDER__
1718 #endif
1720 __EOF__
1724 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1725 #endif /* !defined (_SYS_BYTEORDER_H) */
1726 __EOF__
1728 chmod a+r ${LIB}/sys/byteorder.h
1730 done
1732 exit 0