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