* i386.c (notice_update_cc): Remove bogus pentium GCC code.
[official-gcc.git] / gcc / fixinc.svr4
blob46e07ce0ac9fc508f8a929a261a972ed7acfbc4e
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 s/__STDC__ - 0 == 1/defined (__STRICT_ANSI__)/g
207 /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
208 ' $2/$file > $2/$file.sed
209 mv $2/$file.sed $2/$file
210 if cmp $file $2/$file >/dev/null 2>&1; then
211 rm $2/$file
212 else
213 echo Fixed $file
216 done
217 shift; shift
218 done
220 # Install the proper definition of the three standard types in header files
221 # that they come from.
222 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
223 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
224 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
225 chmod +w ${LIB}/$file 2>/dev/null
226 chmod a+r ${LIB}/$file 2>/dev/null
229 if [ -r ${LIB}/$file ]; then
230 echo Fixing size_t, ptrdiff_t and wchar_t in $file
231 sed \
232 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
233 #ifndef __SIZE_TYPE__\
234 #define __SIZE_TYPE__ long unsigned int\
235 #endif
237 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
238 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
239 #ifndef __PTRDIFF_TYPE__\
240 #define __PTRDIFF_TYPE__ long int\
241 #endif
243 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
244 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
245 #ifndef __WCHAR_TYPE__\
246 #define __WCHAR_TYPE__ int\
247 #endif
249 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
250 ${LIB}/$file > ${LIB}/${file}.sed
251 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
252 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
253 rm ${LIB}/$file
256 done
258 # Fix first broken decl of getcwd present on some svr4 systems.
260 file=stdlib.h
261 base=`basename $file`
262 if [ -r ${LIB}/$file ]; then
263 file_to_fix=${LIB}/$file
264 else
265 if [ -r ${INPUT}/$file ]; then
266 file_to_fix=${INPUT}/$file
267 else
268 file_to_fix=""
271 if [ \! -z "$file_to_fix" ]; then
272 echo Checking $file_to_fix
273 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
274 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
275 true
276 else
277 echo Fixed $file_to_fix
278 rm -f ${LIB}/$file
279 cp /tmp/$base ${LIB}/$file
280 chmod a+r ${LIB}/$file
282 rm -f /tmp/$base
285 # Fix second broken decl of getcwd present on some svr4 systems. Also
286 # fix the incorrect decl of profil present on some svr4 systems.
288 file=unistd.h
289 base=`basename $file`
290 if [ -r ${LIB}/$file ]; then
291 file_to_fix=${LIB}/$file
292 else
293 if [ -r ${INPUT}/$file ]; then
294 file_to_fix=${INPUT}/$file
295 else
296 file_to_fix=""
299 if [ \! -z "$file_to_fix" ]; then
300 echo Checking $file_to_fix
301 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
302 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
303 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
304 true
305 else
306 echo Fixed $file_to_fix
307 rm -f ${LIB}/$file
308 cp /tmp/$base ${LIB}/$file
309 chmod a+r ${LIB}/$file
311 rm -f /tmp/$base
314 # Fix the definition of NULL in <sys/param.h> so that it is conditional
315 # and so that it is correct for both C and C++.
317 file=sys/param.h
318 base=`basename $file`
319 if [ -r ${LIB}/$file ]; then
320 file_to_fix=${LIB}/$file
321 else
322 if [ -r ${INPUT}/$file ]; then
323 file_to_fix=${INPUT}/$file
324 else
325 file_to_fix=""
328 if [ \! -z "$file_to_fix" ]; then
329 echo Checking $file_to_fix
330 cp $file_to_fix /tmp/$base
331 chmod +w /tmp/$base
332 chmod a+r /tmp/$base
333 sed -e '/^#define[ ]*NULL[ ]*0$/c\
334 #ifndef NULL\
335 #ifdef __cplusplus\
336 #define __NULL_TYPE\
337 #else /* !defined(__cplusplus) */\
338 #define __NULL_TYPE (void *)\
339 #endif /* !defined(__cplusplus) */\
340 #define NULL (__NULL_TYPE 0)\
341 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
342 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
343 true
344 else
345 echo Fixed $file_to_fix
346 rm -f ${LIB}/$file
347 cp /tmp/$base.sed ${LIB}/$file
348 chmod a+r ${LIB}/$file
350 rm -f /tmp/$base /tmp/$base.sed
353 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
354 # and so that it is correct for both C and C++.
356 file=stdio.h
357 base=`basename $file`
358 if [ -r ${LIB}/$file ]; then
359 file_to_fix=${LIB}/$file
360 else
361 if [ -r ${INPUT}/$file ]; then
362 file_to_fix=${INPUT}/$file
363 else
364 file_to_fix=""
367 if [ \! -z "$file_to_fix" ]; then
368 echo Checking $file_to_fix
369 cp $file_to_fix /tmp/$base
370 chmod +w /tmp/$base
371 sed -e '/^#define[ ]*NULL[ ]*0$/c\
372 #ifdef __cplusplus\
373 #define __NULL_TYPE\
374 #else /* !defined(__cplusplus) */\
375 #define __NULL_TYPE (void *)\
376 #endif /* !defined(__cplusplus) */\
377 #define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
378 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
379 true
380 else
381 echo Fixed $file_to_fix
382 rm -f ${LIB}/$file
383 cp /tmp/$base.sed ${LIB}/$file
384 chmod a+r ${LIB}/$file
386 rm -f /tmp/$base /tmp/$base.sed
389 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
390 # and so that it is correct for both C and C++.
392 file=dbm.h
393 base=`basename $file`
394 if [ -r ${LIB}/$file ]; then
395 file_to_fix=${LIB}/$file
396 else
397 if [ -r ${INPUT}/$file ]; then
398 file_to_fix=${INPUT}/$file
399 else
400 file_to_fix=""
403 if [ \! -z "$file_to_fix" ]; then
404 echo Checking $file_to_fix
405 cp $file_to_fix /tmp/$base
406 chmod +w /tmp/$base
407 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
408 #ifndef NULL\
409 #ifdef __cplusplus\
410 #define __NULL_TYPE\
411 #else /* !defined(__cplusplus) */\
412 #define __NULL_TYPE (void *)\
413 #endif /* !defined(__cplusplus) */\
414 #define NULL (__NULL_TYPE 0)\
415 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
416 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
417 true
418 else
419 echo Fixed $file_to_fix
420 rm -f ${LIB}/$file
421 cp /tmp/$base.sed ${LIB}/$file
422 chmod a+r ${LIB}/$file
424 rm -f /tmp/$base /tmp/$base.sed
427 # Add a prototyped declaration of mmap to <sys/mman.h>.
429 file=sys/mman.h
430 base=`basename $file`
431 if [ -r ${LIB}/$file ]; then
432 file_to_fix=${LIB}/$file
433 else
434 if [ -r ${INPUT}/$file ]; then
435 file_to_fix=${INPUT}/$file
436 else
437 file_to_fix=""
440 if [ \! -z "$file_to_fix" ]; then
441 echo Checking $file_to_fix
442 cp $file_to_fix /tmp/$base
443 chmod +w /tmp/$base
444 sed -e '/^extern caddr_t mmap();$/c\
445 #ifdef __STDC__\
446 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
447 #else /* !defined(__STDC__) */\
448 extern caddr_t mmap ();\
449 #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
450 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
451 true
452 else
453 echo Fixed $file_to_fix
454 rm -f ${LIB}/$file
455 cp /tmp/$base.sed ${LIB}/$file
456 chmod a+r ${LIB}/$file
458 rm -f /tmp/$base /tmp/$base.sed
461 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
462 # the file <ftw.h> contains extern declarations of these functions followed
463 # by explicitly `static' definitions of these functions... and that's not
464 # allowed according to ANSI C. (Note however that on Solaris, this header
465 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
466 # there are no static definitions of any function so we don't need to do
467 # any of this stuff when on Solaris.
469 file=ftw.h
470 base=`basename $file`
471 if [ -r ${LIB}/$file ]; then
472 file_to_fix=${LIB}/$file
473 else
474 if [ -r ${INPUT}/$file ]; then
475 file_to_fix=${INPUT}/$file
476 else
477 file_to_fix=""
480 if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
481 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
482 # one. Either way, we don't have to do anything.
483 true
484 else
485 echo Checking $file_to_fix
486 cp $file_to_fix /tmp/$base
487 chmod +w /tmp/$base
488 sed -e '/^extern int ftw(const/i\
489 #if !defined(_STYPES)\
490 static\
491 #else\
492 extern\
493 #endif
495 -e 's/extern \(int ftw(const.*\)$/\1/' \
496 -e '/^extern int nftw/i\
497 #if defined(_STYPES)\
498 static\
499 #else\
500 extern\
501 #endif
503 -e 's/extern \(int nftw.*\)$/\1/' \
504 -e '/^extern int ftw(),/c\
505 #if !defined(_STYPES)\
506 static\
507 #else\
508 extern\
509 #endif\
510 int ftw();\
511 #if defined(_STYPES)\
512 static\
513 #else\
514 extern\
515 #endif\
516 int nftw();' /tmp/$base > /tmp/$base.sed
517 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
518 true
519 else
520 echo Fixed $file_to_fix
521 rm -f ${LIB}/$file
522 cp /tmp/$base.sed ${LIB}/$file
523 chmod a+r ${LIB}/$file
525 rm -f /tmp/$base /tmp/$base.sed
528 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
529 # g++, since it's now an official type in the C++ language.
530 file=curses.h
531 base=`basename $file`
532 if [ -r ${LIB}/$file ]; then
533 file_to_fix=${LIB}/$file
534 else
535 if [ -r ${INPUT}/$file ]; then
536 file_to_fix=${INPUT}/$file
537 else
538 file_to_fix=""
542 if [ \! -z "$file_to_fix" ]; then
543 echo Checking $file_to_fix
544 cp $file_to_fix /tmp/$base
545 chmod +w /tmp/$base
546 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
547 typedef char bool;\
548 #endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed
549 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
550 true
551 else
552 echo Fixed $file_to_fix
553 rm -f ${LIB}/$file
554 cp /tmp/$base.sed ${LIB}/$file
555 chmod a+r ${LIB}/$file
557 rm -f /tmp/$base /tmp/$base.sed
560 # Add a `static' declaration of `getrnge' into <regexp.h>.
562 # Don't do this if there is already a `static void getrnge' declaration
563 # present, since this would cause a redeclaration error. Solaris 2.x has
564 # such a declaration.
566 file=regexp.h
567 base=`basename $file`
568 if [ -r ${LIB}/$file ]; then
569 file_to_fix=${LIB}/$file
570 else
571 if [ -r ${INPUT}/$file ]; then
572 file_to_fix=${INPUT}/$file
573 else
574 file_to_fix=""
577 if [ \! -z "$file_to_fix" ]; then
578 echo Checking $file_to_fix
579 if grep "static void getrnge" $file_to_fix > /dev/null; then
580 true
581 else
582 cp $file_to_fix /tmp/$base
583 chmod +w /tmp/$base
584 sed -e '/^static int[ ]*size;/c\
585 static int size ;\
587 static int getrnge ();' /tmp/$base > /tmp/$base.sed
588 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
589 true
590 else
591 echo Fixed $file_to_fix
592 rm -f ${LIB}/$file
593 cp /tmp/$base.sed ${LIB}/$file
594 chmod a+r ${LIB}/$file
597 rm -f /tmp/$base /tmp/$base.sed
600 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
601 # that is visible to any ANSI compiler using this include. Simply
602 # delete the lines that #define some string functions to internal forms.
604 file=string.h
605 base=`basename $file`
606 if [ -r ${LIB}/$file ]; then
607 file_to_fix=${LIB}/$file
608 else
609 if [ -r ${INPUT}/$file ]; then
610 file_to_fix=${INPUT}/$file
611 else
612 file_to_fix=""
615 if [ \! -z "$file_to_fix" ]; then
616 echo Checking $file_to_fix
617 cp $file_to_fix /tmp/$base
618 chmod +w /tmp/$base
619 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
620 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
621 true
622 else
623 echo Fixed $file_to_fix
624 rm -f ${LIB}/$file
625 cp /tmp/$base.sed ${LIB}/$file
626 chmod a+r ${LIB}/$file
628 rm -f /tmp/$base /tmp/$base.sed
631 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
632 # tend to conflict with the compiler's own definition of this symbol. (We
633 # will use the compiler's definition.)
634 # Likewise __sparc, for Solaris, and __i860, and a few others
635 # (guessing it is necessary for all of them).
637 file=ieeefp.h
638 base=`basename $file`
639 if [ -r ${LIB}/$file ]; then
640 file_to_fix=${LIB}/$file
641 else
642 if [ -r ${INPUT}/$file ]; then
643 file_to_fix=${INPUT}/$file
644 else
645 file_to_fix=""
648 if [ \! -z "$file_to_fix" ]; then
649 echo Checking $file_to_fix
650 cp $file_to_fix /tmp/$base
651 chmod +w /tmp/$base
652 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
653 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
654 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
655 /tmp/$base > /tmp/$base.sed
656 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
657 true
658 else
659 echo Fixed $file_to_fix
660 rm -f ${LIB}/$file
661 cp /tmp/$base.sed ${LIB}/$file
662 chmod a+r ${LIB}/$file
664 rm -f /tmp/$base /tmp/$base.sed
667 # Add a #define of _SIGACTION_ into <sys/signal.h>.
668 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
670 file=sys/signal.h
671 base=`basename $file`
672 if [ -r ${LIB}/$file ]; then
673 file_to_fix=${LIB}/$file
674 else
675 if [ -r ${INPUT}/$file ]; then
676 file_to_fix=${INPUT}/$file
677 else
678 file_to_fix=""
681 if [ \! -z "$file_to_fix" ]; then
682 echo Checking $file_to_fix
683 cp $file_to_fix /tmp/$base
684 chmod +w /tmp/$base
685 sed -e '/^struct sigaction {/c\
686 #define _SIGACTION_\
687 struct sigaction {' \
688 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
689 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
690 true
691 else
692 echo Fixed $file_to_fix
693 rm -f ${LIB}/$file
694 cp /tmp/$base.sed ${LIB}/$file
695 chmod a+r ${LIB}/$file
697 rm -f /tmp/$base /tmp/$base.sed
700 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
702 file=sys/mkdev.h
703 base=`basename $file`
704 if [ -r ${LIB}/$file ]; then
705 file_to_fix=${LIB}/$file
706 else
707 if [ -r ${INPUT}/$file ]; then
708 file_to_fix=${INPUT}/$file
709 else
710 file_to_fix=""
713 if [ \! -z "$file_to_fix" ]; then
714 echo Checking $file_to_fix
715 cp $file_to_fix /tmp/$base
716 chmod +w /tmp/$base
717 sed -e '/^dev_t makedev(const/c\
718 static dev_t makedev(const major_t, const minor_t);' \
719 -e '/^dev_t makedev()/c\
720 static dev_t makedev();' \
721 -e '/^major_t major(const/c\
722 static major_t major(const dev_t);' \
723 -e '/^major_t major()/c\
724 static major_t major();' \
725 -e '/^minor_t minor(const/c\
726 static minor_t minor(const dev_t);' \
727 -e '/^minor_t minor()/c\
728 static minor_t minor();' /tmp/$base > /tmp/$base.sed
729 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
730 true
731 else
732 echo Fixed $file_to_fix
733 rm -f ${LIB}/$file
734 cp /tmp/$base.sed ${LIB}/$file
735 chmod a+r ${LIB}/$file
737 rm -f /tmp/$base /tmp/$base.sed
740 # Fix reference to NMSZ in <sys/adv.h>.
742 file=sys/adv.h
743 base=`basename $file`
744 if [ -r ${LIB}/$file ]; then
745 file_to_fix=${LIB}/$file
746 else
747 if [ -r ${INPUT}/$file ]; then
748 file_to_fix=${INPUT}/$file
749 else
750 file_to_fix=""
753 if [ \! -z "$file_to_fix" ]; then
754 echo Checking $file_to_fix
755 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
756 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
757 true
758 else
759 echo Fixed $file_to_fix
760 rm -f ${LIB}/$file
761 cp /tmp/$base ${LIB}/$file
762 chmod a+r ${LIB}/$file
764 rm -f /tmp/$base
767 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
768 # array initializers.
770 file=sys/netcspace.h
771 base=`basename $file`
772 if [ -r ${LIB}/$file ]; then
773 file_to_fix=${LIB}/$file
774 else
775 if [ -r ${INPUT}/$file ]; then
776 file_to_fix=${INPUT}/$file
777 else
778 file_to_fix=""
781 if [ \! -z "$file_to_fix" ]; then
782 echo Checking $file_to_fix
783 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
784 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
785 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
786 true
787 else
788 echo Fixed $file_to_fix
789 rm -f ${LIB}/$file
790 cp /tmp/$base ${LIB}/$file
791 chmod a+r ${LIB}/$file
793 rm -f /tmp/$base
796 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
798 file=fs/rfs/rf_cache.h
799 base=`basename $file`
800 if [ -r ${LIB}/$file ]; then
801 file_to_fix=${LIB}/$file
802 else
803 if [ -r ${INPUT}/$file ]; then
804 file_to_fix=${INPUT}/$file
805 else
806 file_to_fix=""
809 if [ \! -z "$file_to_fix" ]; then
810 echo Checking $file_to_fix
811 if grep _KERNEL $file_to_fix > /dev/null; then
812 true
813 else
814 echo '#ifdef _KERNEL' > /tmp/$base
815 cat $file_to_fix >> /tmp/$base
816 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
817 echo Fixed $file_to_fix
818 rm -f ${LIB}/$file
819 cp /tmp/$base ${LIB}/$file
820 chmod a+r ${LIB}/$file
821 rm -f /tmp/$base
825 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
827 file=sys/erec.h
828 base=`basename $file`
829 if [ -r ${LIB}/$file ]; then
830 file_to_fix=${LIB}/$file
831 else
832 if [ -r ${INPUT}/$file ]; then
833 file_to_fix=${INPUT}/$file
834 else
835 file_to_fix=""
838 if [ \! -z "$file_to_fix" ]; then
839 echo Checking $file_to_fix
840 if grep _KERNEL $file_to_fix > /dev/null; then
841 true
842 else
843 echo '#ifdef _KERNEL' > /tmp/$base
844 cat $file_to_fix >> /tmp/$base
845 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
846 echo Fixed $file_to_fix
847 rm -f ${LIB}/$file
848 cp /tmp/$base ${LIB}/$file
849 chmod a+r ${LIB}/$file
850 rm -f /tmp/$base
854 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
856 file=sys/err.h
857 base=`basename $file`
858 if [ -r ${LIB}/$file ]; then
859 file_to_fix=${LIB}/$file
860 else
861 if [ -r ${INPUT}/$file ]; then
862 file_to_fix=${INPUT}/$file
863 else
864 file_to_fix=""
867 if [ \! -z "$file_to_fix" ]; then
868 echo Checking $file_to_fix
869 if grep _KERNEL $file_to_fix > /dev/null; then
870 true
871 else
872 echo '#ifdef _KERNEL' > /tmp/$base
873 cat $file_to_fix >> /tmp/$base
874 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
875 echo Fixed $file_to_fix
876 rm -f ${LIB}/$file
877 cp /tmp/$base ${LIB}/$file
878 chmod a+r ${LIB}/$file
879 rm -f /tmp/$base
883 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
885 file=sys/char.h
886 base=`basename $file`
887 if [ -r ${LIB}/$file ]; then
888 file_to_fix=${LIB}/$file
889 else
890 if [ -r ${INPUT}/$file ]; then
891 file_to_fix=${INPUT}/$file
892 else
893 file_to_fix=""
896 if [ \! -z "$file_to_fix" ]; then
897 echo Checking $file_to_fix
898 if grep _KERNEL $file_to_fix > /dev/null; then
899 true
900 else
901 echo '#ifdef _KERNEL' > /tmp/$base
902 cat $file_to_fix >> /tmp/$base
903 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
904 echo Fixed $file_to_fix
905 rm -f ${LIB}/$file
906 cp /tmp/$base ${LIB}/$file
907 chmod a+r ${LIB}/$file
908 rm -f /tmp/$base
912 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
914 file=sys/getpages.h
915 base=`basename $file`
916 if [ -r ${LIB}/$file ]; then
917 file_to_fix=${LIB}/$file
918 else
919 if [ -r ${INPUT}/$file ]; then
920 file_to_fix=${INPUT}/$file
921 else
922 file_to_fix=""
925 if [ \! -z "$file_to_fix" ]; then
926 echo Checking $file_to_fix
927 if grep _KERNEL $file_to_fix > /dev/null; then
928 true
929 else
930 echo '#ifdef _KERNEL' > /tmp/$base
931 cat $file_to_fix >> /tmp/$base
932 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
933 echo Fixed $file_to_fix
934 rm -f ${LIB}/$file
935 cp /tmp/$base ${LIB}/$file
936 chmod a+r ${LIB}/$file
937 rm -f /tmp/$base
941 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
943 file=sys/map.h
944 base=`basename $file`
945 if [ -r ${LIB}/$file ]; then
946 file_to_fix=${LIB}/$file
947 else
948 if [ -r ${INPUT}/$file ]; then
949 file_to_fix=${INPUT}/$file
950 else
951 file_to_fix=""
954 if [ \! -z "$file_to_fix" ]; then
955 echo Checking $file_to_fix
956 if grep _KERNEL $file_to_fix > /dev/null; then
957 true
958 else
959 echo '#ifdef _KERNEL' > /tmp/$base
960 cat $file_to_fix >> /tmp/$base
961 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
962 echo Fixed $file_to_fix
963 rm -f ${LIB}/$file
964 cp /tmp/$base ${LIB}/$file
965 chmod a+r ${LIB}/$file
966 rm -f /tmp/$base
970 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
972 file=sys/cmn_err.h
973 base=`basename $file`
974 if [ -r ${LIB}/$file ]; then
975 file_to_fix=${LIB}/$file
976 else
977 if [ -r ${INPUT}/$file ]; then
978 file_to_fix=${INPUT}/$file
979 else
980 file_to_fix=""
983 if [ \! -z "$file_to_fix" ]; then
984 echo Checking $file_to_fix
985 if grep _KERNEL $file_to_fix > /dev/null; then
986 true
987 else
988 echo '#ifdef _KERNEL' > /tmp/$base
989 cat $file_to_fix >> /tmp/$base
990 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
991 echo Fixed $file_to_fix
992 rm -f ${LIB}/$file
993 cp /tmp/$base ${LIB}/$file
994 chmod a+r ${LIB}/$file
995 rm -f /tmp/$base
999 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
1001 file=sys/kdebugger.h
1002 base=`basename $file`
1003 if [ -r ${LIB}/$file ]; then
1004 file_to_fix=${LIB}/$file
1005 else
1006 if [ -r ${INPUT}/$file ]; then
1007 file_to_fix=${INPUT}/$file
1008 else
1009 file_to_fix=""
1012 if [ \! -z "$file_to_fix" ]; then
1013 echo Checking $file_to_fix
1014 if grep _KERNEL $file_to_fix > /dev/null; then
1015 true
1016 else
1017 echo '#ifdef _KERNEL' > /tmp/$base
1018 cat $file_to_fix >> /tmp/$base
1019 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
1020 echo Fixed $file_to_fix
1021 rm -f ${LIB}/$file
1022 cp /tmp/$base ${LIB}/$file
1023 chmod a+r ${LIB}/$file
1024 rm -f /tmp/$base
1028 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1029 # This has been taken out because it breaks on some versions of
1030 # DYNIX/ptx, and it does not seem to do much good on any system.
1031 # file=netinet/in.h
1032 # base=`basename $file`
1033 # if [ -r ${LIB}/$file ]; then
1034 # file_to_fix=${LIB}/$file
1035 # else
1036 # if [ -r ${INPUT}/$file ]; then
1037 # file_to_fix=${INPUT}/$file
1038 # else
1039 # file_to_fix=""
1040 # fi
1041 # fi
1042 # if [ \! -z "$file_to_fix" ]; then
1043 # echo Checking $file_to_fix
1044 # if grep _KERNEL $file_to_fix > /dev/null; then
1045 # true
1046 # else
1047 # sed -e '/#ifdef INKERNEL/i\
1048 # #ifdef _KERNEL
1049 # ' \
1050 # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1051 # #endif /* _KERNEL */
1052 # ' \
1053 # $file_to_fix > ${LIB}/${file}.sed
1054 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1055 # echo Fixed $file_to_fix
1056 # fi
1057 # fi
1059 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1061 file=sys/endian.h
1062 base=`basename $file`
1063 if [ -r ${LIB}/$file ]; then
1064 file_to_fix=${LIB}/$file
1065 else
1066 if [ -r ${INPUT}/$file ]; then
1067 file_to_fix=${INPUT}/$file
1068 else
1069 file_to_fix=""
1072 if [ \! -z "$file_to_fix" ]; then
1073 echo Checking $file_to_fix
1074 if grep __GNUC__ $file_to_fix > /dev/null; then
1075 true
1076 else
1077 sed -e '/# ifdef __STDC__/i\
1078 # if !defined (__GNUC__) && !defined (__GNUG__)
1080 -e '/# include <sys\/byteorder.h>/s/ / /'\
1081 -e '/# include <sys\/byteorder.h>/i\
1082 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */
1084 $file_to_fix > ${LIB}/${file}.sed
1085 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1086 echo Fixed $file_to_fix
1090 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1091 # and the text in types.h is not erroneous.
1092 ## In sys/types.h, don't name the enum for booleans.
1094 #file=sys/types.h
1095 #base=`basename $file`
1096 #if [ -r ${LIB}/$file ]; then
1097 # file_to_fix=${LIB}/$file
1098 #else
1099 # if [ -r ${INPUT}/$file ]; then
1100 # file_to_fix=${INPUT}/$file
1101 # else
1102 # file_to_fix=""
1103 # fi
1105 #if [ \! -z "$file_to_fix" ]; then
1106 # echo Checking $file_to_fix
1107 # if grep "enum boolean" $file_to_fix > /dev/null; then
1108 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1109 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1110 # echo Fixed $file_to_fix
1111 # else
1112 # true
1113 # fi
1116 # Remove useless extern keyword from struct forward declarations in
1117 # <sys/stream.h> and <sys/strsubr.h>
1119 file=sys/stream.h
1120 base=`basename $file`
1121 if [ -r ${LIB}/$file ]; then
1122 file_to_fix=${LIB}/$file
1123 else
1124 if [ -r ${INPUT}/$file ]; then
1125 file_to_fix=${INPUT}/$file
1126 else
1127 file_to_fix=""
1130 if [ \! -z "$file_to_fix" ]; then
1131 echo Checking $file_to_fix
1132 sed -e '
1133 s/extern struct stdata;/struct stdata;/g
1134 s/extern struct strevent;/struct strevent;/g
1135 ' $file_to_fix > /tmp/$base
1136 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1137 true
1138 else
1139 echo Fixed $file_to_fix
1140 rm -f ${LIB}/$file
1141 cp /tmp/$base ${LIB}/$file
1142 chmod a+r ${LIB}/$file
1144 rm -f /tmp/$base
1147 file=sys/strsubr.h
1148 base=`basename $file`
1149 if [ -r ${LIB}/$file ]; then
1150 file_to_fix=${LIB}/$file
1151 else
1152 if [ -r ${INPUT}/$file ]; then
1153 file_to_fix=${INPUT}/$file
1154 else
1155 file_to_fix=""
1158 if [ \! -z "$file_to_fix" ]; then
1159 echo Checking $file_to_fix
1160 sed -e '
1161 s/extern struct strbuf;/struct strbuf;/g
1162 s/extern struct uio;/struct uio;/g
1163 s/extern struct thread;/struct thread;/g
1164 s/extern struct proc;/struct proc;/g
1165 ' $file_to_fix > /tmp/$base
1166 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1167 true
1168 else
1169 echo Fixed $file_to_fix
1170 rm -f ${LIB}/$file
1171 cp /tmp/$base ${LIB}/$file
1172 chmod a+r ${LIB}/$file
1174 rm -f /tmp/$base
1177 # Put storage class at start of decl, to avoid warning.
1178 file=rpc/types.h
1179 base=`basename $file`
1180 if [ -r ${LIB}/$file ]; then
1181 file_to_fix=${LIB}/$file
1182 else
1183 if [ -r ${INPUT}/$file ]; then
1184 file_to_fix=${INPUT}/$file
1185 else
1186 file_to_fix=""
1189 if [ \! -z "$file_to_fix" ]; then
1190 echo Checking $file_to_fix
1191 sed -e '
1192 s/const extern/extern const/g
1193 ' $file_to_fix > /tmp/$base
1194 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1195 true
1196 else
1197 echo Fixed $file_to_fix
1198 rm -f ${LIB}/$file
1199 cp /tmp/$base ${LIB}/$file
1200 chmod a+r ${LIB}/$file
1202 rm -f /tmp/$base
1205 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1207 file=sys/stat.h
1208 base=`basename $file`
1209 if [ -r ${LIB}/$file ]; then
1210 file_to_fix=${LIB}/$file
1211 else
1212 if [ -r ${INPUT}/$file ]; then
1213 file_to_fix=${INPUT}/$file
1214 else
1215 file_to_fix=""
1218 if [ \! -z "$file_to_fix" ]; then
1219 echo Checking $file_to_fix
1220 cp $file_to_fix /tmp/$base
1221 chmod +w /tmp/$base
1222 sed -e '/^stat([ ]*[^c]/{
1225 s/(.*)\n/( /
1226 s/;\n/, /
1227 s/;$/)/
1228 }' \
1229 -e '/^lstat([ ]*[^c]/{
1232 s/(.*)\n/( /
1233 s/;\n/, /
1234 s/;$/)/
1235 }' \
1236 -e '/^fstat([ ]*[^i]/{
1239 s/(.*)\n/( /
1240 s/;\n/, /
1241 s/;$/)/
1242 }' \
1243 -e '/^mknod([ ]*[^c]/{
1247 s/(.*)\n/( /
1248 s/;\n/, /g
1249 s/;$/)/
1250 }' \
1251 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1252 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1253 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1254 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1255 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1256 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1257 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1258 true
1259 else
1260 echo Fixed $file_to_fix
1261 rm -f ${LIB}/$file
1262 cp /tmp/$base.sed ${LIB}/$file
1263 chmod a+r ${LIB}/$file
1265 rm -f /tmp/$base /tmp/$base.sed
1268 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1270 if [ -x /bin/sony ]; then
1271 if /bin/sony; then
1273 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1275 file=stdio.h
1276 base=`basename $file`
1277 if [ -r ${LIB}/$file ]; then
1278 file_to_fix=${LIB}/$file
1279 else
1280 if [ -r ${INPUT}/$file ]; then
1281 file_to_fix=${INPUT}/$file
1282 else
1283 file_to_fix=""
1286 if [ \! -z "$file_to_fix" ]; then
1287 echo Checking $file_to_fix
1288 cp $file_to_fix /tmp/$base
1289 chmod +w /tmp/$base
1290 sed -e '
1291 s/__filbuf/_filbuf/g
1292 s/__flsbuf/_flsbuf/g
1293 s/__iob/_iob/g
1294 ' /tmp/$base > /tmp/$base.sed
1295 mv /tmp/$base.sed /tmp/$base
1296 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1297 true
1298 else
1299 echo Fixed $file_to_fix
1300 rm -f ${LIB}/$file
1301 cp /tmp/$base ${LIB}/$file
1302 chmod a+r ${LIB}/$file
1304 rm -f /tmp/$base
1307 # Change <ctype.h> to not define __ctype
1309 file=ctype.h
1310 base=`basename $file`
1311 if [ -r ${LIB}/$file ]; then
1312 file_to_fix=${LIB}/$file
1313 else
1314 if [ -r ${INPUT}/$file ]; then
1315 file_to_fix=${INPUT}/$file
1316 else
1317 file_to_fix=""
1320 if [ \! -z "$file_to_fix" ]; then
1321 echo Checking $file_to_fix
1322 cp $file_to_fix /tmp/$base
1323 chmod +w /tmp/$base
1324 sed -e '
1325 s/__ctype/_ctype/g
1326 ' /tmp/$base > /tmp/$base.sed
1327 mv /tmp/$base.sed /tmp/$base
1328 if cmp $file_to_fix /tmp/$base.sed >/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
1341 # In limits.h, put #ifndefs around things that are supposed to be defined
1342 # in float.h to avoid redefinition errors if float.h is included first.
1343 # Solaris 2.1 has this problem.
1345 file=limits.h
1346 base=`basename $file`
1347 if [ -r ${LIB}/$file ]; then
1348 file_to_fix=${LIB}/$file
1349 else
1350 if [ -r ${INPUT}/$file ]; then
1351 file_to_fix=${INPUT}/$file
1352 else
1353 file_to_fix=""
1356 if [ \! -z "$file_to_fix" ]; then
1357 echo Checking $file_to_fix
1358 sed -e '/[ ]FLT_MIN[ ]/i\
1359 #ifndef FLT_MIN
1361 -e '/[ ]FLT_MIN[ ]/a\
1362 #endif
1364 -e '/[ ]FLT_MAX[ ]/i\
1365 #ifndef FLT_MAX
1367 -e '/[ ]FLT_MAX[ ]/a\
1368 #endif
1370 -e '/[ ]FLT_DIG[ ]/i\
1371 #ifndef FLT_DIG
1373 -e '/[ ]FLT_DIG[ ]/a\
1374 #endif
1376 -e '/[ ]DBL_MIN[ ]/i\
1377 #ifndef DBL_MIN
1379 -e '/[ ]DBL_MIN[ ]/a\
1380 #endif
1382 -e '/[ ]DBL_MAX[ ]/i\
1383 #ifndef DBL_MAX
1385 -e '/[ ]DBL_MAX[ ]/a\
1386 #endif
1388 -e '/[ ]DBL_DIG[ ]/i\
1389 #ifndef DBL_DIG
1391 -e '/[ ]DBL_DIG[ ]/a\
1392 #endif
1393 ' $file_to_fix > /tmp/$base
1394 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1395 true
1396 else
1397 echo Fixed $file_to_fix
1398 rm -f ${LIB}/$file
1399 cp /tmp/$base ${LIB}/$file
1400 chmod a+r ${LIB}/$file
1402 rm -f /tmp/$base
1405 # Completely replace <sys/varargs.h> with a file that includes gcc's
1406 # stdarg.h or varargs.h files as appropriate.
1408 file=sys/varargs.h
1409 if [ -r ${INPUT}/$file ]; then
1410 echo Replacing $file
1411 cat > ${LIB}/$file << EOF
1412 /* This file was generated by fixincludes. */
1413 #ifndef _SYS_VARARGS_H
1414 #define _SYS_VARARGS_H
1416 #ifdef __STDC__
1417 #include <stdarg.h>
1418 #else
1419 #include <varargs.h>
1420 #endif
1422 #endif /* _SYS_VARARGS_H */
1424 chmod a+r ${LIB}/$file
1427 # In math.h, put #ifndefs around things that might be defined in a gcc
1428 # specific math-*.h file.
1430 file=math.h
1431 base=`basename $file`
1432 if [ -r ${LIB}/$file ]; then
1433 file_to_fix=${LIB}/$file
1434 else
1435 if [ -r ${INPUT}/$file ]; then
1436 file_to_fix=${INPUT}/$file
1437 else
1438 file_to_fix=""
1441 if [ \! -z "$file_to_fix" ]; then
1442 echo Checking $file_to_fix
1443 sed -e '/define[ ]HUGE_VAL[ ]/i\
1444 #ifndef HUGE_VAL
1446 -e '/define[ ]HUGE_VAL[ ]/a\
1447 #endif
1448 ' $file_to_fix > /tmp/$base
1449 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1450 true
1451 else
1452 echo Fixed $file_to_fix
1453 rm -f ${LIB}/$file
1454 cp /tmp/$base ${LIB}/$file
1455 chmod a+r ${LIB}/$file
1457 rm -f /tmp/$base
1460 # Solaris math.h and floatingpoint.h define __P without protection,
1461 # which conflicts with the fixproto definition. The fixproto
1462 # definition and the Solaris definition are used the same way.
1463 for file in math.h floatingpoint.h; do
1464 base=`basename $file`
1465 if [ -r ${LIB}/$file ]; then
1466 file_to_fix=${LIB}/$file
1467 else
1468 if [ -r ${INPUT}/$file ]; then
1469 file_to_fix=${INPUT}/$file
1470 else
1471 file_to_fix=""
1474 if [ \! -z "$file_to_fix" ]; then
1475 echo Checking $file_to_fix
1476 sed -e '/^#define[ ]*__P/i\
1477 #ifndef __P
1479 -e '/^#define[ ]*__P/a\
1480 #endif
1481 ' $file_to_fix > /tmp/$base
1482 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1483 true
1484 else
1485 echo Fixed $file_to_fix
1486 rm -f ${LIB}/$file
1487 cp /tmp/$base ${LIB}/$file
1488 chmod a+r ${LIB}/$file
1490 rm -f /tmp/$base
1492 done
1494 # The Solaris math.h defines struct exception, which conflicts with
1495 # the class exception defined in the C++ file std/stdexcept.h. We
1496 # redefine it to __math_exception. This is not a great fix, but I
1497 # haven't been able to think of anything better.
1498 file=math.h
1499 base=`basename $file`
1500 if [ -r ${LIB}/$file ]; then
1501 file_to_fix=${LIB}/$file
1502 else
1503 if [ -r ${INPUT}/$file ]; then
1504 file_to_fix=${INPUT}/$file
1505 else
1506 file_to_fix=""
1509 if [ \! -z "$file_to_fix" ]; then
1510 echo Checking $file_to_fix
1511 sed -e '/struct exception/i\
1512 #ifdef __cplusplus\
1513 #define exception __math_exception\
1514 #endif'\
1515 -e '/struct exception/a\
1516 #ifdef __cplusplus\
1517 #undef exception\
1518 #endif' $file_to_fix > /tmp/$base
1519 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1520 true
1521 else
1522 echo Fixed $file_to_fix
1523 rm -f ${LIB}/$file
1524 cp /tmp/$base ${LIB}/$file
1525 chmod a+r ${LIB}/$file
1527 rm -f /tmp/$base
1530 echo 'Removing unneeded directories:'
1531 cd $LIB
1532 files=`find . -type d -print | sort -r`
1533 for file in $files; do
1534 rmdir $LIB/$file > /dev/null 2>&1
1535 done
1537 if $LINKS; then
1538 echo 'Making internal symbolic non-directory links'
1539 cd ${INPUT}
1540 files=`find . -type l -print`
1541 for file in $files; do
1542 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1543 if expr "$dest" : '[^/].*' > /dev/null; then
1544 target=${LIB}/`echo $file | sed "s|[^/]*\$|$dest|"`
1545 if [ -f $target ]; then
1546 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1549 done
1552 cd ${ORIG_DIR}
1554 echo 'Replacing <sys/byteorder.h>'
1555 if [ \! -d $LIB/sys ]; then
1556 mkdir $LIB/sys
1558 rm -f ${LIB}/sys/byteorder.h
1559 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1560 #ifndef _SYS_BYTEORDER_H
1561 #define _SYS_BYTEORDER_H
1563 /* Functions to convert `short' and `long' quantities from host byte order
1564 to (internet) network byte order (i.e. big-endian).
1566 Written by Ron Guilmette (rfg@ncd.com).
1568 This isn't actually used by GCC. It is installed by fixinc.svr4.
1570 For big-endian machines these functions are essentially no-ops.
1572 For little-endian machines, we define the functions using specialized
1573 asm sequences in cases where doing so yields better code (e.g. i386). */
1575 #if !defined (__GNUC__) && !defined (__GNUG__)
1576 #error You lose! This file is only useful with GNU compilers.
1577 #endif
1579 #ifndef __BYTE_ORDER__
1580 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1581 double underscores added at the front and back. */
1582 #define __LITTLE_ENDIAN__ 1234
1583 #define __BIG_ENDIAN__ 4321
1584 #define __PDP_ENDIAN__ 3412
1585 #endif
1587 #ifdef __STDC__
1588 static __inline__ unsigned long htonl (unsigned long);
1589 static __inline__ unsigned short htons (unsigned int);
1590 static __inline__ unsigned long ntohl (unsigned long);
1591 static __inline__ unsigned short ntohs (unsigned int);
1592 #endif /* defined (__STDC__) */
1594 #if defined (__i386__)
1596 #ifndef __BYTE_ORDER__
1597 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1598 #endif
1600 /* Convert a host long to a network long. */
1602 /* We must use a new-style function definition, so that this will also
1603 be valid for C++. */
1604 static __inline__ unsigned long
1605 htonl (unsigned long __arg)
1607 register unsigned long __result;
1609 __asm__ ("xchg%B0 %b0,%h0\n\
1610 ror%L0 $16,%0\n\
1611 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1612 return __result;
1615 /* Convert a host short to a network short. */
1617 static __inline__ unsigned short
1618 htons (unsigned int __arg)
1620 register unsigned short __result;
1622 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1623 return __result;
1626 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1627 || defined (__ns32k__) || defined (__vax__) \
1628 || defined (__spur__) || defined (__arm__))
1630 #ifndef __BYTE_ORDER__
1631 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1632 #endif
1634 /* For other little-endian machines, using C code is just as efficient as
1635 using assembly code. */
1637 /* Convert a host long to a network long. */
1639 static __inline__ unsigned long
1640 htonl (unsigned long __arg)
1642 register unsigned long __result;
1644 __result = (__arg >> 24) & 0x000000ff;
1645 __result |= (__arg >> 8) & 0x0000ff00;
1646 __result |= (__arg << 8) & 0x00ff0000;
1647 __result |= (__arg << 24) & 0xff000000;
1648 return __result;
1651 /* Convert a host short to a network short. */
1653 static __inline__ unsigned short
1654 htons (unsigned int __arg)
1656 register unsigned short __result;
1658 __result = (__arg << 8) & 0xff00;
1659 __result |= (__arg >> 8) & 0x00ff;
1660 return __result;
1663 #else /* must be a big-endian machine */
1665 #ifndef __BYTE_ORDER__
1666 #define __BYTE_ORDER__ __BIG_ENDIAN__
1667 #endif
1669 /* Convert a host long to a network long. */
1671 static __inline__ unsigned long
1672 htonl (unsigned long __arg)
1674 return __arg;
1677 /* Convert a host short to a network short. */
1679 static __inline__ unsigned short
1680 htons (unsigned int __arg)
1682 return __arg;
1685 #endif /* big-endian */
1687 /* Convert a network long to a host long. */
1689 static __inline__ unsigned long
1690 ntohl (unsigned long __arg)
1692 return htonl (__arg);
1695 /* Convert a network short to a host short. */
1697 static __inline__ unsigned short
1698 ntohs (unsigned int __arg)
1700 return htons (__arg);
1703 __EOF__
1705 if [ -r ${INPUT}/sys/byteorder.h ]; then
1706 if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
1707 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1708 #ifndef BYTE_ORDER
1709 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1710 #define BIG_ENDIAN __BIG_ENDIAN__
1711 #define PDP_ENDIAN __PDP_ENDIAN__
1712 #define BYTE_ORDER __BYTE_ORDER__
1713 #endif
1715 __EOF__
1719 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1720 #endif /* !defined (_SYS_BYTEORDER_H) */
1721 __EOF__
1723 chmod a+r ${LIB}/sys/byteorder.h
1725 exit 0