]> gcc.gnu.org Git - gcc.git/blame - gcc/fixincludes
(mark_loop_jump): Handle weird cases like jumping to a symbol_ref.
[gcc.git] / gcc / fixincludes
CommitLineData
c61a25b1
DM
1#! /bin/sh
2# Install modified versions of certain ANSI-incompatible system header files
3# which are fixed to work correctly with ANSI C
4# and placed in a directory that GNU C will search.
5
6# See README-fixinc for more information.
7
b7b62369
RS
8# Directory where gcc sources (and sometimes special include files) live.
9# fixincludes doesn't use this, but fixinc.svr4 does, and I want to make
10# sure somebody doesn't try to use arg3 for something incompatible. -- gumby
11SRCDIR=${3-${SRCDIR-.}}
12
c61a25b1
DM
13# Directory containing the original header files.
14# (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
15INPUT=${2-${INPUT-/usr/include}}
16
ffc47266
JW
17# Directory in which to store the results.
18LIB=${1?"fixincludes: output directory not specified"}
c61a25b1 19
4ed15f9d
RS
20# Define PWDCMD as a command to use to get the working dir
21# in the form that we want.
22PWDCMD=pwd
23case "`pwd`" in
24//*)
25 # On an Apollo, discard everything before `/usr'.
d45ceebe 26 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
4ed15f9d
RS
27 ;;
28esac
29
631e21eb
DE
30# Original directory.
31ORIGDIR=`${PWDCMD}`
32
c61a25b1
DM
33# Make sure it exists.
34if [ ! -d $LIB ]; then
35 mkdir $LIB || exit 1
36fi
37
e1fa48b5
RS
38# Make LIB absolute only if needed to avoid problems with the amd.
39case $LIB in
40/*)
41 ;;
42*)
43 cd $LIB; LIB=`${PWDCMD}`
44 ;;
45esac
c61a25b1 46
8befb954
RS
47# Make SRCDIR absolute only if needed to avoid problems with the amd.
48cd $ORIGDIR
49case $SRCDIR in
50/*)
51 ;;
52*)
53 cd $SRCDIR; SRCDIR=`${PWDCMD}`
54 ;;
55esac
56
c61a25b1
DM
57# Fail if no arg to specify a directory for the output.
58if [ x$1 = x ]
59then echo fixincludes: no output directory specified
60exit 1
61fi
62
1ac7d389 63echo Building fixed headers in ${LIB}
c61a25b1
DM
64
65# Determine whether this system has symbolic links.
66if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
67 rm -f $LIB/ShouldNotExist
0fa2faf0
RS
68 LINKS=true
69elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
70 rm -f /tmp/ShouldNotExist
c61a25b1
DM
71 LINKS=true
72else
73 LINKS=false
74fi
75
1ac7d389 76echo Finding directories and links to directories
c61a25b1 77cd ${INPUT}
3308e40a 78# Find all directories and all symlinks that point to directories.
f1f1ae8e
RS
79# Put the list in $files.
80# Each time we find a symlink, add it to newdirs
81# so that we do another find within the dir the link points to.
82# Note that $files may have duplicates in it;
83# later parts of this file are supposed to ignore them.
84dirs="."
fd297e33
RS
85levels=2
86while [ -n "$dirs" ] && [ $levels -gt 0 ]
f1f1ae8e 87do
fd297e33 88 levels=`expr $levels - 1`
f1f1ae8e 89 newdirs=
fd297e33 90 for d in $dirs
f1f1ae8e 91 do
1ac7d389 92 echo " Searching $INPUT/$d"
f1f1ae8e
RS
93 if [ "$d" != . ]
94 then
95 d=$d/.
96 fi
97
fd297e33 98 # Find all directories under $d, relative to $d, excluding $d itself.
165b3941
RS
99 files="$files `find $d -type d -print | \
100 sed -e '/\/\.$/d' -e '/^\.$/d'`"
101 # Find all links to directories.
102 # Using `-exec test -d' in find fails on some systems,
103 # and trying to run test via sh fails on others,
104 # so this is the simplest alternative left.
105 # First find all the links, then test each one.
106 theselinks=
f1f1ae8e 107 $LINKS && \
165b3941
RS
108 theselinks=`find $d -type l -print`
109 for d1 in $theselinks --dummy--
110 do
1ac7d389
RS
111 # If the link points to a directory,
112 # add that dir to $newdirs
165b3941
RS
113 if [ -d $d1 ]
114 then
115 newdirs="$newdirs $d1"
116 fi
117 done
f1f1ae8e
RS
118 done
119
89ccb80f 120 files="$files $newdirs"
f1f1ae8e 121 dirs="$newdirs"
f1f1ae8e
RS
122done
123
124dirs=
1ac7d389 125echo "All directories (including links to directories):"
f1f1ae8e
RS
126echo $files
127
c61a25b1
DM
128for file in $files; do
129 rm -rf $LIB/$file
130 if [ ! -d $LIB/$file ]
131 then mkdir $LIB/$file
132 fi
133done
1ac7d389 134mkdir $LIB/root
c61a25b1
DM
135
136# treetops gets an alternating list
137# of old directories to copy
138# and the new directories to copy to.
139treetops="${INPUT} ${LIB}"
140
141if $LINKS; then
1ac7d389 142 echo 'Making symbolic directory links'
c61a25b1
DM
143 for file in $files; do
144 dest=`ls -ld $file | sed -n 's/.*-> //p'`
145 if [ "$dest" ]; then
4ed15f9d 146 cwd=`${PWDCMD}`
c61a25b1
DM
147 # In case $dest is relative, get to $file's dir first.
148 cd ${INPUT}
149 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
150 # Check that the target directory exists.
151 # Redirections changed to avoid bug in sh on Ultrix.
152 (cd $dest) > /dev/null 2>&1
153 if [ $? = 0 ]; then
154 cd $dest
155 # X gets the dir that the link actually leads to.
4ed15f9d 156 x=`${PWDCMD}`
1ac7d389
RS
157 # If a link points to ., make a similar link to .
158 if [ $x = $INPUT ]; then
159 echo $file '->' . ': Making link'
160 rm -fr ${LIB}/$file > /dev/null 2>&1
161 ln -s . ${LIB}/$file > /dev/null 2>&1
c61a25b1
DM
162 # If link leads back into ${INPUT},
163 # make a similar link here.
1ac7d389 164 elif expr $x : "${INPUT}/.*" > /dev/null; then
c61a25b1
DM
165 # Y gets the actual target dir name, relative to ${INPUT}.
166 y=`echo $x | sed -n "s&${INPUT}/&&p"`
884caf18
PE
167 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
168 dots=`echo "$file" |
169 sed -e 's@^./@@' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
170 echo $file '->' $dots$y ': Making link'
c61a25b1 171 rm -fr ${LIB}/$file > /dev/null 2>&1
884caf18 172 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
c61a25b1 173 else
1ac7d389
RS
174 # If the link is to a dir $target outside ${INPUT},
175 # repoint the link at ${INPUT}/root$target
176 # and process $target into ${INPUT}/root$target
c61a25b1 177 # treat this directory as if it actually contained the files.
1ac7d389
RS
178 echo $file '->' root$x ': Making link'
179 if [ -d $LIB/root$x ]
180 then true
181 else
182 dirname=root$x/
183 dirmade=.
184 cd $LIB
185 while [ x$dirname != x ]; do
186 component=`echo $dirname | sed -e 's|/.*$||'`
187 mkdir $component >/dev/null 2>&1
188 cd $component
189 dirmade=$dirmade/$component
190 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
191 done
192 fi
f744b2ce
RS
193 # Duplicate directory structure created in ${LIB}/$file in new
194 # root area.
195 for file2 in $files; do
196 case $file2 in
638fa106 197 $file/./*)
f744b2ce
RS
198 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
199 echo "Duplicating ${file}'s ${dupdir}"
200 if [ -d ${dupdir} ]
201 then true
202 else
203 mkdir ${dupdir}
204 fi
205 ;;
638fa106
BK
206 *)
207 ;;
f744b2ce
RS
208 esac
209 done
884caf18
PE
210 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
211 dots=`echo "$file" |
212 sed -e 's@^./@@' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
1ac7d389 213 rm -fr ${LIB}/$file > /dev/null 2>&1
884caf18 214 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
1ac7d389 215 treetops="$treetops $x ${LIB}/root$x"
c61a25b1
DM
216 fi
217 fi
218 cd $cwd
219 fi
220 done
221fi
222
25e51a69
ILT
223set x $treetops
224shift
c61a25b1
DM
225while [ $# != 0 ]; do
226 # $1 is an old directory to copy, and $2 is the new directory to copy to.
c61a25b1
DM
227 cd ${INPUT}
228 cd $1
1ac7d389
RS
229# The same dir can appear more than once in treetops.
230# There's no need to scan it more than once.
231 if [ -f $2/DONE ]
232 then
233 files=
234 else
235 touch $2/DONE
236 echo Fixing directory $1 into $2
8c31e6b6
RS
237# Check .h files which are symlinks as well as those which are files.
238# A link to a header file will not be processed by anything but this.
73bdfabc
RS
239 if $LINKS; then
240 files=`find . -name '*.h' \( -type f -o -type l \) -print`
241 else
242 files=`find . -name '*.h' -type f -print`
243 fi
1ac7d389
RS
244 echo Checking header files
245 fi
c61a25b1
DM
246# Note that BSD43_* are used on recent MIPS systems.
247 for file in $files; do
248# This call to egrep is essential, since checking a file with egrep
249# is much faster than actually trying to fix it.
3308e40a
RS
250# It is also essential that most files *not* match!
251# Thus, matching every #endif is unacceptable.
c61a25b1
DM
252# But the argument to egrep must be kept small, or many versions of egrep
253# won't be able to handle it.
25e51a69
ILT
254#
255# We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
256# following #else or #endif because some buggy egreps think [^/] matches
257# newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
258#
259# We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
260# following #if or #elif that is not surrounded by __. The `a-ce-km-z'
261# in this pattern lacks `d' and `l'; this means we don't worry about
262# identifiers starting with `d' or `l'. This is OK, since none of the
263# identifiers below start with `d' or `l'. It also greatly improves
264# performance, since many files contain lines of the form `#if ... defined ...'
265# or `#if lint'.
266 if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-z][a-z0-9]' $file >/dev/null; then
c61a25b1
DM
267 if [ -r $file ]; then
268 cp $file $2/$file >/dev/null 2>&1 \
269 || echo "Can't copy $file"
270 chmod +w $2/$file
2e4cd151 271 chmod a+r $2/$file
8caf703c
RS
272 # Here is how the sed commands in braces work.
273 # (It doesn't work to put the comments inside the sed commands.)
274 # Surround each word with spaces, to simplify matching below.
275 # ANSIfy each pre-ANSI machine-dependent symbol
276 # by surrounding it with __ __.
277 # Remove the spaces that we inserted around each word.
c61a25b1
DM
278 sed -e '
279 :loop
280 /\\$/ N
281 /\\$/ b loop
20c74d5e
PE
282 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
283 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
284 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
ec4738c0
RS
285 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
286 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
883bc780 287 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
2a46424a 288 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
c61a25b1 289 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
a2790172 290 /#define._IO/ s/'\''\([cgx]\)'\''/\1/g
25e51a69 291 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
d7c768e7
RS
292 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
293 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
c87e58bb
RS
294 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
295 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
a2790172 296 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
25e51a69 297 /#[el]*if/{
25e51a69
ILT
298 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
299
25e51a69
ILT
300 s/ bsd4\([0-9]\) / __bsd4\1__ /g
301 s/ _*i386 / __i386__ /g
302 s/ is68k / __is68k__ /g
303 s/ m68k / __m68k__ /g
304 s/ mc680\([0-9]\)0 / __mc680\10__ /g
305 s/ news\([0-9]*\) / __news\1__ /g
306 s/ ns32000 / __ns32000__ /g
307 s/ pyr / __pyr__ /g
308 s/ sony_news / __sony_news__ /g
309 s/ sparc / __sparc__ /g
310 s/ sun\([a-z0-9]*\) / __sun\1__ /g
311 s/ unix / __unix__ /g
312 s/ vax / __vax__ /g
313
25e51a69
ILT
314 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
315 }
45b33951 316 /^#define.NULL[ ]/ i\
c61a25b1 317 #undef NULL
78c5c646
RS
318 ' $2/$file > $2/$file.
319 mv $2/$file. $2/$file
c61a25b1 320 if cmp $file $2/$file >/dev/null 2>&1; then
c61a25b1 321 rm $2/$file
b52a4b72
RS
322 else
323 echo Fixed $file
c61a25b1
DM
324 fi
325 fi
326 fi
327 done
328 shift; shift
329done
330
331cd ${INPUT}
332
cd3383a3 333# Install the proper definition of size_t in header files that it comes from.
1f1ff018 334for file in sys/types.h stdlib.h sys/stdtypes.h; do
cd3383a3
RS
335 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
336 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
337 chmod +w ${LIB}/$file 2>/dev/null
338 chmod a+r ${LIB}/$file 2>/dev/null
339 fi
340
341 if [ -r ${LIB}/$file ]; then
342 echo Fixing $file comment
343 # Extract the definition of SIZE_TYPE, if any.
344 # (This file must be called something.c).
345 echo "#include \"tm.h\"
631e21eb 346gobblegobble SIZE_TYPE" > ${LIB}/types.c
5ec88efd 347 foo=`cd ${LIB}; cc -E -I${ORIGDIR} -I${SRCDIR} -I${SRCDIR}/config types.c | grep gobblegobble | sed -e "s/gobblegobble[ ]*//"`
631e21eb 348 rm -f ${LIB}/types.c
cd3383a3 349 # Default to our preferred type.
8befb954 350 if [ "$foo" = SIZE_TYPE ]; then foo="unsigned long int"; else foo=`echo $foo | sed -e 's/^.*"\(.*\)".*$/\1/'`; fi
cd3383a3
RS
351 sed -e "s/typedef[ a-z_]*[ ]size_t/typedef $foo size_t/" ${LIB}/$file > ${LIB}/${file}.sed
352 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
353 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
354 rm ${LIB}/$file
355 fi
356 fi
357done
358
c61a25b1
DM
359# Fix one other error in this file: a mismatched quote not inside a C comment.
360file=sundev/vuid_event.h
361if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
362 mkdir ${LIB}/sundev 2>/dev/null
363 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
364 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 365 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
366fi
367
368if [ -r ${LIB}/$file ]; then
369 echo Fixing $file comment
ffc47266
JW
370 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
371 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 372 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
373 rm ${LIB}/$file
374 fi
375fi
376
4ba0ff2d
JW
377# Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
378file=sunwindow/win_cursor.h
379if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
380# mkdir ${LIB}/sunwindow 2>/dev/null
381 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
382 chmod +w ${LIB}/$file 2>/dev/null
383fi
384if [ -r ${LIB}/$file ]; then
385 echo Fixing $file
386 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
387 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
388 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
389 rm ${LIB}/$file
390 fi
391fi
392file=sunwindow/win_lock.h
393if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
394# mkdir ${LIB}/sunwindow 2>/dev/null
395 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
396 chmod +w ${LIB}/$file 2>/dev/null
397fi
398if [ -r ${LIB}/$file ]; then
399 echo Fixing $file
400 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
401 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
402 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
403 rm ${LIB}/$file
404 fi
405fi
406
6dc42e49 407# Fix this Sun file to avoid interfering with stddef.h.
c61a25b1
DM
408file=sys/stdtypes.h
409if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
410 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
411 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 412 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
413fi
414
415if [ -r ${LIB}/$file ]; then
416 echo Fixing $file
daa4489f 417sed -e '/[ ]size_t.*;/i\
ffc47266
JW
418#ifndef _GCC_SIZE_T\
419#define _GCC_SIZE_T' \
daa4489f 420 -e '/[ ]size_t.*;/a\
ffc47266 421#endif' \
daa4489f 422 -e '/[ ]ptrdiff_t.*;/i\
ffc47266
JW
423#ifndef _GCC_PTRDIFF_T\
424#define _GCC_PTRDIFF_T' \
daa4489f 425 -e '/[ ]ptrdiff_t.*;/a\
ffc47266 426#endif' \
daa4489f 427 -e '/[ ]wchar_t.*;/i\
ffc47266
JW
428#ifndef _GCC_WCHAR_T\
429#define _GCC_WCHAR_T' \
daa4489f 430 -e '/[ ]wchar_t.*;/a\
ffc47266
JW
431#endif' ${LIB}/$file > ${LIB}/${file}.sed
432 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 433 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
434 rm ${LIB}/$file
435 fi
436fi
437
fd9287ae
JW
438# Fix this file to avoid interfering with stddef.h, but don't mistakenly
439# match e.g. ssize_t present in AIX for the ps/2.
c61a25b1
DM
440file=sys/types.h
441if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
442 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
443 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 444 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
445fi
446
447if [ -r ${LIB}/$file ]; then
448 echo Fixing $file
590d6f8e 449sed -e '/[ ]size_t.*;/i\
ffc47266
JW
450#ifndef _GCC_SIZE_T\
451#define _GCC_SIZE_T' \
590d6f8e 452 -e '/[ ]size_t.*;/a\
ffc47266
JW
453#endif' ${LIB}/$file > ${LIB}/${file}.sed
454 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 455 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
456 rm ${LIB}/$file
457 fi
458fi
459
08455880
TW
460# Fix an error in this file: the #if says _cplusplus, not the double
461# underscore __cplusplus that it should be
462file=tinfo.h
463if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
464 mkdir ${LIB}/rpcsvc 2>/dev/null
465 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
466 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 467 chmod a+r ${LIB}/$file 2>/dev/null
08455880
TW
468fi
469
470if [ -r ${LIB}/$file ]; then
471 echo Fixing $file, __cplusplus macro
472 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
473 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
474 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
475 rm ${LIB}/$file
476 fi
477fi
478
c61a25b1
DM
479# Fix an error in this file: a missing semi-colon at the end of the statsswtch
480# structure definition.
481file=rpcsvc/rstat.h
482if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
483 mkdir ${LIB}/rpcsvc 2>/dev/null
484 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
485 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 486 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
487fi
488
489if [ -r ${LIB}/$file ]; then
490 echo Fixing $file, definition of statsswtch
ffc47266
JW
491 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
492 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 493 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
494 rm ${LIB}/$file
495 fi
496fi
497
498# Fix an error in this file: a missing semi-colon at the end of the nodeent
499# structure definition.
500file=netdnet/dnetdb.h
501if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
502 mkdir ${LIB}/netdnet 2>/dev/null
503 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
504 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 505 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
506fi
507
508if [ -r ${LIB}/$file ]; then
509 echo Fixing $file, definition of nodeent
ffc47266
JW
510 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
511 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 512 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
513 rm ${LIB}/$file
514 fi
515fi
516
517# Check for bad #ifdef line (in Ultrix 4.1)
518file=sys/file.h
519if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
520 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
521 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 522 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
523fi
524
525if [ -r ${LIB}/$file ]; then
526 echo Fixing $file, bad \#ifdef line
ffc47266
JW
527 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
528 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 529 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
530 rm ${LIB}/$file
531 fi
532fi
533
534# Check for superfluous `static' (in Ultrix 4.2)
535file=machine/cpu.h
536if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
537 mkdir ${LIB}/machine 2>/dev/null
538 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
539 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 540 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
541fi
542
543if [ -r ${LIB}/$file ]; then
544 echo Fixing $file, superfluous static
ffc47266
JW
545 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed
546 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 547 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
548 rm ${LIB}/$file
549 else
550# This file has an alternative name, mips/cpu.h. Fix that name, too.
1f1ff018 551 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
c61a25b1
DM
552 mkdir ${LIB}/mips 2>&-
553 ln ${LIB}/$file ${LIB}/mips/cpu.h
554 fi
555 fi
556fi
557
75251fe0 558# Incorrect sprintf declaration in X11/Xmu.h
c61a25b1
DM
559file=X11/Xmu.h
560if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
561 mkdir ${LIB}/X11 2>/dev/null
562 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
563 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 564 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
565fi
566
567if [ -r ${LIB}/$file ]; then
568 echo Fixing $file sprintf declaration
ffc47266
JW
569 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
570extern char * sprintf();\
8739838d 571#endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
ffc47266 572 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 573 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
574 rm ${LIB}/$file
575 fi
576fi
577
3a6aca8e
RS
578# Incorrect sprintf declaration in X11/Xmu/Xmu.h
579# (It's not clear whether the right file name is this or X11/Xmu.h.)
580file=X11/Xmu/Xmu.h
581if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
582 mkdir ${LIB}/X11/Xmu 2>/dev/null
583 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
584 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 585 chmod a+r ${LIB}/$file 2>/dev/null
3a6aca8e
RS
586fi
587
588if [ -r ${LIB}/$file ]; then
589 echo Fixing $file sprintf declaration
ffc47266
JW
590 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
591extern char * sprintf();\
8739838d 592#endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
ffc47266 593 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3a6aca8e 594 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
3a6aca8e
RS
595 rm ${LIB}/$file
596 fi
597fi
598
c61a25b1
DM
599# Check for missing ';' in struct
600file=netinet/ip.h
601if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
602 mkdir ${LIB}/netinet 2>/dev/null
603 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
604 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 605 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
606fi
607
608if [ -r ${LIB}/$file ]; then
609 echo Fixing $file
610 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
611 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
612 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
613 rm -f ${LIB}/$file
614 fi
615fi
616
75251fe0 617# Fix the CAT macro in SunOS memvar.h.
c61a25b1
DM
618file=pixrect/memvar.h
619if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
620 mkdir ${LIB}/pixrect 2>/dev/null
621 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
622 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 623 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
624fi
625
626if [ -r ${LIB}/$file ]; then
627 echo Fixing $file
628 sed -e '/^#define.CAT(a,b)/ i\
629#ifdef __STDC__ \
630#define CAT(a,b) a##b\
631#else
632/^#define.CAT(a,b)/ a\
633#endif
634' ${LIB}/$file > ${LIB}/${file}.sed
635 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
636 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
637 rm -f ${LIB}/$file
638 fi
639fi
640
641# Check for yet more missing ';' in struct (in SunOS 4.0.x)
642file=rpcsvc/rusers.h
643if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
644 mkdir ${LIB}/rpcsvc 2>/dev/null
645 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
646 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 647 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
648fi
649
650if [ -r ${LIB}/$file ]; then
651 echo Fixing $file
652 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
653 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
654 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
655 rm -f ${LIB}/$file
656 fi
657fi
658
659# Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
c87e58bb 660# Also wrap protection around size_t for m88k-sysv3 systems.
c61a25b1
DM
661file=stdlib.h
662if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
663 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
664 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 665 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
666fi
667
668if [ -r ${LIB}/$file ]; then
669 echo Fixing $file
670 sed -e 's/int abort/void abort/g' \
25f75d8a
RS
671 -e 's/int free/void free/g' \
672 -e 's/char \* calloc/void \* calloc/g' \
673 -e 's/char \* malloc/void \* malloc/g' \
674 -e 's/char \* realloc/void \* realloc/g' \
c87e58bb 675 -e 's/int exit/void exit/g' \
a3f6caa7 676 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
c87e58bb
RS
677#ifndef _GCC_SIZE_T\
678#define _GCC_SIZE_T' \
a3f6caa7 679 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
c87e58bb
RS
680#endif' \
681 ${LIB}/$file > ${LIB}/${file}.sed
c61a25b1
DM
682 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
683 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
684 rm -f ${LIB}/$file
685 fi
686fi
687
460d7c18
TG
688# Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
689file=malloc.h
690if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
691 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
692 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 693 chmod a+r ${LIB}/$file 2>/dev/null
460d7c18
TG
694fi
695
696if [ -r ${LIB}/$file ]; then
697 echo Fixing $file
350027ec 698 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
12fe670b 699 -e 's/int[ ][ ]*free/void free/g' \
460d7c18
TG
700 ${LIB}/$file > ${LIB}/${file}.sed
701 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
702 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
460d7c18
TG
703 rm -f ${LIB}/$file
704 fi
705fi
706
c61a25b1
DM
707# Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
708file=hsfs/hsfs_spec.h
709if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
710 mkdir ${LIB}/hsfs 2>/dev/null
711 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
712 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 713 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
714fi
715
716if [ -r ${LIB}/$file ]; then
717 echo Fixing $file
718 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
78c5c646
RS
719 ${LIB}/$file > ${LIB}/${file}.
720 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
c61a25b1 721 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
722 rm -f ${LIB}/$file
723 fi
724fi
725
726# Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
727file=hsfs/hsnode.h
728if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
729 mkdir ${LIB}/hsfs 2>/dev/null
730 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
731 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 732 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
733fi
734
735if [ -r ${LIB}/$file ]; then
736 echo Fixing $file
737 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
738 ${LIB}/$file > ${LIB}/${file}.sed
739 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
740 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
741 rm -f ${LIB}/$file
742 fi
743fi
744
745# Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
746file=hsfs/iso_spec.h
747if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
748 mkdir ${LIB}/hsfs 2>/dev/null
749 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
750 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 751 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
752fi
753
754if [ -r ${LIB}/$file ]; then
755 echo Fixing $file
756 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
757 ${LIB}/$file > ${LIB}/${file}.sed
758 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
759 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
760 rm -f ${LIB}/$file
761 fi
762fi
763
75251fe0
DM
764# Incorrect #include in Sony News-OS 3.2.
765file=machine/machparam.h
766if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
767 mkdir ${LIB}/machine 2>/dev/null
768 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
769 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 770 chmod a+r ${LIB}/$file 2>/dev/null
75251fe0
DM
771fi
772
773if [ -r ${LIB}/$file ]; then
774 echo Fixing $file, incorrect \#include
775 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
78c5c646
RS
776 ${LIB}/$file > ${LIB}/${file}.
777 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
75251fe0 778 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
75251fe0
DM
779 rm -f ${LIB}/$file
780 fi
781fi
782
783# Multiline comment after typedef on IRIX 4.0.1.
784file=sys/types.h
785if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
786 mkdir ${LIB}/sys 2>/dev/null
787 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
788 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 789 chmod a+r ${LIB}/$file 2>/dev/null
75251fe0
DM
790fi
791
792if [ -r ${LIB}/$file ]; then
793 echo Fixing $file, comment in the middle of \#ifdef
794 sed -e 's@type of the result@type of the result */@' \
795 -e 's@of the sizeof@/* of the sizeof@' \
796 ${LIB}/$file > ${LIB}/${file}.sed
797 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
798 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
75251fe0
DM
799 rm -f ${LIB}/$file
800 fi
801fi
802
2a46424a
ILT
803# Turning // comments into /* */ comments trashes this IRIX 4.0.1
804# header file, which embeds // comments inside multi-line /* */
805# comments. If this looks like the IRIX header file, we refix it by
806# just throwing away the // comments.
807file=fam.h
808if [ -r ${LIB}/$file ]; then
809 if egrep indigo.esd ${LIB}/$file > /dev/null; then
810 echo Fixing $file, overeager sed script
811 rm ${LIB}/$file
812 sed -e 's|//.*$||g' $file > ${LIB}/$file
813 chmod +w ${LIB}/$file 2>/dev/null
814 chmod a+r ${LIB}/$file 2>/dev/null
815 fi
816fi
817
7313c84b
ILT
818# Another IRIX 4.0.1 header file contains the string "//"
819file=elf_abi.h
820if [ -r ${LIB}/$file ]; then
821 echo Fixing $file, overeager sed script
822 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
823 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
824 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
825 rm -f ${LIB}/$file
826 fi
827fi
828
4d449554
JW
829# Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
830# declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
831# many other systems have similar text but correct versions of the file.
832# To ensure only Sun's is fixed, we grep for a likely unique string.
833file=memory.h
6a25991d
RS
834if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
835 if [ ! -r ${LIB}/$file ]; then
4d449554
JW
836 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
837 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 838 chmod a+r ${LIB}/$file 2>/dev/null
4d449554
JW
839 fi
840 if [ -r ${LIB}/$file ]; then
841 echo Replacing $file
842 cat > ${LIB}/$file << EOF
843/* This file was generated by fixincludes */
844#ifndef __memory_h__
845#define __memory_h__
846
847#ifdef __STDC__
848extern void *memccpy();
849extern void *memchr();
850extern void *memcpy();
851extern void *memset();
852#else
853extern char *memccpy();
854extern char *memchr();
855extern char *memcpy();
856extern char *memset();
857#endif /* __STDC__ */
858
859extern int memcmp();
860
eb13d323 861#endif /* __memory_h__ */
4d449554
JW
862EOF
863 fi
864fi
865
7d349561
JW
866# parameters not const on DECstation Ultrix V4.0.
867file=stdio.h
868if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
869 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
870 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 871 chmod a+r ${LIB}/$file 2>/dev/null
7d349561
JW
872fi
873
874if [ -r ${LIB}/$file ]; then
875 echo Fixing $file, non-const arg
876 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
877 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
878 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
879 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
880 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
881 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
882 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
883 ${LIB}/$file > ${LIB}/${file}.sed
884 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
885 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
7d349561
JW
886 rm -f ${LIB}/$file
887 fi
888fi
889
f45a4d6a
JW
890# parameters conflict with C++ new on rs/6000
891file=stdio.h
892if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
893 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
894 chmod +w ${LIB}/$file 2>/dev/null
895fi
896
897if [ -r ${LIB}/$file ]; then
898 echo Fixing $file, parameter name conflicts
899 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
900 ${LIB}/$file > ${LIB}/${file}.sed
901 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
902 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
903 rm -f ${LIB}/$file
904 fi
905fi
906
1ac7d389
RS
907# Don't use or define the name va_list in stdio.h.
908# This is for ANSI and also to interoperate properly with gvarargs.h.
909file=stdio.h
910if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
911 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
912 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 913 chmod a+r ${LIB}/$file 2>/dev/null
1ac7d389
RS
914fi
915
916if [ -r ${LIB}/$file ]; then
917 echo Fixing $file, use of va_list
918 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
919 (echo "#define __need___va_list"
920 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
921 # Use __gnuc_va_list in arg types in place of va_list.
d5891360
JW
922 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
923 # trailing parentheses and semicolon save all other systems from this.
1ac7d389
RS
924 # Define __va_list__ (something harmless and unused) instead of va_list.
925 # Don't claim to have defined va_list.
926 sed -e 's@ va_list @ __gnuc_va_list @' \
8befb954 927 -e 's@ va_list)@ __gnuc_va_list)@' \
d5891360 928 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1ac7d389 929 -e 's@ va_list@ __va_list__@' \
be71bebd 930 -e 's@\*va_list@*__va_list__@' \
75d98655 931 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1ac7d389 932 -e 's@VA_LIST@DUMMY_VA_LIST@' \
75d98655 933 -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
1ac7d389
RS
934 ${LIB}/$file >> ${LIB}/${file}.sed
935
936 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
937 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1ac7d389
RS
938 rm -f ${LIB}/$file
939 fi
940fi
941
e63c1d35
RS
942# Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
943file=ansi_compat.h
944if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
945 if grep -s ULTRIX $file; then
946 echo "/* This file intentionally left blank. */" > $LIB/$file
947 fi
948fi
949
7d349561 950# parameter to atof not const on DECstation Ultrix V4.0.
28bbe06b 951# also get rid of bogus inline definitions in HP-UX 8.0
7d349561
JW
952file=math.h
953if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
954 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
955 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 956 chmod a+r ${LIB}/$file 2>/dev/null
7d349561
JW
957fi
958
959if [ -r ${LIB}/$file ]; then
960 echo Fixing $file, non-const arg
961 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
28bbe06b
RS
962 -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \
963 -e 's@inline double abs(double d) { return fabs(d); }@@' \
7d349561
JW
964 ${LIB}/$file > ${LIB}/${file}.sed
965 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
966 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
7d349561
JW
967 rm -f ${LIB}/$file
968 fi
969fi
970
6ef797ea
RS
971# In limits.h, put #ifndefs around things that are supposed to be defined
972# in float.h to avoid redefinition errors if float.h is included first.
c49c4803
ILT
973# On HP/UX this patch does not work, because on HP/UX limits.h uses
974# multi line comments and the inserted #endif winds up inside the
975# comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
976# we find a #ifndef FLT_MIN we assume that all the required #ifndefs
977# are there, and we do not add them ourselves.
6ef797ea
RS
978file=limits.h
979if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
980 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
981 chmod +w ${LIB}/$file 2>/dev/null
982 chmod a+r ${LIB}/$file 2>/dev/null
983fi
984
985if [ -r ${LIB}/$file ]; then
c49c4803
ILT
986 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
987 true
988 else
989 echo Fixing $file
990 sed -e '/[ ]FLT_MIN[ ]/i\
6ef797ea 991#ifndef FLT_MIN'\
c49c4803 992 -e '/[ ]FLT_MIN[ ]/a\
6ef797ea 993#endif'\
c49c4803 994 -e '/[ ]FLT_MAX[ ]/i\
6ef797ea 995#ifndef FLT_MAX'\
c49c4803 996 -e '/[ ]FLT_MAX[ ]/a\
6ef797ea 997#endif'\
c49c4803 998 -e '/[ ]FLT_DIG[ ]/i\
6ef797ea 999#ifndef FLT_DIG'\
c49c4803 1000 -e '/[ ]FLT_DIG[ ]/a\
6ef797ea 1001#endif'\
c49c4803 1002 -e '/[ ]DBL_MIN[ ]/i\
6ef797ea 1003#ifndef DBL_MIN'\
c49c4803 1004 -e '/[ ]DBL_MIN[ ]/a\
6ef797ea 1005#endif'\
c49c4803 1006 -e '/[ ]DBL_MAX[ ]/i\
6ef797ea 1007#ifndef DBL_MAX'\
c49c4803 1008 -e '/[ ]DBL_MAX[ ]/a\
6ef797ea 1009#endif'\
c49c4803 1010 -e '/[ ]DBL_DIG[ ]/i\
6ef797ea 1011#ifndef DBL_DIG'\
c49c4803 1012 -e '/[ ]DBL_DIG[ ]/a\
6ef797ea 1013#endif'\
c49c4803
ILT
1014 ${LIB}/$file > ${LIB}/${file}.sed
1015 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1016 fi
6ef797ea
RS
1017 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1018 echo Deleting ${LIB}/$file\; no fixes were needed.
1019 rm -f ${LIB}/$file
1020 fi
1021fi
1022
5959a6cd
RS
1023# These two files on SunOS 4 are included by other files
1024# in the same directory, using "...". So we must make sure they exist
cd10f7b6
RS
1025# in the same directory as the other fixed files.
1026if [ -r ${INPUT}/multimedia/audio_errno.h ]
5959a6cd 1027then
cd10f7b6 1028 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
5959a6cd 1029fi
cd10f7b6 1030if [ -r ${INPUT}/multimedia/audio_hdr.h ]
5959a6cd 1031then
cd10f7b6 1032 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
5959a6cd
RS
1033fi
1034
315198ab
RS
1035# Determine if we're on Interactive Unix 2.2 or later, in which case we
1036# need to fix some additional files. This is the same test for ISC that
1037# Autoconf uses.
1038if test -d /etc/conf/kconfig.d \
1039 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
1040 echo "Fixing ISC __STDC__ goof in several files..."
1041 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
1042 echo $name
1043 if test -r ${LIB}/$name; then
1044 file=${LIB}/$name
1045 else
1046 file=${INPUT}/$name
1047 fi
1048 # On Interactive 2.2, certain traditional Unix definitions
1049 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
1050 # defined, not just if _POSIX_SOURCE is defined. This makes it
1051 # impossible to compile any nontrivial program except with -posix.
1052 sed \
1053's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
1054 < $file > ${LIB}/$name.
1055 mv ${LIB}/$name. ${LIB}/$name
1056 done
1057
1058 echo "Fixing ISC fmod declaration"
1059 # This one's already been fixed for other things.
1060 file=${LIB}/math.h
1061 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
1062 mv $file. $file
1063
1064 echo "Fixing nested comments in ISC <sys/limits.h>"
1065 file=sys/limits.h
1066 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
1067 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
1068fi
1069
c61a25b1
DM
1070echo 'Removing unneeded directories:'
1071cd $LIB
1072files=`find . -type d -print | sort -r`
1073for file in $files; do
1074 rmdir $LIB/$file > /dev/null 2>&1
1075done
1076
1077if $LINKS; then
1078 echo 'Making internal symbolic non-directory links'
1079 cd ${INPUT}
1080 files=`find . -type l -print`
1081 for file in $files; do
1082 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1083 if expr "$dest" : '[^/].*' > /dev/null; then
1084 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1085 if [ -f $target ]; then
1086 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1087 fi
1088 fi
1089 done
1090fi
1091
25e51a69
ILT
1092echo 'Cleaning up DONE files.'
1093cd $LIB
1094find . -name DONE -exec rm -f {} ';'
db27aeec 1095
c61a25b1 1096exit 0
This page took 1.717753 seconds and 5 git commands to generate.