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