]> gcc.gnu.org Git - gcc.git/blob - gcc/fixinc.svr4
get rid of CYGNUS LOCAL comment
[gcc.git] / gcc / fixinc.svr4
1 #! /bin/sh
2 #
3 # fixinc.svr4 -- Install modified versions of certain ANSI-incompatible
4 # native System V Release 4 system include files.
5 #
6 # Written by Ron Guilmette (rfg@ncd.com).
7 #
8 # This file is part of GNU CC.
9 #
10 # GNU CC is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
13 # any later version.
14 #
15 # GNU CC is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with GNU CC; see the file COPYING. If not, write to
22 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 #
24 # This script munges the native include files provided with System V
25 # Release 4 systems so as to remove things which are violations of the
26 # ANSI C standard. Once munged, the resulting new system include files
27 # are placed in a directory that GNU C will search *before* searching
28 # the /usr/include directory. This script should work properly for most
29 # System V Release 4 systems. For other types of systems, you should
30 # use the `fixincludes' script instead.
31 #
32 # See README-fixinc for more information.
33
34 # Directory where gcc sources (and sometimes special include files) live.
35 SRCDIR=${3-${SRCDIR-.}}
36
37 # Directory containing the original header files.
38 INPUT=${2-${INPUT-/usr/include}}
39
40 # Fail if no arg to specify a directory for the output.
41 if [ x$1 = x ]
42 then echo fixincludes: no output directory specified
43 exit 1
44 fi
45
46 # Directory in which to store the results.
47 LIB=${1?"fixincludes: output directory not specified"}
48
49 # Make sure it exists.
50 if [ ! -d $LIB ]; then
51 mkdir $LIB || exit 1
52 fi
53
54 ORIG_DIR=`pwd`
55
56 # Make LIB absolute if it is relative.
57 # Don't do this if not necessary, since may screw up automounters.
58 case $LIB in
59 /*)
60 ;;
61 *)
62 LIB=$ORIG_DIR/$LIB
63 ;;
64 esac
65
66 echo 'Building fixincludes in ' ${LIB}
67
68 # Determine whether this filesystem has symbolic links.
69 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
70 rm -f $LIB/ShouldNotExist
71 LINKS=true
72 else
73 LINKS=false
74 fi
75
76 echo 'Making directories:'
77 cd ${INPUT}
78 if $LINKS; then
79 files=`ls -LR | sed -n s/:$//p`
80 else
81 files=`find . -type d -print | sed '/^.$/d'`
82 fi
83 for file in $files; do
84 rm -rf $LIB/$file
85 if [ ! -d $LIB/$file ]
86 then mkdir $LIB/$file
87 fi
88 done
89
90 # treetops gets an alternating list
91 # of old directories to copy
92 # and the new directories to copy to.
93 treetops="${INPUT} ${LIB}"
94
95 if $LINKS; then
96 echo 'Making internal symbolic directory links'
97 for file in $files; do
98 dest=`ls -ld $file | sed -n 's/.*-> //p'`
99 if [ "$dest" ]; then
100 cwd=`pwd`
101 # In case $dest is relative, get to $file's dir first.
102 cd ${INPUT}
103 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
104 # Check that the target directory exists.
105 # Redirections changed to avoid bug in sh on Ultrix.
106 (cd $dest) > /dev/null 2>&1
107 if [ $? = 0 ]; then
108 cd $dest
109 # X gets the dir that the link actually leads to.
110 x=`pwd`
111 # If link leads back into ${INPUT},
112 # make a similar link here.
113 if expr $x : "${INPUT}/.*" > /dev/null; then
114 # Y gets the actual target dir name, relative to ${INPUT}.
115 y=`echo $x | sed -n "s&${INPUT}/&&p"`
116 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
117 dots=`echo "$file" |
118 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
119 echo $file '->' $dots$y ': Making link'
120 rm -fr ${LIB}/$file > /dev/null 2>&1
121 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
122 else
123 # If the link is to outside ${INPUT},
124 # treat this directory as if it actually contained the files.
125 # This line used to have $dest instead of $x.
126 # $dest seemed to be wrong for links found in subdirectories
127 # of ${INPUT}. Does this change break anything?
128 treetops="$treetops $x ${LIB}/$file"
129 fi
130 fi
131 cd $cwd
132 fi
133 done
134 fi
135
136 set - $treetops
137 while [ $# != 0 ]; do
138 # $1 is an old directory to copy, and $2 is the new directory to copy to.
139 echo "Finding header files in $1:"
140 cd ${INPUT}
141 cd $1
142 files=`find . -name '*.h' -type f -print`
143 echo 'Checking header files:'
144 for file in $files; do
145 if [ -r $file ]; then
146 cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
147 chmod +w $2/$file
148 chmod a+r $2/$file
149
150 # The following have been removed from the sed command below
151 # because it is more useful to leave these things in.
152 # The only reason to remove them was for -pedantic,
153 # which isn't much of a reason. -- rms.
154 # /^[ ]*#[ ]*ident/d
155
156 # This code makes Solaris SCSI fail, because it changes the
157 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
158 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
159 # Disable these also, since they probably aren't safe either.
160 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
161 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
162 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
163 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
164
165 # The change of u_char, etc, to u_int
166 # applies to bit fields.
167 sed -e '
168 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
169 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
170 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
171 s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
172 s/#lint(on)/defined(lint)/g
173 s/#lint(off)/!defined(lint)/g
174 s/#machine(\([^)]*\))/defined(__\1__)/g
175 s/#system(\([^)]*\))/defined(__\1__)/g
176 s/#cpu(\([^)]*\))/defined(__\1__)/g
177 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
178 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
179 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
180 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
181 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
182 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
183 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
184 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
185 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
186 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
187 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
188 s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
189 s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
190 s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
191 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
192 ' $2/$file > $2/$file.sed
193 mv $2/$file.sed $2/$file
194 if cmp $file $2/$file >/dev/null 2>&1; then
195 rm $2/$file
196 else
197 echo Fixed $file
198 fi
199 fi
200 done
201 shift; shift
202 done
203
204 # Fix first broken decl of getcwd present on some svr4 systems.
205
206 file=stdlib.h
207 base=`basename $file`
208 if [ -r ${LIB}/$file ]; then
209 file_to_fix=${LIB}/$file
210 else
211 if [ -r ${INPUT}/$file ]; then
212 file_to_fix=${INPUT}/$file
213 else
214 file_to_fix=""
215 fi
216 fi
217 if [ \! -z "$file_to_fix" ]; then
218 echo Checking $file_to_fix
219 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
220 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
221 true
222 else
223 echo Fixed $file_to_fix
224 rm -f ${LIB}/$file
225 cp /tmp/$base ${LIB}/$file
226 chmod a+r ${LIB}/$file
227 fi
228 rm -f /tmp/$base
229 fi
230
231 # Fix second broken decl of getcwd present on some svr4 systems. Also
232 # fix the incorrect decl of profil present on some svr4 systems.
233
234 file=unistd.h
235 base=`basename $file`
236 if [ -r ${LIB}/$file ]; then
237 file_to_fix=${LIB}/$file
238 else
239 if [ -r ${INPUT}/$file ]; then
240 file_to_fix=${INPUT}/$file
241 else
242 file_to_fix=""
243 fi
244 fi
245 if [ \! -z "$file_to_fix" ]; then
246 echo Checking $file_to_fix
247 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
248 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
249 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
250 true
251 else
252 echo Fixed $file_to_fix
253 rm -f ${LIB}/$file
254 cp /tmp/$base ${LIB}/$file
255 chmod a+r ${LIB}/$file
256 fi
257 rm -f /tmp/$base
258 fi
259
260 # Fix the definition of NULL in <sys/param.h> so that it is conditional
261 # and so that it is correct for both C and C++.
262
263 file=sys/param.h
264 base=`basename $file`
265 if [ -r ${LIB}/$file ]; then
266 file_to_fix=${LIB}/$file
267 else
268 if [ -r ${INPUT}/$file ]; then
269 file_to_fix=${INPUT}/$file
270 else
271 file_to_fix=""
272 fi
273 fi
274 if [ \! -z "$file_to_fix" ]; then
275 echo Checking $file_to_fix
276 cp $file_to_fix /tmp/$base
277 chmod +w /tmp/$base
278 chmod a+r /tmp/$base
279 sed -e '/^#define[ ]*NULL[ ]*0$/c\
280 #ifndef NULL\
281 #ifdef __cplusplus\
282 #define __NULL_TYPE\
283 #else /* !defined(__cplusplus) */\
284 #define __NULL_TYPE (void *)\
285 #endif /* !defined(__cplusplus) */\
286 #define NULL (__NULL_TYPE 0)\
287 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
288 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
289 true
290 else
291 echo Fixed $file_to_fix
292 rm -f ${LIB}/$file
293 cp /tmp/$base.sed ${LIB}/$file
294 chmod a+r ${LIB}/$file
295 fi
296 rm -f /tmp/$base /tmp/$base.sed
297 fi
298
299 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
300 # and so that it is correct for both C and C++.
301
302 file=stdio.h
303 base=`basename $file`
304 if [ -r ${LIB}/$file ]; then
305 file_to_fix=${LIB}/$file
306 else
307 if [ -r ${INPUT}/$file ]; then
308 file_to_fix=${INPUT}/$file
309 else
310 file_to_fix=""
311 fi
312 fi
313 if [ \! -z "$file_to_fix" ]; then
314 echo Checking $file_to_fix
315 cp $file_to_fix /tmp/$base
316 chmod +w /tmp/$base
317 sed -e '/^#define[ ]*NULL[ ]*0$/c\
318 #ifdef __cplusplus\
319 #define __NULL_TYPE\
320 #else /* !defined(__cplusplus) */\
321 #define __NULL_TYPE (void *)\
322 #endif /* !defined(__cplusplus) */\
323 #define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
324 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
325 true
326 else
327 echo Fixed $file_to_fix
328 rm -f ${LIB}/$file
329 cp /tmp/$base.sed ${LIB}/$file
330 chmod a+r ${LIB}/$file
331 fi
332 rm -f /tmp/$base /tmp/$base.sed
333 fi
334
335 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
336 # and so that it is correct for both C and C++.
337
338 file=dbm.h
339 base=`basename $file`
340 if [ -r ${LIB}/$file ]; then
341 file_to_fix=${LIB}/$file
342 else
343 if [ -r ${INPUT}/$file ]; then
344 file_to_fix=${INPUT}/$file
345 else
346 file_to_fix=""
347 fi
348 fi
349 if [ \! -z "$file_to_fix" ]; then
350 echo Checking $file_to_fix
351 cp $file_to_fix /tmp/$base
352 chmod +w /tmp/$base
353 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
354 #ifndef NULL\
355 #ifdef __cplusplus\
356 #define __NULL_TYPE\
357 #else /* !defined(__cplusplus) */\
358 #define __NULL_TYPE (void *)\
359 #endif /* !defined(__cplusplus) */\
360 #define NULL (__NULL_TYPE 0)\
361 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
362 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
363 true
364 else
365 echo Fixed $file_to_fix
366 rm -f ${LIB}/$file
367 cp /tmp/$base.sed ${LIB}/$file
368 chmod a+r ${LIB}/$file
369 fi
370 rm -f /tmp/$base /tmp/$base.sed
371 fi
372
373 # Add a prototyped declaration of mmap to <sys/mman.h>.
374
375 file=sys/mman.h
376 base=`basename $file`
377 if [ -r ${LIB}/$file ]; then
378 file_to_fix=${LIB}/$file
379 else
380 if [ -r ${INPUT}/$file ]; then
381 file_to_fix=${INPUT}/$file
382 else
383 file_to_fix=""
384 fi
385 fi
386 if [ \! -z "$file_to_fix" ]; then
387 echo Checking $file_to_fix
388 cp $file_to_fix /tmp/$base
389 chmod +w /tmp/$base
390 sed -e '/^extern caddr_t mmap();$/c\
391 #ifdef __STDC__\
392 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
393 #else /* !defined(__STDC__) */\
394 extern caddr_t mmap ();\
395 #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
396 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
397 true
398 else
399 echo Fixed $file_to_fix
400 rm -f ${LIB}/$file
401 cp /tmp/$base.sed ${LIB}/$file
402 chmod a+r ${LIB}/$file
403 fi
404 rm -f /tmp/$base /tmp/$base.sed
405 fi
406
407 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
408 # the file <ftw.h> contains extern declarations of these functions followed
409 # by explicitly `static' definitions of these functions... and that's not
410 # allowed according to ANSI C. (Note however that on Solaris, this header
411 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
412 # there are no static definitions of any function so we don't need to do
413 # any of this stuff when on Solaris.
414
415 file=ftw.h
416 base=`basename $file`
417 if [ -r ${LIB}/$file ]; then
418 file_to_fix=${LIB}/$file
419 else
420 if [ -r ${INPUT}/$file ]; then
421 file_to_fix=${INPUT}/$file
422 else
423 file_to_fix=""
424 fi
425 fi
426 if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
427 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
428 # one. Either way, we don't have to do anything.
429 true
430 else
431 echo Checking $file_to_fix
432 cp $file_to_fix /tmp/$base
433 chmod +w /tmp/$base
434 sed -e '/^extern int ftw(const/i\
435 #if !defined(_STYPES)\
436 static\
437 #else\
438 extern\
439 #endif'\
440 -e 's/extern \(int ftw(const.*\)$/\1/' \
441 -e '/^extern int nftw/i\
442 #if defined(_STYPES)\
443 static\
444 #else\
445 extern\
446 #endif'\
447 -e 's/extern \(int nftw.*\)$/\1/' \
448 -e '/^extern int ftw(),/c\
449 #if !defined(_STYPES)\
450 static\
451 #else\
452 extern\
453 #endif\
454 int ftw();\
455 #if defined(_STYPES)\
456 static\
457 #else\
458 extern\
459 #endif\
460 int nftw();' /tmp/$base > /tmp/$base.sed
461 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
462 true
463 else
464 echo Fixed $file_to_fix
465 rm -f ${LIB}/$file
466 cp /tmp/$base.sed ${LIB}/$file
467 chmod a+r ${LIB}/$file
468 fi
469 rm -f /tmp/$base /tmp/$base.sed
470 fi
471
472 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
473 # g++, since it's now an official type in the C++ language.
474 file=curses.h
475 base=`basename $file`
476 if [ -r ${LIB}/$file ]; then
477 file_to_fix=${LIB}/$file
478 else
479 if [ -r ${INPUT}/$file ]; then
480 file_to_fix=${INPUT}/$file
481 else
482 file_to_fix=""
483 fi
484 fi
485
486 if [ \! -z "$file_to_fix" ]; then
487 echo Checking $file_to_fix
488 cp $file_to_fix /tmp/$base
489 chmod +w /tmp/$base
490 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
491 typedef char bool;\
492 #endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed
493 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
494 true
495 else
496 echo Fixed $file_to_fix
497 rm -f ${LIB}/$file
498 cp /tmp/$base.sed ${LIB}/$file
499 chmod a+r ${LIB}/$file
500 fi
501 rm -f /tmp/$base /tmp/$base.sed
502 fi
503
504 # Add a `static' declaration of `getrnge' into <regexp.h>.
505
506 # Don't do this if there is already a `static void getrnge' declaration
507 # present, since this would cause a redeclaration error. Solaris 2.x has
508 # such a declaration.
509
510 file=regexp.h
511 base=`basename $file`
512 if [ -r ${LIB}/$file ]; then
513 file_to_fix=${LIB}/$file
514 else
515 if [ -r ${INPUT}/$file ]; then
516 file_to_fix=${INPUT}/$file
517 else
518 file_to_fix=""
519 fi
520 fi
521 if [ \! -z "$file_to_fix" ]; then
522 echo Checking $file_to_fix
523 if grep "static void getrnge" $file_to_fix > /dev/null; then
524 true
525 else
526 cp $file_to_fix /tmp/$base
527 chmod +w /tmp/$base
528 sed -e '/^static int[ ]*size;/c\
529 static int size ;\
530 \
531 static int getrnge ();' /tmp/$base > /tmp/$base.sed
532 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
533 true
534 else
535 echo Fixed $file_to_fix
536 rm -f ${LIB}/$file
537 cp /tmp/$base.sed ${LIB}/$file
538 chmod a+r ${LIB}/$file
539 fi
540 fi
541 rm -f /tmp/$base /tmp/$base.sed
542 fi
543
544 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
545 # that is visible to any ANSI compiler using this include. Simply
546 # delete the lines that #define some string functions to internal forms.
547
548 file=string.h
549 base=`basename $file`
550 if [ -r ${LIB}/$file ]; then
551 file_to_fix=${LIB}/$file
552 else
553 if [ -r ${INPUT}/$file ]; then
554 file_to_fix=${INPUT}/$file
555 else
556 file_to_fix=""
557 fi
558 fi
559 if [ \! -z "$file_to_fix" ]; then
560 echo Checking $file_to_fix
561 cp $file_to_fix /tmp/$base
562 chmod +w /tmp/$base
563 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
564 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
565 true
566 else
567 echo Fixed $file_to_fix
568 rm -f ${LIB}/$file
569 cp /tmp/$base.sed ${LIB}/$file
570 chmod a+r ${LIB}/$file
571 fi
572 rm -f /tmp/$base /tmp/$base.sed
573 fi
574
575 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
576 # tend to conflict with the compiler's own definition of this symbol. (We
577 # will use the compiler's definition.)
578 # Likewise __sparc, for Solaris, and __i860, and a few others
579 # (guessing it is necessary for all of them).
580
581 file=ieeefp.h
582 base=`basename $file`
583 if [ -r ${LIB}/$file ]; then
584 file_to_fix=${LIB}/$file
585 else
586 if [ -r ${INPUT}/$file ]; then
587 file_to_fix=${INPUT}/$file
588 else
589 file_to_fix=""
590 fi
591 fi
592 if [ \! -z "$file_to_fix" ]; then
593 echo Checking $file_to_fix
594 cp $file_to_fix /tmp/$base
595 chmod +w /tmp/$base
596 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
597 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
598 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
599 /tmp/$base > /tmp/$base.sed
600 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
601 true
602 else
603 echo Fixed $file_to_fix
604 rm -f ${LIB}/$file
605 cp /tmp/$base.sed ${LIB}/$file
606 chmod a+r ${LIB}/$file
607 fi
608 rm -f /tmp/$base /tmp/$base.sed
609 fi
610
611 # Add a #define of _SIGACTION_ into <sys/signal.h>.
612 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
613
614 file=sys/signal.h
615 base=`basename $file`
616 if [ -r ${LIB}/$file ]; then
617 file_to_fix=${LIB}/$file
618 else
619 if [ -r ${INPUT}/$file ]; then
620 file_to_fix=${INPUT}/$file
621 else
622 file_to_fix=""
623 fi
624 fi
625 if [ \! -z "$file_to_fix" ]; then
626 echo Checking $file_to_fix
627 cp $file_to_fix /tmp/$base
628 chmod +w /tmp/$base
629 sed -e '/^struct sigaction {/c\
630 #define _SIGACTION_\
631 struct sigaction {' \
632 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
633 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
634 true
635 else
636 echo Fixed $file_to_fix
637 rm -f ${LIB}/$file
638 cp /tmp/$base.sed ${LIB}/$file
639 chmod a+r ${LIB}/$file
640 fi
641 rm -f /tmp/$base /tmp/$base.sed
642 fi
643
644 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
645
646 file=sys/mkdev.h
647 base=`basename $file`
648 if [ -r ${LIB}/$file ]; then
649 file_to_fix=${LIB}/$file
650 else
651 if [ -r ${INPUT}/$file ]; then
652 file_to_fix=${INPUT}/$file
653 else
654 file_to_fix=""
655 fi
656 fi
657 if [ \! -z "$file_to_fix" ]; then
658 echo Checking $file_to_fix
659 cp $file_to_fix /tmp/$base
660 chmod +w /tmp/$base
661 sed -e '/^dev_t makedev(const/c\
662 static dev_t makedev(const major_t, const minor_t);' \
663 -e '/^dev_t makedev()/c\
664 static dev_t makedev();' \
665 -e '/^major_t major(const/c\
666 static major_t major(const dev_t);' \
667 -e '/^major_t major()/c\
668 static major_t major();' \
669 -e '/^minor_t minor(const/c\
670 static minor_t minor(const dev_t);' \
671 -e '/^minor_t minor()/c\
672 static minor_t minor();' /tmp/$base > /tmp/$base.sed
673 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
674 true
675 else
676 echo Fixed $file_to_fix
677 rm -f ${LIB}/$file
678 cp /tmp/$base.sed ${LIB}/$file
679 chmod a+r ${LIB}/$file
680 fi
681 rm -f /tmp/$base /tmp/$base.sed
682 fi
683
684 # Fix reference to NMSZ in <sys/adv.h>.
685
686 file=sys/adv.h
687 base=`basename $file`
688 if [ -r ${LIB}/$file ]; then
689 file_to_fix=${LIB}/$file
690 else
691 if [ -r ${INPUT}/$file ]; then
692 file_to_fix=${INPUT}/$file
693 else
694 file_to_fix=""
695 fi
696 fi
697 if [ \! -z "$file_to_fix" ]; then
698 echo Checking $file_to_fix
699 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
700 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
701 true
702 else
703 echo Fixed $file_to_fix
704 rm -f ${LIB}/$file
705 cp /tmp/$base ${LIB}/$file
706 chmod a+r ${LIB}/$file
707 fi
708 rm -f /tmp/$base
709 fi
710
711 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
712 # array initializers.
713
714 file=sys/netcspace.h
715 base=`basename $file`
716 if [ -r ${LIB}/$file ]; then
717 file_to_fix=${LIB}/$file
718 else
719 if [ -r ${INPUT}/$file ]; then
720 file_to_fix=${INPUT}/$file
721 else
722 file_to_fix=""
723 fi
724 fi
725 if [ \! -z "$file_to_fix" ]; then
726 echo Checking $file_to_fix
727 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
728 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
729 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
730 true
731 else
732 echo Fixed $file_to_fix
733 rm -f ${LIB}/$file
734 cp /tmp/$base ${LIB}/$file
735 chmod a+r ${LIB}/$file
736 fi
737 rm -f /tmp/$base
738 fi
739
740 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
741
742 file=fs/rfs/rf_cache.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=""
751 fi
752 fi
753 if [ \! -z "$file_to_fix" ]; then
754 echo Checking $file_to_fix
755 if grep _KERNEL $file_to_fix > /dev/null; then
756 true
757 else
758 echo '#ifdef _KERNEL' > /tmp/$base
759 cat $file_to_fix >> /tmp/$base
760 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
761 echo Fixed $file_to_fix
762 rm -f ${LIB}/$file
763 cp /tmp/$base ${LIB}/$file
764 chmod a+r ${LIB}/$file
765 rm -f /tmp/$base
766 fi
767 fi
768
769 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
770
771 file=sys/erec.h
772 base=`basename $file`
773 if [ -r ${LIB}/$file ]; then
774 file_to_fix=${LIB}/$file
775 else
776 if [ -r ${INPUT}/$file ]; then
777 file_to_fix=${INPUT}/$file
778 else
779 file_to_fix=""
780 fi
781 fi
782 if [ \! -z "$file_to_fix" ]; then
783 echo Checking $file_to_fix
784 if grep _KERNEL $file_to_fix > /dev/null; then
785 true
786 else
787 echo '#ifdef _KERNEL' > /tmp/$base
788 cat $file_to_fix >> /tmp/$base
789 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
790 echo Fixed $file_to_fix
791 rm -f ${LIB}/$file
792 cp /tmp/$base ${LIB}/$file
793 chmod a+r ${LIB}/$file
794 rm -f /tmp/$base
795 fi
796 fi
797
798 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
799
800 file=sys/err.h
801 base=`basename $file`
802 if [ -r ${LIB}/$file ]; then
803 file_to_fix=${LIB}/$file
804 else
805 if [ -r ${INPUT}/$file ]; then
806 file_to_fix=${INPUT}/$file
807 else
808 file_to_fix=""
809 fi
810 fi
811 if [ \! -z "$file_to_fix" ]; then
812 echo Checking $file_to_fix
813 if grep _KERNEL $file_to_fix > /dev/null; then
814 true
815 else
816 echo '#ifdef _KERNEL' > /tmp/$base
817 cat $file_to_fix >> /tmp/$base
818 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
819 echo Fixed $file_to_fix
820 rm -f ${LIB}/$file
821 cp /tmp/$base ${LIB}/$file
822 chmod a+r ${LIB}/$file
823 rm -f /tmp/$base
824 fi
825 fi
826
827 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
828
829 file=sys/char.h
830 base=`basename $file`
831 if [ -r ${LIB}/$file ]; then
832 file_to_fix=${LIB}/$file
833 else
834 if [ -r ${INPUT}/$file ]; then
835 file_to_fix=${INPUT}/$file
836 else
837 file_to_fix=""
838 fi
839 fi
840 if [ \! -z "$file_to_fix" ]; then
841 echo Checking $file_to_fix
842 if grep _KERNEL $file_to_fix > /dev/null; then
843 true
844 else
845 echo '#ifdef _KERNEL' > /tmp/$base
846 cat $file_to_fix >> /tmp/$base
847 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
848 echo Fixed $file_to_fix
849 rm -f ${LIB}/$file
850 cp /tmp/$base ${LIB}/$file
851 chmod a+r ${LIB}/$file
852 rm -f /tmp/$base
853 fi
854 fi
855
856 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
857
858 file=sys/getpages.h
859 base=`basename $file`
860 if [ -r ${LIB}/$file ]; then
861 file_to_fix=${LIB}/$file
862 else
863 if [ -r ${INPUT}/$file ]; then
864 file_to_fix=${INPUT}/$file
865 else
866 file_to_fix=""
867 fi
868 fi
869 if [ \! -z "$file_to_fix" ]; then
870 echo Checking $file_to_fix
871 if grep _KERNEL $file_to_fix > /dev/null; then
872 true
873 else
874 echo '#ifdef _KERNEL' > /tmp/$base
875 cat $file_to_fix >> /tmp/$base
876 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
877 echo Fixed $file_to_fix
878 rm -f ${LIB}/$file
879 cp /tmp/$base ${LIB}/$file
880 chmod a+r ${LIB}/$file
881 rm -f /tmp/$base
882 fi
883 fi
884
885 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
886
887 file=sys/map.h
888 base=`basename $file`
889 if [ -r ${LIB}/$file ]; then
890 file_to_fix=${LIB}/$file
891 else
892 if [ -r ${INPUT}/$file ]; then
893 file_to_fix=${INPUT}/$file
894 else
895 file_to_fix=""
896 fi
897 fi
898 if [ \! -z "$file_to_fix" ]; then
899 echo Checking $file_to_fix
900 if grep _KERNEL $file_to_fix > /dev/null; then
901 true
902 else
903 echo '#ifdef _KERNEL' > /tmp/$base
904 cat $file_to_fix >> /tmp/$base
905 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
906 echo Fixed $file_to_fix
907 rm -f ${LIB}/$file
908 cp /tmp/$base ${LIB}/$file
909 chmod a+r ${LIB}/$file
910 rm -f /tmp/$base
911 fi
912 fi
913
914 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
915
916 file=sys/cmn_err.h
917 base=`basename $file`
918 if [ -r ${LIB}/$file ]; then
919 file_to_fix=${LIB}/$file
920 else
921 if [ -r ${INPUT}/$file ]; then
922 file_to_fix=${INPUT}/$file
923 else
924 file_to_fix=""
925 fi
926 fi
927 if [ \! -z "$file_to_fix" ]; then
928 echo Checking $file_to_fix
929 if grep _KERNEL $file_to_fix > /dev/null; then
930 true
931 else
932 echo '#ifdef _KERNEL' > /tmp/$base
933 cat $file_to_fix >> /tmp/$base
934 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
935 echo Fixed $file_to_fix
936 rm -f ${LIB}/$file
937 cp /tmp/$base ${LIB}/$file
938 chmod a+r ${LIB}/$file
939 rm -f /tmp/$base
940 fi
941 fi
942
943 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
944
945 file=sys/kdebugger.h
946 base=`basename $file`
947 if [ -r ${LIB}/$file ]; then
948 file_to_fix=${LIB}/$file
949 else
950 if [ -r ${INPUT}/$file ]; then
951 file_to_fix=${INPUT}/$file
952 else
953 file_to_fix=""
954 fi
955 fi
956 if [ \! -z "$file_to_fix" ]; then
957 echo Checking $file_to_fix
958 if grep _KERNEL $file_to_fix > /dev/null; then
959 true
960 else
961 echo '#ifdef _KERNEL' > /tmp/$base
962 cat $file_to_fix >> /tmp/$base
963 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
964 echo Fixed $file_to_fix
965 rm -f ${LIB}/$file
966 cp /tmp/$base ${LIB}/$file
967 chmod a+r ${LIB}/$file
968 rm -f /tmp/$base
969 fi
970 fi
971
972 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
973
974 file=netinet/in.h
975 base=`basename $file`
976 if [ -r ${LIB}/$file ]; then
977 file_to_fix=${LIB}/$file
978 else
979 if [ -r ${INPUT}/$file ]; then
980 file_to_fix=${INPUT}/$file
981 else
982 file_to_fix=""
983 fi
984 fi
985 if [ \! -z "$file_to_fix" ]; then
986 echo Checking $file_to_fix
987 if grep _KERNEL $file_to_fix > /dev/null; then
988 true
989 else
990 sed -e '/#ifdef INKERNEL/i\
991 #ifdef _KERNEL' \
992 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
993 #endif /* _KERNEL */' \
994 $file_to_fix > ${LIB}/${file}.sed
995 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
996 echo Fixed $file_to_fix
997 fi
998 fi
999
1000 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1001
1002 file=sys/endian.h
1003 base=`basename $file`
1004 if [ -r ${LIB}/$file ]; then
1005 file_to_fix=${LIB}/$file
1006 else
1007 if [ -r ${INPUT}/$file ]; then
1008 file_to_fix=${INPUT}/$file
1009 else
1010 file_to_fix=""
1011 fi
1012 fi
1013 if [ \! -z "$file_to_fix" ]; then
1014 echo Checking $file_to_fix
1015 if grep __GNUC__ $file_to_fix > /dev/null; then
1016 true
1017 else
1018 sed -e '/# ifdef __STDC__/i\
1019 # if !defined (__GNUC__) && !defined (__GNUG__)' \
1020 -e '/# include <sys\/byteorder.h>/s/ / /'\
1021 -e '/# include <sys\/byteorder.h>/i\
1022 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
1023 $file_to_fix > ${LIB}/${file}.sed
1024 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1025 echo Fixed $file_to_fix
1026 fi
1027 fi
1028
1029 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1030 # and the text in types.h is not erroneous.
1031 ## In sys/types.h, don't name the enum for booleans.
1032 #
1033 #file=sys/types.h
1034 #base=`basename $file`
1035 #if [ -r ${LIB}/$file ]; then
1036 # file_to_fix=${LIB}/$file
1037 #else
1038 # if [ -r ${INPUT}/$file ]; then
1039 # file_to_fix=${INPUT}/$file
1040 # else
1041 # file_to_fix=""
1042 # fi
1043 #fi
1044 #if [ \! -z "$file_to_fix" ]; then
1045 # echo Checking $file_to_fix
1046 # if grep "enum boolean" $file_to_fix > /dev/null; then
1047 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1048 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1049 # echo Fixed $file_to_fix
1050 # else
1051 # true
1052 # fi
1053 #fi
1054
1055 # Remove useless extern keyword from struct forward declarations in
1056 # <sys/stream.h> and <sys/strsubr.h>
1057
1058 file=sys/stream.h
1059 base=`basename $file`
1060 if [ -r ${LIB}/$file ]; then
1061 file_to_fix=${LIB}/$file
1062 else
1063 if [ -r ${INPUT}/$file ]; then
1064 file_to_fix=${INPUT}/$file
1065 else
1066 file_to_fix=""
1067 fi
1068 fi
1069 if [ \! -z "$file_to_fix" ]; then
1070 echo Checking $file_to_fix
1071 sed -e '
1072 s/extern struct stdata;/struct stdata;/g
1073 s/extern struct strevent;/struct strevent;/g
1074 ' $file_to_fix > /tmp/$base
1075 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1076 true
1077 else
1078 echo Fixed $file_to_fix
1079 rm -f ${LIB}/$file
1080 cp /tmp/$base ${LIB}/$file
1081 chmod a+r ${LIB}/$file
1082 fi
1083 rm -f /tmp/$base
1084 fi
1085
1086 file=sys/strsubr.h
1087 base=`basename $file`
1088 if [ -r ${LIB}/$file ]; then
1089 file_to_fix=${LIB}/$file
1090 else
1091 if [ -r ${INPUT}/$file ]; then
1092 file_to_fix=${INPUT}/$file
1093 else
1094 file_to_fix=""
1095 fi
1096 fi
1097 if [ \! -z "$file_to_fix" ]; then
1098 echo Checking $file_to_fix
1099 sed -e '
1100 s/extern struct strbuf;/struct strbuf;/g
1101 s/extern struct uio;/struct uio;/g
1102 s/extern struct thread;/struct thread;/g
1103 s/extern struct proc;/struct proc;/g
1104 ' $file_to_fix > /tmp/$base
1105 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1106 true
1107 else
1108 echo Fixed $file_to_fix
1109 rm -f ${LIB}/$file
1110 cp /tmp/$base ${LIB}/$file
1111 chmod a+r ${LIB}/$file
1112 fi
1113 rm -f /tmp/$base
1114 fi
1115
1116 # Put storage class at start of decl, to avoid warning.
1117 file=rpc/types.h
1118 base=`basename $file`
1119 if [ -r ${LIB}/$file ]; then
1120 file_to_fix=${LIB}/$file
1121 else
1122 if [ -r ${INPUT}/$file ]; then
1123 file_to_fix=${INPUT}/$file
1124 else
1125 file_to_fix=""
1126 fi
1127 fi
1128 if [ \! -z "$file_to_fix" ]; then
1129 echo Checking $file_to_fix
1130 sed -e '
1131 s/const extern/extern const/g
1132 ' $file_to_fix > /tmp/$base
1133 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1134 true
1135 else
1136 echo Fixed $file_to_fix
1137 rm -f ${LIB}/$file
1138 cp /tmp/$base ${LIB}/$file
1139 chmod a+r ${LIB}/$file
1140 fi
1141 rm -f /tmp/$base
1142 fi
1143
1144 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1145
1146 file=sys/stat.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=""
1155 fi
1156 fi
1157 if [ \! -z "$file_to_fix" ]; then
1158 echo Checking $file_to_fix
1159 cp $file_to_fix /tmp/$base
1160 chmod +w /tmp/$base
1161 sed -e '/^stat([ ]*[^c]/{
1162 N
1163 N
1164 s/(.*)\n/( /
1165 s/;\n/, /
1166 s/;$/)/
1167 }' \
1168 -e '/^lstat([ ]*[^c]/{
1169 N
1170 N
1171 s/(.*)\n/( /
1172 s/;\n/, /
1173 s/;$/)/
1174 }' \
1175 -e '/^fstat([ ]*[^i]/{
1176 N
1177 N
1178 s/(.*)\n/( /
1179 s/;\n/, /
1180 s/;$/)/
1181 }' \
1182 -e '/^mknod([ ]*[^c]/{
1183 N
1184 N
1185 N
1186 s/(.*)\n/( /
1187 s/;\n/, /g
1188 s/;$/)/
1189 }' \
1190 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1191 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1192 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1193 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1194 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1195 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1196 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1197 true
1198 else
1199 echo Fixed $file_to_fix
1200 rm -f ${LIB}/$file
1201 cp /tmp/$base.sed ${LIB}/$file
1202 chmod a+r ${LIB}/$file
1203 fi
1204 rm -f /tmp/$base /tmp/$base.sed
1205 fi
1206
1207 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1208
1209 if [ -x /bin/sony ]; then
1210 if /bin/sony; then
1211
1212 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1213
1214 file=stdio.h
1215 base=`basename $file`
1216 if [ -r ${LIB}/$file ]; then
1217 file_to_fix=${LIB}/$file
1218 else
1219 if [ -r ${INPUT}/$file ]; then
1220 file_to_fix=${INPUT}/$file
1221 else
1222 file_to_fix=""
1223 fi
1224 fi
1225 if [ \! -z "$file_to_fix" ]; then
1226 echo Checking $file_to_fix
1227 cp $file_to_fix /tmp/$base
1228 chmod +w /tmp/$base
1229 sed -e '
1230 s/__filbuf/_filbuf/g
1231 s/__flsbuf/_flsbuf/g
1232 s/__iob/_iob/g
1233 ' /tmp/$base > /tmp/$base.sed
1234 mv /tmp/$base.sed /tmp/$base
1235 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1236 true
1237 else
1238 echo Fixed $file_to_fix
1239 rm -f ${LIB}/$file
1240 cp /tmp/$base ${LIB}/$file
1241 chmod a+r ${LIB}/$file
1242 fi
1243 rm -f /tmp/$base
1244 fi
1245
1246 # Change <ctype.h> to not define __ctype
1247
1248 file=ctype.h
1249 base=`basename $file`
1250 if [ -r ${LIB}/$file ]; then
1251 file_to_fix=${LIB}/$file
1252 else
1253 if [ -r ${INPUT}/$file ]; then
1254 file_to_fix=${INPUT}/$file
1255 else
1256 file_to_fix=""
1257 fi
1258 fi
1259 if [ \! -z "$file_to_fix" ]; then
1260 echo Checking $file_to_fix
1261 cp $file_to_fix /tmp/$base
1262 chmod +w /tmp/$base
1263 sed -e '
1264 s/__ctype/_ctype/g
1265 ' /tmp/$base > /tmp/$base.sed
1266 mv /tmp/$base.sed /tmp/$base
1267 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1268 true
1269 else
1270 echo Fixed $file_to_fix
1271 rm -f ${LIB}/$file
1272 cp /tmp/$base ${LIB}/$file
1273 chmod a+r ${LIB}/$file
1274 fi
1275 rm -f /tmp/$base
1276 fi
1277 fi
1278 fi
1279
1280 # In limits.h, put #ifndefs around things that are supposed to be defined
1281 # in float.h to avoid redefinition errors if float.h is included first.
1282 # Solaris 2.1 has this problem.
1283
1284 file=limits.h
1285 base=`basename $file`
1286 if [ -r ${LIB}/$file ]; then
1287 file_to_fix=${LIB}/$file
1288 else
1289 if [ -r ${INPUT}/$file ]; then
1290 file_to_fix=${INPUT}/$file
1291 else
1292 file_to_fix=""
1293 fi
1294 fi
1295 if [ \! -z "$file_to_fix" ]; then
1296 echo Checking $file_to_fix
1297 sed -e '/[ ]FLT_MIN[ ]/i\
1298 #ifndef FLT_MIN'\
1299 -e '/[ ]FLT_MIN[ ]/a\
1300 #endif'\
1301 -e '/[ ]FLT_MAX[ ]/i\
1302 #ifndef FLT_MAX'\
1303 -e '/[ ]FLT_MAX[ ]/a\
1304 #endif'\
1305 -e '/[ ]FLT_DIG[ ]/i\
1306 #ifndef FLT_DIG'\
1307 -e '/[ ]FLT_DIG[ ]/a\
1308 #endif'\
1309 -e '/[ ]DBL_MIN[ ]/i\
1310 #ifndef DBL_MIN'\
1311 -e '/[ ]DBL_MIN[ ]/a\
1312 #endif'\
1313 -e '/[ ]DBL_MAX[ ]/i\
1314 #ifndef DBL_MAX'\
1315 -e '/[ ]DBL_MAX[ ]/a\
1316 #endif'\
1317 -e '/[ ]DBL_DIG[ ]/i\
1318 #ifndef DBL_DIG'\
1319 -e '/[ ]DBL_DIG[ ]/a\
1320 #endif' $file_to_fix > /tmp/$base
1321 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1322 true
1323 else
1324 echo Fixed $file_to_fix
1325 rm -f ${LIB}/$file
1326 cp /tmp/$base ${LIB}/$file
1327 chmod a+r ${LIB}/$file
1328 fi
1329 rm -f /tmp/$base
1330 fi
1331
1332 # Completely replace <sys/varargs.h> with a file that includes gcc's
1333 # stdarg.h or varargs.h files as appropriate.
1334
1335 file=sys/varargs.h
1336 if [ -r ${INPUT}/$file ]; then
1337 echo Replacing $file
1338 cat > ${LIB}/$file << EOF
1339 /* This file was generated by fixincludes. */
1340 #ifndef _SYS_VARARGS_H
1341 #define _SYS_VARARGS_H
1342
1343 #ifdef __STDC__
1344 #include <stdarg.h>
1345 #else
1346 #include <varargs.h>
1347 #endif
1348
1349 #endif /* _SYS_VARARGS_H */
1350 EOF
1351 chmod a+r ${LIB}/$file
1352 fi
1353
1354 # In math.h, put #ifndefs around things that might be defined in a gcc
1355 # specific math-*.h file.
1356
1357 file=math.h
1358 base=`basename $file`
1359 if [ -r ${LIB}/$file ]; then
1360 file_to_fix=${LIB}/$file
1361 else
1362 if [ -r ${INPUT}/$file ]; then
1363 file_to_fix=${INPUT}/$file
1364 else
1365 file_to_fix=""
1366 fi
1367 fi
1368 if [ \! -z "$file_to_fix" ]; then
1369 echo Checking $file_to_fix
1370 sed -e '/define[ ]HUGE_VAL[ ]/i\
1371 #ifndef HUGE_VAL'\
1372 -e '/define[ ]HUGE_VAL[ ]/a\
1373 #endif' $file_to_fix > /tmp/$base
1374 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1375 true
1376 else
1377 echo Fixed $file_to_fix
1378 rm -f ${LIB}/$file
1379 cp /tmp/$base ${LIB}/$file
1380 chmod a+r ${LIB}/$file
1381 fi
1382 rm -f /tmp/$base
1383 fi
1384
1385 echo 'Removing unneeded directories:'
1386 cd $LIB
1387 files=`find . -type d -print | sort -r`
1388 for file in $files; do
1389 rmdir $LIB/$file > /dev/null 2>&1
1390 done
1391
1392 if $LINKS; then
1393 echo 'Making internal symbolic non-directory links'
1394 cd ${INPUT}
1395 files=`find . -type l -print`
1396 for file in $files; do
1397 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1398 if expr "$dest" : '[^/].*' > /dev/null; then
1399 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1400 if [ -f $target ]; then
1401 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1402 fi
1403 fi
1404 done
1405 fi
1406
1407 cd ${ORIG_DIR}
1408
1409 echo 'Replacing <sys/byteorder.h>'
1410 if [ \! -d $LIB/sys ]; then
1411 mkdir $LIB/sys
1412 fi
1413 rm -f ${LIB}/sys/byteorder.h
1414 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1415 #ifndef _SYS_BYTEORDER_H
1416 #define _SYS_BYTEORDER_H
1417
1418 /* Functions to convert `short' and `long' quantities from host byte order
1419 to (internet) network byte order (i.e. big-endian).
1420
1421 Written by Ron Guilmette (rfg@ncd.com).
1422
1423 This isn't actually used by GCC. It is installed by fixinc.svr4.
1424
1425 For big-endian machines these functions are essentially no-ops.
1426
1427 For little-endian machines, we define the functions using specialized
1428 asm sequences in cases where doing so yields better code (e.g. i386). */
1429
1430 #if !defined (__GNUC__) && !defined (__GNUG__)
1431 #error You lose! This file is only useful with GNU compilers.
1432 #endif
1433
1434 #ifndef __BYTE_ORDER__
1435 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1436 double underscores added at the front and back. */
1437 #define __LITTLE_ENDIAN__ 1234
1438 #define __BIG_ENDIAN__ 4321
1439 #define __PDP_ENDIAN__ 3412
1440 #endif
1441
1442 #ifdef __GNUC__
1443 #define __STATIC static
1444 #else
1445 #define __STATIC
1446 #endif
1447
1448 #ifdef __STDC__
1449 __STATIC __inline__ unsigned long htonl (unsigned long);
1450 __STATIC __inline__ unsigned short htons (unsigned int);
1451 __STATIC __inline__ unsigned long ntohl (unsigned long);
1452 __STATIC __inline__ unsigned short ntohs (unsigned int);
1453 #endif /* defined (__STDC__) */
1454
1455 #if defined (__i386__)
1456
1457 #ifndef __BYTE_ORDER__
1458 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1459 #endif
1460
1461 /* Convert a host long to a network long. */
1462
1463 /* We must use a new-style function definition, so that this will also
1464 be valid for C++. */
1465 __STATIC __inline__ unsigned long
1466 htonl (unsigned long __arg)
1467 {
1468 register unsigned long __result;
1469
1470 __asm__ ("xchg%B0 %b0,%h0\n\
1471 ror%L0 $16,%0\n\
1472 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1473 return __result;
1474 }
1475
1476 /* Convert a host short to a network short. */
1477
1478 __STATIC __inline__ unsigned short
1479 htons (unsigned int __arg)
1480 {
1481 register unsigned short __result;
1482
1483 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1484 return __result;
1485 }
1486
1487 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1488 || defined (__ns32k__) || defined (__vax__) \
1489 || defined (__spur__) || defined (__arm__))
1490
1491 #ifndef __BYTE_ORDER__
1492 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1493 #endif
1494
1495 /* For other little-endian machines, using C code is just as efficient as
1496 using assembly code. */
1497
1498 /* Convert a host long to a network long. */
1499
1500 __STATIC __inline__ unsigned long
1501 htonl (unsigned long __arg)
1502 {
1503 register unsigned long __result;
1504
1505 __result = (__arg >> 24) & 0x000000ff;
1506 __result |= (__arg >> 8) & 0x0000ff00;
1507 __result |= (__arg << 8) & 0x00ff0000;
1508 __result |= (__arg << 24) & 0xff000000;
1509 return __result;
1510 }
1511
1512 /* Convert a host short to a network short. */
1513
1514 __STATIC __inline__ unsigned short
1515 htons (unsigned int __arg)
1516 {
1517 register unsigned short __result;
1518
1519 __result = (__arg << 8) & 0xff00;
1520 __result |= (__arg >> 8) & 0x00ff;
1521 return __result;
1522 }
1523
1524 #else /* must be a big-endian machine */
1525
1526 #ifndef __BYTE_ORDER__
1527 #define __BYTE_ORDER__ __BIG_ENDIAN__
1528 #endif
1529
1530 /* Convert a host long to a network long. */
1531
1532 __STATIC __inline__ unsigned long
1533 htonl (unsigned long __arg)
1534 {
1535 return __arg;
1536 }
1537
1538 /* Convert a host short to a network short. */
1539
1540 __STATIC __inline__ unsigned short
1541 htons (unsigned int __arg)
1542 {
1543 return __arg;
1544 }
1545
1546 #endif /* big-endian */
1547
1548 /* Convert a network long to a host long. */
1549
1550 __STATIC __inline__ unsigned long
1551 ntohl (unsigned long __arg)
1552 {
1553 return htonl (__arg);
1554 }
1555
1556 /* Convert a network short to a host short. */
1557
1558 __STATIC __inline__ unsigned short
1559 ntohs (unsigned int __arg)
1560 {
1561 return htons (__arg);
1562 }
1563
1564
1565 #undef __STATIC
1566
1567 __EOF__
1568
1569 if [ -r ${INPUT}/sys/byteorder.h ]; then
1570 if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
1571 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1572 #ifndef BYTE_ORDER
1573 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1574 #define BIG_ENDIAN __BIG_ENDIAN__
1575 #define PDP_ENDIAN __PDP_ENDIAN__
1576 #define BYTE_ORDER __BYTE_ORDER__
1577 #endif
1578
1579 __EOF__
1580 fi
1581 fi
1582
1583 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1584 #endif /* !defined (_SYS_BYTEORDER_H) */
1585 __EOF__
1586
1587 chmod a+r ${LIB}/sys/byteorder.h
1588
1589 exit 0
1590
This page took 0.12961 seconds and 6 git commands to generate.