|
|
1.1 root 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 ([email protected]).
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
1.1.1.8 ! root 22: # the Free Software Foundation, 59 Temple Place - Suite 330,
! 23: # Boston, MA 02111-1307, USA.
1.1 root 24: #
25: # This script munges the native include files provided with System V
26: # Release 4 systems so as to remove things which are violations of the
27: # ANSI C standard. Once munged, the resulting new system include files
28: # are placed in a directory that GNU C will search *before* searching
29: # the /usr/include directory. This script should work properly for most
30: # System V Release 4 systems. For other types of systems, you should
31: # use the `fixincludes' script instead.
32: #
33: # See README-fixinc for more information.
34:
35: # Directory containing the original header files.
36: INPUT=${2-${INPUT-/usr/include}}
37:
38: # Fail if no arg to specify a directory for the output.
39: if [ x$1 = x ]
40: then echo fixincludes: no output directory specified
41: exit 1
42: fi
43:
44: # Directory in which to store the results.
1.1.1.4 root 45: LIB=${1?"fixincludes: output directory not specified"}
1.1 root 46:
47: # Make sure it exists.
48: if [ ! -d $LIB ]; then
49: mkdir $LIB || exit 1
50: fi
51:
52: ORIG_DIR=`pwd`
53:
1.1.1.5 root 54: # Make LIB absolute if it is relative.
55: # Don't do this if not necessary, since may screw up automounters.
56: case $LIB in
57: /*)
58: ;;
59: *)
1.1.1.6 root 60: LIB=$ORIG_DIR/$LIB
1.1.1.5 root 61: ;;
62: esac
1.1 root 63:
64: echo 'Building fixincludes in ' ${LIB}
65:
1.1.1.2 root 66: # Determine whether this filesystem has symbolic links.
1.1 root 67: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
68: rm -f $LIB/ShouldNotExist
69: LINKS=true
70: else
71: LINKS=false
72: fi
73:
74: echo 'Making directories:'
75: cd ${INPUT}
76: if $LINKS; then
77: files=`ls -LR | sed -n s/:$//p`
78: else
79: files=`find . -type d -print | sed '/^.$/d'`
80: fi
81: for file in $files; do
82: rm -rf $LIB/$file
83: if [ ! -d $LIB/$file ]
84: then mkdir $LIB/$file
85: fi
86: done
87:
88: # treetops gets an alternating list
89: # of old directories to copy
90: # and the new directories to copy to.
91: treetops="${INPUT} ${LIB}"
92:
93: if $LINKS; then
94: echo 'Making internal symbolic directory links'
95: for file in $files; do
96: dest=`ls -ld $file | sed -n 's/.*-> //p'`
97: if [ "$dest" ]; then
98: cwd=`pwd`
99: # In case $dest is relative, get to $file's dir first.
100: cd ${INPUT}
101: cd `echo ./$file | sed -n 's&[^/]*$&&p'`
102: # Check that the target directory exists.
103: # Redirections changed to avoid bug in sh on Ultrix.
104: (cd $dest) > /dev/null 2>&1
105: if [ $? = 0 ]; then
106: cd $dest
107: # X gets the dir that the link actually leads to.
108: x=`pwd`
109: # If link leads back into ${INPUT},
110: # make a similar link here.
111: if expr $x : "${INPUT}/.*" > /dev/null; then
112: # Y gets the actual target dir name, relative to ${INPUT}.
113: y=`echo $x | sed -n "s&${INPUT}/&&p"`
1.1.1.6 root 114: # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
115: dots=`echo "$file" |
116: sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
117: echo $file '->' $dots$y ': Making link'
1.1 root 118: rm -fr ${LIB}/$file > /dev/null 2>&1
1.1.1.6 root 119: ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
1.1 root 120: else
121: # If the link is to outside ${INPUT},
122: # treat this directory as if it actually contained the files.
123: # This line used to have $dest instead of $x.
124: # $dest seemed to be wrong for links found in subdirectories
125: # of ${INPUT}. Does this change break anything?
126: treetops="$treetops $x ${LIB}/$file"
127: fi
128: fi
129: cd $cwd
130: fi
131: done
132: fi
133:
134: set - $treetops
135: while [ $# != 0 ]; do
136: # $1 is an old directory to copy, and $2 is the new directory to copy to.
137: echo "Finding header files in $1:"
138: cd ${INPUT}
139: cd $1
140: files=`find . -name '*.h' -type f -print`
141: echo 'Checking header files:'
142: for file in $files; do
143: if [ -r $file ]; then
144: cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
145: chmod +w $2/$file
1.1.1.5 root 146: chmod a+r $2/$file
1.1 root 147:
148: # The following have been removed from the sed command below
149: # because it is more useful to leave these things in.
150: # The only reason to remove them was for -pedantic,
151: # which isn't much of a reason. -- rms.
152: # /^[ ]*#[ ]*ident/d
153:
1.1.1.4 root 154: # This code makes Solaris SCSI fail, because it changes the
155: # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
156: # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
157: # Disable these also, since they probably aren't safe either.
158: # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
159: # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
160: # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
161: # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
162:
1.1 root 163: # The change of u_char, etc, to u_int
164: # applies to bit fields.
165: sed -e '
1.1.1.6 root 166: s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
167: s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
168: s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
169: s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
1.1 root 170: s/#lint(on)/defined(lint)/g
171: s/#lint(off)/!defined(lint)/g
172: s/#machine(\([^)]*\))/defined(__\1__)/g
173: s/#system(\([^)]*\))/defined(__\1__)/g
174: s/#cpu(\([^)]*\))/defined(__\1__)/g
1.1.1.2 root 175: /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
1.1.1.3 root 176: /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
1.1.1.2 root 177: /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
1.1.1.7 root 178: /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g
179: /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/g
1.1.1.2 root 180: /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
181: /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
182: /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
183: /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
184: /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
185: /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
186: /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
187: /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
1.1.1.6 root 188: s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
189: s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
190: s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
1.1 root 191: s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
1.1.1.8 ! root 192: /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
1.1 root 193: ' $2/$file > $2/$file.sed
194: mv $2/$file.sed $2/$file
195: if cmp $file $2/$file >/dev/null 2>&1; then
196: rm $2/$file
1.1.1.5 root 197: else
198: echo Fixed $file
1.1 root 199: fi
200: fi
201: done
202: shift; shift
203: done
204:
1.1.1.7 root 205: # Install the proper definition of the three standard types in header files
206: # that they come from.
207: for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
208: if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
209: cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
210: chmod +w ${LIB}/$file 2>/dev/null
211: chmod a+r ${LIB}/$file 2>/dev/null
212: fi
213:
214: if [ -r ${LIB}/$file ]; then
215: echo Fixing size_t, ptrdiff_t and wchar_t in $file
216: sed \
217: -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
218: #ifndef __SIZE_TYPE__\
219: #define __SIZE_TYPE__ long unsigned int\
220: #endif
221: ' \
222: -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
223: -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
224: #ifndef __PTRDIFF_TYPE__\
225: #define __PTRDIFF_TYPE__ long int\
226: #endif
227: ' \
228: -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
229: -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
230: #ifndef __WCHAR_TYPE__\
231: #define __WCHAR_TYPE__ int\
232: #endif
233: ' \
234: -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
235: ${LIB}/$file > ${LIB}/${file}.sed
236: rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
237: if cmp $file ${LIB}/$file >/dev/null 2>&1; then
238: rm ${LIB}/$file
239: fi
240: fi
241: done
242:
1.1 root 243: # Fix first broken decl of getcwd present on some svr4 systems.
244:
245: file=stdlib.h
246: base=`basename $file`
247: if [ -r ${LIB}/$file ]; then
248: file_to_fix=${LIB}/$file
249: else
250: if [ -r ${INPUT}/$file ]; then
251: file_to_fix=${INPUT}/$file
252: else
253: file_to_fix=""
254: fi
255: fi
256: if [ \! -z "$file_to_fix" ]; then
257: echo Checking $file_to_fix
258: sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
259: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1.1.1.5 root 260: true
1.1 root 261: else
262: echo Fixed $file_to_fix
263: rm -f ${LIB}/$file
264: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 265: chmod a+r ${LIB}/$file
1.1 root 266: fi
267: rm -f /tmp/$base
268: fi
269:
270: # Fix second broken decl of getcwd present on some svr4 systems. Also
271: # fix the incorrect decl of profil present on some svr4 systems.
272:
273: file=unistd.h
274: base=`basename $file`
275: if [ -r ${LIB}/$file ]; then
276: file_to_fix=${LIB}/$file
277: else
278: if [ -r ${INPUT}/$file ]; then
279: file_to_fix=${INPUT}/$file
280: else
281: file_to_fix=""
282: fi
283: fi
284: if [ \! -z "$file_to_fix" ]; then
285: echo Checking $file_to_fix
286: sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
287: | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
288: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1.1.1.5 root 289: true
1.1 root 290: else
291: echo Fixed $file_to_fix
292: rm -f ${LIB}/$file
293: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 294: chmod a+r ${LIB}/$file
1.1 root 295: fi
296: rm -f /tmp/$base
297: fi
298:
299: # Fix the definition of NULL in <sys/param.h> so that it is conditional
300: # and so that it is correct for both C and C++.
301:
302: file=sys/param.h
303: base=`basename $file`
304: if [ -r ${LIB}/$file ]; then
305: file_to_fix=${LIB}/$file
306: else
307: if [ -r ${INPUT}/$file ]; then
308: file_to_fix=${INPUT}/$file
309: else
310: file_to_fix=""
311: fi
312: fi
313: if [ \! -z "$file_to_fix" ]; then
314: echo Checking $file_to_fix
315: cp $file_to_fix /tmp/$base
316: chmod +w /tmp/$base
1.1.1.5 root 317: chmod a+r /tmp/$base
318: sed -e '/^#define[ ]*NULL[ ]*0$/c\
319: #ifndef NULL\
320: #ifdef __cplusplus\
321: #define __NULL_TYPE\
322: #else /* !defined(__cplusplus) */\
323: #define __NULL_TYPE (void *)\
324: #endif /* !defined(__cplusplus) */\
325: #define NULL (__NULL_TYPE 0)\
326: #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
327: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
328: true
1.1 root 329: else
330: echo Fixed $file_to_fix
331: rm -f ${LIB}/$file
1.1.1.5 root 332: cp /tmp/$base.sed ${LIB}/$file
333: chmod a+r ${LIB}/$file
1.1 root 334: fi
1.1.1.5 root 335: rm -f /tmp/$base /tmp/$base.sed
1.1 root 336: fi
337:
338: # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
339: # and so that it is correct for both C and C++.
340:
341: file=stdio.h
342: base=`basename $file`
343: if [ -r ${LIB}/$file ]; then
344: file_to_fix=${LIB}/$file
345: else
346: if [ -r ${INPUT}/$file ]; then
347: file_to_fix=${INPUT}/$file
348: else
349: file_to_fix=""
350: fi
351: fi
352: if [ \! -z "$file_to_fix" ]; then
353: echo Checking $file_to_fix
354: cp $file_to_fix /tmp/$base
355: chmod +w /tmp/$base
1.1.1.5 root 356: sed -e '/^#define[ ]*NULL[ ]*0$/c\
357: #ifdef __cplusplus\
358: #define __NULL_TYPE\
359: #else /* !defined(__cplusplus) */\
360: #define __NULL_TYPE (void *)\
361: #endif /* !defined(__cplusplus) */\
362: #define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
363: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
364: true
1.1 root 365: else
366: echo Fixed $file_to_fix
367: rm -f ${LIB}/$file
1.1.1.5 root 368: cp /tmp/$base.sed ${LIB}/$file
369: chmod a+r ${LIB}/$file
1.1 root 370: fi
1.1.1.5 root 371: rm -f /tmp/$base /tmp/$base.sed
1.1 root 372: fi
373:
1.1.1.3 root 374: # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
375: # and so that it is correct for both C and C++.
376:
377: file=dbm.h
378: base=`basename $file`
379: if [ -r ${LIB}/$file ]; then
380: file_to_fix=${LIB}/$file
381: else
382: if [ -r ${INPUT}/$file ]; then
383: file_to_fix=${INPUT}/$file
384: else
385: file_to_fix=""
386: fi
387: fi
388: if [ \! -z "$file_to_fix" ]; then
389: echo Checking $file_to_fix
390: cp $file_to_fix /tmp/$base
391: chmod +w /tmp/$base
1.1.1.5 root 392: sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
393: #ifndef NULL\
394: #ifdef __cplusplus\
395: #define __NULL_TYPE\
396: #else /* !defined(__cplusplus) */\
397: #define __NULL_TYPE (void *)\
398: #endif /* !defined(__cplusplus) */\
399: #define NULL (__NULL_TYPE 0)\
400: #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
401: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
402: true
1.1.1.3 root 403: else
404: echo Fixed $file_to_fix
405: rm -f ${LIB}/$file
1.1.1.5 root 406: cp /tmp/$base.sed ${LIB}/$file
407: chmod a+r ${LIB}/$file
1.1.1.3 root 408: fi
1.1.1.5 root 409: rm -f /tmp/$base /tmp/$base.sed
1.1.1.3 root 410: fi
411:
1.1.1.4 root 412: # Add a prototyped declaration of mmap to <sys/mman.h>.
1.1 root 413:
414: file=sys/mman.h
415: base=`basename $file`
416: if [ -r ${LIB}/$file ]; then
417: file_to_fix=${LIB}/$file
418: else
419: if [ -r ${INPUT}/$file ]; then
420: file_to_fix=${INPUT}/$file
421: else
422: file_to_fix=""
423: fi
424: fi
425: if [ \! -z "$file_to_fix" ]; then
426: echo Checking $file_to_fix
427: cp $file_to_fix /tmp/$base
428: chmod +w /tmp/$base
1.1.1.5 root 429: sed -e '/^extern caddr_t mmap();$/c\
430: #ifdef __STDC__\
1.1.1.7 root 431: extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
1.1.1.5 root 432: #else /* !defined(__STDC__) */\
433: extern caddr_t mmap ();\
434: #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
435: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
436: true
1.1 root 437: else
438: echo Fixed $file_to_fix
439: rm -f ${LIB}/$file
1.1.1.5 root 440: cp /tmp/$base.sed ${LIB}/$file
441: chmod a+r ${LIB}/$file
1.1 root 442: fi
1.1.1.5 root 443: rm -f /tmp/$base /tmp/$base.sed
1.1 root 444: fi
445:
1.1.1.6 root 446: # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
447: # the file <ftw.h> contains extern declarations of these functions followed
448: # by explicitly `static' definitions of these functions... and that's not
449: # allowed according to ANSI C. (Note however that on Solaris, this header
450: # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
451: # there are no static definitions of any function so we don't need to do
452: # any of this stuff when on Solaris.
1.1 root 453:
454: file=ftw.h
455: base=`basename $file`
456: if [ -r ${LIB}/$file ]; then
457: file_to_fix=${LIB}/$file
458: else
459: if [ -r ${INPUT}/$file ]; then
460: file_to_fix=${INPUT}/$file
461: else
462: file_to_fix=""
463: fi
464: fi
1.1.1.6 root 465: if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
466: # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
467: # one. Either way, we don't have to do anything.
468: true
469: else
1.1 root 470: echo Checking $file_to_fix
471: cp $file_to_fix /tmp/$base
472: chmod +w /tmp/$base
1.1.1.6 root 473: sed -e '/^extern int ftw(const/i\
1.1.1.5 root 474: #if !defined(_STYPES)\
475: static\
476: #else\
477: extern\
1.1.1.6 root 478: #endif'\
479: -e 's/extern \(int ftw(const.*\)$/\1/' \
480: -e '/^extern int nftw/i\
1.1.1.5 root 481: #if defined(_STYPES)\
482: static\
483: #else\
484: extern\
1.1.1.6 root 485: #endif'\
486: -e 's/extern \(int nftw.*\)$/\1/' \
1.1.1.5 root 487: -e '/^extern int ftw(),/c\
488: #if !defined(_STYPES)\
489: static\
490: #else\
491: extern\
492: #endif\
493: int ftw();\
494: #if defined(_STYPES)\
495: static\
496: #else\
497: extern\
498: #endif\
499: int nftw();' /tmp/$base > /tmp/$base.sed
500: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
501: true
1.1 root 502: else
503: echo Fixed $file_to_fix
504: rm -f ${LIB}/$file
1.1.1.5 root 505: cp /tmp/$base.sed ${LIB}/$file
506: chmod a+r ${LIB}/$file
1.1 root 507: fi
1.1.1.5 root 508: rm -f /tmp/$base /tmp/$base.sed
1.1 root 509: fi
510:
1.1.1.7 root 511: # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
512: # g++, since it's now an official type in the C++ language.
513: file=curses.h
514: base=`basename $file`
515: if [ -r ${LIB}/$file ]; then
516: file_to_fix=${LIB}/$file
517: else
518: if [ -r ${INPUT}/$file ]; then
519: file_to_fix=${INPUT}/$file
520: else
521: file_to_fix=""
522: fi
523: fi
524:
525: if [ \! -z "$file_to_fix" ]; then
526: echo Checking $file_to_fix
527: cp $file_to_fix /tmp/$base
528: chmod +w /tmp/$base
529: sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
530: typedef char bool;\
531: #endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed
532: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
533: true
534: else
535: echo Fixed $file_to_fix
536: rm -f ${LIB}/$file
537: cp /tmp/$base.sed ${LIB}/$file
538: chmod a+r ${LIB}/$file
539: fi
540: rm -f /tmp/$base /tmp/$base.sed
541: fi
542:
1.1 root 543: # Add a `static' declaration of `getrnge' into <regexp.h>.
544:
1.1.1.4 root 545: # Don't do this if there is already a `static void getrnge' declaration
546: # present, since this would cause a redeclaration error. Solaris 2.x has
547: # such a declaration.
548:
1.1 root 549: file=regexp.h
550: base=`basename $file`
551: if [ -r ${LIB}/$file ]; then
552: file_to_fix=${LIB}/$file
553: else
554: if [ -r ${INPUT}/$file ]; then
555: file_to_fix=${INPUT}/$file
556: else
557: file_to_fix=""
558: fi
559: fi
560: if [ \! -z "$file_to_fix" ]; then
561: echo Checking $file_to_fix
1.1.1.4 root 562: if grep "static void getrnge" $file_to_fix > /dev/null; then
563: true
564: else
565: cp $file_to_fix /tmp/$base
566: chmod +w /tmp/$base
1.1.1.5 root 567: sed -e '/^static int[ ]*size;/c\
568: static int size ;\
569: \
570: static int getrnge ();' /tmp/$base > /tmp/$base.sed
571: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
572: true
1.1.1.4 root 573: else
574: echo Fixed $file_to_fix
575: rm -f ${LIB}/$file
1.1.1.5 root 576: cp /tmp/$base.sed ${LIB}/$file
577: chmod a+r ${LIB}/$file
1.1.1.4 root 578: fi
579: fi
1.1.1.5 root 580: rm -f /tmp/$base /tmp/$base.sed
1.1.1.4 root 581: fi
582:
583: # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
584: # that is visible to any ANSI compiler using this include. Simply
1.1.1.5 root 585: # delete the lines that #define some string functions to internal forms.
1.1.1.4 root 586:
587: file=string.h
588: base=`basename $file`
589: if [ -r ${LIB}/$file ]; then
590: file_to_fix=${LIB}/$file
591: else
592: if [ -r ${INPUT}/$file ]; then
593: file_to_fix=${INPUT}/$file
594: else
595: file_to_fix=""
596: fi
597: fi
598: if [ \! -z "$file_to_fix" ]; then
599: echo Checking $file_to_fix
600: cp $file_to_fix /tmp/$base
601: chmod +w /tmp/$base
1.1.1.5 root 602: sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
603: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
604: true
1.1 root 605: else
606: echo Fixed $file_to_fix
607: rm -f ${LIB}/$file
1.1.1.5 root 608: cp /tmp/$base.sed ${LIB}/$file
609: chmod a+r ${LIB}/$file
610: fi
611: rm -f /tmp/$base /tmp/$base.sed
612: fi
613:
614: # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
615: # tend to conflict with the compiler's own definition of this symbol. (We
616: # will use the compiler's definition.)
617: # Likewise __sparc, for Solaris, and __i860, and a few others
618: # (guessing it is necessary for all of them).
619:
620: file=ieeefp.h
621: base=`basename $file`
622: if [ -r ${LIB}/$file ]; then
623: file_to_fix=${LIB}/$file
624: else
625: if [ -r ${INPUT}/$file ]; then
626: file_to_fix=${INPUT}/$file
627: else
628: file_to_fix=""
1.1 root 629: fi
630: fi
1.1.1.5 root 631: if [ \! -z "$file_to_fix" ]; then
632: echo Checking $file_to_fix
633: cp $file_to_fix /tmp/$base
634: chmod +w /tmp/$base
635: sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
636: -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
637: -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
638: /tmp/$base > /tmp/$base.sed
639: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
640: true
641: else
642: echo Fixed $file_to_fix
643: rm -f ${LIB}/$file
644: cp /tmp/$base.sed ${LIB}/$file
645: chmod a+r ${LIB}/$file
646: fi
647: rm -f /tmp/$base /tmp/$base.sed
648: fi
1.1 root 649:
650: # Add a #define of _SIGACTION_ into <sys/signal.h>.
1.1.1.4 root 651: # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
1.1 root 652:
653: file=sys/signal.h
654: base=`basename $file`
655: if [ -r ${LIB}/$file ]; then
656: file_to_fix=${LIB}/$file
657: else
658: if [ -r ${INPUT}/$file ]; then
659: file_to_fix=${INPUT}/$file
660: else
661: file_to_fix=""
662: fi
663: fi
664: if [ \! -z "$file_to_fix" ]; then
665: echo Checking $file_to_fix
666: cp $file_to_fix /tmp/$base
667: chmod +w /tmp/$base
1.1.1.5 root 668: sed -e '/^struct sigaction {/c\
669: #define _SIGACTION_\
670: struct sigaction {' \
671: -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
672: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
673: true
1.1 root 674: else
675: echo Fixed $file_to_fix
676: rm -f ${LIB}/$file
1.1.1.5 root 677: cp /tmp/$base.sed ${LIB}/$file
678: chmod a+r ${LIB}/$file
1.1 root 679: fi
1.1.1.5 root 680: rm -f /tmp/$base /tmp/$base.sed
1.1 root 681: fi
682:
683: # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
684:
685: file=sys/mkdev.h
686: base=`basename $file`
687: if [ -r ${LIB}/$file ]; then
688: file_to_fix=${LIB}/$file
689: else
690: if [ -r ${INPUT}/$file ]; then
691: file_to_fix=${INPUT}/$file
692: else
693: file_to_fix=""
694: fi
695: fi
696: if [ \! -z "$file_to_fix" ]; then
697: echo Checking $file_to_fix
698: cp $file_to_fix /tmp/$base
699: chmod +w /tmp/$base
1.1.1.5 root 700: sed -e '/^dev_t makedev(const/c\
701: static dev_t makedev(const major_t, const minor_t);' \
702: -e '/^dev_t makedev()/c\
703: static dev_t makedev();' \
704: -e '/^major_t major(const/c\
705: static major_t major(const dev_t);' \
706: -e '/^major_t major()/c\
707: static major_t major();' \
708: -e '/^minor_t minor(const/c\
709: static minor_t minor(const dev_t);' \
710: -e '/^minor_t minor()/c\
711: static minor_t minor();' /tmp/$base > /tmp/$base.sed
712: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
713: true
1.1 root 714: else
715: echo Fixed $file_to_fix
716: rm -f ${LIB}/$file
1.1.1.5 root 717: cp /tmp/$base.sed ${LIB}/$file
718: chmod a+r ${LIB}/$file
1.1 root 719: fi
1.1.1.5 root 720: rm -f /tmp/$base /tmp/$base.sed
1.1 root 721: fi
722:
723: # Fix reference to NMSZ in <sys/adv.h>.
724:
725: file=sys/adv.h
726: base=`basename $file`
727: if [ -r ${LIB}/$file ]; then
728: file_to_fix=${LIB}/$file
729: else
730: if [ -r ${INPUT}/$file ]; then
731: file_to_fix=${INPUT}/$file
732: else
733: file_to_fix=""
734: fi
735: fi
736: if [ \! -z "$file_to_fix" ]; then
737: echo Checking $file_to_fix
738: sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
739: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1.1.1.5 root 740: true
1.1 root 741: else
742: echo Fixed $file_to_fix
743: rm -f ${LIB}/$file
744: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 745: chmod a+r ${LIB}/$file
1.1 root 746: fi
747: rm -f /tmp/$base
748: fi
749:
750: # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
751: # array initializers.
752:
753: file=sys/netcspace.h
754: base=`basename $file`
755: if [ -r ${LIB}/$file ]; then
756: file_to_fix=${LIB}/$file
757: else
758: if [ -r ${INPUT}/$file ]; then
759: file_to_fix=${INPUT}/$file
760: else
761: file_to_fix=""
762: fi
763: fi
764: if [ \! -z "$file_to_fix" ]; then
765: echo Checking $file_to_fix
766: sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
767: | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
768: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1.1.1.5 root 769: true
1.1 root 770: else
771: echo Fixed $file_to_fix
772: rm -f ${LIB}/$file
773: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 774: chmod a+r ${LIB}/$file
1.1 root 775: fi
776: rm -f /tmp/$base
777: fi
778:
779: # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
780:
781: file=fs/rfs/rf_cache.h
782: base=`basename $file`
783: if [ -r ${LIB}/$file ]; then
784: file_to_fix=${LIB}/$file
785: else
786: if [ -r ${INPUT}/$file ]; then
787: file_to_fix=${INPUT}/$file
788: else
789: file_to_fix=""
790: fi
791: fi
792: if [ \! -z "$file_to_fix" ]; then
793: echo Checking $file_to_fix
794: if grep _KERNEL $file_to_fix > /dev/null; then
1.1.1.5 root 795: true
1.1 root 796: else
797: echo '#ifdef _KERNEL' > /tmp/$base
798: cat $file_to_fix >> /tmp/$base
799: echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
800: echo Fixed $file_to_fix
801: rm -f ${LIB}/$file
802: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 803: chmod a+r ${LIB}/$file
1.1 root 804: rm -f /tmp/$base
805: fi
806: fi
807:
808: # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
809:
810: file=sys/erec.h
811: base=`basename $file`
812: if [ -r ${LIB}/$file ]; then
813: file_to_fix=${LIB}/$file
814: else
815: if [ -r ${INPUT}/$file ]; then
816: file_to_fix=${INPUT}/$file
817: else
818: file_to_fix=""
819: fi
820: fi
821: if [ \! -z "$file_to_fix" ]; then
822: echo Checking $file_to_fix
823: if grep _KERNEL $file_to_fix > /dev/null; then
1.1.1.5 root 824: true
1.1 root 825: else
826: echo '#ifdef _KERNEL' > /tmp/$base
827: cat $file_to_fix >> /tmp/$base
828: echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
829: echo Fixed $file_to_fix
830: rm -f ${LIB}/$file
831: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 832: chmod a+r ${LIB}/$file
1.1 root 833: rm -f /tmp/$base
834: fi
835: fi
836:
837: # Conditionalize all of <sys/err.h> on _KERNEL being defined.
838:
839: file=sys/err.h
840: base=`basename $file`
841: if [ -r ${LIB}/$file ]; then
842: file_to_fix=${LIB}/$file
843: else
844: if [ -r ${INPUT}/$file ]; then
845: file_to_fix=${INPUT}/$file
846: else
847: file_to_fix=""
848: fi
849: fi
850: if [ \! -z "$file_to_fix" ]; then
851: echo Checking $file_to_fix
852: if grep _KERNEL $file_to_fix > /dev/null; then
1.1.1.5 root 853: true
1.1 root 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
1.1.1.5 root 861: chmod a+r ${LIB}/$file
1.1 root 862: rm -f /tmp/$base
863: fi
864: fi
865:
866: # Conditionalize all of <sys/char.h> on _KERNEL being defined.
867:
868: file=sys/char.h
869: base=`basename $file`
870: if [ -r ${LIB}/$file ]; then
871: file_to_fix=${LIB}/$file
872: else
873: if [ -r ${INPUT}/$file ]; then
874: file_to_fix=${INPUT}/$file
875: else
876: file_to_fix=""
877: fi
878: fi
879: if [ \! -z "$file_to_fix" ]; then
880: echo Checking $file_to_fix
881: if grep _KERNEL $file_to_fix > /dev/null; then
1.1.1.5 root 882: true
1.1 root 883: else
884: echo '#ifdef _KERNEL' > /tmp/$base
885: cat $file_to_fix >> /tmp/$base
886: echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
887: echo Fixed $file_to_fix
888: rm -f ${LIB}/$file
889: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 890: chmod a+r ${LIB}/$file
1.1 root 891: rm -f /tmp/$base
892: fi
893: fi
894:
895: # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
896:
897: file=sys/getpages.h
898: base=`basename $file`
899: if [ -r ${LIB}/$file ]; then
900: file_to_fix=${LIB}/$file
901: else
902: if [ -r ${INPUT}/$file ]; then
903: file_to_fix=${INPUT}/$file
904: else
905: file_to_fix=""
906: fi
907: fi
908: if [ \! -z "$file_to_fix" ]; then
909: echo Checking $file_to_fix
910: if grep _KERNEL $file_to_fix > /dev/null; then
1.1.1.5 root 911: true
1.1 root 912: else
913: echo '#ifdef _KERNEL' > /tmp/$base
914: cat $file_to_fix >> /tmp/$base
915: echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
916: echo Fixed $file_to_fix
917: rm -f ${LIB}/$file
918: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 919: chmod a+r ${LIB}/$file
1.1 root 920: rm -f /tmp/$base
921: fi
922: fi
923:
924: # Conditionalize all of <sys/map.h> on _KERNEL being defined.
925:
926: file=sys/map.h
927: base=`basename $file`
928: if [ -r ${LIB}/$file ]; then
929: file_to_fix=${LIB}/$file
930: else
931: if [ -r ${INPUT}/$file ]; then
932: file_to_fix=${INPUT}/$file
933: else
934: file_to_fix=""
935: fi
936: fi
937: if [ \! -z "$file_to_fix" ]; then
938: echo Checking $file_to_fix
939: if grep _KERNEL $file_to_fix > /dev/null; then
1.1.1.5 root 940: true
1.1 root 941: else
942: echo '#ifdef _KERNEL' > /tmp/$base
943: cat $file_to_fix >> /tmp/$base
944: echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
945: echo Fixed $file_to_fix
946: rm -f ${LIB}/$file
947: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 948: chmod a+r ${LIB}/$file
1.1 root 949: rm -f /tmp/$base
950: fi
951: fi
952:
953: # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
954:
955: file=sys/cmn_err.h
956: base=`basename $file`
957: if [ -r ${LIB}/$file ]; then
958: file_to_fix=${LIB}/$file
959: else
960: if [ -r ${INPUT}/$file ]; then
961: file_to_fix=${INPUT}/$file
962: else
963: file_to_fix=""
964: fi
965: fi
966: if [ \! -z "$file_to_fix" ]; then
967: echo Checking $file_to_fix
968: if grep _KERNEL $file_to_fix > /dev/null; then
1.1.1.5 root 969: true
1.1 root 970: else
971: echo '#ifdef _KERNEL' > /tmp/$base
972: cat $file_to_fix >> /tmp/$base
973: echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
974: echo Fixed $file_to_fix
975: rm -f ${LIB}/$file
976: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 977: chmod a+r ${LIB}/$file
1.1 root 978: rm -f /tmp/$base
979: fi
980: fi
981:
982: # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
983:
984: file=sys/kdebugger.h
985: base=`basename $file`
986: if [ -r ${LIB}/$file ]; then
987: file_to_fix=${LIB}/$file
988: else
989: if [ -r ${INPUT}/$file ]; then
990: file_to_fix=${INPUT}/$file
991: else
992: file_to_fix=""
993: fi
994: fi
995: if [ \! -z "$file_to_fix" ]; then
996: echo Checking $file_to_fix
997: if grep _KERNEL $file_to_fix > /dev/null; then
1.1.1.5 root 998: true
1.1 root 999: else
1000: echo '#ifdef _KERNEL' > /tmp/$base
1001: cat $file_to_fix >> /tmp/$base
1002: echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
1003: echo Fixed $file_to_fix
1004: rm -f ${LIB}/$file
1005: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 1006: chmod a+r ${LIB}/$file
1.1 root 1007: rm -f /tmp/$base
1008: fi
1009: fi
1010:
1.1.1.4 root 1011: # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1.1.1.8 ! root 1012: # This has been taken out because it breaks on some versions of
! 1013: # DYNIX/ptx, and it does not seem to do much good on any system.
! 1014: # file=netinet/in.h
! 1015: # base=`basename $file`
! 1016: # if [ -r ${LIB}/$file ]; then
! 1017: # file_to_fix=${LIB}/$file
! 1018: # else
! 1019: # if [ -r ${INPUT}/$file ]; then
! 1020: # file_to_fix=${INPUT}/$file
! 1021: # else
! 1022: # file_to_fix=""
! 1023: # fi
! 1024: # fi
! 1025: # if [ \! -z "$file_to_fix" ]; then
! 1026: # echo Checking $file_to_fix
! 1027: # if grep _KERNEL $file_to_fix > /dev/null; then
! 1028: # true
! 1029: # else
! 1030: # sed -e '/#ifdef INKERNEL/i\
! 1031: # #ifdef _KERNEL' \
! 1032: # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
! 1033: # #endif /* _KERNEL */' \
! 1034: # $file_to_fix > ${LIB}/${file}.sed
! 1035: # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
! 1036: # echo Fixed $file_to_fix
! 1037: # fi
! 1038: # fi
1.1.1.4 root 1039:
1040: # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1041:
1042: file=sys/endian.h
1043: base=`basename $file`
1044: if [ -r ${LIB}/$file ]; then
1045: file_to_fix=${LIB}/$file
1046: else
1047: if [ -r ${INPUT}/$file ]; then
1048: file_to_fix=${INPUT}/$file
1049: else
1050: file_to_fix=""
1051: fi
1052: fi
1053: if [ \! -z "$file_to_fix" ]; then
1054: echo Checking $file_to_fix
1055: if grep __GNUC__ $file_to_fix > /dev/null; then
1.1.1.5 root 1056: true
1.1.1.4 root 1057: else
1058: sed -e '/# ifdef __STDC__/i\
1059: # if !defined (__GNUC__) && !defined (__GNUG__)' \
1060: -e '/# include <sys\/byteorder.h>/s/ / /'\
1061: -e '/# include <sys\/byteorder.h>/i\
1062: # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
1063: $file_to_fix > ${LIB}/${file}.sed
1064: rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1065: echo Fixed $file_to_fix
1066: fi
1067: fi
1068:
1069: # Commented out because [email protected] says we don't clearly need it
1070: # and the text in types.h is not erroneous.
1071: ## In sys/types.h, don't name the enum for booleans.
1072: #
1073: #file=sys/types.h
1074: #base=`basename $file`
1075: #if [ -r ${LIB}/$file ]; then
1076: # file_to_fix=${LIB}/$file
1077: #else
1078: # if [ -r ${INPUT}/$file ]; then
1079: # file_to_fix=${INPUT}/$file
1080: # else
1081: # file_to_fix=""
1082: # fi
1083: #fi
1084: #if [ \! -z "$file_to_fix" ]; then
1085: # echo Checking $file_to_fix
1086: # if grep "enum boolean" $file_to_fix > /dev/null; then
1087: # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1088: # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1089: # echo Fixed $file_to_fix
1090: # else
1.1.1.5 root 1091: # true
1.1.1.4 root 1092: # fi
1093: #fi
1094:
1095: # Remove useless extern keyword from struct forward declarations in
1096: # <sys/stream.h> and <sys/strsubr.h>
1097:
1098: file=sys/stream.h
1099: base=`basename $file`
1100: if [ -r ${LIB}/$file ]; then
1101: file_to_fix=${LIB}/$file
1102: else
1103: if [ -r ${INPUT}/$file ]; then
1104: file_to_fix=${INPUT}/$file
1105: else
1106: file_to_fix=""
1107: fi
1108: fi
1109: if [ \! -z "$file_to_fix" ]; then
1110: echo Checking $file_to_fix
1111: sed -e '
1112: s/extern struct stdata;/struct stdata;/g
1113: s/extern struct strevent;/struct strevent;/g
1114: ' $file_to_fix > /tmp/$base
1115: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1.1.1.5 root 1116: true
1.1.1.4 root 1117: else
1118: echo Fixed $file_to_fix
1119: rm -f ${LIB}/$file
1120: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 1121: chmod a+r ${LIB}/$file
1.1.1.4 root 1122: fi
1123: rm -f /tmp/$base
1124: fi
1125:
1126: file=sys/strsubr.h
1127: base=`basename $file`
1128: if [ -r ${LIB}/$file ]; then
1129: file_to_fix=${LIB}/$file
1130: else
1131: if [ -r ${INPUT}/$file ]; then
1132: file_to_fix=${INPUT}/$file
1133: else
1134: file_to_fix=""
1135: fi
1136: fi
1137: if [ \! -z "$file_to_fix" ]; then
1138: echo Checking $file_to_fix
1139: sed -e '
1140: s/extern struct strbuf;/struct strbuf;/g
1141: s/extern struct uio;/struct uio;/g
1142: s/extern struct thread;/struct thread;/g
1143: s/extern struct proc;/struct proc;/g
1144: ' $file_to_fix > /tmp/$base
1145: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1.1.1.5 root 1146: true
1.1.1.4 root 1147: else
1148: echo Fixed $file_to_fix
1149: rm -f ${LIB}/$file
1150: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 1151: chmod a+r ${LIB}/$file
1152: fi
1153: rm -f /tmp/$base
1154: fi
1155:
1156: # Put storage class at start of decl, to avoid warning.
1157: file=rpc/types.h
1158: base=`basename $file`
1159: if [ -r ${LIB}/$file ]; then
1160: file_to_fix=${LIB}/$file
1161: else
1162: if [ -r ${INPUT}/$file ]; then
1163: file_to_fix=${INPUT}/$file
1164: else
1165: file_to_fix=""
1166: fi
1167: fi
1168: if [ \! -z "$file_to_fix" ]; then
1169: echo Checking $file_to_fix
1170: sed -e '
1171: s/const extern/extern const/g
1172: ' $file_to_fix > /tmp/$base
1173: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1174: true
1175: else
1176: echo Fixed $file_to_fix
1177: rm -f ${LIB}/$file
1178: cp /tmp/$base ${LIB}/$file
1179: chmod a+r ${LIB}/$file
1.1.1.4 root 1180: fi
1181: rm -f /tmp/$base
1182: fi
1183:
1184: # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1185:
1186: file=sys/stat.h
1187: base=`basename $file`
1188: if [ -r ${LIB}/$file ]; then
1189: file_to_fix=${LIB}/$file
1190: else
1191: if [ -r ${INPUT}/$file ]; then
1192: file_to_fix=${INPUT}/$file
1193: else
1194: file_to_fix=""
1195: fi
1196: fi
1197: if [ \! -z "$file_to_fix" ]; then
1198: echo Checking $file_to_fix
1199: cp $file_to_fix /tmp/$base
1200: chmod +w /tmp/$base
1.1.1.6 root 1201: sed -e '/^stat([ ]*[^c]/{
1.1.1.5 root 1202: N
1203: N
1204: s/(.*)\n/( /
1205: s/;\n/, /
1206: s/;$/)/
1207: }' \
1.1.1.6 root 1208: -e '/^lstat([ ]*[^c]/{
1.1.1.5 root 1209: N
1210: N
1211: s/(.*)\n/( /
1212: s/;\n/, /
1213: s/;$/)/
1214: }' \
1.1.1.6 root 1215: -e '/^fstat([ ]*[^i]/{
1.1.1.5 root 1216: N
1217: N
1218: s/(.*)\n/( /
1219: s/;\n/, /
1220: s/;$/)/
1221: }' \
1.1.1.6 root 1222: -e '/^mknod([ ]*[^c]/{
1.1.1.5 root 1223: N
1224: N
1225: N
1226: s/(.*)\n/( /
1227: s/;\n/, /g
1228: s/;$/)/
1229: }' \
1230: -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1231: -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1232: -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1233: -e '1,$s/ret\([^u]\)/__ret\1/g' \
1234: -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1235: -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1236: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1237: true
1238: else
1239: echo Fixed $file_to_fix
1240: rm -f ${LIB}/$file
1241: cp /tmp/$base.sed ${LIB}/$file
1242: chmod a+r ${LIB}/$file
1243: fi
1244: rm -f /tmp/$base /tmp/$base.sed
1.1.1.4 root 1245: fi
1246:
1.1.1.2 root 1247: # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1248:
1249: if [ -x /bin/sony ]; then
1250: if /bin/sony; then
1251:
1252: # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1253:
1254: file=stdio.h
1255: base=`basename $file`
1256: if [ -r ${LIB}/$file ]; then
1257: file_to_fix=${LIB}/$file
1258: else
1259: if [ -r ${INPUT}/$file ]; then
1260: file_to_fix=${INPUT}/$file
1261: else
1262: file_to_fix=""
1263: fi
1264: fi
1265: if [ \! -z "$file_to_fix" ]; then
1266: echo Checking $file_to_fix
1267: cp $file_to_fix /tmp/$base
1268: chmod +w /tmp/$base
1269: sed -e '
1270: s/__filbuf/_filbuf/g
1271: s/__flsbuf/_flsbuf/g
1272: s/__iob/_iob/g
1273: ' /tmp/$base > /tmp/$base.sed
1274: mv /tmp/$base.sed /tmp/$base
1275: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1.1.1.5 root 1276: true
1.1.1.2 root 1277: else
1278: echo Fixed $file_to_fix
1279: rm -f ${LIB}/$file
1280: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 1281: chmod a+r ${LIB}/$file
1.1.1.2 root 1282: fi
1283: rm -f /tmp/$base
1284: fi
1285:
1286: # Change <ctype.h> to not define __ctype
1287:
1288: file=ctype.h
1289: base=`basename $file`
1290: if [ -r ${LIB}/$file ]; then
1291: file_to_fix=${LIB}/$file
1292: else
1293: if [ -r ${INPUT}/$file ]; then
1294: file_to_fix=${INPUT}/$file
1295: else
1296: file_to_fix=""
1297: fi
1298: fi
1299: if [ \! -z "$file_to_fix" ]; then
1300: echo Checking $file_to_fix
1301: cp $file_to_fix /tmp/$base
1302: chmod +w /tmp/$base
1303: sed -e '
1304: s/__ctype/_ctype/g
1305: ' /tmp/$base > /tmp/$base.sed
1306: mv /tmp/$base.sed /tmp/$base
1307: if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1.1.1.5 root 1308: true
1.1.1.2 root 1309: else
1310: echo Fixed $file_to_fix
1311: rm -f ${LIB}/$file
1312: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 1313: chmod a+r ${LIB}/$file
1.1.1.2 root 1314: fi
1315: rm -f /tmp/$base
1316: fi
1317: fi
1318: fi
1319:
1.1.1.4 root 1320: # In limits.h, put #ifndefs around things that are supposed to be defined
1321: # in float.h to avoid redefinition errors if float.h is included first.
1322: # Solaris 2.1 has this problem.
1323:
1324: file=limits.h
1325: base=`basename $file`
1326: if [ -r ${LIB}/$file ]; then
1327: file_to_fix=${LIB}/$file
1328: else
1329: if [ -r ${INPUT}/$file ]; then
1330: file_to_fix=${INPUT}/$file
1331: else
1332: file_to_fix=""
1333: fi
1334: fi
1335: if [ \! -z "$file_to_fix" ]; then
1336: echo Checking $file_to_fix
1337: sed -e '/[ ]FLT_MIN[ ]/i\
1338: #ifndef FLT_MIN'\
1339: -e '/[ ]FLT_MIN[ ]/a\
1340: #endif'\
1341: -e '/[ ]FLT_MAX[ ]/i\
1342: #ifndef FLT_MAX'\
1343: -e '/[ ]FLT_MAX[ ]/a\
1344: #endif'\
1345: -e '/[ ]FLT_DIG[ ]/i\
1346: #ifndef FLT_DIG'\
1347: -e '/[ ]FLT_DIG[ ]/a\
1348: #endif'\
1349: -e '/[ ]DBL_MIN[ ]/i\
1350: #ifndef DBL_MIN'\
1351: -e '/[ ]DBL_MIN[ ]/a\
1352: #endif'\
1353: -e '/[ ]DBL_MAX[ ]/i\
1354: #ifndef DBL_MAX'\
1355: -e '/[ ]DBL_MAX[ ]/a\
1356: #endif'\
1357: -e '/[ ]DBL_DIG[ ]/i\
1358: #ifndef DBL_DIG'\
1359: -e '/[ ]DBL_DIG[ ]/a\
1360: #endif' $file_to_fix > /tmp/$base
1361: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1.1.1.5 root 1362: true
1.1.1.4 root 1363: else
1364: echo Fixed $file_to_fix
1365: rm -f ${LIB}/$file
1366: cp /tmp/$base ${LIB}/$file
1.1.1.5 root 1367: chmod a+r ${LIB}/$file
1.1.1.4 root 1368: fi
1369: rm -f /tmp/$base
1370: fi
1371:
1.1.1.5 root 1372: # Completely replace <sys/varargs.h> with a file that includes gcc's
1373: # stdarg.h or varargs.h files as appropriate.
1374:
1375: file=sys/varargs.h
1376: if [ -r ${INPUT}/$file ]; then
1377: echo Replacing $file
1378: cat > ${LIB}/$file << EOF
1379: /* This file was generated by fixincludes. */
1380: #ifndef _SYS_VARARGS_H
1381: #define _SYS_VARARGS_H
1382:
1383: #ifdef __STDC__
1384: #include <stdarg.h>
1385: #else
1386: #include <varargs.h>
1387: #endif
1388:
1389: #endif /* _SYS_VARARGS_H */
1390: EOF
1391: chmod a+r ${LIB}/$file
1392: fi
1393:
1.1.1.6 root 1394: # In math.h, put #ifndefs around things that might be defined in a gcc
1395: # specific math-*.h file.
1396:
1397: file=math.h
1398: base=`basename $file`
1399: if [ -r ${LIB}/$file ]; then
1400: file_to_fix=${LIB}/$file
1401: else
1402: if [ -r ${INPUT}/$file ]; then
1403: file_to_fix=${INPUT}/$file
1404: else
1405: file_to_fix=""
1406: fi
1407: fi
1408: if [ \! -z "$file_to_fix" ]; then
1409: echo Checking $file_to_fix
1410: sed -e '/define[ ]HUGE_VAL[ ]/i\
1411: #ifndef HUGE_VAL'\
1412: -e '/define[ ]HUGE_VAL[ ]/a\
1413: #endif' $file_to_fix > /tmp/$base
1414: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1415: true
1416: else
1417: echo Fixed $file_to_fix
1418: rm -f ${LIB}/$file
1419: cp /tmp/$base ${LIB}/$file
1420: chmod a+r ${LIB}/$file
1421: fi
1422: rm -f /tmp/$base
1423: fi
1424:
1.1.1.7 root 1425: # Solaris math.h and floatingpoint.h define __P without protection,
1426: # which conflicts with the fixproto definition. The fixproto
1427: # definition and the Solaris definition are used the same way.
1428: for file in math.h floatingpoint.h; do
1429: base=`basename $file`
1430: if [ -r ${LIB}/$file ]; then
1431: file_to_fix=${LIB}/$file
1432: else
1433: if [ -r ${INPUT}/$file ]; then
1434: file_to_fix=${INPUT}/$file
1435: else
1436: file_to_fix=""
1437: fi
1438: fi
1439: if [ \! -z "$file_to_fix" ]; then
1440: echo Checking $file_to_fix
1441: sed -e '/^#define[ ]*__P/i\
1442: #ifndef __P'\
1443: -e '/^#define[ ]*__P/a\
1444: #endif' $file_to_fix > /tmp/$base
1445: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1446: true
1447: else
1448: echo Fixed $file_to_fix
1449: rm -f ${LIB}/$file
1450: cp /tmp/$base ${LIB}/$file
1451: chmod a+r ${LIB}/$file
1452: fi
1453: rm -f /tmp/$base
1454: fi
1455: done
1456:
1.1 root 1457: echo 'Removing unneeded directories:'
1458: cd $LIB
1459: files=`find . -type d -print | sort -r`
1460: for file in $files; do
1461: rmdir $LIB/$file > /dev/null 2>&1
1462: done
1463:
1464: if $LINKS; then
1465: echo 'Making internal symbolic non-directory links'
1466: cd ${INPUT}
1467: files=`find . -type l -print`
1468: for file in $files; do
1469: dest=`ls -ld $file | sed -n 's/.*-> //p'`
1470: if expr "$dest" : '[^/].*' > /dev/null; then
1471: target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1472: if [ -f $target ]; then
1473: ln -s $dest ${LIB}/$file >/dev/null 2>&1
1474: fi
1475: fi
1476: done
1477: fi
1478:
1479: cd ${ORIG_DIR}
1480:
1481: echo 'Replacing <sys/byteorder.h>'
1.1.1.7 root 1482: if [ \! -d $LIB/sys ]; then
1483: mkdir $LIB/sys
1484: fi
1.1 root 1485: rm -f ${LIB}/sys/byteorder.h
1.1.1.7 root 1486: cat <<'__EOF__' >${LIB}/sys/byteorder.h
1487: #ifndef _SYS_BYTEORDER_H
1488: #define _SYS_BYTEORDER_H
1489:
1490: /* Functions to convert `short' and `long' quantities from host byte order
1491: to (internet) network byte order (i.e. big-endian).
1492:
1493: Written by Ron Guilmette ([email protected]).
1494:
1495: This isn't actually used by GCC. It is installed by fixinc.svr4.
1496:
1497: For big-endian machines these functions are essentially no-ops.
1498:
1499: For little-endian machines, we define the functions using specialized
1500: asm sequences in cases where doing so yields better code (e.g. i386). */
1501:
1502: #if !defined (__GNUC__) && !defined (__GNUG__)
1503: #error You lose! This file is only useful with GNU compilers.
1504: #endif
1505:
1506: #ifndef __BYTE_ORDER__
1507: /* Byte order defines. These are as defined on UnixWare 1.1, but with
1508: double underscores added at the front and back. */
1509: #define __LITTLE_ENDIAN__ 1234
1510: #define __BIG_ENDIAN__ 4321
1511: #define __PDP_ENDIAN__ 3412
1512: #endif
1513:
1514: #ifdef __STDC__
1.1.1.8 ! root 1515: static __inline__ unsigned long htonl (unsigned long);
! 1516: static __inline__ unsigned short htons (unsigned int);
! 1517: static __inline__ unsigned long ntohl (unsigned long);
! 1518: static __inline__ unsigned short ntohs (unsigned int);
1.1.1.7 root 1519: #endif /* defined (__STDC__) */
1520:
1521: #if defined (__i386__)
1522:
1523: #ifndef __BYTE_ORDER__
1524: #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1525: #endif
1526:
1527: /* Convert a host long to a network long. */
1528:
1529: /* We must use a new-style function definition, so that this will also
1530: be valid for C++. */
1.1.1.8 ! root 1531: static __inline__ unsigned long
1.1.1.7 root 1532: htonl (unsigned long __arg)
1533: {
1534: register unsigned long __result;
1535:
1536: __asm__ ("xchg%B0 %b0,%h0\n\
1537: ror%L0 $16,%0\n\
1538: xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1539: return __result;
1540: }
1541:
1542: /* Convert a host short to a network short. */
1543:
1.1.1.8 ! root 1544: static __inline__ unsigned short
1.1.1.7 root 1545: htons (unsigned int __arg)
1546: {
1547: register unsigned short __result;
1548:
1549: __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1550: return __result;
1551: }
1552:
1553: #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1554: || defined (__ns32k__) || defined (__vax__) \
1555: || defined (__spur__) || defined (__arm__))
1556:
1557: #ifndef __BYTE_ORDER__
1558: #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1559: #endif
1560:
1561: /* For other little-endian machines, using C code is just as efficient as
1562: using assembly code. */
1563:
1564: /* Convert a host long to a network long. */
1565:
1.1.1.8 ! root 1566: static __inline__ unsigned long
1.1.1.7 root 1567: htonl (unsigned long __arg)
1568: {
1569: register unsigned long __result;
1570:
1571: __result = (__arg >> 24) & 0x000000ff;
1572: __result |= (__arg >> 8) & 0x0000ff00;
1573: __result |= (__arg << 8) & 0x00ff0000;
1574: __result |= (__arg << 24) & 0xff000000;
1575: return __result;
1576: }
1577:
1578: /* Convert a host short to a network short. */
1579:
1.1.1.8 ! root 1580: static __inline__ unsigned short
1.1.1.7 root 1581: htons (unsigned int __arg)
1582: {
1583: register unsigned short __result;
1584:
1585: __result = (__arg << 8) & 0xff00;
1586: __result |= (__arg >> 8) & 0x00ff;
1587: return __result;
1588: }
1589:
1590: #else /* must be a big-endian machine */
1591:
1592: #ifndef __BYTE_ORDER__
1593: #define __BYTE_ORDER__ __BIG_ENDIAN__
1594: #endif
1595:
1596: /* Convert a host long to a network long. */
1597:
1.1.1.8 ! root 1598: static __inline__ unsigned long
1.1.1.7 root 1599: htonl (unsigned long __arg)
1600: {
1601: return __arg;
1602: }
1603:
1604: /* Convert a host short to a network short. */
1605:
1.1.1.8 ! root 1606: static __inline__ unsigned short
1.1.1.7 root 1607: htons (unsigned int __arg)
1608: {
1609: return __arg;
1610: }
1611:
1612: #endif /* big-endian */
1613:
1614: /* Convert a network long to a host long. */
1615:
1.1.1.8 ! root 1616: static __inline__ unsigned long
1.1.1.7 root 1617: ntohl (unsigned long __arg)
1618: {
1619: return htonl (__arg);
1620: }
1621:
1622: /* Convert a network short to a host short. */
1623:
1.1.1.8 ! root 1624: static __inline__ unsigned short
1.1.1.7 root 1625: ntohs (unsigned int __arg)
1626: {
1627: return htons (__arg);
1628: }
1629:
1630: __EOF__
1631:
1632: if [ -r ${INPUT}/sys/byteorder.h ]; then
1633: if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
1634: cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1635: #ifndef BYTE_ORDER
1636: #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1637: #define BIG_ENDIAN __BIG_ENDIAN__
1638: #define PDP_ENDIAN __PDP_ENDIAN__
1639: #define BYTE_ORDER __BYTE_ORDER__
1640: #endif
1641:
1642: __EOF__
1643: fi
1644: fi
1645:
1646: cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1647: #endif /* !defined (_SYS_BYTEORDER_H) */
1648: __EOF__
1649:
1650: chmod a+r ${LIB}/sys/byteorder.h
1.1 root 1651:
1652: exit 0
1653:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.