]> gcc.gnu.org Git - gcc.git/blob - gcc/fixinc.svr4
When compute DOTS, convert /./ to / to avoid
[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 addr, size_t len, int prot, int flags,\
393 int fd, off_t off);\
394 #else /* !defined(__STDC__) */\
395 extern caddr_t mmap ();\
396 #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
397 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
398 true
399 else
400 echo Fixed $file_to_fix
401 rm -f ${LIB}/$file
402 cp /tmp/$base.sed ${LIB}/$file
403 chmod a+r ${LIB}/$file
404 fi
405 rm -f /tmp/$base /tmp/$base.sed
406 fi
407
408 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
409 # the file <ftw.h> contains extern declarations of these functions followed
410 # by explicitly `static' definitions of these functions... and that's not
411 # allowed according to ANSI C. (Note however that on Solaris, this header
412 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
413 # there are no static definitions of any function so we don't need to do
414 # any of this stuff when on Solaris.
415
416 file=ftw.h
417 base=`basename $file`
418 if [ -r ${LIB}/$file ]; then
419 file_to_fix=${LIB}/$file
420 else
421 if [ -r ${INPUT}/$file ]; then
422 file_to_fix=${INPUT}/$file
423 else
424 file_to_fix=""
425 fi
426 fi
427 if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
428 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
429 # one. Either way, we don't have to do anything.
430 true
431 else
432 echo Checking $file_to_fix
433 cp $file_to_fix /tmp/$base
434 chmod +w /tmp/$base
435 sed -e '/^extern int ftw(const/i\
436 #if !defined(_STYPES)\
437 static\
438 #else\
439 extern\
440 #endif'\
441 -e 's/extern \(int ftw(const.*\)$/\1/' \
442 -e '/^extern int nftw/i\
443 #if defined(_STYPES)\
444 static\
445 #else\
446 extern\
447 #endif'\
448 -e 's/extern \(int nftw.*\)$/\1/' \
449 -e '/^extern int ftw(),/c\
450 #if !defined(_STYPES)\
451 static\
452 #else\
453 extern\
454 #endif\
455 int ftw();\
456 #if defined(_STYPES)\
457 static\
458 #else\
459 extern\
460 #endif\
461 int nftw();' /tmp/$base > /tmp/$base.sed
462 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
463 true
464 else
465 echo Fixed $file_to_fix
466 rm -f ${LIB}/$file
467 cp /tmp/$base.sed ${LIB}/$file
468 chmod a+r ${LIB}/$file
469 fi
470 rm -f /tmp/$base /tmp/$base.sed
471 fi
472
473 # Add a `static' declaration of `getrnge' into <regexp.h>.
474
475 # Don't do this if there is already a `static void getrnge' declaration
476 # present, since this would cause a redeclaration error. Solaris 2.x has
477 # such a declaration.
478
479 file=regexp.h
480 base=`basename $file`
481 if [ -r ${LIB}/$file ]; then
482 file_to_fix=${LIB}/$file
483 else
484 if [ -r ${INPUT}/$file ]; then
485 file_to_fix=${INPUT}/$file
486 else
487 file_to_fix=""
488 fi
489 fi
490 if [ \! -z "$file_to_fix" ]; then
491 echo Checking $file_to_fix
492 if grep "static void getrnge" $file_to_fix > /dev/null; then
493 true
494 else
495 cp $file_to_fix /tmp/$base
496 chmod +w /tmp/$base
497 sed -e '/^static int[ ]*size;/c\
498 static int size ;\
499 \
500 static int getrnge ();' /tmp/$base > /tmp/$base.sed
501 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
502 true
503 else
504 echo Fixed $file_to_fix
505 rm -f ${LIB}/$file
506 cp /tmp/$base.sed ${LIB}/$file
507 chmod a+r ${LIB}/$file
508 fi
509 fi
510 rm -f /tmp/$base /tmp/$base.sed
511 fi
512
513 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
514 # that is visible to any ANSI compiler using this include. Simply
515 # delete the lines that #define some string functions to internal forms.
516
517 file=string.h
518 base=`basename $file`
519 if [ -r ${LIB}/$file ]; then
520 file_to_fix=${LIB}/$file
521 else
522 if [ -r ${INPUT}/$file ]; then
523 file_to_fix=${INPUT}/$file
524 else
525 file_to_fix=""
526 fi
527 fi
528 if [ \! -z "$file_to_fix" ]; then
529 echo Checking $file_to_fix
530 cp $file_to_fix /tmp/$base
531 chmod +w /tmp/$base
532 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
533 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
534 true
535 else
536 echo Fixed $file_to_fix
537 rm -f ${LIB}/$file
538 cp /tmp/$base.sed ${LIB}/$file
539 chmod a+r ${LIB}/$file
540 fi
541 rm -f /tmp/$base /tmp/$base.sed
542 fi
543
544 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
545 # tend to conflict with the compiler's own definition of this symbol. (We
546 # will use the compiler's definition.)
547 # Likewise __sparc, for Solaris, and __i860, and a few others
548 # (guessing it is necessary for all of them).
549
550 file=ieeefp.h
551 base=`basename $file`
552 if [ -r ${LIB}/$file ]; then
553 file_to_fix=${LIB}/$file
554 else
555 if [ -r ${INPUT}/$file ]; then
556 file_to_fix=${INPUT}/$file
557 else
558 file_to_fix=""
559 fi
560 fi
561 if [ \! -z "$file_to_fix" ]; then
562 echo Checking $file_to_fix
563 cp $file_to_fix /tmp/$base
564 chmod +w /tmp/$base
565 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
566 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
567 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
568 /tmp/$base > /tmp/$base.sed
569 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
570 true
571 else
572 echo Fixed $file_to_fix
573 rm -f ${LIB}/$file
574 cp /tmp/$base.sed ${LIB}/$file
575 chmod a+r ${LIB}/$file
576 fi
577 rm -f /tmp/$base /tmp/$base.sed
578 fi
579
580 # Add a #define of _SIGACTION_ into <sys/signal.h>.
581 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
582
583 file=sys/signal.h
584 base=`basename $file`
585 if [ -r ${LIB}/$file ]; then
586 file_to_fix=${LIB}/$file
587 else
588 if [ -r ${INPUT}/$file ]; then
589 file_to_fix=${INPUT}/$file
590 else
591 file_to_fix=""
592 fi
593 fi
594 if [ \! -z "$file_to_fix" ]; then
595 echo Checking $file_to_fix
596 cp $file_to_fix /tmp/$base
597 chmod +w /tmp/$base
598 sed -e '/^struct sigaction {/c\
599 #define _SIGACTION_\
600 struct sigaction {' \
601 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
602 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
603 true
604 else
605 echo Fixed $file_to_fix
606 rm -f ${LIB}/$file
607 cp /tmp/$base.sed ${LIB}/$file
608 chmod a+r ${LIB}/$file
609 fi
610 rm -f /tmp/$base /tmp/$base.sed
611 fi
612
613 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
614
615 file=sys/mkdev.h
616 base=`basename $file`
617 if [ -r ${LIB}/$file ]; then
618 file_to_fix=${LIB}/$file
619 else
620 if [ -r ${INPUT}/$file ]; then
621 file_to_fix=${INPUT}/$file
622 else
623 file_to_fix=""
624 fi
625 fi
626 if [ \! -z "$file_to_fix" ]; then
627 echo Checking $file_to_fix
628 cp $file_to_fix /tmp/$base
629 chmod +w /tmp/$base
630 sed -e '/^dev_t makedev(const/c\
631 static dev_t makedev(const major_t, const minor_t);' \
632 -e '/^dev_t makedev()/c\
633 static dev_t makedev();' \
634 -e '/^major_t major(const/c\
635 static major_t major(const dev_t);' \
636 -e '/^major_t major()/c\
637 static major_t major();' \
638 -e '/^minor_t minor(const/c\
639 static minor_t minor(const dev_t);' \
640 -e '/^minor_t minor()/c\
641 static minor_t minor();' /tmp/$base > /tmp/$base.sed
642 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
643 true
644 else
645 echo Fixed $file_to_fix
646 rm -f ${LIB}/$file
647 cp /tmp/$base.sed ${LIB}/$file
648 chmod a+r ${LIB}/$file
649 fi
650 rm -f /tmp/$base /tmp/$base.sed
651 fi
652
653 # Fix reference to NMSZ in <sys/adv.h>.
654
655 file=sys/adv.h
656 base=`basename $file`
657 if [ -r ${LIB}/$file ]; then
658 file_to_fix=${LIB}/$file
659 else
660 if [ -r ${INPUT}/$file ]; then
661 file_to_fix=${INPUT}/$file
662 else
663 file_to_fix=""
664 fi
665 fi
666 if [ \! -z "$file_to_fix" ]; then
667 echo Checking $file_to_fix
668 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
669 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
670 true
671 else
672 echo Fixed $file_to_fix
673 rm -f ${LIB}/$file
674 cp /tmp/$base ${LIB}/$file
675 chmod a+r ${LIB}/$file
676 fi
677 rm -f /tmp/$base
678 fi
679
680 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
681 # array initializers.
682
683 file=sys/netcspace.h
684 base=`basename $file`
685 if [ -r ${LIB}/$file ]; then
686 file_to_fix=${LIB}/$file
687 else
688 if [ -r ${INPUT}/$file ]; then
689 file_to_fix=${INPUT}/$file
690 else
691 file_to_fix=""
692 fi
693 fi
694 if [ \! -z "$file_to_fix" ]; then
695 echo Checking $file_to_fix
696 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
697 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
698 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
699 true
700 else
701 echo Fixed $file_to_fix
702 rm -f ${LIB}/$file
703 cp /tmp/$base ${LIB}/$file
704 chmod a+r ${LIB}/$file
705 fi
706 rm -f /tmp/$base
707 fi
708
709 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
710
711 file=fs/rfs/rf_cache.h
712 base=`basename $file`
713 if [ -r ${LIB}/$file ]; then
714 file_to_fix=${LIB}/$file
715 else
716 if [ -r ${INPUT}/$file ]; then
717 file_to_fix=${INPUT}/$file
718 else
719 file_to_fix=""
720 fi
721 fi
722 if [ \! -z "$file_to_fix" ]; then
723 echo Checking $file_to_fix
724 if grep _KERNEL $file_to_fix > /dev/null; then
725 true
726 else
727 echo '#ifdef _KERNEL' > /tmp/$base
728 cat $file_to_fix >> /tmp/$base
729 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
730 echo Fixed $file_to_fix
731 rm -f ${LIB}/$file
732 cp /tmp/$base ${LIB}/$file
733 chmod a+r ${LIB}/$file
734 rm -f /tmp/$base
735 fi
736 fi
737
738 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
739
740 file=sys/erec.h
741 base=`basename $file`
742 if [ -r ${LIB}/$file ]; then
743 file_to_fix=${LIB}/$file
744 else
745 if [ -r ${INPUT}/$file ]; then
746 file_to_fix=${INPUT}/$file
747 else
748 file_to_fix=""
749 fi
750 fi
751 if [ \! -z "$file_to_fix" ]; then
752 echo Checking $file_to_fix
753 if grep _KERNEL $file_to_fix > /dev/null; then
754 true
755 else
756 echo '#ifdef _KERNEL' > /tmp/$base
757 cat $file_to_fix >> /tmp/$base
758 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
759 echo Fixed $file_to_fix
760 rm -f ${LIB}/$file
761 cp /tmp/$base ${LIB}/$file
762 chmod a+r ${LIB}/$file
763 rm -f /tmp/$base
764 fi
765 fi
766
767 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
768
769 file=sys/err.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=""
778 fi
779 fi
780 if [ \! -z "$file_to_fix" ]; then
781 echo Checking $file_to_fix
782 if grep _KERNEL $file_to_fix > /dev/null; then
783 true
784 else
785 echo '#ifdef _KERNEL' > /tmp/$base
786 cat $file_to_fix >> /tmp/$base
787 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
788 echo Fixed $file_to_fix
789 rm -f ${LIB}/$file
790 cp /tmp/$base ${LIB}/$file
791 chmod a+r ${LIB}/$file
792 rm -f /tmp/$base
793 fi
794 fi
795
796 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
797
798 file=sys/char.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=""
807 fi
808 fi
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
822 fi
823 fi
824
825 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
826
827 file=sys/getpages.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=""
836 fi
837 fi
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
851 fi
852 fi
853
854 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
855
856 file=sys/map.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=""
865 fi
866 fi
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
880 fi
881 fi
882
883 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
884
885 file=sys/cmn_err.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=""
894 fi
895 fi
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
909 fi
910 fi
911
912 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
913
914 file=sys/kdebugger.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=""
923 fi
924 fi
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
938 fi
939 fi
940
941 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
942
943 file=netinet/in.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=""
952 fi
953 fi
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 sed -e '/#ifdef INKERNEL/i\
960 #ifdef _KERNEL' \
961 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
962 #endif /* _KERNEL */' \
963 $file_to_fix > ${LIB}/${file}.sed
964 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
965 echo Fixed $file_to_fix
966 fi
967 fi
968
969 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
970
971 file=sys/endian.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=""
980 fi
981 fi
982 if [ \! -z "$file_to_fix" ]; then
983 echo Checking $file_to_fix
984 if grep __GNUC__ $file_to_fix > /dev/null; then
985 true
986 else
987 sed -e '/# ifdef __STDC__/i\
988 # if !defined (__GNUC__) && !defined (__GNUG__)' \
989 -e '/# include <sys\/byteorder.h>/s/ / /'\
990 -e '/# include <sys\/byteorder.h>/i\
991 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
992 $file_to_fix > ${LIB}/${file}.sed
993 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
994 echo Fixed $file_to_fix
995 fi
996 fi
997
998 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
999 # and the text in types.h is not erroneous.
1000 ## In sys/types.h, don't name the enum for booleans.
1001 #
1002 #file=sys/types.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 "enum boolean" $file_to_fix > /dev/null; then
1016 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1017 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1018 # echo Fixed $file_to_fix
1019 # else
1020 # true
1021 # fi
1022 #fi
1023
1024 # Remove useless extern keyword from struct forward declarations in
1025 # <sys/stream.h> and <sys/strsubr.h>
1026
1027 file=sys/stream.h
1028 base=`basename $file`
1029 if [ -r ${LIB}/$file ]; then
1030 file_to_fix=${LIB}/$file
1031 else
1032 if [ -r ${INPUT}/$file ]; then
1033 file_to_fix=${INPUT}/$file
1034 else
1035 file_to_fix=""
1036 fi
1037 fi
1038 if [ \! -z "$file_to_fix" ]; then
1039 echo Checking $file_to_fix
1040 sed -e '
1041 s/extern struct stdata;/struct stdata;/g
1042 s/extern struct strevent;/struct strevent;/g
1043 ' $file_to_fix > /tmp/$base
1044 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1045 true
1046 else
1047 echo Fixed $file_to_fix
1048 rm -f ${LIB}/$file
1049 cp /tmp/$base ${LIB}/$file
1050 chmod a+r ${LIB}/$file
1051 fi
1052 rm -f /tmp/$base
1053 fi
1054
1055 file=sys/strsubr.h
1056 base=`basename $file`
1057 if [ -r ${LIB}/$file ]; then
1058 file_to_fix=${LIB}/$file
1059 else
1060 if [ -r ${INPUT}/$file ]; then
1061 file_to_fix=${INPUT}/$file
1062 else
1063 file_to_fix=""
1064 fi
1065 fi
1066 if [ \! -z "$file_to_fix" ]; then
1067 echo Checking $file_to_fix
1068 sed -e '
1069 s/extern struct strbuf;/struct strbuf;/g
1070 s/extern struct uio;/struct uio;/g
1071 s/extern struct thread;/struct thread;/g
1072 s/extern struct proc;/struct proc;/g
1073 ' $file_to_fix > /tmp/$base
1074 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1075 true
1076 else
1077 echo Fixed $file_to_fix
1078 rm -f ${LIB}/$file
1079 cp /tmp/$base ${LIB}/$file
1080 chmod a+r ${LIB}/$file
1081 fi
1082 rm -f /tmp/$base
1083 fi
1084
1085 # Put storage class at start of decl, to avoid warning.
1086 file=rpc/types.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/const extern/extern const/g
1101 ' $file_to_fix > /tmp/$base
1102 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1103 true
1104 else
1105 echo Fixed $file_to_fix
1106 rm -f ${LIB}/$file
1107 cp /tmp/$base ${LIB}/$file
1108 chmod a+r ${LIB}/$file
1109 fi
1110 rm -f /tmp/$base
1111 fi
1112
1113 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1114
1115 file=sys/stat.h
1116 base=`basename $file`
1117 if [ -r ${LIB}/$file ]; then
1118 file_to_fix=${LIB}/$file
1119 else
1120 if [ -r ${INPUT}/$file ]; then
1121 file_to_fix=${INPUT}/$file
1122 else
1123 file_to_fix=""
1124 fi
1125 fi
1126 if [ \! -z "$file_to_fix" ]; then
1127 echo Checking $file_to_fix
1128 cp $file_to_fix /tmp/$base
1129 chmod +w /tmp/$base
1130 sed -e '/^stat([ ]*[^c]/{
1131 N
1132 N
1133 s/(.*)\n/( /
1134 s/;\n/, /
1135 s/;$/)/
1136 }' \
1137 -e '/^lstat([ ]*[^c]/{
1138 N
1139 N
1140 s/(.*)\n/( /
1141 s/;\n/, /
1142 s/;$/)/
1143 }' \
1144 -e '/^fstat([ ]*[^i]/{
1145 N
1146 N
1147 s/(.*)\n/( /
1148 s/;\n/, /
1149 s/;$/)/
1150 }' \
1151 -e '/^mknod([ ]*[^c]/{
1152 N
1153 N
1154 N
1155 s/(.*)\n/( /
1156 s/;\n/, /g
1157 s/;$/)/
1158 }' \
1159 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1160 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1161 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1162 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1163 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1164 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1165 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1166 true
1167 else
1168 echo Fixed $file_to_fix
1169 rm -f ${LIB}/$file
1170 cp /tmp/$base.sed ${LIB}/$file
1171 chmod a+r ${LIB}/$file
1172 fi
1173 rm -f /tmp/$base /tmp/$base.sed
1174 fi
1175
1176 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1177
1178 if [ -x /bin/sony ]; then
1179 if /bin/sony; then
1180
1181 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1182
1183 file=stdio.h
1184 base=`basename $file`
1185 if [ -r ${LIB}/$file ]; then
1186 file_to_fix=${LIB}/$file
1187 else
1188 if [ -r ${INPUT}/$file ]; then
1189 file_to_fix=${INPUT}/$file
1190 else
1191 file_to_fix=""
1192 fi
1193 fi
1194 if [ \! -z "$file_to_fix" ]; then
1195 echo Checking $file_to_fix
1196 cp $file_to_fix /tmp/$base
1197 chmod +w /tmp/$base
1198 sed -e '
1199 s/__filbuf/_filbuf/g
1200 s/__flsbuf/_flsbuf/g
1201 s/__iob/_iob/g
1202 ' /tmp/$base > /tmp/$base.sed
1203 mv /tmp/$base.sed /tmp/$base
1204 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1205 true
1206 else
1207 echo Fixed $file_to_fix
1208 rm -f ${LIB}/$file
1209 cp /tmp/$base ${LIB}/$file
1210 chmod a+r ${LIB}/$file
1211 fi
1212 rm -f /tmp/$base
1213 fi
1214
1215 # Change <ctype.h> to not define __ctype
1216
1217 file=ctype.h
1218 base=`basename $file`
1219 if [ -r ${LIB}/$file ]; then
1220 file_to_fix=${LIB}/$file
1221 else
1222 if [ -r ${INPUT}/$file ]; then
1223 file_to_fix=${INPUT}/$file
1224 else
1225 file_to_fix=""
1226 fi
1227 fi
1228 if [ \! -z "$file_to_fix" ]; then
1229 echo Checking $file_to_fix
1230 cp $file_to_fix /tmp/$base
1231 chmod +w /tmp/$base
1232 sed -e '
1233 s/__ctype/_ctype/g
1234 ' /tmp/$base > /tmp/$base.sed
1235 mv /tmp/$base.sed /tmp/$base
1236 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1237 true
1238 else
1239 echo Fixed $file_to_fix
1240 rm -f ${LIB}/$file
1241 cp /tmp/$base ${LIB}/$file
1242 chmod a+r ${LIB}/$file
1243 fi
1244 rm -f /tmp/$base
1245 fi
1246 fi
1247 fi
1248
1249 # In limits.h, put #ifndefs around things that are supposed to be defined
1250 # in float.h to avoid redefinition errors if float.h is included first.
1251 # Solaris 2.1 has this problem.
1252
1253 file=limits.h
1254 base=`basename $file`
1255 if [ -r ${LIB}/$file ]; then
1256 file_to_fix=${LIB}/$file
1257 else
1258 if [ -r ${INPUT}/$file ]; then
1259 file_to_fix=${INPUT}/$file
1260 else
1261 file_to_fix=""
1262 fi
1263 fi
1264 if [ \! -z "$file_to_fix" ]; then
1265 echo Checking $file_to_fix
1266 sed -e '/[ ]FLT_MIN[ ]/i\
1267 #ifndef FLT_MIN'\
1268 -e '/[ ]FLT_MIN[ ]/a\
1269 #endif'\
1270 -e '/[ ]FLT_MAX[ ]/i\
1271 #ifndef FLT_MAX'\
1272 -e '/[ ]FLT_MAX[ ]/a\
1273 #endif'\
1274 -e '/[ ]FLT_DIG[ ]/i\
1275 #ifndef FLT_DIG'\
1276 -e '/[ ]FLT_DIG[ ]/a\
1277 #endif'\
1278 -e '/[ ]DBL_MIN[ ]/i\
1279 #ifndef DBL_MIN'\
1280 -e '/[ ]DBL_MIN[ ]/a\
1281 #endif'\
1282 -e '/[ ]DBL_MAX[ ]/i\
1283 #ifndef DBL_MAX'\
1284 -e '/[ ]DBL_MAX[ ]/a\
1285 #endif'\
1286 -e '/[ ]DBL_DIG[ ]/i\
1287 #ifndef DBL_DIG'\
1288 -e '/[ ]DBL_DIG[ ]/a\
1289 #endif' $file_to_fix > /tmp/$base
1290 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1291 true
1292 else
1293 echo Fixed $file_to_fix
1294 rm -f ${LIB}/$file
1295 cp /tmp/$base ${LIB}/$file
1296 chmod a+r ${LIB}/$file
1297 fi
1298 rm -f /tmp/$base
1299 fi
1300
1301 # Completely replace <sys/varargs.h> with a file that includes gcc's
1302 # stdarg.h or varargs.h files as appropriate.
1303
1304 file=sys/varargs.h
1305 if [ -r ${INPUT}/$file ]; then
1306 echo Replacing $file
1307 cat > ${LIB}/$file << EOF
1308 /* This file was generated by fixincludes. */
1309 #ifndef _SYS_VARARGS_H
1310 #define _SYS_VARARGS_H
1311
1312 #ifdef __STDC__
1313 #include <stdarg.h>
1314 #else
1315 #include <varargs.h>
1316 #endif
1317
1318 #endif /* _SYS_VARARGS_H */
1319 EOF
1320 chmod a+r ${LIB}/$file
1321 fi
1322
1323 # In math.h, put #ifndefs around things that might be defined in a gcc
1324 # specific math-*.h file.
1325
1326 file=math.h
1327 base=`basename $file`
1328 if [ -r ${LIB}/$file ]; then
1329 file_to_fix=${LIB}/$file
1330 else
1331 if [ -r ${INPUT}/$file ]; then
1332 file_to_fix=${INPUT}/$file
1333 else
1334 file_to_fix=""
1335 fi
1336 fi
1337 if [ \! -z "$file_to_fix" ]; then
1338 echo Checking $file_to_fix
1339 sed -e '/define[ ]HUGE_VAL[ ]/i\
1340 #ifndef HUGE_VAL'\
1341 -e '/define[ ]HUGE_VAL[ ]/a\
1342 #endif' $file_to_fix > /tmp/$base
1343 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1344 true
1345 else
1346 echo Fixed $file_to_fix
1347 rm -f ${LIB}/$file
1348 cp /tmp/$base ${LIB}/$file
1349 chmod a+r ${LIB}/$file
1350 fi
1351 rm -f /tmp/$base
1352 fi
1353
1354 echo 'Removing unneeded directories:'
1355 cd $LIB
1356 files=`find . -type d -print | sort -r`
1357 for file in $files; do
1358 rmdir $LIB/$file > /dev/null 2>&1
1359 done
1360
1361 if $LINKS; then
1362 echo 'Making internal symbolic non-directory links'
1363 cd ${INPUT}
1364 files=`find . -type l -print`
1365 for file in $files; do
1366 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1367 if expr "$dest" : '[^/].*' > /dev/null; then
1368 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1369 if [ -f $target ]; then
1370 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1371 fi
1372 fi
1373 done
1374 fi
1375
1376 cd ${ORIG_DIR}
1377
1378 echo 'Replacing <sys/byteorder.h>'
1379 rm -f ${LIB}/sys/byteorder.h
1380 cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h
1381
1382 exit 0
1383
This page took 0.294143 seconds and 6 git commands to generate.