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