]> gcc.gnu.org Git - gcc.git/blob - gcc/fixinc.svr4
entered into RCS
[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.
57 cd $LIB; LIB=`pwd`
58
59 # This prevents /bin/ex from failing if the current terminal type is
60 # unrecognizable.
61 TERM=dumb
62 export TERM
63
64 echo 'Building fixincludes in ' ${LIB}
65
66 # Determine whether this filesystem has symbolic links.
67 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
68 rm -f $LIB/ShouldNotExist
69 LINKS=true
70 else
71 LINKS=false
72 fi
73
74 echo 'Making directories:'
75 cd ${INPUT}
76 if $LINKS; then
77 files=`ls -LR | sed -n s/:$//p`
78 else
79 files=`find . -type d -print | sed '/^.$/d'`
80 fi
81 for file in $files; do
82 rm -rf $LIB/$file
83 if [ ! -d $LIB/$file ]
84 then mkdir $LIB/$file
85 fi
86 done
87
88 # treetops gets an alternating list
89 # of old directories to copy
90 # and the new directories to copy to.
91 treetops="${INPUT} ${LIB}"
92
93 if $LINKS; then
94 echo 'Making internal symbolic directory links'
95 for file in $files; do
96 dest=`ls -ld $file | sed -n 's/.*-> //p'`
97 if [ "$dest" ]; then
98 cwd=`pwd`
99 # In case $dest is relative, get to $file's dir first.
100 cd ${INPUT}
101 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
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 $x : "${INPUT}/.*" > /dev/null; then
112 # Y gets the actual target dir name, relative to ${INPUT}.
113 y=`echo $x | sed -n "s&${INPUT}/&&p"`
114 echo $file '->' $y ': Making link'
115 rm -fr ${LIB}/$file > /dev/null 2>&1
116 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
117 else
118 # If the link is to outside ${INPUT},
119 # treat this directory as if it actually contained the files.
120 # This line used to have $dest instead of $x.
121 # $dest seemed to be wrong for links found in subdirectories
122 # of ${INPUT}. Does this change break anything?
123 treetops="$treetops $x ${LIB}/$file"
124 fi
125 fi
126 cd $cwd
127 fi
128 done
129 fi
130
131 set - $treetops
132 while [ $# != 0 ]; do
133 # $1 is an old directory to copy, and $2 is the new directory to copy to.
134 echo "Finding header files in $1:"
135 cd ${INPUT}
136 cd $1
137 files=`find . -name '*.h' -type f -print`
138 echo 'Checking header files:'
139 for file in $files; do
140 echo Fixing $file
141 if [ -r $file ]; then
142 cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
143 chmod +w $2/$file
144
145 # The following have been removed from the sed command below
146 # because it is more useful to leave these things in.
147 # The only reason to remove them was for -pedantic,
148 # which isn't much of a reason. -- rms.
149 # /^[ ]*#[ ]*ident/d
150
151 # The change of u_char, etc, to u_int
152 # applies to bit fields.
153 sed -e '
154 s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
155 s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
156 s/#lint(on)/defined(lint)/g
157 s/#lint(off)/!defined(lint)/g
158 s/#machine(\([^)]*\))/defined(__\1__)/g
159 s/#system(\([^)]*\))/defined(__\1__)/g
160 s/#cpu(\([^)]*\))/defined(__\1__)/g
161 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
162 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
163 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
164 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
165 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
166 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
167 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
168 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
169 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
170 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
171 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
172 s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
173 s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
174 s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
175 s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
176 s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
177 s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
178 s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
179 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
180 ' $2/$file > $2/$file.sed
181 mv $2/$file.sed $2/$file
182 if cmp $file $2/$file >/dev/null 2>&1; then
183 echo Deleting $2/$file\; no fixes were needed.
184 rm $2/$file
185 fi
186 fi
187 done
188 shift; shift
189 done
190
191 # Fix first broken decl of getcwd present on some svr4 systems.
192
193 file=stdlib.h
194 base=`basename $file`
195 if [ -r ${LIB}/$file ]; then
196 file_to_fix=${LIB}/$file
197 else
198 if [ -r ${INPUT}/$file ]; then
199 file_to_fix=${INPUT}/$file
200 else
201 file_to_fix=""
202 fi
203 fi
204 if [ \! -z "$file_to_fix" ]; then
205 echo Checking $file_to_fix
206 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
207 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
208 echo No change needed in $file_to_fix
209 else
210 echo Fixed $file_to_fix
211 rm -f ${LIB}/$file
212 cp /tmp/$base ${LIB}/$file
213 fi
214 rm -f /tmp/$base
215 fi
216
217 # Fix second broken decl of getcwd present on some svr4 systems. Also
218 # fix the incorrect decl of profil present on some svr4 systems.
219
220 file=unistd.h
221 base=`basename $file`
222 if [ -r ${LIB}/$file ]; then
223 file_to_fix=${LIB}/$file
224 else
225 if [ -r ${INPUT}/$file ]; then
226 file_to_fix=${INPUT}/$file
227 else
228 file_to_fix=""
229 fi
230 fi
231 if [ \! -z "$file_to_fix" ]; then
232 echo Checking $file_to_fix
233 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
234 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
235 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
236 echo No change needed in $file_to_fix
237 else
238 echo Fixed $file_to_fix
239 rm -f ${LIB}/$file
240 cp /tmp/$base ${LIB}/$file
241 fi
242 rm -f /tmp/$base
243 fi
244
245 # Fix the definition of NULL in <sys/param.h> so that it is conditional
246 # and so that it is correct for both C and C++.
247
248 file=sys/param.h
249 base=`basename $file`
250 if [ -r ${LIB}/$file ]; then
251 file_to_fix=${LIB}/$file
252 else
253 if [ -r ${INPUT}/$file ]; then
254 file_to_fix=${INPUT}/$file
255 else
256 file_to_fix=""
257 fi
258 fi
259 if [ \! -z "$file_to_fix" ]; then
260 echo Checking $file_to_fix
261 cp $file_to_fix /tmp/$base
262 chmod +w /tmp/$base
263 ex /tmp/$base <<EOF
264 /^#define[ ]*NULL[ ]*0$/c
265 #ifndef NULL
266 #ifdef __cplusplus
267 #define __NULL_TYPE
268 #else /* !defined(__cplusplus) */
269 #define __NULL_TYPE (void *)
270 #endif /* !defined(__cplusplus) */
271 #define NULL (__NULL_TYPE 0)
272 #endif /* !defined(NULL) */
273 .
274 wq
275 EOF
276 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
277 echo No change needed in $file_to_fix
278 else
279 echo Fixed $file_to_fix
280 rm -f ${LIB}/$file
281 cp /tmp/$base ${LIB}/$file
282 fi
283 rm -f /tmp/$base
284 fi
285
286 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
287 # and so that it is correct for both C and C++.
288
289 file=stdio.h
290 base=`basename $file`
291 if [ -r ${LIB}/$file ]; then
292 file_to_fix=${LIB}/$file
293 else
294 if [ -r ${INPUT}/$file ]; then
295 file_to_fix=${INPUT}/$file
296 else
297 file_to_fix=""
298 fi
299 fi
300 if [ \! -z "$file_to_fix" ]; then
301 echo Checking $file_to_fix
302 cp $file_to_fix /tmp/$base
303 chmod +w /tmp/$base
304 ex /tmp/$base <<EOF
305 /^#define[ ]*NULL[ ]*0$/c
306 #ifdef __cplusplus
307 #define __NULL_TYPE
308 #else /* !defined(__cplusplus) */
309 #define __NULL_TYPE (void *)
310 #endif /* !defined(__cplusplus) */
311 #define NULL (__NULL_TYPE 0)
312 .
313 wq
314 EOF
315 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
316 echo No change needed in $file_to_fix
317 else
318 echo Fixed $file_to_fix
319 rm -f ${LIB}/$file
320 cp /tmp/$base ${LIB}/$file
321 fi
322 rm -f /tmp/$base
323 fi
324
325 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
326 # and so that it is correct for both C and C++.
327
328 file=dbm.h
329 base=`basename $file`
330 if [ -r ${LIB}/$file ]; then
331 file_to_fix=${LIB}/$file
332 else
333 if [ -r ${INPUT}/$file ]; then
334 file_to_fix=${INPUT}/$file
335 else
336 file_to_fix=""
337 fi
338 fi
339 if [ \! -z "$file_to_fix" ]; then
340 echo Checking $file_to_fix
341 cp $file_to_fix /tmp/$base
342 chmod +w /tmp/$base
343 ex /tmp/$base <<EOF
344 /^#define[ ]*NULL[ ]*((char \*) 0)$/c
345 #ifndef NULL
346 #ifdef __cplusplus
347 #define __NULL_TYPE
348 #else /* !defined(__cplusplus) */
349 #define __NULL_TYPE (void *)
350 #endif /* !defined(__cplusplus) */
351 #define NULL (__NULL_TYPE 0)
352 #endif /* !defined(NULL) */
353 .
354 wq
355 EOF
356 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
357 echo No change needed in $file_to_fix
358 else
359 echo Fixed $file_to_fix
360 rm -f ${LIB}/$file
361 cp /tmp/$base ${LIB}/$file
362 fi
363 rm -f /tmp/$base
364 fi
365
366 # Add a prototyped declaration of mmap to <sys/mman.h>.
367
368 file=sys/mman.h
369 base=`basename $file`
370 if [ -r ${LIB}/$file ]; then
371 file_to_fix=${LIB}/$file
372 else
373 if [ -r ${INPUT}/$file ]; then
374 file_to_fix=${INPUT}/$file
375 else
376 file_to_fix=""
377 fi
378 fi
379 if [ \! -z "$file_to_fix" ]; then
380 echo Checking $file_to_fix
381 cp $file_to_fix /tmp/$base
382 chmod +w /tmp/$base
383 ex /tmp/$base <<EOF
384 /^extern caddr_t mmap();$/c
385 #ifdef __STDC__
386 extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,
387 int fd, off_t off);
388 #else /* !defined(__STDC__) */
389 extern caddr_t mmap ();
390 #endif /* !defined(__STDC__) */
391 .
392 wq
393 EOF
394 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
395 echo No changed needed in $file_to_fix
396 else
397 echo Fixed $file_to_fix
398 rm -f ${LIB}/$file
399 cp /tmp/$base ${LIB}/$file
400 fi
401 rm -f /tmp/$base
402 fi
403
404 # Fix declarations of `ftw' and `nftw' in <ftw.h>.
405
406 file=ftw.h
407 base=`basename $file`
408 if [ -r ${LIB}/$file ]; then
409 file_to_fix=${LIB}/$file
410 else
411 if [ -r ${INPUT}/$file ]; then
412 file_to_fix=${INPUT}/$file
413 else
414 file_to_fix=""
415 fi
416 fi
417 if [ \! -z "$file_to_fix" ]; then
418 echo Checking $file_to_fix
419 cp $file_to_fix /tmp/$base
420 chmod +w /tmp/$base
421 ex /tmp/$base <<EOF
422 /^extern int ftw(const/c
423 #if !defined(_STYPES)
424 static
425 #else
426 extern
427 #endif
428 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
429 .
430 /^extern int nftw/c
431 #if defined(_STYPES)
432 static
433 #else
434 extern
435 #endif
436 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);
437 .
438 /^extern int ftw(),/c
439 #if !defined(_STYPES)
440 static
441 #else
442 extern
443 #endif
444 int ftw();
445 #if defined(_STYPES)
446 static
447 #else
448 extern
449 #endif
450 int nftw();
451 .
452 wq
453 EOF
454 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
455 echo No change needed in $file_to_fix
456 else
457 echo Fixed $file_to_fix
458 rm -f ${LIB}/$file
459 cp /tmp/$base ${LIB}/$file
460 fi
461 rm -f /tmp/$base
462 fi
463
464 # Add a `static' declaration of `getrnge' into <regexp.h>.
465
466 file=regexp.h
467 base=`basename $file`
468 if [ -r ${LIB}/$file ]; then
469 file_to_fix=${LIB}/$file
470 else
471 if [ -r ${INPUT}/$file ]; then
472 file_to_fix=${INPUT}/$file
473 else
474 file_to_fix=""
475 fi
476 fi
477 if [ \! -z "$file_to_fix" ]; then
478 echo Checking $file_to_fix
479 cp $file_to_fix /tmp/$base
480 chmod +w /tmp/$base
481 ex /tmp/$base <<EOF
482 /^static int[ ]*size;/c
483 static int size ;
484
485 static int getrnge ();
486 .
487 wq
488 EOF
489 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
490 echo No change needed in $file_to_fix
491 else
492 echo Fixed $file_to_fix
493 rm -f ${LIB}/$file
494 cp /tmp/$base ${LIB}/$file
495 fi
496 rm -f /tmp/$base
497 fi
498
499 # Add a #define of _SIGACTION_ into <sys/signal.h>.
500
501 file=sys/signal.h
502 base=`basename $file`
503 if [ -r ${LIB}/$file ]; then
504 file_to_fix=${LIB}/$file
505 else
506 if [ -r ${INPUT}/$file ]; then
507 file_to_fix=${INPUT}/$file
508 else
509 file_to_fix=""
510 fi
511 fi
512 if [ \! -z "$file_to_fix" ]; then
513 echo Checking $file_to_fix
514 cp $file_to_fix /tmp/$base
515 chmod +w /tmp/$base
516 ex /tmp/$base <<EOF
517 /^struct sigaction {/c
518 #define _SIGACTION_
519 struct sigaction {
520 .
521 wq
522 EOF
523 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
524 echo No change needed in $file_to_fix
525 else
526 echo Fixed $file_to_fix
527 rm -f ${LIB}/$file
528 cp /tmp/$base ${LIB}/$file
529 fi
530 rm -f /tmp/$base
531 fi
532
533 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
534
535 file=sys/mkdev.h
536 base=`basename $file`
537 if [ -r ${LIB}/$file ]; then
538 file_to_fix=${LIB}/$file
539 else
540 if [ -r ${INPUT}/$file ]; then
541 file_to_fix=${INPUT}/$file
542 else
543 file_to_fix=""
544 fi
545 fi
546 if [ \! -z "$file_to_fix" ]; then
547 echo Checking $file_to_fix
548 cp $file_to_fix /tmp/$base
549 chmod +w /tmp/$base
550 ex /tmp/$base <<EOF
551 /^dev_t makedev(const/c
552 static dev_t makedev(const major_t, const minor_t);
553 .
554 /^dev_t makedev()/c
555 static dev_t makedev();
556 .
557 /^major_t major(const/c
558 static major_t major(const dev_t);
559 .
560 /^major_t major()/c
561 static major_t major();
562 .
563 /^minor_t minor(const/c
564 static minor_t minor(const dev_t);
565 .
566 /^minor_t minor()/c
567 static minor_t minor();
568 .
569 wq
570 EOF
571 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
572 echo No change needed in $file_to_fix
573 else
574 echo Fixed $file_to_fix
575 rm -f ${LIB}/$file
576 cp /tmp/$base ${LIB}/$file
577 fi
578 rm -f /tmp/$base
579 fi
580
581 # Fix reference to NMSZ in <sys/adv.h>.
582
583 file=sys/adv.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 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
597 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
598 echo No change needed in $file_to_fix
599 else
600 echo Fixed $file_to_fix
601 rm -f ${LIB}/$file
602 cp /tmp/$base ${LIB}/$file
603 fi
604 rm -f /tmp/$base
605 fi
606
607 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
608 # array initializers.
609
610 file=sys/netcspace.h
611 base=`basename $file`
612 if [ -r ${LIB}/$file ]; then
613 file_to_fix=${LIB}/$file
614 else
615 if [ -r ${INPUT}/$file ]; then
616 file_to_fix=${INPUT}/$file
617 else
618 file_to_fix=""
619 fi
620 fi
621 if [ \! -z "$file_to_fix" ]; then
622 echo Checking $file_to_fix
623 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
624 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
625 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
626 echo No change needed in $file_to_fix
627 else
628 echo Fixed $file_to_fix
629 rm -f ${LIB}/$file
630 cp /tmp/$base ${LIB}/$file
631 fi
632 rm -f /tmp/$base
633 fi
634
635 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
636
637 file=fs/rfs/rf_cache.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=""
646 fi
647 fi
648 if [ \! -z "$file_to_fix" ]; then
649 echo Checking $file_to_fix
650 if grep _KERNEL $file_to_fix > /dev/null; then
651 echo No change needed in $file_to_fix
652 else
653 echo '#ifdef _KERNEL' > /tmp/$base
654 cat $file_to_fix >> /tmp/$base
655 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
656 echo Fixed $file_to_fix
657 rm -f ${LIB}/$file
658 cp /tmp/$base ${LIB}/$file
659 rm -f /tmp/$base
660 fi
661 fi
662
663 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
664
665 file=sys/erec.h
666 base=`basename $file`
667 if [ -r ${LIB}/$file ]; then
668 file_to_fix=${LIB}/$file
669 else
670 if [ -r ${INPUT}/$file ]; then
671 file_to_fix=${INPUT}/$file
672 else
673 file_to_fix=""
674 fi
675 fi
676 if [ \! -z "$file_to_fix" ]; then
677 echo Checking $file_to_fix
678 if grep _KERNEL $file_to_fix > /dev/null; then
679 echo No change needed in $file_to_fix
680 else
681 echo '#ifdef _KERNEL' > /tmp/$base
682 cat $file_to_fix >> /tmp/$base
683 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
684 echo Fixed $file_to_fix
685 rm -f ${LIB}/$file
686 cp /tmp/$base ${LIB}/$file
687 rm -f /tmp/$base
688 fi
689 fi
690
691 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
692
693 file=sys/err.h
694 base=`basename $file`
695 if [ -r ${LIB}/$file ]; then
696 file_to_fix=${LIB}/$file
697 else
698 if [ -r ${INPUT}/$file ]; then
699 file_to_fix=${INPUT}/$file
700 else
701 file_to_fix=""
702 fi
703 fi
704 if [ \! -z "$file_to_fix" ]; then
705 echo Checking $file_to_fix
706 if grep _KERNEL $file_to_fix > /dev/null; then
707 echo No change needed in $file_to_fix
708 else
709 echo '#ifdef _KERNEL' > /tmp/$base
710 cat $file_to_fix >> /tmp/$base
711 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
712 echo Fixed $file_to_fix
713 rm -f ${LIB}/$file
714 cp /tmp/$base ${LIB}/$file
715 rm -f /tmp/$base
716 fi
717 fi
718
719 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
720
721 file=sys/char.h
722 base=`basename $file`
723 if [ -r ${LIB}/$file ]; then
724 file_to_fix=${LIB}/$file
725 else
726 if [ -r ${INPUT}/$file ]; then
727 file_to_fix=${INPUT}/$file
728 else
729 file_to_fix=""
730 fi
731 fi
732 if [ \! -z "$file_to_fix" ]; then
733 echo Checking $file_to_fix
734 if grep _KERNEL $file_to_fix > /dev/null; then
735 echo No change needed in $file_to_fix
736 else
737 echo '#ifdef _KERNEL' > /tmp/$base
738 cat $file_to_fix >> /tmp/$base
739 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
740 echo Fixed $file_to_fix
741 rm -f ${LIB}/$file
742 cp /tmp/$base ${LIB}/$file
743 rm -f /tmp/$base
744 fi
745 fi
746
747 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
748
749 file=sys/getpages.h
750 base=`basename $file`
751 if [ -r ${LIB}/$file ]; then
752 file_to_fix=${LIB}/$file
753 else
754 if [ -r ${INPUT}/$file ]; then
755 file_to_fix=${INPUT}/$file
756 else
757 file_to_fix=""
758 fi
759 fi
760 if [ \! -z "$file_to_fix" ]; then
761 echo Checking $file_to_fix
762 if grep _KERNEL $file_to_fix > /dev/null; then
763 echo No change needed in $file_to_fix
764 else
765 echo '#ifdef _KERNEL' > /tmp/$base
766 cat $file_to_fix >> /tmp/$base
767 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
768 echo Fixed $file_to_fix
769 rm -f ${LIB}/$file
770 cp /tmp/$base ${LIB}/$file
771 rm -f /tmp/$base
772 fi
773 fi
774
775 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
776
777 file=sys/map.h
778 base=`basename $file`
779 if [ -r ${LIB}/$file ]; then
780 file_to_fix=${LIB}/$file
781 else
782 if [ -r ${INPUT}/$file ]; then
783 file_to_fix=${INPUT}/$file
784 else
785 file_to_fix=""
786 fi
787 fi
788 if [ \! -z "$file_to_fix" ]; then
789 echo Checking $file_to_fix
790 if grep _KERNEL $file_to_fix > /dev/null; then
791 echo No change needed in $file_to_fix
792 else
793 echo '#ifdef _KERNEL' > /tmp/$base
794 cat $file_to_fix >> /tmp/$base
795 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
796 echo Fixed $file_to_fix
797 rm -f ${LIB}/$file
798 cp /tmp/$base ${LIB}/$file
799 rm -f /tmp/$base
800 fi
801 fi
802
803 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
804
805 file=sys/cmn_err.h
806 base=`basename $file`
807 if [ -r ${LIB}/$file ]; then
808 file_to_fix=${LIB}/$file
809 else
810 if [ -r ${INPUT}/$file ]; then
811 file_to_fix=${INPUT}/$file
812 else
813 file_to_fix=""
814 fi
815 fi
816 if [ \! -z "$file_to_fix" ]; then
817 echo Checking $file_to_fix
818 if grep _KERNEL $file_to_fix > /dev/null; then
819 echo No change needed in $file_to_fix
820 else
821 echo '#ifdef _KERNEL' > /tmp/$base
822 cat $file_to_fix >> /tmp/$base
823 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
824 echo Fixed $file_to_fix
825 rm -f ${LIB}/$file
826 cp /tmp/$base ${LIB}/$file
827 rm -f /tmp/$base
828 fi
829 fi
830
831 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
832
833 file=sys/kdebugger.h
834 base=`basename $file`
835 if [ -r ${LIB}/$file ]; then
836 file_to_fix=${LIB}/$file
837 else
838 if [ -r ${INPUT}/$file ]; then
839 file_to_fix=${INPUT}/$file
840 else
841 file_to_fix=""
842 fi
843 fi
844 if [ \! -z "$file_to_fix" ]; then
845 echo Checking $file_to_fix
846 if grep _KERNEL $file_to_fix > /dev/null; then
847 echo No change needed in $file_to_fix
848 else
849 echo '#ifdef _KERNEL' > /tmp/$base
850 cat $file_to_fix >> /tmp/$base
851 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
852 echo Fixed $file_to_fix
853 rm -f ${LIB}/$file
854 cp /tmp/$base ${LIB}/$file
855 rm -f /tmp/$base
856 fi
857 fi
858
859 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
860
861 if [ -x /bin/sony ]; then
862 if /bin/sony; then
863
864 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
865
866 file=stdio.h
867 base=`basename $file`
868 if [ -r ${LIB}/$file ]; then
869 file_to_fix=${LIB}/$file
870 else
871 if [ -r ${INPUT}/$file ]; then
872 file_to_fix=${INPUT}/$file
873 else
874 file_to_fix=""
875 fi
876 fi
877 if [ \! -z "$file_to_fix" ]; then
878 echo Checking $file_to_fix
879 cp $file_to_fix /tmp/$base
880 chmod +w /tmp/$base
881 sed -e '
882 s/__filbuf/_filbuf/g
883 s/__flsbuf/_flsbuf/g
884 s/__iob/_iob/g
885 ' /tmp/$base > /tmp/$base.sed
886 mv /tmp/$base.sed /tmp/$base
887 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
888 echo No change needed in $file_to_fix
889 else
890 echo Fixed $file_to_fix
891 rm -f ${LIB}/$file
892 cp /tmp/$base ${LIB}/$file
893 fi
894 rm -f /tmp/$base
895 fi
896
897 # Change <ctype.h> to not define __ctype
898
899 file=ctype.h
900 base=`basename $file`
901 if [ -r ${LIB}/$file ]; then
902 file_to_fix=${LIB}/$file
903 else
904 if [ -r ${INPUT}/$file ]; then
905 file_to_fix=${INPUT}/$file
906 else
907 file_to_fix=""
908 fi
909 fi
910 if [ \! -z "$file_to_fix" ]; then
911 echo Checking $file_to_fix
912 cp $file_to_fix /tmp/$base
913 chmod +w /tmp/$base
914 sed -e '
915 s/__ctype/_ctype/g
916 ' /tmp/$base > /tmp/$base.sed
917 mv /tmp/$base.sed /tmp/$base
918 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
919 echo No change needed in $file_to_fix
920 else
921 echo Fixed $file_to_fix
922 rm -f ${LIB}/$file
923 cp /tmp/$base ${LIB}/$file
924 fi
925 rm -f /tmp/$base
926 fi
927 fi
928 fi
929
930 echo 'Removing unneeded directories:'
931 cd $LIB
932 files=`find . -type d -print | sort -r`
933 for file in $files; do
934 rmdir $LIB/$file > /dev/null 2>&1
935 done
936
937 if $LINKS; then
938 echo 'Making internal symbolic non-directory links'
939 cd ${INPUT}
940 files=`find . -type l -print`
941 for file in $files; do
942 dest=`ls -ld $file | sed -n 's/.*-> //p'`
943 if expr "$dest" : '[^/].*' > /dev/null; then
944 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
945 if [ -f $target ]; then
946 ln -s $dest ${LIB}/$file >/dev/null 2>&1
947 fi
948 fi
949 done
950 fi
951
952 cd ${ORIG_DIR}
953
954 echo 'Replacing <sys/byteorder.h>'
955 rm -f ${LIB}/sys/byteorder.h
956 cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h
957
958 exit 0
959
This page took 0.092531 seconds and 6 git commands to generate.