]> gcc.gnu.org Git - gcc.git/blob - gcc/fixinc.svr4
Use pwd if PWDCMD is undefined. Add missing echo command.
[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 cd $LIB; LIB=`${PWDCMD-pwd}`
63 ;;
64 esac
65
66 # This prevents /bin/ex from failing if the current terminal type is
67 # unrecognizable.
68 TERM=dumb
69 export TERM
70 # This prevents /bin/ex from failing if the EXINIT environment variable
71 # was set to something invalid.
72 EXINIT=""
73 export EXINIT
74
75 echo 'Building fixincludes in ' ${LIB}
76
77 # Determine whether this filesystem has symbolic links.
78 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
79 rm -f $LIB/ShouldNotExist
80 LINKS=true
81 else
82 LINKS=false
83 fi
84
85 echo 'Making directories:'
86 cd ${INPUT}
87 if $LINKS; then
88 files=`ls -LR | sed -n s/:$//p`
89 else
90 files=`find . -type d -print | sed '/^.$/d'`
91 fi
92 for file in $files; do
93 rm -rf $LIB/$file
94 if [ ! -d $LIB/$file ]
95 then mkdir $LIB/$file
96 fi
97 done
98
99 # treetops gets an alternating list
100 # of old directories to copy
101 # and the new directories to copy to.
102 treetops="${INPUT} ${LIB}"
103
104 if $LINKS; then
105 echo 'Making internal symbolic directory links'
106 for file in $files; do
107 dest=`ls -ld $file | sed -n 's/.*-> //p'`
108 if [ "$dest" ]; then
109 cwd=`pwd`
110 # In case $dest is relative, get to $file's dir first.
111 cd ${INPUT}
112 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
113 # Check that the target directory exists.
114 # Redirections changed to avoid bug in sh on Ultrix.
115 (cd $dest) > /dev/null 2>&1
116 if [ $? = 0 ]; then
117 cd $dest
118 # X gets the dir that the link actually leads to.
119 x=`pwd`
120 # If link leads back into ${INPUT},
121 # make a similar link here.
122 if expr $x : "${INPUT}/.*" > /dev/null; then
123 # Y gets the actual target dir name, relative to ${INPUT}.
124 y=`echo $x | sed -n "s&${INPUT}/&&p"`
125 echo $file '->' $y ': Making link'
126 rm -fr ${LIB}/$file > /dev/null 2>&1
127 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
128 else
129 # If the link is to outside ${INPUT},
130 # treat this directory as if it actually contained the files.
131 # This line used to have $dest instead of $x.
132 # $dest seemed to be wrong for links found in subdirectories
133 # of ${INPUT}. Does this change break anything?
134 treetops="$treetops $x ${LIB}/$file"
135 fi
136 fi
137 cd $cwd
138 fi
139 done
140 fi
141
142 set - $treetops
143 while [ $# != 0 ]; do
144 # $1 is an old directory to copy, and $2 is the new directory to copy to.
145 echo "Finding header files in $1:"
146 cd ${INPUT}
147 cd $1
148 files=`find . -name '*.h' -type f -print`
149 echo 'Checking header files:'
150 for file in $files; do
151 if [ -r $file ]; then
152 cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
153 chmod +w $2/$file
154 chmod a+r $2/$file
155
156 # The following have been removed from the sed command below
157 # because it is more useful to leave these things in.
158 # The only reason to remove them was for -pedantic,
159 # which isn't much of a reason. -- rms.
160 # /^[ ]*#[ ]*ident/d
161
162 # This code makes Solaris SCSI fail, because it changes the
163 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
164 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
165 # Disable these also, since they probably aren't safe either.
166 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
167 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
168 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
169 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
170
171 # The change of u_char, etc, to u_int
172 # applies to bit fields.
173 sed -e '
174 s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
175 s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
176 s/#lint(on)/defined(lint)/g
177 s/#lint(off)/!defined(lint)/g
178 s/#machine(\([^)]*\))/defined(__\1__)/g
179 s/#system(\([^)]*\))/defined(__\1__)/g
180 s/#cpu(\([^)]*\))/defined(__\1__)/g
181 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
182 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
183 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
184 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
185 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
186 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
187 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
188 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
189 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
190 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
191 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
192 s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
193 s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
194 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
195 ' $2/$file > $2/$file.sed
196 mv $2/$file.sed $2/$file
197 if cmp $file $2/$file >/dev/null 2>&1; then
198 rm $2/$file
199 else
200 echo Fixed $file
201 fi
202 fi
203 done
204 shift; shift
205 done
206
207 # Fix first broken decl of getcwd present on some svr4 systems.
208
209 file=stdlib.h
210 base=`basename $file`
211 if [ -r ${LIB}/$file ]; then
212 file_to_fix=${LIB}/$file
213 else
214 if [ -r ${INPUT}/$file ]; then
215 file_to_fix=${INPUT}/$file
216 else
217 file_to_fix=""
218 fi
219 fi
220 if [ \! -z "$file_to_fix" ]; then
221 echo Checking $file_to_fix
222 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
223 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
224 true
225 else
226 echo Fixed $file_to_fix
227 rm -f ${LIB}/$file
228 cp /tmp/$base ${LIB}/$file
229 chmod a+r ${LIB}/$file
230 fi
231 rm -f /tmp/$base
232 fi
233
234 # Fix second broken decl of getcwd present on some svr4 systems. Also
235 # fix the incorrect decl of profil present on some svr4 systems.
236
237 file=unistd.h
238 base=`basename $file`
239 if [ -r ${LIB}/$file ]; then
240 file_to_fix=${LIB}/$file
241 else
242 if [ -r ${INPUT}/$file ]; then
243 file_to_fix=${INPUT}/$file
244 else
245 file_to_fix=""
246 fi
247 fi
248 if [ \! -z "$file_to_fix" ]; then
249 echo Checking $file_to_fix
250 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
251 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
252 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
253 true
254 else
255 echo Fixed $file_to_fix
256 rm -f ${LIB}/$file
257 cp /tmp/$base ${LIB}/$file
258 chmod a+r ${LIB}/$file
259 fi
260 rm -f /tmp/$base
261 fi
262
263 # Fix the definition of NULL in <sys/param.h> so that it is conditional
264 # and so that it is correct for both C and C++.
265
266 file=sys/param.h
267 base=`basename $file`
268 if [ -r ${LIB}/$file ]; then
269 file_to_fix=${LIB}/$file
270 else
271 if [ -r ${INPUT}/$file ]; then
272 file_to_fix=${INPUT}/$file
273 else
274 file_to_fix=""
275 fi
276 fi
277 if [ \! -z "$file_to_fix" ]; then
278 echo Checking $file_to_fix
279 cp $file_to_fix /tmp/$base
280 chmod +w /tmp/$base
281 chmod a+r /tmp/$base
282 ex /tmp/$base <<EOF
283 /^#define[ ]*NULL[ ]*0$/c
284 #ifndef NULL
285 #ifdef __cplusplus
286 #define __NULL_TYPE
287 #else /* !defined(__cplusplus) */
288 #define __NULL_TYPE (void *)
289 #endif /* !defined(__cplusplus) */
290 #define NULL (__NULL_TYPE 0)
291 #endif /* !defined(NULL) */
292 .
293 wq
294 EOF
295 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
296 true
297 else
298 echo Fixed $file_to_fix
299 rm -f ${LIB}/$file
300 cp /tmp/$base ${LIB}/$file
301 chmod a+r ${LIB}/$file
302 fi
303 rm -f /tmp/$base
304 fi
305
306 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
307 # and so that it is correct for both C and C++.
308
309 file=stdio.h
310 base=`basename $file`
311 if [ -r ${LIB}/$file ]; then
312 file_to_fix=${LIB}/$file
313 else
314 if [ -r ${INPUT}/$file ]; then
315 file_to_fix=${INPUT}/$file
316 else
317 file_to_fix=""
318 fi
319 fi
320 if [ \! -z "$file_to_fix" ]; then
321 echo Checking $file_to_fix
322 cp $file_to_fix /tmp/$base
323 chmod +w /tmp/$base
324 ex /tmp/$base <<EOF
325 /^#define[ ]*NULL[ ]*0$/c
326 #ifdef __cplusplus
327 #define __NULL_TYPE
328 #else /* !defined(__cplusplus) */
329 #define __NULL_TYPE (void *)
330 #endif /* !defined(__cplusplus) */
331 #define NULL (__NULL_TYPE 0)
332 .
333 wq
334 EOF
335 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
336 true
337 else
338 echo Fixed $file_to_fix
339 rm -f ${LIB}/$file
340 cp /tmp/$base ${LIB}/$file
341 chmod a+r ${LIB}/$file
342 fi
343 rm -f /tmp/$base
344 fi
345
346 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
347 # and so that it is correct for both C and C++.
348
349 file=dbm.h
350 base=`basename $file`
351 if [ -r ${LIB}/$file ]; then
352 file_to_fix=${LIB}/$file
353 else
354 if [ -r ${INPUT}/$file ]; then
355 file_to_fix=${INPUT}/$file
356 else
357 file_to_fix=""
358 fi
359 fi
360 if [ \! -z "$file_to_fix" ]; then
361 echo Checking $file_to_fix
362 cp $file_to_fix /tmp/$base
363 chmod +w /tmp/$base
364 ex /tmp/$base <<EOF
365 /^#define[ ]*NULL[ ]*((char \*) 0)$/c
366 #ifndef NULL
367 #ifdef __cplusplus
368 #define __NULL_TYPE
369 #else /* !defined(__cplusplus) */
370 #define __NULL_TYPE (void *)
371 #endif /* !defined(__cplusplus) */
372 #define NULL (__NULL_TYPE 0)
373 #endif /* !defined(NULL) */
374 .
375 wq
376 EOF
377 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
378 true
379 else
380 echo Fixed $file_to_fix
381 rm -f ${LIB}/$file
382 cp /tmp/$base ${LIB}/$file
383 chmod a+r ${LIB}/$file
384 fi
385 rm -f /tmp/$base
386 fi
387
388 # Add a prototyped declaration of mmap to <sys/mman.h>.
389
390 file=sys/mman.h
391 base=`basename $file`
392 if [ -r ${LIB}/$file ]; then
393 file_to_fix=${LIB}/$file
394 else
395 if [ -r ${INPUT}/$file ]; then
396 file_to_fix=${INPUT}/$file
397 else
398 file_to_fix=""
399 fi
400 fi
401 if [ \! -z "$file_to_fix" ]; then
402 echo Checking $file_to_fix
403 cp $file_to_fix /tmp/$base
404 chmod +w /tmp/$base
405 ex /tmp/$base <<EOF
406 /^extern caddr_t mmap();$/c
407 #ifdef __STDC__
408 extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,
409 int fd, off_t off);
410 #else /* !defined(__STDC__) */
411 extern caddr_t mmap ();
412 #endif /* !defined(__STDC__) */
413 .
414 wq
415 EOF
416 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
417 true
418 else
419 echo Fixed $file_to_fix
420 rm -f ${LIB}/$file
421 cp /tmp/$base ${LIB}/$file
422 chmod a+r ${LIB}/$file
423 fi
424 rm -f /tmp/$base
425 fi
426
427 # Fix declarations of `ftw' and `nftw' in <ftw.h>.
428
429 file=ftw.h
430 base=`basename $file`
431 if [ -r ${LIB}/$file ]; then
432 file_to_fix=${LIB}/$file
433 else
434 if [ -r ${INPUT}/$file ]; then
435 file_to_fix=${INPUT}/$file
436 else
437 file_to_fix=""
438 fi
439 fi
440 if [ \! -z "$file_to_fix" ]; then
441 echo Checking $file_to_fix
442 cp $file_to_fix /tmp/$base
443 chmod +w /tmp/$base
444 ex /tmp/$base <<EOF
445 /^extern int ftw(const/c
446 #if !defined(_STYPES)
447 static
448 #else
449 extern
450 #endif
451 int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
452 .
453 /^extern int nftw/c
454 #if defined(_STYPES)
455 static
456 #else
457 extern
458 #endif
459 int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);
460 .
461 /^extern int ftw(),/c
462 #if !defined(_STYPES)
463 static
464 #else
465 extern
466 #endif
467 int ftw();
468 #if defined(_STYPES)
469 static
470 #else
471 extern
472 #endif
473 int nftw();
474 .
475 wq
476 EOF
477 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
478 true
479 else
480 echo Fixed $file_to_fix
481 rm -f ${LIB}/$file
482 cp /tmp/$base ${LIB}/$file
483 chmod a+r ${LIB}/$file
484 fi
485 rm -f /tmp/$base
486 fi
487
488 # Add a `static' declaration of `getrnge' into <regexp.h>.
489
490 # Don't do this if there is already a `static void getrnge' declaration
491 # present, since this would cause a redeclaration error. Solaris 2.x has
492 # such a declaration.
493
494 file=regexp.h
495 base=`basename $file`
496 if [ -r ${LIB}/$file ]; then
497 file_to_fix=${LIB}/$file
498 else
499 if [ -r ${INPUT}/$file ]; then
500 file_to_fix=${INPUT}/$file
501 else
502 file_to_fix=""
503 fi
504 fi
505 if [ \! -z "$file_to_fix" ]; then
506 echo Checking $file_to_fix
507 if grep "static void getrnge" $file_to_fix > /dev/null; then
508 true
509 else
510 cp $file_to_fix /tmp/$base
511 chmod +w /tmp/$base
512 ex /tmp/$base <<EOF
513 /^static int[ ]*size;/c
514 static int size ;
515
516 static int getrnge ();
517 .
518 wq
519 EOF
520 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
521 true
522 else
523 echo Fixed $file_to_fix
524 rm -f ${LIB}/$file
525 cp /tmp/$base ${LIB}/$file
526 chmod a+r ${LIB}/$file
527 fi
528 fi
529 rm -f /tmp/$base
530 fi
531
532 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
533 # that is visible to any ANSI compiler using this include. Simply
534 # delete the lines the #define some string functions to internal forms.
535
536 file=string.h
537 base=`basename $file`
538 if [ -r ${LIB}/$file ]; then
539 file_to_fix=${LIB}/$file
540 else
541 if [ -r ${INPUT}/$file ]; then
542 file_to_fix=${INPUT}/$file
543 else
544 file_to_fix=""
545 fi
546 fi
547 if [ \! -z "$file_to_fix" ]; then
548 echo Checking $file_to_fix
549 cp $file_to_fix /tmp/$base
550 chmod +w /tmp/$base
551 ex /tmp/$base <<EOF
552 g/#define.*__std_hdr_/d
553 wq
554 EOF
555 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
556 true
557 else
558 echo Fixed $file_to_fix
559 rm -f ${LIB}/$file
560 cp /tmp/$base ${LIB}/$file
561 chmod a+r ${LIB}/$file
562 fi
563 rm -f /tmp/$base
564 fi
565
566 # Add a #define of _SIGACTION_ into <sys/signal.h>.
567 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
568
569 file=sys/signal.h
570 base=`basename $file`
571 if [ -r ${LIB}/$file ]; then
572 file_to_fix=${LIB}/$file
573 else
574 if [ -r ${INPUT}/$file ]; then
575 file_to_fix=${INPUT}/$file
576 else
577 file_to_fix=""
578 fi
579 fi
580 if [ \! -z "$file_to_fix" ]; then
581 echo Checking $file_to_fix
582 cp $file_to_fix /tmp/$base
583 chmod +w /tmp/$base
584 ex /tmp/$base <<EOF
585 /^struct sigaction {/c
586 #define _SIGACTION_
587 struct sigaction {
588 .
589 1,\$s/(void *(\*)())/(void (*)(int))/
590 wq
591 EOF
592 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
593 true
594 else
595 echo Fixed $file_to_fix
596 rm -f ${LIB}/$file
597 cp /tmp/$base ${LIB}/$file
598 chmod a+r ${LIB}/$file
599 fi
600 rm -f /tmp/$base
601 fi
602
603 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
604
605 file=sys/mkdev.h
606 base=`basename $file`
607 if [ -r ${LIB}/$file ]; then
608 file_to_fix=${LIB}/$file
609 else
610 if [ -r ${INPUT}/$file ]; then
611 file_to_fix=${INPUT}/$file
612 else
613 file_to_fix=""
614 fi
615 fi
616 if [ \! -z "$file_to_fix" ]; then
617 echo Checking $file_to_fix
618 cp $file_to_fix /tmp/$base
619 chmod +w /tmp/$base
620 ex /tmp/$base <<EOF
621 /^dev_t makedev(const/c
622 static dev_t makedev(const major_t, const minor_t);
623 .
624 /^dev_t makedev()/c
625 static dev_t makedev();
626 .
627 /^major_t major(const/c
628 static major_t major(const dev_t);
629 .
630 /^major_t major()/c
631 static major_t major();
632 .
633 /^minor_t minor(const/c
634 static minor_t minor(const dev_t);
635 .
636 /^minor_t minor()/c
637 static minor_t minor();
638 .
639 wq
640 EOF
641 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
642 true
643 else
644 echo Fixed $file_to_fix
645 rm -f ${LIB}/$file
646 cp /tmp/$base ${LIB}/$file
647 chmod a+r ${LIB}/$file
648 fi
649 rm -f /tmp/$base
650 fi
651
652 # Fix reference to NMSZ in <sys/adv.h>.
653
654 file=sys/adv.h
655 base=`basename $file`
656 if [ -r ${LIB}/$file ]; then
657 file_to_fix=${LIB}/$file
658 else
659 if [ -r ${INPUT}/$file ]; then
660 file_to_fix=${INPUT}/$file
661 else
662 file_to_fix=""
663 fi
664 fi
665 if [ \! -z "$file_to_fix" ]; then
666 echo Checking $file_to_fix
667 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
668 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
669 true
670 else
671 echo Fixed $file_to_fix
672 rm -f ${LIB}/$file
673 cp /tmp/$base ${LIB}/$file
674 chmod a+r ${LIB}/$file
675 fi
676 rm -f /tmp/$base
677 fi
678
679 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
680 # array initializers.
681
682 file=sys/netcspace.h
683 base=`basename $file`
684 if [ -r ${LIB}/$file ]; then
685 file_to_fix=${LIB}/$file
686 else
687 if [ -r ${INPUT}/$file ]; then
688 file_to_fix=${INPUT}/$file
689 else
690 file_to_fix=""
691 fi
692 fi
693 if [ \! -z "$file_to_fix" ]; then
694 echo Checking $file_to_fix
695 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
696 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
697 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
698 true
699 else
700 echo Fixed $file_to_fix
701 rm -f ${LIB}/$file
702 cp /tmp/$base ${LIB}/$file
703 chmod a+r ${LIB}/$file
704 fi
705 rm -f /tmp/$base
706 fi
707
708 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
709
710 file=fs/rfs/rf_cache.h
711 base=`basename $file`
712 if [ -r ${LIB}/$file ]; then
713 file_to_fix=${LIB}/$file
714 else
715 if [ -r ${INPUT}/$file ]; then
716 file_to_fix=${INPUT}/$file
717 else
718 file_to_fix=""
719 fi
720 fi
721 if [ \! -z "$file_to_fix" ]; then
722 echo Checking $file_to_fix
723 if grep _KERNEL $file_to_fix > /dev/null; then
724 true
725 else
726 echo '#ifdef _KERNEL' > /tmp/$base
727 cat $file_to_fix >> /tmp/$base
728 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
729 echo Fixed $file_to_fix
730 rm -f ${LIB}/$file
731 cp /tmp/$base ${LIB}/$file
732 chmod a+r ${LIB}/$file
733 rm -f /tmp/$base
734 fi
735 fi
736
737 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
738
739 file=sys/erec.h
740 base=`basename $file`
741 if [ -r ${LIB}/$file ]; then
742 file_to_fix=${LIB}/$file
743 else
744 if [ -r ${INPUT}/$file ]; then
745 file_to_fix=${INPUT}/$file
746 else
747 file_to_fix=""
748 fi
749 fi
750 if [ \! -z "$file_to_fix" ]; then
751 echo Checking $file_to_fix
752 if grep _KERNEL $file_to_fix > /dev/null; then
753 true
754 else
755 echo '#ifdef _KERNEL' > /tmp/$base
756 cat $file_to_fix >> /tmp/$base
757 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
758 echo Fixed $file_to_fix
759 rm -f ${LIB}/$file
760 cp /tmp/$base ${LIB}/$file
761 chmod a+r ${LIB}/$file
762 rm -f /tmp/$base
763 fi
764 fi
765
766 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
767
768 file=sys/err.h
769 base=`basename $file`
770 if [ -r ${LIB}/$file ]; then
771 file_to_fix=${LIB}/$file
772 else
773 if [ -r ${INPUT}/$file ]; then
774 file_to_fix=${INPUT}/$file
775 else
776 file_to_fix=""
777 fi
778 fi
779 if [ \! -z "$file_to_fix" ]; then
780 echo Checking $file_to_fix
781 if grep _KERNEL $file_to_fix > /dev/null; then
782 true
783 else
784 echo '#ifdef _KERNEL' > /tmp/$base
785 cat $file_to_fix >> /tmp/$base
786 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
787 echo Fixed $file_to_fix
788 rm -f ${LIB}/$file
789 cp /tmp/$base ${LIB}/$file
790 chmod a+r ${LIB}/$file
791 rm -f /tmp/$base
792 fi
793 fi
794
795 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
796
797 file=sys/char.h
798 base=`basename $file`
799 if [ -r ${LIB}/$file ]; then
800 file_to_fix=${LIB}/$file
801 else
802 if [ -r ${INPUT}/$file ]; then
803 file_to_fix=${INPUT}/$file
804 else
805 file_to_fix=""
806 fi
807 fi
808 if [ \! -z "$file_to_fix" ]; then
809 echo Checking $file_to_fix
810 if grep _KERNEL $file_to_fix > /dev/null; then
811 true
812 else
813 echo '#ifdef _KERNEL' > /tmp/$base
814 cat $file_to_fix >> /tmp/$base
815 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
816 echo Fixed $file_to_fix
817 rm -f ${LIB}/$file
818 cp /tmp/$base ${LIB}/$file
819 chmod a+r ${LIB}/$file
820 rm -f /tmp/$base
821 fi
822 fi
823
824 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
825
826 file=sys/getpages.h
827 base=`basename $file`
828 if [ -r ${LIB}/$file ]; then
829 file_to_fix=${LIB}/$file
830 else
831 if [ -r ${INPUT}/$file ]; then
832 file_to_fix=${INPUT}/$file
833 else
834 file_to_fix=""
835 fi
836 fi
837 if [ \! -z "$file_to_fix" ]; then
838 echo Checking $file_to_fix
839 if grep _KERNEL $file_to_fix > /dev/null; then
840 true
841 else
842 echo '#ifdef _KERNEL' > /tmp/$base
843 cat $file_to_fix >> /tmp/$base
844 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
845 echo Fixed $file_to_fix
846 rm -f ${LIB}/$file
847 cp /tmp/$base ${LIB}/$file
848 chmod a+r ${LIB}/$file
849 rm -f /tmp/$base
850 fi
851 fi
852
853 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
854
855 file=sys/map.h
856 base=`basename $file`
857 if [ -r ${LIB}/$file ]; then
858 file_to_fix=${LIB}/$file
859 else
860 if [ -r ${INPUT}/$file ]; then
861 file_to_fix=${INPUT}/$file
862 else
863 file_to_fix=""
864 fi
865 fi
866 if [ \! -z "$file_to_fix" ]; then
867 echo Checking $file_to_fix
868 if grep _KERNEL $file_to_fix > /dev/null; then
869 true
870 else
871 echo '#ifdef _KERNEL' > /tmp/$base
872 cat $file_to_fix >> /tmp/$base
873 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
874 echo Fixed $file_to_fix
875 rm -f ${LIB}/$file
876 cp /tmp/$base ${LIB}/$file
877 chmod a+r ${LIB}/$file
878 rm -f /tmp/$base
879 fi
880 fi
881
882 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
883
884 file=sys/cmn_err.h
885 base=`basename $file`
886 if [ -r ${LIB}/$file ]; then
887 file_to_fix=${LIB}/$file
888 else
889 if [ -r ${INPUT}/$file ]; then
890 file_to_fix=${INPUT}/$file
891 else
892 file_to_fix=""
893 fi
894 fi
895 if [ \! -z "$file_to_fix" ]; then
896 echo Checking $file_to_fix
897 if grep _KERNEL $file_to_fix > /dev/null; then
898 true
899 else
900 echo '#ifdef _KERNEL' > /tmp/$base
901 cat $file_to_fix >> /tmp/$base
902 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
903 echo Fixed $file_to_fix
904 rm -f ${LIB}/$file
905 cp /tmp/$base ${LIB}/$file
906 chmod a+r ${LIB}/$file
907 rm -f /tmp/$base
908 fi
909 fi
910
911 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
912
913 file=sys/kdebugger.h
914 base=`basename $file`
915 if [ -r ${LIB}/$file ]; then
916 file_to_fix=${LIB}/$file
917 else
918 if [ -r ${INPUT}/$file ]; then
919 file_to_fix=${INPUT}/$file
920 else
921 file_to_fix=""
922 fi
923 fi
924 if [ \! -z "$file_to_fix" ]; then
925 echo Checking $file_to_fix
926 if grep _KERNEL $file_to_fix > /dev/null; then
927 true
928 else
929 echo '#ifdef _KERNEL' > /tmp/$base
930 cat $file_to_fix >> /tmp/$base
931 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
932 echo Fixed $file_to_fix
933 rm -f ${LIB}/$file
934 cp /tmp/$base ${LIB}/$file
935 chmod a+r ${LIB}/$file
936 rm -f /tmp/$base
937 fi
938 fi
939
940 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
941
942 file=netinet/in.h
943 base=`basename $file`
944 if [ -r ${LIB}/$file ]; then
945 file_to_fix=${LIB}/$file
946 else
947 if [ -r ${INPUT}/$file ]; then
948 file_to_fix=${INPUT}/$file
949 else
950 file_to_fix=""
951 fi
952 fi
953 if [ \! -z "$file_to_fix" ]; then
954 echo Checking $file_to_fix
955 if grep _KERNEL $file_to_fix > /dev/null; then
956 true
957 else
958 sed -e '/#ifdef INKERNEL/i\
959 #ifdef _KERNEL' \
960 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
961 #endif /* _KERNEL */' \
962 $file_to_fix > ${LIB}/${file}.sed
963 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
964 echo Fixed $file_to_fix
965 fi
966 fi
967
968 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
969
970 file=sys/endian.h
971 base=`basename $file`
972 if [ -r ${LIB}/$file ]; then
973 file_to_fix=${LIB}/$file
974 else
975 if [ -r ${INPUT}/$file ]; then
976 file_to_fix=${INPUT}/$file
977 else
978 file_to_fix=""
979 fi
980 fi
981 if [ \! -z "$file_to_fix" ]; then
982 echo Checking $file_to_fix
983 if grep __GNUC__ $file_to_fix > /dev/null; then
984 true
985 else
986 sed -e '/# ifdef __STDC__/i\
987 # if !defined (__GNUC__) && !defined (__GNUG__)' \
988 -e '/# include <sys\/byteorder.h>/s/ / /'\
989 -e '/# include <sys\/byteorder.h>/i\
990 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
991 $file_to_fix > ${LIB}/${file}.sed
992 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
993 echo Fixed $file_to_fix
994 fi
995 fi
996
997 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
998 # and the text in types.h is not erroneous.
999 ## In sys/types.h, don't name the enum for booleans.
1000 #
1001 #file=sys/types.h
1002 #base=`basename $file`
1003 #if [ -r ${LIB}/$file ]; then
1004 # file_to_fix=${LIB}/$file
1005 #else
1006 # if [ -r ${INPUT}/$file ]; then
1007 # file_to_fix=${INPUT}/$file
1008 # else
1009 # file_to_fix=""
1010 # fi
1011 #fi
1012 #if [ \! -z "$file_to_fix" ]; then
1013 # echo Checking $file_to_fix
1014 # if grep "enum boolean" $file_to_fix > /dev/null; then
1015 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1016 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1017 # echo Fixed $file_to_fix
1018 # else
1019 # true
1020 # fi
1021 #fi
1022
1023 # Remove useless extern keyword from struct forward declarations in
1024 # <sys/stream.h> and <sys/strsubr.h>
1025
1026 file=sys/stream.h
1027 base=`basename $file`
1028 if [ -r ${LIB}/$file ]; then
1029 file_to_fix=${LIB}/$file
1030 else
1031 if [ -r ${INPUT}/$file ]; then
1032 file_to_fix=${INPUT}/$file
1033 else
1034 file_to_fix=""
1035 fi
1036 fi
1037 if [ \! -z "$file_to_fix" ]; then
1038 echo Checking $file_to_fix
1039 sed -e '
1040 s/extern struct stdata;/struct stdata;/g
1041 s/extern struct strevent;/struct strevent;/g
1042 ' $file_to_fix > /tmp/$base
1043 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1044 true
1045 else
1046 echo Fixed $file_to_fix
1047 rm -f ${LIB}/$file
1048 cp /tmp/$base ${LIB}/$file
1049 chmod a+r ${LIB}/$file
1050 fi
1051 rm -f /tmp/$base
1052 fi
1053
1054 file=sys/strsubr.h
1055 base=`basename $file`
1056 if [ -r ${LIB}/$file ]; then
1057 file_to_fix=${LIB}/$file
1058 else
1059 if [ -r ${INPUT}/$file ]; then
1060 file_to_fix=${INPUT}/$file
1061 else
1062 file_to_fix=""
1063 fi
1064 fi
1065 if [ \! -z "$file_to_fix" ]; then
1066 echo Checking $file_to_fix
1067 sed -e '
1068 s/extern struct strbuf;/struct strbuf;/g
1069 s/extern struct uio;/struct uio;/g
1070 s/extern struct thread;/struct thread;/g
1071 s/extern struct proc;/struct proc;/g
1072 ' $file_to_fix > /tmp/$base
1073 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1074 true
1075 else
1076 echo Fixed $file_to_fix
1077 rm -f ${LIB}/$file
1078 cp /tmp/$base ${LIB}/$file
1079 chmod a+r ${LIB}/$file
1080 fi
1081 rm -f /tmp/$base
1082 fi
1083
1084 # Put storage class at start of decl, to avoid warning.
1085 file=rpc/types.h
1086 base=`basename $file`
1087 if [ -r ${LIB}/$file ]; then
1088 file_to_fix=${LIB}/$file
1089 else
1090 if [ -r ${INPUT}/$file ]; then
1091 file_to_fix=${INPUT}/$file
1092 else
1093 file_to_fix=""
1094 fi
1095 fi
1096 if [ \! -z "$file_to_fix" ]; then
1097 echo Checking $file_to_fix
1098 sed -e '
1099 s/const extern/extern const/g
1100 ' $file_to_fix > /tmp/$base
1101 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1102 true
1103 else
1104 echo Fixed $file_to_fix
1105 rm -f ${LIB}/$file
1106 cp /tmp/$base ${LIB}/$file
1107 chmod a+r ${LIB}/$file
1108 fi
1109 rm -f /tmp/$base
1110 fi
1111
1112 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1113
1114 file=sys/stat.h
1115 base=`basename $file`
1116 if [ -r ${LIB}/$file ]; then
1117 file_to_fix=${LIB}/$file
1118 else
1119 if [ -r ${INPUT}/$file ]; then
1120 file_to_fix=${INPUT}/$file
1121 else
1122 file_to_fix=""
1123 fi
1124 fi
1125 if [ \! -z "$file_to_fix" ]; then
1126 echo Checking $file_to_fix
1127 cp $file_to_fix /tmp/$base
1128 chmod +w /tmp/$base
1129 ex /tmp/$base <<EOF
1130 /^stat(/
1131 s/(.*$/(/
1132 j
1133 s/;/,/
1134 j
1135 s/;/)/
1136 /^lstat(/
1137 s/(.*$/(/
1138 j
1139 s/;/,/
1140 j
1141 s/;/)/
1142 /^fstat(/
1143 s/(.*$/(/
1144 j
1145 s/;/,/
1146 j
1147 s/;/)/
1148 /^mknod(/
1149 s/(.*$/(/
1150 j
1151 s/;/,/
1152 j
1153 s/;/,/
1154 j
1155 s/;/)/
1156 1,\$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g
1157 1,\$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g
1158 1,\$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g
1159 1,\$s/ret\([^u]\)/__ret\1/g
1160 1,\$s/\([^_]\)mode\([^_]\)/\1__mode\2/g
1161 1,\$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g
1162 wq
1163 EOF
1164 echo Fixed $file_to_fix
1165 rm -f ${LIB}/$file
1166 cp /tmp/$base ${LIB}/$file
1167 chmod a+r ${LIB}/$file
1168 rm -f /tmp/$base
1169 fi
1170
1171 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1172
1173 if [ -x /bin/sony ]; then
1174 if /bin/sony; then
1175
1176 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1177
1178 file=stdio.h
1179 base=`basename $file`
1180 if [ -r ${LIB}/$file ]; then
1181 file_to_fix=${LIB}/$file
1182 else
1183 if [ -r ${INPUT}/$file ]; then
1184 file_to_fix=${INPUT}/$file
1185 else
1186 file_to_fix=""
1187 fi
1188 fi
1189 if [ \! -z "$file_to_fix" ]; then
1190 echo Checking $file_to_fix
1191 cp $file_to_fix /tmp/$base
1192 chmod +w /tmp/$base
1193 sed -e '
1194 s/__filbuf/_filbuf/g
1195 s/__flsbuf/_flsbuf/g
1196 s/__iob/_iob/g
1197 ' /tmp/$base > /tmp/$base.sed
1198 mv /tmp/$base.sed /tmp/$base
1199 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1200 true
1201 else
1202 echo Fixed $file_to_fix
1203 rm -f ${LIB}/$file
1204 cp /tmp/$base ${LIB}/$file
1205 chmod a+r ${LIB}/$file
1206 fi
1207 rm -f /tmp/$base
1208 fi
1209
1210 # Change <ctype.h> to not define __ctype
1211
1212 file=ctype.h
1213 base=`basename $file`
1214 if [ -r ${LIB}/$file ]; then
1215 file_to_fix=${LIB}/$file
1216 else
1217 if [ -r ${INPUT}/$file ]; then
1218 file_to_fix=${INPUT}/$file
1219 else
1220 file_to_fix=""
1221 fi
1222 fi
1223 if [ \! -z "$file_to_fix" ]; then
1224 echo Checking $file_to_fix
1225 cp $file_to_fix /tmp/$base
1226 chmod +w /tmp/$base
1227 sed -e '
1228 s/__ctype/_ctype/g
1229 ' /tmp/$base > /tmp/$base.sed
1230 mv /tmp/$base.sed /tmp/$base
1231 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1232 true
1233 else
1234 echo Fixed $file_to_fix
1235 rm -f ${LIB}/$file
1236 cp /tmp/$base ${LIB}/$file
1237 chmod a+r ${LIB}/$file
1238 fi
1239 rm -f /tmp/$base
1240 fi
1241 fi
1242 fi
1243
1244 # In limits.h, put #ifndefs around things that are supposed to be defined
1245 # in float.h to avoid redefinition errors if float.h is included first.
1246 # Solaris 2.1 has this problem.
1247
1248 file=limits.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 sed -e '/[ ]FLT_MIN[ ]/i\
1262 #ifndef FLT_MIN'\
1263 -e '/[ ]FLT_MIN[ ]/a\
1264 #endif'\
1265 -e '/[ ]FLT_MAX[ ]/i\
1266 #ifndef FLT_MAX'\
1267 -e '/[ ]FLT_MAX[ ]/a\
1268 #endif'\
1269 -e '/[ ]FLT_DIG[ ]/i\
1270 #ifndef FLT_DIG'\
1271 -e '/[ ]FLT_DIG[ ]/a\
1272 #endif'\
1273 -e '/[ ]DBL_MIN[ ]/i\
1274 #ifndef DBL_MIN'\
1275 -e '/[ ]DBL_MIN[ ]/a\
1276 #endif'\
1277 -e '/[ ]DBL_MAX[ ]/i\
1278 #ifndef DBL_MAX'\
1279 -e '/[ ]DBL_MAX[ ]/a\
1280 #endif'\
1281 -e '/[ ]DBL_DIG[ ]/i\
1282 #ifndef DBL_DIG'\
1283 -e '/[ ]DBL_DIG[ ]/a\
1284 #endif' $file_to_fix > /tmp/$base
1285 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1286 true
1287 else
1288 echo Fixed $file_to_fix
1289 rm -f ${LIB}/$file
1290 cp /tmp/$base ${LIB}/$file
1291 chmod a+r ${LIB}/$file
1292 fi
1293 rm -f /tmp/$base
1294 fi
1295
1296 echo 'Removing unneeded directories:'
1297 cd $LIB
1298 files=`find . -type d -print | sort -r`
1299 for file in $files; do
1300 rmdir $LIB/$file > /dev/null 2>&1
1301 done
1302
1303 if $LINKS; then
1304 echo 'Making internal symbolic non-directory links'
1305 cd ${INPUT}
1306 files=`find . -type l -print`
1307 for file in $files; do
1308 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1309 if expr "$dest" : '[^/].*' > /dev/null; then
1310 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1311 if [ -f $target ]; then
1312 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1313 fi
1314 fi
1315 done
1316 fi
1317
1318 cd ${ORIG_DIR}
1319
1320 echo 'Replacing <sys/byteorder.h>'
1321 rm -f ${LIB}/sys/byteorder.h
1322 cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h
1323
1324 exit 0
1325
This page took 0.110307 seconds and 6 git commands to generate.