Add powerpc embedded targets to --with-cpu=n.
[official-gcc.git] / gcc / fixinc.svr4
blobc0418b69d59ae115d20b6600d2a0e2814e623526
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 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 # Directory containing the original header files.
35 INPUT=${2-${INPUT-/usr/include}}
37 # Fail if no arg to specify a directory for the output.
38 if [ x$1 = x ]
39 then echo fixincludes: no output directory specified
40 exit 1
43 # Directory in which to store the results.
44 LIB=${1?"fixincludes: output directory not specified"}
46 # Make sure it exists.
47 if [ ! -d $LIB ]; then
48 mkdir $LIB || exit 1
51 ORIG_DIR=`pwd`
53 # Make LIB absolute if it is relative.
54 # Don't do this if not necessary, since may screw up automounters.
55 case $LIB in
56 /*)
59 LIB=$ORIG_DIR/$LIB
61 esac
63 echo 'Building fixincludes in ' ${LIB}
65 # Determine whether this filesystem has symbolic links.
66 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
67 rm -f $LIB/ShouldNotExist
68 LINKS=true
69 else
70 LINKS=false
73 echo 'Making directories:'
74 cd ${INPUT}
75 if $LINKS; then
76 files=`find . -follow -type d -print 2>/dev/null | sed '/^.$/d'`
77 else
78 files=`find . -type d -print | sed '/^.$/d'`
80 for file in $files; do
81 rm -rf $LIB/$file
82 if [ ! -d $LIB/$file ]
83 then mkdir $LIB/$file
85 done
87 # treetops gets an alternating list
88 # of old directories to copy
89 # and the new directories to copy to.
90 treetops="${INPUT} ${LIB}"
92 if $LINKS; then
93 echo 'Making internal symbolic directory links'
94 for file in $files; do
95 dest=`ls -ld $file | sed -n 's/.*-> //p'`
96 if [ "$dest" ]; then
97 cwd=`pwd`
98 # In case $dest is relative, get to $file's dir first.
99 cd ${INPUT}
100 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
101 rwd=`pwd`
102 # Check that the target directory exists.
103 # Redirections changed to avoid bug in sh on Ultrix.
104 (cd $dest) > /dev/null 2>&1
105 if [ $? = 0 ]; then
106 cd $dest
107 # X gets the dir that the link actually leads to.
108 x=`pwd`
109 # If link leads back into ${INPUT},
110 # make a similar link here.
111 if expr "$dest" : '[^/][^/]*' >/dev/null && [ ! -h $dest ]; then
112 echo $file '->' $dest': Making link'
113 rm -fr ${LIB}/$file > /dev/null 2>&1
114 ln -s $dest ${LIB}/$file > /dev/null 2>&1
115 elif expr $x : "${INPUT}/.*" > /dev/null; then
116 # Y gets the actual target dir name, relative to ${INPUT}.
117 y=`echo $x | sed -n "s&${INPUT}/&&p"`
118 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
119 dots=`echo "$file" |
120 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
121 echo $file '->' $dots$y ': Making link'
122 rm -fr ${LIB}/$file > /dev/null 2>&1
123 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
124 elif expr $x : "${rwd}/.*" > /dev/null; then
125 # Y gets the actual target dir name, relative to the directory where the link is.
126 y=`echo $x | sed -n "s&${rwd}/&&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 else
134 # If the link is to outside ${INPUT},
135 # treat this directory as if it actually contained the files.
136 # This line used to have $dest instead of $x.
137 # $dest seemed to be wrong for links found in subdirectories
138 # of ${INPUT}. Does this change break anything?
139 treetops="$treetops $x ${LIB}/$file"
142 cd $cwd
144 done
147 set - $treetops
148 while [ $# != 0 ]; do
149 # $1 is an old directory to copy, and $2 is the new directory to copy to.
150 echo "Finding header files in $1:"
151 cd ${INPUT}
152 cd $1
153 files=`find . -name '*.h' -type f -print`
154 echo 'Checking header files:'
155 for file in $files; do
156 if [ -r $file ]; then
157 cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
158 chmod +w $2/$file
159 chmod a+r $2/$file
161 # The following have been removed from the sed command below
162 # because it is more useful to leave these things in.
163 # The only reason to remove them was for -pedantic,
164 # which isn't much of a reason. -- rms.
165 # /^[ ]*#[ ]*ident/d
167 # This code makes Solaris SCSI fail, because it changes the
168 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
169 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
170 # Disable these also, since they probably aren't safe either.
171 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
172 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
173 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
174 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
176 # The change of u_char, etc, to u_int
177 # applies to bit fields.
178 sed -e '
179 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
180 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
181 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
182 s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
183 s/#lint(on)/defined(lint)/g
184 s/#lint(off)/!defined(lint)/g
185 s/#machine(\([^)]*\))/defined(__\1__)/g
186 s/#system(\([^)]*\))/defined(__\1__)/g
187 s/#cpu(\([^)]*\))/defined(__\1__)/g
188 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
189 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
190 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
191 /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g
192 /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/g
193 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
194 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
195 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
196 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
197 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
198 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
199 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
200 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
201 s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
202 s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
203 s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
204 s/__STDC__[ ][ ]*!=[ ][ ]*1/!defined (__STRICT_ANSI__)/g
205 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
206 /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
207 ' $2/$file > $2/$file.sed
208 mv $2/$file.sed $2/$file
209 if cmp $file $2/$file >/dev/null 2>&1; then
210 rm $2/$file
211 else
212 echo Fixed $file
215 done
216 shift; shift
217 done
219 # Install the proper definition of the three standard types in header files
220 # that they come from.
221 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
222 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
223 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
224 chmod +w ${LIB}/$file 2>/dev/null
225 chmod a+r ${LIB}/$file 2>/dev/null
228 if [ -r ${LIB}/$file ]; then
229 echo Fixing size_t, ptrdiff_t and wchar_t in $file
230 sed \
231 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
232 #ifndef __SIZE_TYPE__\
233 #define __SIZE_TYPE__ long unsigned int\
234 #endif
236 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
237 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
238 #ifndef __PTRDIFF_TYPE__\
239 #define __PTRDIFF_TYPE__ long int\
240 #endif
242 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
243 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
244 #ifndef __WCHAR_TYPE__\
245 #define __WCHAR_TYPE__ int\
246 #endif
248 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
249 ${LIB}/$file > ${LIB}/${file}.sed
250 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
251 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
252 rm ${LIB}/$file
255 done
257 # Fix first broken decl of getcwd present on some svr4 systems.
259 file=stdlib.h
260 base=`basename $file`
261 if [ -r ${LIB}/$file ]; then
262 file_to_fix=${LIB}/$file
263 else
264 if [ -r ${INPUT}/$file ]; then
265 file_to_fix=${INPUT}/$file
266 else
267 file_to_fix=""
270 if [ \! -z "$file_to_fix" ]; then
271 echo Checking $file_to_fix
272 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
273 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
274 true
275 else
276 echo Fixed $file_to_fix
277 rm -f ${LIB}/$file
278 cp /tmp/$base ${LIB}/$file
279 chmod a+r ${LIB}/$file
281 rm -f /tmp/$base
284 # Fix second broken decl of getcwd present on some svr4 systems. Also
285 # fix the incorrect decl of profil present on some svr4 systems.
287 file=unistd.h
288 base=`basename $file`
289 if [ -r ${LIB}/$file ]; then
290 file_to_fix=${LIB}/$file
291 else
292 if [ -r ${INPUT}/$file ]; then
293 file_to_fix=${INPUT}/$file
294 else
295 file_to_fix=""
298 if [ \! -z "$file_to_fix" ]; then
299 echo Checking $file_to_fix
300 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
301 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
302 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
303 true
304 else
305 echo Fixed $file_to_fix
306 rm -f ${LIB}/$file
307 cp /tmp/$base ${LIB}/$file
308 chmod a+r ${LIB}/$file
310 rm -f /tmp/$base
313 # Fix the definition of NULL in <sys/param.h> so that it is conditional
314 # and so that it is correct for both C and C++.
316 file=sys/param.h
317 base=`basename $file`
318 if [ -r ${LIB}/$file ]; then
319 file_to_fix=${LIB}/$file
320 else
321 if [ -r ${INPUT}/$file ]; then
322 file_to_fix=${INPUT}/$file
323 else
324 file_to_fix=""
327 if [ \! -z "$file_to_fix" ]; then
328 echo Checking $file_to_fix
329 cp $file_to_fix /tmp/$base
330 chmod +w /tmp/$base
331 chmod a+r /tmp/$base
332 sed -e '/^#define[ ]*NULL[ ]*0$/c\
333 #ifndef NULL\
334 #ifdef __cplusplus\
335 #define __NULL_TYPE\
336 #else /* !defined(__cplusplus) */\
337 #define __NULL_TYPE (void *)\
338 #endif /* !defined(__cplusplus) */\
339 #define NULL (__NULL_TYPE 0)\
340 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
341 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
342 true
343 else
344 echo Fixed $file_to_fix
345 rm -f ${LIB}/$file
346 cp /tmp/$base.sed ${LIB}/$file
347 chmod a+r ${LIB}/$file
349 rm -f /tmp/$base /tmp/$base.sed
352 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
353 # and so that it is correct for both C and C++.
355 file=stdio.h
356 base=`basename $file`
357 if [ -r ${LIB}/$file ]; then
358 file_to_fix=${LIB}/$file
359 else
360 if [ -r ${INPUT}/$file ]; then
361 file_to_fix=${INPUT}/$file
362 else
363 file_to_fix=""
366 if [ \! -z "$file_to_fix" ]; then
367 echo Checking $file_to_fix
368 cp $file_to_fix /tmp/$base
369 chmod +w /tmp/$base
370 sed -e '/^#define[ ]*NULL[ ]*0$/c\
371 #ifdef __cplusplus\
372 #define __NULL_TYPE\
373 #else /* !defined(__cplusplus) */\
374 #define __NULL_TYPE (void *)\
375 #endif /* !defined(__cplusplus) */\
376 #define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
377 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
378 true
379 else
380 echo Fixed $file_to_fix
381 rm -f ${LIB}/$file
382 cp /tmp/$base.sed ${LIB}/$file
383 chmod a+r ${LIB}/$file
385 rm -f /tmp/$base /tmp/$base.sed
388 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
389 # and so that it is correct for both C and C++.
391 file=dbm.h
392 base=`basename $file`
393 if [ -r ${LIB}/$file ]; then
394 file_to_fix=${LIB}/$file
395 else
396 if [ -r ${INPUT}/$file ]; then
397 file_to_fix=${INPUT}/$file
398 else
399 file_to_fix=""
402 if [ \! -z "$file_to_fix" ]; then
403 echo Checking $file_to_fix
404 cp $file_to_fix /tmp/$base
405 chmod +w /tmp/$base
406 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
407 #ifndef NULL\
408 #ifdef __cplusplus\
409 #define __NULL_TYPE\
410 #else /* !defined(__cplusplus) */\
411 #define __NULL_TYPE (void *)\
412 #endif /* !defined(__cplusplus) */\
413 #define NULL (__NULL_TYPE 0)\
414 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
415 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
416 true
417 else
418 echo Fixed $file_to_fix
419 rm -f ${LIB}/$file
420 cp /tmp/$base.sed ${LIB}/$file
421 chmod a+r ${LIB}/$file
423 rm -f /tmp/$base /tmp/$base.sed
426 # Add a prototyped declaration of mmap to <sys/mman.h>.
428 file=sys/mman.h
429 base=`basename $file`
430 if [ -r ${LIB}/$file ]; then
431 file_to_fix=${LIB}/$file
432 else
433 if [ -r ${INPUT}/$file ]; then
434 file_to_fix=${INPUT}/$file
435 else
436 file_to_fix=""
439 if [ \! -z "$file_to_fix" ]; then
440 echo Checking $file_to_fix
441 cp $file_to_fix /tmp/$base
442 chmod +w /tmp/$base
443 sed -e '/^extern caddr_t mmap();$/c\
444 #ifdef __STDC__\
445 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
446 #else /* !defined(__STDC__) */\
447 extern caddr_t mmap ();\
448 #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
449 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
450 true
451 else
452 echo Fixed $file_to_fix
453 rm -f ${LIB}/$file
454 cp /tmp/$base.sed ${LIB}/$file
455 chmod a+r ${LIB}/$file
457 rm -f /tmp/$base /tmp/$base.sed
460 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
461 # the file <ftw.h> contains extern declarations of these functions followed
462 # by explicitly `static' definitions of these functions... and that's not
463 # allowed according to ANSI C. (Note however that on Solaris, this header
464 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
465 # there are no static definitions of any function so we don't need to do
466 # any of this stuff when on Solaris.
468 file=ftw.h
469 base=`basename $file`
470 if [ -r ${LIB}/$file ]; then
471 file_to_fix=${LIB}/$file
472 else
473 if [ -r ${INPUT}/$file ]; then
474 file_to_fix=${INPUT}/$file
475 else
476 file_to_fix=""
479 if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
480 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
481 # one. Either way, we don't have to do anything.
482 true
483 else
484 echo Checking $file_to_fix
485 cp $file_to_fix /tmp/$base
486 chmod +w /tmp/$base
487 sed -e '/^extern int ftw(const/i\
488 #if !defined(_STYPES)\
489 static\
490 #else\
491 extern\
492 #endif
494 -e 's/extern \(int ftw(const.*\)$/\1/' \
495 -e '/^extern int nftw/i\
496 #if defined(_STYPES)\
497 static\
498 #else\
499 extern\
500 #endif
502 -e 's/extern \(int nftw.*\)$/\1/' \
503 -e '/^extern int ftw(),/c\
504 #if !defined(_STYPES)\
505 static\
506 #else\
507 extern\
508 #endif\
509 int ftw();\
510 #if defined(_STYPES)\
511 static\
512 #else\
513 extern\
514 #endif\
515 int nftw();' /tmp/$base > /tmp/$base.sed
516 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
517 true
518 else
519 echo Fixed $file_to_fix
520 rm -f ${LIB}/$file
521 cp /tmp/$base.sed ${LIB}/$file
522 chmod a+r ${LIB}/$file
524 rm -f /tmp/$base /tmp/$base.sed
527 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
528 # g++, since it's now an official type in the C++ language.
529 file=curses.h
530 base=`basename $file`
531 if [ -r ${LIB}/$file ]; then
532 file_to_fix=${LIB}/$file
533 else
534 if [ -r ${INPUT}/$file ]; then
535 file_to_fix=${INPUT}/$file
536 else
537 file_to_fix=""
541 if [ \! -z "$file_to_fix" ]; then
542 echo Checking $file_to_fix
543 cp $file_to_fix /tmp/$base
544 chmod +w /tmp/$base
545 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
546 typedef char bool;\
547 #endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed
548 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
549 true
550 else
551 echo Fixed $file_to_fix
552 rm -f ${LIB}/$file
553 cp /tmp/$base.sed ${LIB}/$file
554 chmod a+r ${LIB}/$file
556 rm -f /tmp/$base /tmp/$base.sed
559 # Add a `static' declaration of `getrnge' into <regexp.h>.
561 # Don't do this if there is already a `static void getrnge' declaration
562 # present, since this would cause a redeclaration error. Solaris 2.x has
563 # such a declaration.
565 file=regexp.h
566 base=`basename $file`
567 if [ -r ${LIB}/$file ]; then
568 file_to_fix=${LIB}/$file
569 else
570 if [ -r ${INPUT}/$file ]; then
571 file_to_fix=${INPUT}/$file
572 else
573 file_to_fix=""
576 if [ \! -z "$file_to_fix" ]; then
577 echo Checking $file_to_fix
578 if grep "static void getrnge" $file_to_fix > /dev/null; then
579 true
580 else
581 cp $file_to_fix /tmp/$base
582 chmod +w /tmp/$base
583 sed -e '/^static int[ ]*size;/c\
584 static int size ;\
586 static int getrnge ();' /tmp/$base > /tmp/$base.sed
587 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
588 true
589 else
590 echo Fixed $file_to_fix
591 rm -f ${LIB}/$file
592 cp /tmp/$base.sed ${LIB}/$file
593 chmod a+r ${LIB}/$file
596 rm -f /tmp/$base /tmp/$base.sed
599 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
600 # that is visible to any ANSI compiler using this include. Simply
601 # delete the lines that #define some string functions to internal forms.
603 file=string.h
604 base=`basename $file`
605 if [ -r ${LIB}/$file ]; then
606 file_to_fix=${LIB}/$file
607 else
608 if [ -r ${INPUT}/$file ]; then
609 file_to_fix=${INPUT}/$file
610 else
611 file_to_fix=""
614 if [ \! -z "$file_to_fix" ]; then
615 echo Checking $file_to_fix
616 cp $file_to_fix /tmp/$base
617 chmod +w /tmp/$base
618 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
619 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
620 true
621 else
622 echo Fixed $file_to_fix
623 rm -f ${LIB}/$file
624 cp /tmp/$base.sed ${LIB}/$file
625 chmod a+r ${LIB}/$file
627 rm -f /tmp/$base /tmp/$base.sed
630 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
631 # tend to conflict with the compiler's own definition of this symbol. (We
632 # will use the compiler's definition.)
633 # Likewise __sparc, for Solaris, and __i860, and a few others
634 # (guessing it is necessary for all of them).
636 file=ieeefp.h
637 base=`basename $file`
638 if [ -r ${LIB}/$file ]; then
639 file_to_fix=${LIB}/$file
640 else
641 if [ -r ${INPUT}/$file ]; then
642 file_to_fix=${INPUT}/$file
643 else
644 file_to_fix=""
647 if [ \! -z "$file_to_fix" ]; then
648 echo Checking $file_to_fix
649 cp $file_to_fix /tmp/$base
650 chmod +w /tmp/$base
651 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
652 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
653 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
654 /tmp/$base > /tmp/$base.sed
655 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
656 true
657 else
658 echo Fixed $file_to_fix
659 rm -f ${LIB}/$file
660 cp /tmp/$base.sed ${LIB}/$file
661 chmod a+r ${LIB}/$file
663 rm -f /tmp/$base /tmp/$base.sed
666 # Add a #define of _SIGACTION_ into <sys/signal.h>.
667 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
669 file=sys/signal.h
670 base=`basename $file`
671 if [ -r ${LIB}/$file ]; then
672 file_to_fix=${LIB}/$file
673 else
674 if [ -r ${INPUT}/$file ]; then
675 file_to_fix=${INPUT}/$file
676 else
677 file_to_fix=""
680 if [ \! -z "$file_to_fix" ]; then
681 echo Checking $file_to_fix
682 cp $file_to_fix /tmp/$base
683 chmod +w /tmp/$base
684 sed -e '/^struct sigaction {/c\
685 #define _SIGACTION_\
686 struct sigaction {' \
687 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
688 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
689 true
690 else
691 echo Fixed $file_to_fix
692 rm -f ${LIB}/$file
693 cp /tmp/$base.sed ${LIB}/$file
694 chmod a+r ${LIB}/$file
696 rm -f /tmp/$base /tmp/$base.sed
699 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
701 file=sys/mkdev.h
702 base=`basename $file`
703 if [ -r ${LIB}/$file ]; then
704 file_to_fix=${LIB}/$file
705 else
706 if [ -r ${INPUT}/$file ]; then
707 file_to_fix=${INPUT}/$file
708 else
709 file_to_fix=""
712 if [ \! -z "$file_to_fix" ]; then
713 echo Checking $file_to_fix
714 cp $file_to_fix /tmp/$base
715 chmod +w /tmp/$base
716 sed -e '/^dev_t makedev(const/c\
717 static dev_t makedev(const major_t, const minor_t);' \
718 -e '/^dev_t makedev()/c\
719 static dev_t makedev();' \
720 -e '/^major_t major(const/c\
721 static major_t major(const dev_t);' \
722 -e '/^major_t major()/c\
723 static major_t major();' \
724 -e '/^minor_t minor(const/c\
725 static minor_t minor(const dev_t);' \
726 -e '/^minor_t minor()/c\
727 static minor_t minor();' /tmp/$base > /tmp/$base.sed
728 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
729 true
730 else
731 echo Fixed $file_to_fix
732 rm -f ${LIB}/$file
733 cp /tmp/$base.sed ${LIB}/$file
734 chmod a+r ${LIB}/$file
736 rm -f /tmp/$base /tmp/$base.sed
739 # Fix reference to NMSZ in <sys/adv.h>.
741 file=sys/adv.h
742 base=`basename $file`
743 if [ -r ${LIB}/$file ]; then
744 file_to_fix=${LIB}/$file
745 else
746 if [ -r ${INPUT}/$file ]; then
747 file_to_fix=${INPUT}/$file
748 else
749 file_to_fix=""
752 if [ \! -z "$file_to_fix" ]; then
753 echo Checking $file_to_fix
754 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
755 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
756 true
757 else
758 echo Fixed $file_to_fix
759 rm -f ${LIB}/$file
760 cp /tmp/$base ${LIB}/$file
761 chmod a+r ${LIB}/$file
763 rm -f /tmp/$base
766 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
767 # array initializers.
769 file=sys/netcspace.h
770 base=`basename $file`
771 if [ -r ${LIB}/$file ]; then
772 file_to_fix=${LIB}/$file
773 else
774 if [ -r ${INPUT}/$file ]; then
775 file_to_fix=${INPUT}/$file
776 else
777 file_to_fix=""
780 if [ \! -z "$file_to_fix" ]; then
781 echo Checking $file_to_fix
782 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
783 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
784 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
785 true
786 else
787 echo Fixed $file_to_fix
788 rm -f ${LIB}/$file
789 cp /tmp/$base ${LIB}/$file
790 chmod a+r ${LIB}/$file
792 rm -f /tmp/$base
795 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
797 file=fs/rfs/rf_cache.h
798 base=`basename $file`
799 if [ -r ${LIB}/$file ]; then
800 file_to_fix=${LIB}/$file
801 else
802 if [ -r ${INPUT}/$file ]; then
803 file_to_fix=${INPUT}/$file
804 else
805 file_to_fix=""
808 if [ \! -z "$file_to_fix" ]; then
809 echo Checking $file_to_fix
810 if grep _KERNEL $file_to_fix > /dev/null; then
811 true
812 else
813 echo '#ifdef _KERNEL' > /tmp/$base
814 cat $file_to_fix >> /tmp/$base
815 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
816 echo Fixed $file_to_fix
817 rm -f ${LIB}/$file
818 cp /tmp/$base ${LIB}/$file
819 chmod a+r ${LIB}/$file
820 rm -f /tmp/$base
824 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
826 file=sys/erec.h
827 base=`basename $file`
828 if [ -r ${LIB}/$file ]; then
829 file_to_fix=${LIB}/$file
830 else
831 if [ -r ${INPUT}/$file ]; then
832 file_to_fix=${INPUT}/$file
833 else
834 file_to_fix=""
837 if [ \! -z "$file_to_fix" ]; then
838 echo Checking $file_to_fix
839 if grep _KERNEL $file_to_fix > /dev/null; then
840 true
841 else
842 echo '#ifdef _KERNEL' > /tmp/$base
843 cat $file_to_fix >> /tmp/$base
844 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
845 echo Fixed $file_to_fix
846 rm -f ${LIB}/$file
847 cp /tmp/$base ${LIB}/$file
848 chmod a+r ${LIB}/$file
849 rm -f /tmp/$base
853 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
855 file=sys/err.h
856 base=`basename $file`
857 if [ -r ${LIB}/$file ]; then
858 file_to_fix=${LIB}/$file
859 else
860 if [ -r ${INPUT}/$file ]; then
861 file_to_fix=${INPUT}/$file
862 else
863 file_to_fix=""
866 if [ \! -z "$file_to_fix" ]; then
867 echo Checking $file_to_fix
868 if grep _KERNEL $file_to_fix > /dev/null; then
869 true
870 else
871 echo '#ifdef _KERNEL' > /tmp/$base
872 cat $file_to_fix >> /tmp/$base
873 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
874 echo Fixed $file_to_fix
875 rm -f ${LIB}/$file
876 cp /tmp/$base ${LIB}/$file
877 chmod a+r ${LIB}/$file
878 rm -f /tmp/$base
882 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
884 file=sys/char.h
885 base=`basename $file`
886 if [ -r ${LIB}/$file ]; then
887 file_to_fix=${LIB}/$file
888 else
889 if [ -r ${INPUT}/$file ]; then
890 file_to_fix=${INPUT}/$file
891 else
892 file_to_fix=""
895 if [ \! -z "$file_to_fix" ]; then
896 echo Checking $file_to_fix
897 if grep _KERNEL $file_to_fix > /dev/null; then
898 true
899 else
900 echo '#ifdef _KERNEL' > /tmp/$base
901 cat $file_to_fix >> /tmp/$base
902 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
903 echo Fixed $file_to_fix
904 rm -f ${LIB}/$file
905 cp /tmp/$base ${LIB}/$file
906 chmod a+r ${LIB}/$file
907 rm -f /tmp/$base
911 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
913 file=sys/getpages.h
914 base=`basename $file`
915 if [ -r ${LIB}/$file ]; then
916 file_to_fix=${LIB}/$file
917 else
918 if [ -r ${INPUT}/$file ]; then
919 file_to_fix=${INPUT}/$file
920 else
921 file_to_fix=""
924 if [ \! -z "$file_to_fix" ]; then
925 echo Checking $file_to_fix
926 if grep _KERNEL $file_to_fix > /dev/null; then
927 true
928 else
929 echo '#ifdef _KERNEL' > /tmp/$base
930 cat $file_to_fix >> /tmp/$base
931 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
932 echo Fixed $file_to_fix
933 rm -f ${LIB}/$file
934 cp /tmp/$base ${LIB}/$file
935 chmod a+r ${LIB}/$file
936 rm -f /tmp/$base
940 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
942 file=sys/map.h
943 base=`basename $file`
944 if [ -r ${LIB}/$file ]; then
945 file_to_fix=${LIB}/$file
946 else
947 if [ -r ${INPUT}/$file ]; then
948 file_to_fix=${INPUT}/$file
949 else
950 file_to_fix=""
953 if [ \! -z "$file_to_fix" ]; then
954 echo Checking $file_to_fix
955 if grep _KERNEL $file_to_fix > /dev/null; then
956 true
957 else
958 echo '#ifdef _KERNEL' > /tmp/$base
959 cat $file_to_fix >> /tmp/$base
960 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
961 echo Fixed $file_to_fix
962 rm -f ${LIB}/$file
963 cp /tmp/$base ${LIB}/$file
964 chmod a+r ${LIB}/$file
965 rm -f /tmp/$base
969 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
971 file=sys/cmn_err.h
972 base=`basename $file`
973 if [ -r ${LIB}/$file ]; then
974 file_to_fix=${LIB}/$file
975 else
976 if [ -r ${INPUT}/$file ]; then
977 file_to_fix=${INPUT}/$file
978 else
979 file_to_fix=""
982 if [ \! -z "$file_to_fix" ]; then
983 echo Checking $file_to_fix
984 if grep _KERNEL $file_to_fix > /dev/null; then
985 true
986 else
987 echo '#ifdef _KERNEL' > /tmp/$base
988 cat $file_to_fix >> /tmp/$base
989 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
990 echo Fixed $file_to_fix
991 rm -f ${LIB}/$file
992 cp /tmp/$base ${LIB}/$file
993 chmod a+r ${LIB}/$file
994 rm -f /tmp/$base
998 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
1000 file=sys/kdebugger.h
1001 base=`basename $file`
1002 if [ -r ${LIB}/$file ]; then
1003 file_to_fix=${LIB}/$file
1004 else
1005 if [ -r ${INPUT}/$file ]; then
1006 file_to_fix=${INPUT}/$file
1007 else
1008 file_to_fix=""
1011 if [ \! -z "$file_to_fix" ]; then
1012 echo Checking $file_to_fix
1013 if grep _KERNEL $file_to_fix > /dev/null; then
1014 true
1015 else
1016 echo '#ifdef _KERNEL' > /tmp/$base
1017 cat $file_to_fix >> /tmp/$base
1018 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
1019 echo Fixed $file_to_fix
1020 rm -f ${LIB}/$file
1021 cp /tmp/$base ${LIB}/$file
1022 chmod a+r ${LIB}/$file
1023 rm -f /tmp/$base
1027 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1028 # This has been taken out because it breaks on some versions of
1029 # DYNIX/ptx, and it does not seem to do much good on any system.
1030 # file=netinet/in.h
1031 # base=`basename $file`
1032 # if [ -r ${LIB}/$file ]; then
1033 # file_to_fix=${LIB}/$file
1034 # else
1035 # if [ -r ${INPUT}/$file ]; then
1036 # file_to_fix=${INPUT}/$file
1037 # else
1038 # file_to_fix=""
1039 # fi
1040 # fi
1041 # if [ \! -z "$file_to_fix" ]; then
1042 # echo Checking $file_to_fix
1043 # if grep _KERNEL $file_to_fix > /dev/null; then
1044 # true
1045 # else
1046 # sed -e '/#ifdef INKERNEL/i\
1047 # #ifdef _KERNEL
1048 # ' \
1049 # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1050 # #endif /* _KERNEL */
1051 # ' \
1052 # $file_to_fix > ${LIB}/${file}.sed
1053 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1054 # echo Fixed $file_to_fix
1055 # fi
1056 # fi
1058 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1060 file=sys/endian.h
1061 base=`basename $file`
1062 if [ -r ${LIB}/$file ]; then
1063 file_to_fix=${LIB}/$file
1064 else
1065 if [ -r ${INPUT}/$file ]; then
1066 file_to_fix=${INPUT}/$file
1067 else
1068 file_to_fix=""
1071 if [ \! -z "$file_to_fix" ]; then
1072 echo Checking $file_to_fix
1073 if grep __GNUC__ $file_to_fix > /dev/null; then
1074 true
1075 else
1076 sed -e '/# ifdef __STDC__/i\
1077 # if !defined (__GNUC__) && !defined (__GNUG__)
1079 -e '/# include <sys\/byteorder.h>/s/ / /'\
1080 -e '/# include <sys\/byteorder.h>/i\
1081 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */
1083 $file_to_fix > ${LIB}/${file}.sed
1084 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1085 echo Fixed $file_to_fix
1089 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1090 # and the text in types.h is not erroneous.
1091 ## In sys/types.h, don't name the enum for booleans.
1093 #file=sys/types.h
1094 #base=`basename $file`
1095 #if [ -r ${LIB}/$file ]; then
1096 # file_to_fix=${LIB}/$file
1097 #else
1098 # if [ -r ${INPUT}/$file ]; then
1099 # file_to_fix=${INPUT}/$file
1100 # else
1101 # file_to_fix=""
1102 # fi
1104 #if [ \! -z "$file_to_fix" ]; then
1105 # echo Checking $file_to_fix
1106 # if grep "enum boolean" $file_to_fix > /dev/null; then
1107 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1108 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1109 # echo Fixed $file_to_fix
1110 # else
1111 # true
1112 # fi
1115 # Remove useless extern keyword from struct forward declarations in
1116 # <sys/stream.h> and <sys/strsubr.h>
1118 file=sys/stream.h
1119 base=`basename $file`
1120 if [ -r ${LIB}/$file ]; then
1121 file_to_fix=${LIB}/$file
1122 else
1123 if [ -r ${INPUT}/$file ]; then
1124 file_to_fix=${INPUT}/$file
1125 else
1126 file_to_fix=""
1129 if [ \! -z "$file_to_fix" ]; then
1130 echo Checking $file_to_fix
1131 sed -e '
1132 s/extern struct stdata;/struct stdata;/g
1133 s/extern struct strevent;/struct strevent;/g
1134 ' $file_to_fix > /tmp/$base
1135 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1136 true
1137 else
1138 echo Fixed $file_to_fix
1139 rm -f ${LIB}/$file
1140 cp /tmp/$base ${LIB}/$file
1141 chmod a+r ${LIB}/$file
1143 rm -f /tmp/$base
1146 file=sys/strsubr.h
1147 base=`basename $file`
1148 if [ -r ${LIB}/$file ]; then
1149 file_to_fix=${LIB}/$file
1150 else
1151 if [ -r ${INPUT}/$file ]; then
1152 file_to_fix=${INPUT}/$file
1153 else
1154 file_to_fix=""
1157 if [ \! -z "$file_to_fix" ]; then
1158 echo Checking $file_to_fix
1159 sed -e '
1160 s/extern struct strbuf;/struct strbuf;/g
1161 s/extern struct uio;/struct uio;/g
1162 s/extern struct thread;/struct thread;/g
1163 s/extern struct proc;/struct proc;/g
1164 ' $file_to_fix > /tmp/$base
1165 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1166 true
1167 else
1168 echo Fixed $file_to_fix
1169 rm -f ${LIB}/$file
1170 cp /tmp/$base ${LIB}/$file
1171 chmod a+r ${LIB}/$file
1173 rm -f /tmp/$base
1176 # Put storage class at start of decl, to avoid warning.
1177 file=rpc/types.h
1178 base=`basename $file`
1179 if [ -r ${LIB}/$file ]; then
1180 file_to_fix=${LIB}/$file
1181 else
1182 if [ -r ${INPUT}/$file ]; then
1183 file_to_fix=${INPUT}/$file
1184 else
1185 file_to_fix=""
1188 if [ \! -z "$file_to_fix" ]; then
1189 echo Checking $file_to_fix
1190 sed -e '
1191 s/const extern/extern const/g
1192 ' $file_to_fix > /tmp/$base
1193 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1194 true
1195 else
1196 echo Fixed $file_to_fix
1197 rm -f ${LIB}/$file
1198 cp /tmp/$base ${LIB}/$file
1199 chmod a+r ${LIB}/$file
1201 rm -f /tmp/$base
1204 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1206 file=sys/stat.h
1207 base=`basename $file`
1208 if [ -r ${LIB}/$file ]; then
1209 file_to_fix=${LIB}/$file
1210 else
1211 if [ -r ${INPUT}/$file ]; then
1212 file_to_fix=${INPUT}/$file
1213 else
1214 file_to_fix=""
1217 if [ \! -z "$file_to_fix" ]; then
1218 echo Checking $file_to_fix
1219 cp $file_to_fix /tmp/$base
1220 chmod +w /tmp/$base
1221 sed -e '/^stat([ ]*[^c]/{
1224 s/(.*)\n/( /
1225 s/;\n/, /
1226 s/;$/)/
1227 }' \
1228 -e '/^lstat([ ]*[^c]/{
1231 s/(.*)\n/( /
1232 s/;\n/, /
1233 s/;$/)/
1234 }' \
1235 -e '/^fstat([ ]*[^i]/{
1238 s/(.*)\n/( /
1239 s/;\n/, /
1240 s/;$/)/
1241 }' \
1242 -e '/^mknod([ ]*[^c]/{
1246 s/(.*)\n/( /
1247 s/;\n/, /g
1248 s/;$/)/
1249 }' \
1250 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1251 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1252 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1253 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1254 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1255 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1256 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1257 true
1258 else
1259 echo Fixed $file_to_fix
1260 rm -f ${LIB}/$file
1261 cp /tmp/$base.sed ${LIB}/$file
1262 chmod a+r ${LIB}/$file
1264 rm -f /tmp/$base /tmp/$base.sed
1267 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1269 if [ -x /bin/sony ]; then
1270 if /bin/sony; then
1272 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1274 file=stdio.h
1275 base=`basename $file`
1276 if [ -r ${LIB}/$file ]; then
1277 file_to_fix=${LIB}/$file
1278 else
1279 if [ -r ${INPUT}/$file ]; then
1280 file_to_fix=${INPUT}/$file
1281 else
1282 file_to_fix=""
1285 if [ \! -z "$file_to_fix" ]; then
1286 echo Checking $file_to_fix
1287 cp $file_to_fix /tmp/$base
1288 chmod +w /tmp/$base
1289 sed -e '
1290 s/__filbuf/_filbuf/g
1291 s/__flsbuf/_flsbuf/g
1292 s/__iob/_iob/g
1293 ' /tmp/$base > /tmp/$base.sed
1294 mv /tmp/$base.sed /tmp/$base
1295 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1296 true
1297 else
1298 echo Fixed $file_to_fix
1299 rm -f ${LIB}/$file
1300 cp /tmp/$base ${LIB}/$file
1301 chmod a+r ${LIB}/$file
1303 rm -f /tmp/$base
1306 # Change <ctype.h> to not define __ctype
1308 file=ctype.h
1309 base=`basename $file`
1310 if [ -r ${LIB}/$file ]; then
1311 file_to_fix=${LIB}/$file
1312 else
1313 if [ -r ${INPUT}/$file ]; then
1314 file_to_fix=${INPUT}/$file
1315 else
1316 file_to_fix=""
1319 if [ \! -z "$file_to_fix" ]; then
1320 echo Checking $file_to_fix
1321 cp $file_to_fix /tmp/$base
1322 chmod +w /tmp/$base
1323 sed -e '
1324 s/__ctype/_ctype/g
1325 ' /tmp/$base > /tmp/$base.sed
1326 mv /tmp/$base.sed /tmp/$base
1327 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1328 true
1329 else
1330 echo Fixed $file_to_fix
1331 rm -f ${LIB}/$file
1332 cp /tmp/$base ${LIB}/$file
1333 chmod a+r ${LIB}/$file
1335 rm -f /tmp/$base
1340 # In limits.h, put #ifndefs around things that are supposed to be defined
1341 # in float.h to avoid redefinition errors if float.h is included first.
1342 # Solaris 2.1 has this problem.
1344 file=limits.h
1345 base=`basename $file`
1346 if [ -r ${LIB}/$file ]; then
1347 file_to_fix=${LIB}/$file
1348 else
1349 if [ -r ${INPUT}/$file ]; then
1350 file_to_fix=${INPUT}/$file
1351 else
1352 file_to_fix=""
1355 if [ \! -z "$file_to_fix" ]; then
1356 echo Checking $file_to_fix
1357 sed -e '/[ ]FLT_MIN[ ]/i\
1358 #ifndef FLT_MIN
1360 -e '/[ ]FLT_MIN[ ]/a\
1361 #endif
1363 -e '/[ ]FLT_MAX[ ]/i\
1364 #ifndef FLT_MAX
1366 -e '/[ ]FLT_MAX[ ]/a\
1367 #endif
1369 -e '/[ ]FLT_DIG[ ]/i\
1370 #ifndef FLT_DIG
1372 -e '/[ ]FLT_DIG[ ]/a\
1373 #endif
1375 -e '/[ ]DBL_MIN[ ]/i\
1376 #ifndef DBL_MIN
1378 -e '/[ ]DBL_MIN[ ]/a\
1379 #endif
1381 -e '/[ ]DBL_MAX[ ]/i\
1382 #ifndef DBL_MAX
1384 -e '/[ ]DBL_MAX[ ]/a\
1385 #endif
1387 -e '/[ ]DBL_DIG[ ]/i\
1388 #ifndef DBL_DIG
1390 -e '/[ ]DBL_DIG[ ]/a\
1391 #endif
1392 ' $file_to_fix > /tmp/$base
1393 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1394 true
1395 else
1396 echo Fixed $file_to_fix
1397 rm -f ${LIB}/$file
1398 cp /tmp/$base ${LIB}/$file
1399 chmod a+r ${LIB}/$file
1401 rm -f /tmp/$base
1404 # Completely replace <sys/varargs.h> with a file that includes gcc's
1405 # stdarg.h or varargs.h files as appropriate.
1407 file=sys/varargs.h
1408 if [ -r ${INPUT}/$file ]; then
1409 echo Replacing $file
1410 cat > ${LIB}/$file << EOF
1411 /* This file was generated by fixincludes. */
1412 #ifndef _SYS_VARARGS_H
1413 #define _SYS_VARARGS_H
1415 #ifdef __STDC__
1416 #include <stdarg.h>
1417 #else
1418 #include <varargs.h>
1419 #endif
1421 #endif /* _SYS_VARARGS_H */
1423 chmod a+r ${LIB}/$file
1426 # In math.h, put #ifndefs around things that might be defined in a gcc
1427 # specific math-*.h file.
1429 file=math.h
1430 base=`basename $file`
1431 if [ -r ${LIB}/$file ]; then
1432 file_to_fix=${LIB}/$file
1433 else
1434 if [ -r ${INPUT}/$file ]; then
1435 file_to_fix=${INPUT}/$file
1436 else
1437 file_to_fix=""
1440 if [ \! -z "$file_to_fix" ]; then
1441 echo Checking $file_to_fix
1442 sed -e '/define[ ]HUGE_VAL[ ]/i\
1443 #ifndef HUGE_VAL
1445 -e '/define[ ]HUGE_VAL[ ]/a\
1446 #endif
1447 ' $file_to_fix > /tmp/$base
1448 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1449 true
1450 else
1451 echo Fixed $file_to_fix
1452 rm -f ${LIB}/$file
1453 cp /tmp/$base ${LIB}/$file
1454 chmod a+r ${LIB}/$file
1456 rm -f /tmp/$base
1459 # Solaris math.h and floatingpoint.h define __P without protection,
1460 # which conflicts with the fixproto definition. The fixproto
1461 # definition and the Solaris definition are used the same way.
1462 for file in math.h floatingpoint.h; do
1463 base=`basename $file`
1464 if [ -r ${LIB}/$file ]; then
1465 file_to_fix=${LIB}/$file
1466 else
1467 if [ -r ${INPUT}/$file ]; then
1468 file_to_fix=${INPUT}/$file
1469 else
1470 file_to_fix=""
1473 if [ \! -z "$file_to_fix" ]; then
1474 echo Checking $file_to_fix
1475 sed -e '/^#define[ ]*__P/i\
1476 #ifndef __P
1478 -e '/^#define[ ]*__P/a\
1479 #endif
1480 ' $file_to_fix > /tmp/$base
1481 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1482 true
1483 else
1484 echo Fixed $file_to_fix
1485 rm -f ${LIB}/$file
1486 cp /tmp/$base ${LIB}/$file
1487 chmod a+r ${LIB}/$file
1489 rm -f /tmp/$base
1491 done
1493 # The Solaris math.h defines struct exception, which conflicts with
1494 # the class exception defined in the C++ file std/stdexcept.h. We
1495 # redefine it to __math_exception. This is not a great fix, but I
1496 # haven't been able to think of anything better.
1497 file=math.h
1498 base=`basename $file`
1499 if [ -r ${LIB}/$file ]; then
1500 file_to_fix=${LIB}/$file
1501 else
1502 if [ -r ${INPUT}/$file ]; then
1503 file_to_fix=${INPUT}/$file
1504 else
1505 file_to_fix=""
1508 if [ \! -z "$file_to_fix" ]; then
1509 echo Checking $file_to_fix
1510 sed -e '/struct exception/i\
1511 #ifdef __cplusplus\
1512 #define exception __math_exception\
1513 #endif'\
1514 -e '/struct exception/a\
1515 #ifdef __cplusplus\
1516 #undef exception\
1517 #endif' $file_to_fix > /tmp/$base
1518 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1519 true
1520 else
1521 echo Fixed $file_to_fix
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 -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 #ifndef __BYTE_ORDER__
1579 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1580 double underscores added at the front and back. */
1581 #define __LITTLE_ENDIAN__ 1234
1582 #define __BIG_ENDIAN__ 4321
1583 #define __PDP_ENDIAN__ 3412
1584 #endif
1586 #ifdef __STDC__
1587 static __inline__ unsigned long htonl (unsigned long);
1588 static __inline__ unsigned short htons (unsigned int);
1589 static __inline__ unsigned long ntohl (unsigned long);
1590 static __inline__ unsigned short ntohs (unsigned int);
1591 #endif /* defined (__STDC__) */
1593 #if defined (__i386__)
1595 #ifndef __BYTE_ORDER__
1596 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1597 #endif
1599 /* Convert a host long to a network long. */
1601 /* We must use a new-style function definition, so that this will also
1602 be valid for C++. */
1603 static __inline__ unsigned long
1604 htonl (unsigned long __arg)
1606 register unsigned long __result;
1608 __asm__ ("xchg%B0 %b0,%h0\n\
1609 ror%L0 $16,%0\n\
1610 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1611 return __result;
1614 /* Convert a host short to a network short. */
1616 static __inline__ unsigned short
1617 htons (unsigned int __arg)
1619 register unsigned short __result;
1621 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1622 return __result;
1625 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1626 || defined (__ns32k__) || defined (__vax__) \
1627 || defined (__spur__) || defined (__arm__))
1629 #ifndef __BYTE_ORDER__
1630 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1631 #endif
1633 /* For other little-endian machines, using C code is just as efficient as
1634 using assembly code. */
1636 /* Convert a host long to a network long. */
1638 static __inline__ unsigned long
1639 htonl (unsigned long __arg)
1641 register unsigned long __result;
1643 __result = (__arg >> 24) & 0x000000ff;
1644 __result |= (__arg >> 8) & 0x0000ff00;
1645 __result |= (__arg << 8) & 0x00ff0000;
1646 __result |= (__arg << 24) & 0xff000000;
1647 return __result;
1650 /* Convert a host short to a network short. */
1652 static __inline__ unsigned short
1653 htons (unsigned int __arg)
1655 register unsigned short __result;
1657 __result = (__arg << 8) & 0xff00;
1658 __result |= (__arg >> 8) & 0x00ff;
1659 return __result;
1662 #else /* must be a big-endian machine */
1664 #ifndef __BYTE_ORDER__
1665 #define __BYTE_ORDER__ __BIG_ENDIAN__
1666 #endif
1668 /* Convert a host long to a network long. */
1670 static __inline__ unsigned long
1671 htonl (unsigned long __arg)
1673 return __arg;
1676 /* Convert a host short to a network short. */
1678 static __inline__ unsigned short
1679 htons (unsigned int __arg)
1681 return __arg;
1684 #endif /* big-endian */
1686 /* Convert a network long to a host long. */
1688 static __inline__ unsigned long
1689 ntohl (unsigned long __arg)
1691 return htonl (__arg);
1694 /* Convert a network short to a host short. */
1696 static __inline__ unsigned short
1697 ntohs (unsigned int __arg)
1699 return htons (__arg);
1702 __EOF__
1704 if [ -r ${INPUT}/sys/byteorder.h ]; then
1705 if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
1706 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1707 #ifndef BYTE_ORDER
1708 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1709 #define BIG_ENDIAN __BIG_ENDIAN__
1710 #define PDP_ENDIAN __PDP_ENDIAN__
1711 #define BYTE_ORDER __BYTE_ORDER__
1712 #endif
1714 __EOF__
1718 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1719 #endif /* !defined (_SYS_BYTEORDER_H) */
1720 __EOF__
1722 chmod a+r ${LIB}/sys/byteorder.h
1724 exit 0