]> gcc.gnu.org Git - gcc.git/blame - gcc/fixinc.svr4
(va_list) [__SVR4_2__]: Don't set or test _VA_LIST.
[gcc.git] / gcc / fixinc.svr4
CommitLineData
724d9f3d
DM
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
4cf98b83
RS
34# Directory where gcc sources (and sometimes special include files) live.
35SRCDIR=${3-${SRCDIR-.}}
36
724d9f3d
DM
37# Directory containing the original header files.
38INPUT=${2-${INPUT-/usr/include}}
39
40# Fail if no arg to specify a directory for the output.
41if [ x$1 = x ]
42then echo fixincludes: no output directory specified
43exit 1
44fi
45
46# Directory in which to store the results.
8415a5a9 47LIB=${1?"fixincludes: output directory not specified"}
724d9f3d
DM
48
49# Make sure it exists.
50if [ ! -d $LIB ]; then
51 mkdir $LIB || exit 1
52fi
53
54ORIG_DIR=`pwd`
55
56# Make LIB absolute.
57cd $LIB; LIB=`pwd`
58
59# This prevents /bin/ex from failing if the current terminal type is
60# unrecognizable.
4cf98b83 61TERM=dumb
724d9f3d 62export TERM
04b5ab57
JW
63# This prevents /bin/ex from failing if the EXINIT environment variable
64# was set to something invalid.
65EXINIT=""
66export EXINIT
724d9f3d
DM
67
68echo 'Building fixincludes in ' ${LIB}
69
70# Determine whether this filesystem has symbolic links.
71if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
72 rm -f $LIB/ShouldNotExist
73 LINKS=true
74else
75 LINKS=false
76fi
77
78echo 'Making directories:'
79cd ${INPUT}
80if $LINKS; then
81 files=`ls -LR | sed -n s/:$//p`
82else
83 files=`find . -type d -print | sed '/^.$/d'`
84fi
85for file in $files; do
86 rm -rf $LIB/$file
87 if [ ! -d $LIB/$file ]
88 then mkdir $LIB/$file
89 fi
90done
91
92# treetops gets an alternating list
93# of old directories to copy
94# and the new directories to copy to.
95treetops="${INPUT} ${LIB}"
96
97if $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
133fi
134
135set - $treetops
136while [ $# != 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
76124f95 166 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
724d9f3d
DM
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
193done
194
195# Fix first broken decl of getcwd present on some svr4 systems.
196
197file=stdlib.h
198base=`basename $file`
199if [ -r ${LIB}/$file ]; then
200 file_to_fix=${LIB}/$file
201else
202 if [ -r ${INPUT}/$file ]; then
203 file_to_fix=${INPUT}/$file
204 else
205 file_to_fix=""
206 fi
207fi
208if [ \! -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
219fi
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
224file=unistd.h
225base=`basename $file`
226if [ -r ${LIB}/$file ]; then
227 file_to_fix=${LIB}/$file
228else
229 if [ -r ${INPUT}/$file ]; then
230 file_to_fix=${INPUT}/$file
231 else
232 file_to_fix=""
233 fi
234fi
235if [ \! -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
247fi
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
252file=sys/param.h
253base=`basename $file`
254if [ -r ${LIB}/$file ]; then
255 file_to_fix=${LIB}/$file
256else
257 if [ -r ${INPUT}/$file ]; then
258 file_to_fix=${INPUT}/$file
259 else
260 file_to_fix=""
261 fi
262fi
263if [ \! -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
279EOF
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
288fi
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
293file=stdio.h
294base=`basename $file`
295if [ -r ${LIB}/$file ]; then
296 file_to_fix=${LIB}/$file
297else
298 if [ -r ${INPUT}/$file ]; then
299 file_to_fix=${INPUT}/$file
300 else
301 file_to_fix=""
302 fi
303fi
304if [ \! -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
318EOF
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
327fi
328
d2f782d2
RS
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
332file=dbm.h
333base=`basename $file`
334if [ -r ${LIB}/$file ]; then
335 file_to_fix=${LIB}/$file
336else
337 if [ -r ${INPUT}/$file ]; then
338 file_to_fix=${INPUT}/$file
339 else
340 file_to_fix=""
341 fi
342fi
343if [ \! -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
359EOF
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
368fi
369
6b86d358 370# Add a prototyped declaration of mmap to <sys/mman.h>.
724d9f3d
DM
371
372file=sys/mman.h
373base=`basename $file`
374if [ -r ${LIB}/$file ]; then
375 file_to_fix=${LIB}/$file
376else
377 if [ -r ${INPUT}/$file ]; then
378 file_to_fix=${INPUT}/$file
379 else
380 file_to_fix=""
381 fi
382fi
383if [ \! -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__
390extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,
391 int fd, off_t off);
392#else /* !defined(__STDC__) */
393extern caddr_t mmap ();
394#endif /* !defined(__STDC__) */
395.
396 wq
397EOF
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
406fi
407
408# Fix declarations of `ftw' and `nftw' in <ftw.h>.
409
410file=ftw.h
411base=`basename $file`
412if [ -r ${LIB}/$file ]; then
413 file_to_fix=${LIB}/$file
414else
415 if [ -r ${INPUT}/$file ]; then
416 file_to_fix=${INPUT}/$file
417 else
418 file_to_fix=""
419 fi
420fi
421if [ \! -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)
428static
429#else
430extern
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)
436static
437#else
438extern
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)
444static
445#else
446extern
447#endif
448 int ftw();
449#if defined(_STYPES)
450static
451#else
452extern
453#endif
454 int nftw();
455.
456 wq
457EOF
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
466fi
467
468# Add a `static' declaration of `getrnge' into <regexp.h>.
469
470file=regexp.h
471base=`basename $file`
472if [ -r ${LIB}/$file ]; then
473 file_to_fix=${LIB}/$file
474else
475 if [ -r ${INPUT}/$file ]; then
476 file_to_fix=${INPUT}/$file
477 else
478 file_to_fix=""
479 fi
480fi
481if [ \! -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
487static int size ;
488
489static int getrnge ();
490.
491 wq
492EOF
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
501fi
502
503# Add a #define of _SIGACTION_ into <sys/signal.h>.
09a99207 504# Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
724d9f3d
DM
505
506file=sys/signal.h
507base=`basename $file`
508if [ -r ${LIB}/$file ]; then
509 file_to_fix=${LIB}/$file
510else
511 if [ -r ${INPUT}/$file ]; then
512 file_to_fix=${INPUT}/$file
513 else
514 file_to_fix=""
515 fi
516fi
517if [ \! -z "$file_to_fix" ]; then
518 echo Checking $file_to_fix
519 cp $file_to_fix /tmp/$base
520 chmod +w /tmp/$base
521 ex /tmp/$base <<EOF
522 /^struct sigaction {/c
523#define _SIGACTION_
524struct sigaction {
525.
09a99207 526 1,\$s/(void *(\*)())/(void (*)(int))/
724d9f3d
DM
527 wq
528EOF
529 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
530 echo No change needed in $file_to_fix
531 else
532 echo Fixed $file_to_fix
533 rm -f ${LIB}/$file
534 cp /tmp/$base ${LIB}/$file
535 fi
536 rm -f /tmp/$base
537fi
538
539# Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
540
541file=sys/mkdev.h
542base=`basename $file`
543if [ -r ${LIB}/$file ]; then
544 file_to_fix=${LIB}/$file
545else
546 if [ -r ${INPUT}/$file ]; then
547 file_to_fix=${INPUT}/$file
548 else
549 file_to_fix=""
550 fi
551fi
552if [ \! -z "$file_to_fix" ]; then
553 echo Checking $file_to_fix
554 cp $file_to_fix /tmp/$base
555 chmod +w /tmp/$base
556 ex /tmp/$base <<EOF
557 /^dev_t makedev(const/c
558static dev_t makedev(const major_t, const minor_t);
559.
560 /^dev_t makedev()/c
561static dev_t makedev();
562.
563 /^major_t major(const/c
564static major_t major(const dev_t);
565.
566 /^major_t major()/c
567static major_t major();
568.
569 /^minor_t minor(const/c
570static minor_t minor(const dev_t);
571.
572 /^minor_t minor()/c
573static minor_t minor();
574.
575 wq
576EOF
577 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
578 echo No change needed in $file_to_fix
579 else
580 echo Fixed $file_to_fix
581 rm -f ${LIB}/$file
582 cp /tmp/$base ${LIB}/$file
583 fi
584 rm -f /tmp/$base
585fi
586
587# Fix reference to NMSZ in <sys/adv.h>.
588
589file=sys/adv.h
590base=`basename $file`
591if [ -r ${LIB}/$file ]; then
592 file_to_fix=${LIB}/$file
593else
594 if [ -r ${INPUT}/$file ]; then
595 file_to_fix=${INPUT}/$file
596 else
597 file_to_fix=""
598 fi
599fi
600if [ \! -z "$file_to_fix" ]; then
601 echo Checking $file_to_fix
602 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
603 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
604 echo No change needed in $file_to_fix
605 else
606 echo Fixed $file_to_fix
607 rm -f ${LIB}/$file
608 cp /tmp/$base ${LIB}/$file
609 fi
610 rm -f /tmp/$base
611fi
612
613# Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
614# array initializers.
615
616file=sys/netcspace.h
617base=`basename $file`
618if [ -r ${LIB}/$file ]; then
619 file_to_fix=${LIB}/$file
620else
621 if [ -r ${INPUT}/$file ]; then
622 file_to_fix=${INPUT}/$file
623 else
624 file_to_fix=""
625 fi
626fi
627if [ \! -z "$file_to_fix" ]; then
628 echo Checking $file_to_fix
629 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
630 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
631 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
632 echo No change needed in $file_to_fix
633 else
634 echo Fixed $file_to_fix
635 rm -f ${LIB}/$file
636 cp /tmp/$base ${LIB}/$file
637 fi
638 rm -f /tmp/$base
639fi
640
641# Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
642
643file=fs/rfs/rf_cache.h
644base=`basename $file`
645if [ -r ${LIB}/$file ]; then
646 file_to_fix=${LIB}/$file
647else
648 if [ -r ${INPUT}/$file ]; then
649 file_to_fix=${INPUT}/$file
650 else
651 file_to_fix=""
652 fi
653fi
654if [ \! -z "$file_to_fix" ]; then
655 echo Checking $file_to_fix
656 if grep _KERNEL $file_to_fix > /dev/null; then
657 echo No change needed in $file_to_fix
658 else
659 echo '#ifdef _KERNEL' > /tmp/$base
660 cat $file_to_fix >> /tmp/$base
661 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
662 echo Fixed $file_to_fix
663 rm -f ${LIB}/$file
664 cp /tmp/$base ${LIB}/$file
665 rm -f /tmp/$base
666 fi
667fi
668
669# Conditionalize all of <sys/erec.h> on _KERNEL being defined.
670
671file=sys/erec.h
672base=`basename $file`
673if [ -r ${LIB}/$file ]; then
674 file_to_fix=${LIB}/$file
675else
676 if [ -r ${INPUT}/$file ]; then
677 file_to_fix=${INPUT}/$file
678 else
679 file_to_fix=""
680 fi
681fi
682if [ \! -z "$file_to_fix" ]; then
683 echo Checking $file_to_fix
684 if grep _KERNEL $file_to_fix > /dev/null; then
685 echo No change needed in $file_to_fix
686 else
687 echo '#ifdef _KERNEL' > /tmp/$base
688 cat $file_to_fix >> /tmp/$base
689 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
690 echo Fixed $file_to_fix
691 rm -f ${LIB}/$file
692 cp /tmp/$base ${LIB}/$file
693 rm -f /tmp/$base
694 fi
695fi
696
697# Conditionalize all of <sys/err.h> on _KERNEL being defined.
698
699file=sys/err.h
700base=`basename $file`
701if [ -r ${LIB}/$file ]; then
702 file_to_fix=${LIB}/$file
703else
704 if [ -r ${INPUT}/$file ]; then
705 file_to_fix=${INPUT}/$file
706 else
707 file_to_fix=""
708 fi
709fi
710if [ \! -z "$file_to_fix" ]; then
711 echo Checking $file_to_fix
712 if grep _KERNEL $file_to_fix > /dev/null; then
713 echo No change needed in $file_to_fix
714 else
715 echo '#ifdef _KERNEL' > /tmp/$base
716 cat $file_to_fix >> /tmp/$base
717 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
718 echo Fixed $file_to_fix
719 rm -f ${LIB}/$file
720 cp /tmp/$base ${LIB}/$file
721 rm -f /tmp/$base
722 fi
723fi
724
725# Conditionalize all of <sys/char.h> on _KERNEL being defined.
726
727file=sys/char.h
728base=`basename $file`
729if [ -r ${LIB}/$file ]; then
730 file_to_fix=${LIB}/$file
731else
732 if [ -r ${INPUT}/$file ]; then
733 file_to_fix=${INPUT}/$file
734 else
735 file_to_fix=""
736 fi
737fi
738if [ \! -z "$file_to_fix" ]; then
739 echo Checking $file_to_fix
740 if grep _KERNEL $file_to_fix > /dev/null; then
741 echo No change needed in $file_to_fix
742 else
743 echo '#ifdef _KERNEL' > /tmp/$base
744 cat $file_to_fix >> /tmp/$base
745 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
746 echo Fixed $file_to_fix
747 rm -f ${LIB}/$file
748 cp /tmp/$base ${LIB}/$file
749 rm -f /tmp/$base
750 fi
751fi
752
753# Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
754
755file=sys/getpages.h
756base=`basename $file`
757if [ -r ${LIB}/$file ]; then
758 file_to_fix=${LIB}/$file
759else
760 if [ -r ${INPUT}/$file ]; then
761 file_to_fix=${INPUT}/$file
762 else
763 file_to_fix=""
764 fi
765fi
766if [ \! -z "$file_to_fix" ]; then
767 echo Checking $file_to_fix
768 if grep _KERNEL $file_to_fix > /dev/null; then
769 echo No change needed in $file_to_fix
770 else
771 echo '#ifdef _KERNEL' > /tmp/$base
772 cat $file_to_fix >> /tmp/$base
773 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
774 echo Fixed $file_to_fix
775 rm -f ${LIB}/$file
776 cp /tmp/$base ${LIB}/$file
777 rm -f /tmp/$base
778 fi
779fi
780
781# Conditionalize all of <sys/map.h> on _KERNEL being defined.
782
783file=sys/map.h
784base=`basename $file`
785if [ -r ${LIB}/$file ]; then
786 file_to_fix=${LIB}/$file
787else
788 if [ -r ${INPUT}/$file ]; then
789 file_to_fix=${INPUT}/$file
790 else
791 file_to_fix=""
792 fi
793fi
794if [ \! -z "$file_to_fix" ]; then
795 echo Checking $file_to_fix
796 if grep _KERNEL $file_to_fix > /dev/null; then
797 echo No change needed in $file_to_fix
798 else
799 echo '#ifdef _KERNEL' > /tmp/$base
800 cat $file_to_fix >> /tmp/$base
801 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
802 echo Fixed $file_to_fix
803 rm -f ${LIB}/$file
804 cp /tmp/$base ${LIB}/$file
805 rm -f /tmp/$base
806 fi
807fi
808
809# Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
810
811file=sys/cmn_err.h
812base=`basename $file`
813if [ -r ${LIB}/$file ]; then
814 file_to_fix=${LIB}/$file
815else
816 if [ -r ${INPUT}/$file ]; then
817 file_to_fix=${INPUT}/$file
818 else
819 file_to_fix=""
820 fi
821fi
822if [ \! -z "$file_to_fix" ]; then
823 echo Checking $file_to_fix
824 if grep _KERNEL $file_to_fix > /dev/null; then
825 echo No change needed in $file_to_fix
826 else
827 echo '#ifdef _KERNEL' > /tmp/$base
828 cat $file_to_fix >> /tmp/$base
829 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
830 echo Fixed $file_to_fix
831 rm -f ${LIB}/$file
832 cp /tmp/$base ${LIB}/$file
833 rm -f /tmp/$base
834 fi
835fi
836
837# Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
838
839file=sys/kdebugger.h
840base=`basename $file`
841if [ -r ${LIB}/$file ]; then
842 file_to_fix=${LIB}/$file
843else
844 if [ -r ${INPUT}/$file ]; then
845 file_to_fix=${INPUT}/$file
846 else
847 file_to_fix=""
848 fi
849fi
850if [ \! -z "$file_to_fix" ]; then
851 echo Checking $file_to_fix
852 if grep _KERNEL $file_to_fix > /dev/null; then
853 echo No change needed in $file_to_fix
854 else
855 echo '#ifdef _KERNEL' > /tmp/$base
856 cat $file_to_fix >> /tmp/$base
857 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
858 echo Fixed $file_to_fix
859 rm -f ${LIB}/$file
860 cp /tmp/$base ${LIB}/$file
861 rm -f /tmp/$base
862 fi
863fi
864
0ae2f0ff
RS
865# Remove useless extern keyword from struct forward declarations in
866# <sys/stream.h> and <sys/strsubr.h>
867
868file=sys/stream.h
869base=`basename $file`
870if [ -r ${LIB}/$file ]; then
871 file_to_fix=${LIB}/$file
872else
873 if [ -r ${INPUT}/$file ]; then
874 file_to_fix=${INPUT}/$file
875 else
876 file_to_fix=""
877 fi
878fi
879if [ \! -z "$file_to_fix" ]; then
880 echo Checking $file_to_fix
881 sed -e 's/extern struct \(stdata\|strevent\);/struct \1;/' $file_to_fix > /tmp/$base
882 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
883 echo No change needed in $file_to_fix
884 else
885 echo Fixed $file_to_fix
886 rm -f ${LIB}/$file
887 cp /tmp/$base ${LIB}/$file
888 fi
889 rm -f /tmp/$base
890fi
891
892file=sys/strsubr.h
893base=`basename $file`
894if [ -r ${LIB}/$file ]; then
895 file_to_fix=${LIB}/$file
896else
897 if [ -r ${INPUT}/$file ]; then
898 file_to_fix=${INPUT}/$file
899 else
900 file_to_fix=""
901 fi
902fi
903if [ \! -z "$file_to_fix" ]; then
904 echo Checking $file_to_fix
905 sed -e 's/extern struct \(strbuf\|uio\|thread\|proc\);/struct \1;/' $file_to_fix > /tmp/$base
906 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
907 echo No change needed in $file_to_fix
908 else
909 echo Fixed $file_to_fix
910 rm -f ${LIB}/$file
911 cp /tmp/$base ${LIB}/$file
912 fi
913 rm -f /tmp/$base
914fi
915
09a99207
RS
916# Convert functions to prototype form, and fix arg names in <sys/stat.h>.
917
918file=sys/stat.h
919base=`basename $file`
920if [ -r ${LIB}/$file ]; then
921 file_to_fix=${LIB}/$file
922else
923 if [ -r ${INPUT}/$file ]; then
924 file_to_fix=${INPUT}/$file
925 else
926 file_to_fix=""
927 fi
928fi
929if [ \! -z "$file_to_fix" ]; then
930 echo Checking $file_to_fix
931 cp $file_to_fix /tmp/$base
932 chmod +w /tmp/$base
933 ex /tmp/$base <<EOF
934/^stat(path, buf)/j
935j
936-
937/^stat(path, buf)/c
938stat (const char *path, struct stat *buf)
939.
940/^lstat(path, buf)/j
941j
942-
943/^lstat(path, buf)/c
944lstat (const char *path, struct stat *buf)
945.
946/^fstat(fd, buf)/j
947j
948-
949/^fstat(fd, buf)/c
950fstat (int fd, struct stat *buf)
951.
952/^mknod(path, mode, dev)/j
953j
954j
955-
956/^mknod(path, mode, dev)/c
957mknod (const char *path, mode_t mode, dev_t dev)
958.
9591,\$s/path/__path/g
9601,\$s/buf/__buf/g
9611,\$s/fd/__fd/g
9621,\$s/ret\\([^u]\\)/__ret\1/g
9631,\$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g
9641,\$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g
965wq
966EOF
460fe04f
RS
967 echo Fixed $file_to_fix
968 rm -f ${LIB}/$file
969 cp /tmp/$base ${LIB}/$file
970 rm -f /tmp/$base
09a99207
RS
971fi
972
6a2233eb
RS
973# Sony NEWSOS 5.0 does not support the complete ANSI C standard.
974
975if [ -x /bin/sony ]; then
976 if /bin/sony; then
977
978 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
979
980 file=stdio.h
981 base=`basename $file`
982 if [ -r ${LIB}/$file ]; then
983 file_to_fix=${LIB}/$file
984 else
985 if [ -r ${INPUT}/$file ]; then
986 file_to_fix=${INPUT}/$file
987 else
988 file_to_fix=""
989 fi
990 fi
991 if [ \! -z "$file_to_fix" ]; then
992 echo Checking $file_to_fix
993 cp $file_to_fix /tmp/$base
994 chmod +w /tmp/$base
995 sed -e '
996 s/__filbuf/_filbuf/g
997 s/__flsbuf/_flsbuf/g
998 s/__iob/_iob/g
999 ' /tmp/$base > /tmp/$base.sed
1000 mv /tmp/$base.sed /tmp/$base
1001 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1002 echo No change needed in $file_to_fix
1003 else
1004 echo Fixed $file_to_fix
1005 rm -f ${LIB}/$file
1006 cp /tmp/$base ${LIB}/$file
1007 fi
1008 rm -f /tmp/$base
1009 fi
1010
1011 # Change <ctype.h> to not define __ctype
1012
1013 file=ctype.h
1014 base=`basename $file`
1015 if [ -r ${LIB}/$file ]; then
1016 file_to_fix=${LIB}/$file
1017 else
1018 if [ -r ${INPUT}/$file ]; then
1019 file_to_fix=${INPUT}/$file
1020 else
1021 file_to_fix=""
1022 fi
1023 fi
1024 if [ \! -z "$file_to_fix" ]; then
1025 echo Checking $file_to_fix
1026 cp $file_to_fix /tmp/$base
1027 chmod +w /tmp/$base
1028 sed -e '
1029 s/__ctype/_ctype/g
1030 ' /tmp/$base > /tmp/$base.sed
1031 mv /tmp/$base.sed /tmp/$base
1032 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1033 echo No change needed in $file_to_fix
1034 else
1035 echo Fixed $file_to_fix
1036 rm -f ${LIB}/$file
1037 cp /tmp/$base ${LIB}/$file
1038 fi
1039 rm -f /tmp/$base
1040 fi
1041 fi
1042fi
1043
724d9f3d
DM
1044echo 'Removing unneeded directories:'
1045cd $LIB
1046files=`find . -type d -print | sort -r`
1047for file in $files; do
1048 rmdir $LIB/$file > /dev/null 2>&1
1049done
1050
1051if $LINKS; then
1052 echo 'Making internal symbolic non-directory links'
1053 cd ${INPUT}
1054 files=`find . -type l -print`
1055 for file in $files; do
1056 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1057 if expr "$dest" : '[^/].*' > /dev/null; then
1058 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1059 if [ -f $target ]; then
1060 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1061 fi
1062 fi
1063 done
1064fi
1065
1066cd ${ORIG_DIR}
1067
1068echo 'Replacing <sys/byteorder.h>'
1069rm -f ${LIB}/sys/byteorder.h
4cf98b83 1070cp ${SRCDIR}/byteorder.h ${LIB}/sys/byteorder.h
724d9f3d
DM
1071
1072exit 0
1073
This page took 0.173759 seconds and 5 git commands to generate.