]> gcc.gnu.org Git - gcc.git/blob - gcc/fixinc.svr4
Correct the modification of endian.h.
[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 # Don't do this if there is already a `static void getrnge' declaration
471 # present, since this would cause a redeclaration error. Solaris 2.x has
472 # such a declaration.
473
474 file=regexp.h
475 base=`basename $file`
476 if [ -r ${LIB}/$file ]; then
477 file_to_fix=${LIB}/$file
478 else
479 if [ -r ${INPUT}/$file ]; then
480 file_to_fix=${INPUT}/$file
481 else
482 file_to_fix=""
483 fi
484 fi
485 if [ \! -z "$file_to_fix" ]; then
486 echo Checking $file_to_fix
487 if grep "static void getrnge" $file_to_fix > /dev/null; then
488 true
489 else
490 cp $file_to_fix /tmp/$base
491 chmod +w /tmp/$base
492 ex /tmp/$base <<EOF
493 /^static int[ ]*size;/c
494 static int size ;
495
496 static int getrnge ();
497 .
498 wq
499 EOF
500 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
501 No change needed in $file_to_fix
502 else
503 echo Fixed $file_to_fix
504 rm -f ${LIB}/$file
505 cp /tmp/$base ${LIB}/$file
506 fi
507 fi
508 rm -f /tmp/$base
509 fi
510
511 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
512 # that is visible to any ANSI compiler using this include. Simply
513 # delete the lines the #define some string functions to internal forms.
514
515 file=string.h
516 base=`basename $file`
517 if [ -r ${LIB}/$file ]; then
518 file_to_fix=${LIB}/$file
519 else
520 if [ -r ${INPUT}/$file ]; then
521 file_to_fix=${INPUT}/$file
522 else
523 file_to_fix=""
524 fi
525 fi
526 if [ \! -z "$file_to_fix" ]; then
527 echo Checking $file_to_fix
528 cp $file_to_fix /tmp/$base
529 chmod +w /tmp/$base
530 ex /tmp/$base <<EOF
531 g/#define.*__std_hdr_/d
532 wq
533 EOF
534 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
535 echo No change needed in $file_to_fix
536 else
537 echo Fixed $file_to_fix
538 rm -f ${LIB}/$file
539 cp /tmp/$base ${LIB}/$file
540 fi
541 rm -f /tmp/$base
542 fi
543
544 # Add a #define of _SIGACTION_ into <sys/signal.h>.
545 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
546
547 file=sys/signal.h
548 base=`basename $file`
549 if [ -r ${LIB}/$file ]; then
550 file_to_fix=${LIB}/$file
551 else
552 if [ -r ${INPUT}/$file ]; then
553 file_to_fix=${INPUT}/$file
554 else
555 file_to_fix=""
556 fi
557 fi
558 if [ \! -z "$file_to_fix" ]; then
559 echo Checking $file_to_fix
560 cp $file_to_fix /tmp/$base
561 chmod +w /tmp/$base
562 ex /tmp/$base <<EOF
563 /^struct sigaction {/c
564 #define _SIGACTION_
565 struct sigaction {
566 .
567 1,\$s/(void *(\*)())/(void (*)(int))/
568 wq
569 EOF
570 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
571 echo No change needed in $file_to_fix
572 else
573 echo Fixed $file_to_fix
574 rm -f ${LIB}/$file
575 cp /tmp/$base ${LIB}/$file
576 fi
577 rm -f /tmp/$base
578 fi
579
580 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
581
582 file=sys/mkdev.h
583 base=`basename $file`
584 if [ -r ${LIB}/$file ]; then
585 file_to_fix=${LIB}/$file
586 else
587 if [ -r ${INPUT}/$file ]; then
588 file_to_fix=${INPUT}/$file
589 else
590 file_to_fix=""
591 fi
592 fi
593 if [ \! -z "$file_to_fix" ]; then
594 echo Checking $file_to_fix
595 cp $file_to_fix /tmp/$base
596 chmod +w /tmp/$base
597 ex /tmp/$base <<EOF
598 /^dev_t makedev(const/c
599 static dev_t makedev(const major_t, const minor_t);
600 .
601 /^dev_t makedev()/c
602 static dev_t makedev();
603 .
604 /^major_t major(const/c
605 static major_t major(const dev_t);
606 .
607 /^major_t major()/c
608 static major_t major();
609 .
610 /^minor_t minor(const/c
611 static minor_t minor(const dev_t);
612 .
613 /^minor_t minor()/c
614 static minor_t minor();
615 .
616 wq
617 EOF
618 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
619 echo No change needed in $file_to_fix
620 else
621 echo Fixed $file_to_fix
622 rm -f ${LIB}/$file
623 cp /tmp/$base ${LIB}/$file
624 fi
625 rm -f /tmp/$base
626 fi
627
628 # Fix reference to NMSZ in <sys/adv.h>.
629
630 file=sys/adv.h
631 base=`basename $file`
632 if [ -r ${LIB}/$file ]; then
633 file_to_fix=${LIB}/$file
634 else
635 if [ -r ${INPUT}/$file ]; then
636 file_to_fix=${INPUT}/$file
637 else
638 file_to_fix=""
639 fi
640 fi
641 if [ \! -z "$file_to_fix" ]; then
642 echo Checking $file_to_fix
643 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
644 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
645 echo No change needed in $file_to_fix
646 else
647 echo Fixed $file_to_fix
648 rm -f ${LIB}/$file
649 cp /tmp/$base ${LIB}/$file
650 fi
651 rm -f /tmp/$base
652 fi
653
654 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
655 # array initializers.
656
657 file=sys/netcspace.h
658 base=`basename $file`
659 if [ -r ${LIB}/$file ]; then
660 file_to_fix=${LIB}/$file
661 else
662 if [ -r ${INPUT}/$file ]; then
663 file_to_fix=${INPUT}/$file
664 else
665 file_to_fix=""
666 fi
667 fi
668 if [ \! -z "$file_to_fix" ]; then
669 echo Checking $file_to_fix
670 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
671 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
672 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
673 echo No change needed in $file_to_fix
674 else
675 echo Fixed $file_to_fix
676 rm -f ${LIB}/$file
677 cp /tmp/$base ${LIB}/$file
678 fi
679 rm -f /tmp/$base
680 fi
681
682 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
683
684 file=fs/rfs/rf_cache.h
685 base=`basename $file`
686 if [ -r ${LIB}/$file ]; then
687 file_to_fix=${LIB}/$file
688 else
689 if [ -r ${INPUT}/$file ]; then
690 file_to_fix=${INPUT}/$file
691 else
692 file_to_fix=""
693 fi
694 fi
695 if [ \! -z "$file_to_fix" ]; then
696 echo Checking $file_to_fix
697 if grep _KERNEL $file_to_fix > /dev/null; then
698 echo No change needed in $file_to_fix
699 else
700 echo '#ifdef _KERNEL' > /tmp/$base
701 cat $file_to_fix >> /tmp/$base
702 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
703 echo Fixed $file_to_fix
704 rm -f ${LIB}/$file
705 cp /tmp/$base ${LIB}/$file
706 rm -f /tmp/$base
707 fi
708 fi
709
710 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
711
712 file=sys/erec.h
713 base=`basename $file`
714 if [ -r ${LIB}/$file ]; then
715 file_to_fix=${LIB}/$file
716 else
717 if [ -r ${INPUT}/$file ]; then
718 file_to_fix=${INPUT}/$file
719 else
720 file_to_fix=""
721 fi
722 fi
723 if [ \! -z "$file_to_fix" ]; then
724 echo Checking $file_to_fix
725 if grep _KERNEL $file_to_fix > /dev/null; then
726 echo No change needed in $file_to_fix
727 else
728 echo '#ifdef _KERNEL' > /tmp/$base
729 cat $file_to_fix >> /tmp/$base
730 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
731 echo Fixed $file_to_fix
732 rm -f ${LIB}/$file
733 cp /tmp/$base ${LIB}/$file
734 rm -f /tmp/$base
735 fi
736 fi
737
738 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
739
740 file=sys/err.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 echo No change needed in $file_to_fix
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 rm -f /tmp/$base
763 fi
764 fi
765
766 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
767
768 file=sys/char.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 echo No change needed in $file_to_fix
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 rm -f /tmp/$base
791 fi
792 fi
793
794 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
795
796 file=sys/getpages.h
797 base=`basename $file`
798 if [ -r ${LIB}/$file ]; then
799 file_to_fix=${LIB}/$file
800 else
801 if [ -r ${INPUT}/$file ]; then
802 file_to_fix=${INPUT}/$file
803 else
804 file_to_fix=""
805 fi
806 fi
807 if [ \! -z "$file_to_fix" ]; then
808 echo Checking $file_to_fix
809 if grep _KERNEL $file_to_fix > /dev/null; then
810 echo No change needed in $file_to_fix
811 else
812 echo '#ifdef _KERNEL' > /tmp/$base
813 cat $file_to_fix >> /tmp/$base
814 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
815 echo Fixed $file_to_fix
816 rm -f ${LIB}/$file
817 cp /tmp/$base ${LIB}/$file
818 rm -f /tmp/$base
819 fi
820 fi
821
822 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
823
824 file=sys/map.h
825 base=`basename $file`
826 if [ -r ${LIB}/$file ]; then
827 file_to_fix=${LIB}/$file
828 else
829 if [ -r ${INPUT}/$file ]; then
830 file_to_fix=${INPUT}/$file
831 else
832 file_to_fix=""
833 fi
834 fi
835 if [ \! -z "$file_to_fix" ]; then
836 echo Checking $file_to_fix
837 if grep _KERNEL $file_to_fix > /dev/null; then
838 echo No change needed in $file_to_fix
839 else
840 echo '#ifdef _KERNEL' > /tmp/$base
841 cat $file_to_fix >> /tmp/$base
842 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
843 echo Fixed $file_to_fix
844 rm -f ${LIB}/$file
845 cp /tmp/$base ${LIB}/$file
846 rm -f /tmp/$base
847 fi
848 fi
849
850 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
851
852 file=sys/cmn_err.h
853 base=`basename $file`
854 if [ -r ${LIB}/$file ]; then
855 file_to_fix=${LIB}/$file
856 else
857 if [ -r ${INPUT}/$file ]; then
858 file_to_fix=${INPUT}/$file
859 else
860 file_to_fix=""
861 fi
862 fi
863 if [ \! -z "$file_to_fix" ]; then
864 echo Checking $file_to_fix
865 if grep _KERNEL $file_to_fix > /dev/null; then
866 echo No change needed in $file_to_fix
867 else
868 echo '#ifdef _KERNEL' > /tmp/$base
869 cat $file_to_fix >> /tmp/$base
870 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
871 echo Fixed $file_to_fix
872 rm -f ${LIB}/$file
873 cp /tmp/$base ${LIB}/$file
874 rm -f /tmp/$base
875 fi
876 fi
877
878 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
879
880 file=sys/kdebugger.h
881 base=`basename $file`
882 if [ -r ${LIB}/$file ]; then
883 file_to_fix=${LIB}/$file
884 else
885 if [ -r ${INPUT}/$file ]; then
886 file_to_fix=${INPUT}/$file
887 else
888 file_to_fix=""
889 fi
890 fi
891 if [ \! -z "$file_to_fix" ]; then
892 echo Checking $file_to_fix
893 if grep _KERNEL $file_to_fix > /dev/null; then
894 echo No change needed in $file_to_fix
895 else
896 echo '#ifdef _KERNEL' > /tmp/$base
897 cat $file_to_fix >> /tmp/$base
898 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
899 echo Fixed $file_to_fix
900 rm -f ${LIB}/$file
901 cp /tmp/$base ${LIB}/$file
902 rm -f /tmp/$base
903 fi
904 fi
905
906 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
907
908 file=netinet/in.h
909 base=`basename $file`
910 if [ -r ${LIB}/$file ]; then
911 file_to_fix=${LIB}/$file
912 else
913 if [ -r ${INPUT}/$file ]; then
914 file_to_fix=${INPUT}/$file
915 else
916 file_to_fix=""
917 fi
918 fi
919 if [ \! -z "$file_to_fix" ]; then
920 echo Checking $file_to_fix
921 if grep _KERNEL $file_to_fix > /dev/null; then
922 echo No change needed in $file_to_fix
923 else
924 sed -e '/#ifdef INKERNEL/i\
925 #ifdef _KERNEL' \
926 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
927 #endif /* _KERNEL */' \
928 $file_to_fix > ${LIB}/${file}.sed
929 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
930 echo Fixed $file_to_fix
931 fi
932 fi
933
934 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
935
936 file=sys/endian.h
937 base=`basename $file`
938 if [ -r ${LIB}/$file ]; then
939 file_to_fix=${LIB}/$file
940 else
941 if [ -r ${INPUT}/$file ]; then
942 file_to_fix=${INPUT}/$file
943 else
944 file_to_fix=""
945 fi
946 fi
947 if [ \! -z "$file_to_fix" ]; then
948 echo Checking $file_to_fix
949 if grep __GNUC__ $file_to_fix > /dev/null; then
950 echo No change needed in $file_to_fix
951 else
952 sed -e '/# ifdef __STDC__/i\
953 # if !defined (__GNUC__) && !defined (__GNUG__)' \
954 -e '/# include <sys\/byteorder.h>/s/ / /'\
955 -e '/# include <sys\/byteorder.h>/i\
956 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
957 $file_to_fix > ${LIB}/${file}.sed
958 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
959 echo Fixed $file_to_fix
960 fi
961 fi
962
963 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
964 # and the text in types.h is not erroneous.
965 ## In sys/types.h, don't name the enum for booleans.
966 #
967 #file=sys/types.h
968 #base=`basename $file`
969 #if [ -r ${LIB}/$file ]; then
970 # file_to_fix=${LIB}/$file
971 #else
972 # if [ -r ${INPUT}/$file ]; then
973 # file_to_fix=${INPUT}/$file
974 # else
975 # file_to_fix=""
976 # fi
977 #fi
978 #if [ \! -z "$file_to_fix" ]; then
979 # echo Checking $file_to_fix
980 # if grep "enum boolean" $file_to_fix > /dev/null; then
981 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
982 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
983 # echo Fixed $file_to_fix
984 # else
985 # echo No change needed in $file_to_fix
986 # fi
987 #fi
988
989 # Remove useless extern keyword from struct forward declarations in
990 # <sys/stream.h> and <sys/strsubr.h>
991
992 file=sys/stream.h
993 base=`basename $file`
994 if [ -r ${LIB}/$file ]; then
995 file_to_fix=${LIB}/$file
996 else
997 if [ -r ${INPUT}/$file ]; then
998 file_to_fix=${INPUT}/$file
999 else
1000 file_to_fix=""
1001 fi
1002 fi
1003 if [ \! -z "$file_to_fix" ]; then
1004 echo Checking $file_to_fix
1005 sed -e '
1006 s/extern struct stdata;/struct stdata;/g
1007 s/extern struct strevent;/struct strevent;/g
1008 ' $file_to_fix > /tmp/$base
1009 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1010 echo No change needed in $file_to_fix
1011 else
1012 echo Fixed $file_to_fix
1013 rm -f ${LIB}/$file
1014 cp /tmp/$base ${LIB}/$file
1015 fi
1016 rm -f /tmp/$base
1017 fi
1018
1019 file=sys/strsubr.h
1020 base=`basename $file`
1021 if [ -r ${LIB}/$file ]; then
1022 file_to_fix=${LIB}/$file
1023 else
1024 if [ -r ${INPUT}/$file ]; then
1025 file_to_fix=${INPUT}/$file
1026 else
1027 file_to_fix=""
1028 fi
1029 fi
1030 if [ \! -z "$file_to_fix" ]; then
1031 echo Checking $file_to_fix
1032 sed -e '
1033 s/extern struct strbuf;/struct strbuf;/g
1034 s/extern struct uio;/struct uio;/g
1035 s/extern struct thread;/struct thread;/g
1036 s/extern struct proc;/struct proc;/g
1037 ' $file_to_fix > /tmp/$base
1038 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1039 echo No change needed in $file_to_fix
1040 else
1041 echo Fixed $file_to_fix
1042 rm -f ${LIB}/$file
1043 cp /tmp/$base ${LIB}/$file
1044 fi
1045 rm -f /tmp/$base
1046 fi
1047
1048 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1049
1050 file=sys/stat.h
1051 base=`basename $file`
1052 if [ -r ${LIB}/$file ]; then
1053 file_to_fix=${LIB}/$file
1054 else
1055 if [ -r ${INPUT}/$file ]; then
1056 file_to_fix=${INPUT}/$file
1057 else
1058 file_to_fix=""
1059 fi
1060 fi
1061 if [ \! -z "$file_to_fix" ]; then
1062 echo Checking $file_to_fix
1063 cp $file_to_fix /tmp/$base
1064 chmod +w /tmp/$base
1065 ex /tmp/$base <<EOF
1066 /^stat(path, buf)/j
1067 j
1068 -
1069 /^stat(path, buf)/c
1070 stat (const char *path, struct stat *buf)
1071 .
1072 /^lstat(path, buf)/j
1073 j
1074 -
1075 /^lstat(path, buf)/c
1076 lstat (const char *path, struct stat *buf)
1077 .
1078 /^fstat(fd, buf)/j
1079 j
1080 -
1081 /^fstat(fd, buf)/c
1082 fstat (int fd, struct stat *buf)
1083 .
1084 /^mknod(path, mode, dev)/j
1085 j
1086 j
1087 -
1088 /^mknod(path, mode, dev)/c
1089 mknod (const char *path, mode_t mode, dev_t dev)
1090 .
1091 1,\$s/path/__path/g
1092 1,\$s/buf/__buf/g
1093 1,\$s/fd/__fd/g
1094 1,\$s/ret\\([^u]\\)/__ret\1/g
1095 1,\$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g
1096 1,\$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g
1097 wq
1098 EOF
1099 echo Fixed $file_to_fix
1100 rm -f ${LIB}/$file
1101 cp /tmp/$base ${LIB}/$file
1102 rm -f /tmp/$base
1103 fi
1104
1105 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1106
1107 if [ -x /bin/sony ]; then
1108 if /bin/sony; then
1109
1110 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1111
1112 file=stdio.h
1113 base=`basename $file`
1114 if [ -r ${LIB}/$file ]; then
1115 file_to_fix=${LIB}/$file
1116 else
1117 if [ -r ${INPUT}/$file ]; then
1118 file_to_fix=${INPUT}/$file
1119 else
1120 file_to_fix=""
1121 fi
1122 fi
1123 if [ \! -z "$file_to_fix" ]; then
1124 echo Checking $file_to_fix
1125 cp $file_to_fix /tmp/$base
1126 chmod +w /tmp/$base
1127 sed -e '
1128 s/__filbuf/_filbuf/g
1129 s/__flsbuf/_flsbuf/g
1130 s/__iob/_iob/g
1131 ' /tmp/$base > /tmp/$base.sed
1132 mv /tmp/$base.sed /tmp/$base
1133 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1134 echo No change needed in $file_to_fix
1135 else
1136 echo Fixed $file_to_fix
1137 rm -f ${LIB}/$file
1138 cp /tmp/$base ${LIB}/$file
1139 fi
1140 rm -f /tmp/$base
1141 fi
1142
1143 # Change <ctype.h> to not define __ctype
1144
1145 file=ctype.h
1146 base=`basename $file`
1147 if [ -r ${LIB}/$file ]; then
1148 file_to_fix=${LIB}/$file
1149 else
1150 if [ -r ${INPUT}/$file ]; then
1151 file_to_fix=${INPUT}/$file
1152 else
1153 file_to_fix=""
1154 fi
1155 fi
1156 if [ \! -z "$file_to_fix" ]; then
1157 echo Checking $file_to_fix
1158 cp $file_to_fix /tmp/$base
1159 chmod +w /tmp/$base
1160 sed -e '
1161 s/__ctype/_ctype/g
1162 ' /tmp/$base > /tmp/$base.sed
1163 mv /tmp/$base.sed /tmp/$base
1164 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1165 echo No change needed in $file_to_fix
1166 else
1167 echo Fixed $file_to_fix
1168 rm -f ${LIB}/$file
1169 cp /tmp/$base ${LIB}/$file
1170 fi
1171 rm -f /tmp/$base
1172 fi
1173 fi
1174 fi
1175
1176 # In limits.h, put #ifndefs around things that are supposed to be defined
1177 # in float.h to avoid redefinition errors if float.h is included first.
1178 # Solaris 2.1 has this problem.
1179
1180 file=limits.h
1181 base=`basename $file`
1182 if [ -r ${LIB}/$file ]; then
1183 file_to_fix=${LIB}/$file
1184 else
1185 if [ -r ${INPUT}/$file ]; then
1186 file_to_fix=${INPUT}/$file
1187 else
1188 file_to_fix=""
1189 fi
1190 fi
1191 if [ \! -z "$file_to_fix" ]; then
1192 echo Checking $file_to_fix
1193 sed -e '/[ ]FLT_MIN[ ]/i\
1194 #ifndef FLT_MIN'\
1195 -e '/[ ]FLT_MIN[ ]/a\
1196 #endif'\
1197 -e '/[ ]FLT_MAX[ ]/i\
1198 #ifndef FLT_MAX'\
1199 -e '/[ ]FLT_MAX[ ]/a\
1200 #endif'\
1201 -e '/[ ]FLT_DIG[ ]/i\
1202 #ifndef FLT_DIG'\
1203 -e '/[ ]FLT_DIG[ ]/a\
1204 #endif'\
1205 -e '/[ ]DBL_MIN[ ]/i\
1206 #ifndef DBL_MIN'\
1207 -e '/[ ]DBL_MIN[ ]/a\
1208 #endif'\
1209 -e '/[ ]DBL_MAX[ ]/i\
1210 #ifndef DBL_MAX'\
1211 -e '/[ ]DBL_MAX[ ]/a\
1212 #endif'\
1213 -e '/[ ]DBL_DIG[ ]/i\
1214 #ifndef DBL_DIG'\
1215 -e '/[ ]DBL_DIG[ ]/a\
1216 #endif' $file_to_fix > /tmp/$base
1217 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1218 echo No change needed in $file_to_fix
1219 else
1220 echo Fixed $file_to_fix
1221 rm -f ${LIB}/$file
1222 cp /tmp/$base ${LIB}/$file
1223 fi
1224 rm -f /tmp/$base
1225 fi
1226
1227 echo 'Removing unneeded directories:'
1228 cd $LIB
1229 files=`find . -type d -print | sort -r`
1230 for file in $files; do
1231 rmdir $LIB/$file > /dev/null 2>&1
1232 done
1233
1234 if $LINKS; then
1235 echo 'Making internal symbolic non-directory links'
1236 cd ${INPUT}
1237 files=`find . -type l -print`
1238 for file in $files; do
1239 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1240 if expr "$dest" : '[^/].*' > /dev/null; then
1241 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1242 if [ -f $target ]; then
1243 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1244 fi
1245 fi
1246 done
1247 fi
1248
1249 cd ${ORIG_DIR}
1250
1251 echo 'Replacing <sys/byteorder.h>'
1252 rm -f ${LIB}/sys/byteorder.h
1253 cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h
1254
1255 exit 0
1256
This page took 0.109605 seconds and 6 git commands to generate.