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