]> gcc.gnu.org Git - gcc.git/blame - gcc/fixincludes
fixincludes: Avoid removing '.'.
[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
8# Directory containing the original header files.
9# (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
c3c55f86
BK
10if [ "x$1" = "x" ]
11then echo fixincludes: no output directory specified
12exit 1
13fi
c61a25b1 14
c3c55f86
BK
15LIB=${1}
16shift
17
18# Make sure it exists.
19if [ ! -d $LIB ]; then
20 mkdir $LIB || {
21 echo fixincludes: output dir '`'$LIB"' cannot be created"
22 exit 1
23 }
24else
25 ( \cd $LIB && touch DONE && rm DONE ) || {
26 echo fixincludes: output dir '`'$LIB"' is an invalid directory"
27 exit 1
28 }
29fi
c61a25b1 30
7567d496 31# Define what target system we're fixing.
c3c55f86 32#
7567d496 33if test -r ./Makefile; then
c3c55f86 34 target_canonical="`sed -n -e 's,^target[ ]*=[ ]*\(.*\)$,\1,p' < Makefile`"
7567d496
MH
35fi
36
c3c55f86
BK
37# If not from the Makefile, then try config.guess
38#
39if test -z "${target_canonical}" ; then
40 if test -x ./config.guess ; then
41 target_canonical="`config.guess`" ; fi
42 test -z "${target_canonical}" && target_canonical=unknown
43fi
44export target_canonical
45
46# # # # # # # # # # # # # # # # # # # # #
47#
4ed15f9d
RS
48# Define PWDCMD as a command to use to get the working dir
49# in the form that we want.
50PWDCMD=pwd
c3c55f86
BK
51
52case "`$PWDCMD`" in
4ed15f9d 53//*)
c3c55f86
BK
54 # On an Apollo, discard everything before `/usr'.
55 PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'"
56 ;;
4ed15f9d
RS
57esac
58
631e21eb
DE
59# Original directory.
60ORIGDIR=`${PWDCMD}`
61
e1fa48b5
RS
62# Make LIB absolute only if needed to avoid problems with the amd.
63case $LIB in
64/*)
c3c55f86 65 ;;
e1fa48b5 66*)
c3c55f86
BK
67 cd $LIB; LIB=`${PWDCMD}`
68 ;;
e1fa48b5 69esac
c61a25b1 70
c3c55f86 71echo Fixing headers into ${LIB} for ${target_canonical} target
c61a25b1
DM
72
73# Determine whether this system has symbolic links.
74if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
75 rm -f $LIB/ShouldNotExist
0fa2faf0
RS
76 LINKS=true
77elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
78 rm -f /tmp/ShouldNotExist
c61a25b1
DM
79 LINKS=true
80else
81 LINKS=false
82fi
83
c3c55f86
BK
84# # # # # # # # # # # # # # # # # # # # #
85#
86# Search each input directory for broken header files.
87# This loop ends near the end of the file.
88#
89if test $# -eq 0
90then
91 INPUTLIST="/usr/include"
92else
93 INPUTLIST="$@"
94fi
95
96for INPUT in ${INPUTLIST} ; do
97
98cd ${ORIGDIR}
99
100cd ${INPUT} || continue
101INPUT=`${PWDCMD}`
102
103#
104# # # # # # # # # # # # # # # # # # # # #
105#
1ac7d389 106echo Finding directories and links to directories
c3c55f86 107
3308e40a 108# Find all directories and all symlinks that point to directories.
f1f1ae8e
RS
109# Put the list in $files.
110# Each time we find a symlink, add it to newdirs
111# so that we do another find within the dir the link points to.
112# Note that $files may have duplicates in it;
113# later parts of this file are supposed to ignore them.
114dirs="."
fd297e33
RS
115levels=2
116while [ -n "$dirs" ] && [ $levels -gt 0 ]
f1f1ae8e 117do
fd297e33 118 levels=`expr $levels - 1`
f1f1ae8e 119 newdirs=
fd297e33 120 for d in $dirs
f1f1ae8e 121 do
1ac7d389 122 echo " Searching $INPUT/$d"
f1f1ae8e 123
fd297e33 124 # Find all directories under $d, relative to $d, excluding $d itself.
b3ea4fca
PB
125 # (The /. is needed after $d in case $d is a symlink.)
126 files="$files `find $d/. -type d -print | \
127 sed -e '/\/\.$/d' -e 's@/./@/@g'`"
165b3941
RS
128 # Find all links to directories.
129 # Using `-exec test -d' in find fails on some systems,
130 # and trying to run test via sh fails on others,
131 # so this is the simplest alternative left.
132 # First find all the links, then test each one.
133 theselinks=
f1f1ae8e 134 $LINKS && \
b3ea4fca 135 theselinks=`find $d/. -type l -print | sed -e 's@/./@/@g'`
165b3941
RS
136 for d1 in $theselinks --dummy--
137 do
1ac7d389
RS
138 # If the link points to a directory,
139 # add that dir to $newdirs
165b3941
RS
140 if [ -d $d1 ]
141 then
d6228809
ILT
142 files="$files $d1"
143 if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ]
144 then
145 newdirs="$newdirs $d1"
146 fi
165b3941
RS
147 fi
148 done
f1f1ae8e
RS
149 done
150
151 dirs="$newdirs"
f1f1ae8e
RS
152done
153
154dirs=
1ac7d389 155echo "All directories (including links to directories):"
f1f1ae8e
RS
156echo $files
157
c61a25b1
DM
158for file in $files; do
159 rm -rf $LIB/$file
160 if [ ! -d $LIB/$file ]
161 then mkdir $LIB/$file
162 fi
163done
1ac7d389 164mkdir $LIB/root
c61a25b1
DM
165
166# treetops gets an alternating list
167# of old directories to copy
168# and the new directories to copy to.
169treetops="${INPUT} ${LIB}"
170
171if $LINKS; then
1ac7d389 172 echo 'Making symbolic directory links'
c61a25b1
DM
173 for file in $files; do
174 dest=`ls -ld $file | sed -n 's/.*-> //p'`
175 if [ "$dest" ]; then
4ed15f9d 176 cwd=`${PWDCMD}`
c61a25b1
DM
177 # In case $dest is relative, get to $file's dir first.
178 cd ${INPUT}
179 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
180 # Check that the target directory exists.
181 # Redirections changed to avoid bug in sh on Ultrix.
182 (cd $dest) > /dev/null 2>&1
183 if [ $? = 0 ]; then
184 cd $dest
185 # X gets the dir that the link actually leads to.
4ed15f9d 186 x=`${PWDCMD}`
17c96289
ILT
187 # Canonicalize ${INPUT} now to minimize the time an
188 # automounter has to change the result of ${PWDCMD}.
189 cinput=`cd ${INPUT}; ${PWDCMD}`
1ac7d389 190 # If a link points to ., make a similar link to .
17c96289 191 if [ $x = ${cinput} ]; then
1ac7d389
RS
192 echo $file '->' . ': Making link'
193 rm -fr ${LIB}/$file > /dev/null 2>&1
194 ln -s . ${LIB}/$file > /dev/null 2>&1
c61a25b1
DM
195 # If link leads back into ${INPUT},
196 # make a similar link here.
17c96289 197 elif expr $x : "${cinput}/.*" > /dev/null; then
c61a25b1 198 # Y gets the actual target dir name, relative to ${INPUT}.
17c96289 199 y=`echo $x | sed -n "s&${cinput}/&&p"`
884caf18
PE
200 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
201 dots=`echo "$file" |
e5c1a9d2 202 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
884caf18 203 echo $file '->' $dots$y ': Making link'
c61a25b1 204 rm -fr ${LIB}/$file > /dev/null 2>&1
884caf18 205 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
c61a25b1 206 else
1ac7d389
RS
207 # If the link is to a dir $target outside ${INPUT},
208 # repoint the link at ${INPUT}/root$target
209 # and process $target into ${INPUT}/root$target
c61a25b1 210 # treat this directory as if it actually contained the files.
1ac7d389
RS
211 echo $file '->' root$x ': Making link'
212 if [ -d $LIB/root$x ]
213 then true
214 else
215 dirname=root$x/
216 dirmade=.
217 cd $LIB
218 while [ x$dirname != x ]; do
219 component=`echo $dirname | sed -e 's|/.*$||'`
220 mkdir $component >/dev/null 2>&1
221 cd $component
222 dirmade=$dirmade/$component
223 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
224 done
225 fi
f744b2ce
RS
226 # Duplicate directory structure created in ${LIB}/$file in new
227 # root area.
228 for file2 in $files; do
229 case $file2 in
b3ea4fca 230 $file/*)
f744b2ce
RS
231 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
232 echo "Duplicating ${file}'s ${dupdir}"
233 if [ -d ${dupdir} ]
234 then true
235 else
236 mkdir ${dupdir}
237 fi
238 ;;
638fa106
BK
239 *)
240 ;;
f744b2ce
RS
241 esac
242 done
3221f176
ILT
243 # Get the path from ${LIB} to $file, accounting for symlinks.
244 parent=`echo "$file" | sed -e 's@/[^/]*$@@'`
245 libabs=`cd ${LIB}; ${PWDCMD}`
246 file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"`
884caf18 247 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
3221f176 248 dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'`
1ac7d389 249 rm -fr ${LIB}/$file > /dev/null 2>&1
884caf18 250 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
1ac7d389 251 treetops="$treetops $x ${LIB}/root$x"
c61a25b1
DM
252 fi
253 fi
254 cd $cwd
255 fi
256 done
257fi
258
40f1c86c 259required=
25e51a69
ILT
260set x $treetops
261shift
c61a25b1
DM
262while [ $# != 0 ]; do
263 # $1 is an old directory to copy, and $2 is the new directory to copy to.
c61a25b1
DM
264 cd ${INPUT}
265 cd $1
1ac7d389
RS
266# The same dir can appear more than once in treetops.
267# There's no need to scan it more than once.
268 if [ -f $2/DONE ]
269 then
270 files=
271 else
272 touch $2/DONE
273 echo Fixing directory $1 into $2
8c31e6b6
RS
274# Check .h files which are symlinks as well as those which are files.
275# A link to a header file will not be processed by anything but this.
73bdfabc
RS
276 if $LINKS; then
277 files=`find . -name '*.h' \( -type f -o -type l \) -print`
278 else
279 files=`find . -name '*.h' -type f -print`
280 fi
1ac7d389
RS
281 echo Checking header files
282 fi
c61a25b1
DM
283# Note that BSD43_* are used on recent MIPS systems.
284 for file in $files; do
285# This call to egrep is essential, since checking a file with egrep
286# is much faster than actually trying to fix it.
3308e40a
RS
287# It is also essential that most files *not* match!
288# Thus, matching every #endif is unacceptable.
c61a25b1
DM
289# But the argument to egrep must be kept small, or many versions of egrep
290# won't be able to handle it.
25e51a69 291#
e5e809f4 292# We use the pattern [!-.0-z{|}~] instead of [^/ ] to match a noncomment
25e51a69
ILT
293# following #else or #endif because some buggy egreps think [^/] matches
294# newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
e5e809f4 295# [!-.0-~] does not work properly on AIX 4.1.
25e51a69
ILT
296#
297# We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
298# following #if or #elif that is not surrounded by __. The `a-ce-km-z'
299# in this pattern lacks `d' and `l'; this means we don't worry about
300# identifiers starting with `d' or `l'. This is OK, since none of the
301# identifiers below start with `d' or `l'. It also greatly improves
302# performance, since many files contain lines of the form `#if ... defined ...'
303# or `#if lint'.
e5e809f4 304 if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-z\{\|\}\~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-zA-Z][a-zA-Z0-9]' $file >/dev/null; then
c61a25b1
DM
305 if [ -r $file ]; then
306 cp $file $2/$file >/dev/null 2>&1 \
307 || echo "Can't copy $file"
308 chmod +w $2/$file
2e4cd151 309 chmod a+r $2/$file
085540da
ILT
310 # The fixinc_eol stuff is to work around a bug in the sed
311 # program on HP/UX 10.20.
8caf703c
RS
312 # Here is how the sed commands in braces work.
313 # (It doesn't work to put the comments inside the sed commands.)
314 # Surround each word with spaces, to simplify matching below.
315 # ANSIfy each pre-ANSI machine-dependent symbol
316 # by surrounding it with __ __.
317 # Remove the spaces that we inserted around each word.
c61a25b1
DM
318 sed -e '
319 :loop
320 /\\$/ N
085540da 321 s/\\$/\\*fixinc_eol*/
c61a25b1 322 /\\$/ b loop
085540da 323 s/\\\*fixinc_eol\*/\\/g
20c74d5e
PE
324 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
325 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
326 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
ec4738c0
RS
327 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
328 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
883bc780 329 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
9aeba741 330 /^[ ]*\/\/[ ]*/s///
2a46424a 331 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
c61a25b1 332 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
a94729bc
PH
333 /#[ ]*define[ ]*[ ]_IO/ s/'\''\([cgxtf]\)'\''/\1/g
334 /#[ ]*define[ ]*[ ]BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
335 /#[ ]*define[ ]*[ ]DESIOC/ s/'\''\([cdgx]\)'\''/\1/g
d7c768e7
RS
336 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
337 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
a94729bc
PH
338 /#[ ]*define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
339 /#[ ]*define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
340 /#[ ]*define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
d4df2ea5 341 /#[ ]*[el]*if/{
25e51a69
ILT
342 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
343
25e51a69 344 s/ bsd4\([0-9]\) / __bsd4\1__ /g
a6642da8 345 s/ _*host_mips / __host_mips__ /g
25e51a69 346 s/ _*i386 / __i386__ /g
984da0ff 347 s/ M32 / __M32__ /g
25e51a69
ILT
348 s/ is68k / __is68k__ /g
349 s/ m68k / __m68k__ /g
350 s/ mc680\([0-9]\)0 / __mc680\10__ /g
984da0ff 351 s/ m88k / __m88k__ /g
a6642da8 352 s/ _*mips / __mips__ /g
25e51a69
ILT
353 s/ news\([0-9]*\) / __news\1__ /g
354 s/ ns32000 / __ns32000__ /g
984da0ff 355 s/ pdp11 / __pdp11__ /g
25e51a69 356 s/ pyr / __pyr__ /g
863415d1 357 s/ sel / __sel__ /g
25e51a69
ILT
358 s/ sony_news / __sony_news__ /g
359 s/ sparc / __sparc__ /g
360 s/ sun\([a-z0-9]*\) / __sun\1__ /g
863415d1 361 s/ tahoe / __tahoe__ /g
984da0ff
ILT
362 s/ tower\([_0-9]*\) / __tower\1__ /g
363 s/ u370 / __u370__ /g
364 s/ u3b\([0-9]*\) / __u3b\1__ /g
25e51a69
ILT
365 s/ unix / __unix__ /g
366 s/ vax / __vax__ /g
a6642da8 367 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
863415d1 368 s/ _*\([Rr][34]\)000 / __\1000__ /g
a6642da8 369 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
25e51a69 370
25e51a69
ILT
371 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
372 }
45b33951 373 /^#define.NULL[ ]/ i\
c61a25b1 374 #undef NULL
78c5c646
RS
375 ' $2/$file > $2/$file.
376 mv $2/$file. $2/$file
29421402
ILT
377 if cmp $file $2/$file >/dev/null 2>&1 \
378 || egrep 'This file is part of the GNU C Library' $2/$file >/dev/null 2>&1; then
c61a25b1 379 rm $2/$file
b52a4b72
RS
380 else
381 echo Fixed $file
40f1c86c
RS
382 # Find any include directives that use "file".
383 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
384 dir=`echo $file | sed -e s'|/[^/]*$||'`
385 required="$required $1 $dir/$include $2/$dir/$include"
386 done
c61a25b1
DM
387 fi
388 fi
389 fi
390 done
391 shift; shift
392done
393
394cd ${INPUT}
395
6c8ceeae
JM
396# Install the proper definition of the three standard types in header files
397# that they come from.
a6642da8 398for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
cd3383a3
RS
399 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
400 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
401 chmod +w ${LIB}/$file 2>/dev/null
402 chmod a+r ${LIB}/$file 2>/dev/null
403 fi
404
405 if [ -r ${LIB}/$file ]; then
6c8ceeae
JM
406 echo Fixing size_t, ptrdiff_t and wchar_t in $file
407 sed \
ade7386a
MH
408 -e '/^[ ]*\*[ ]*typedef unsigned int size_t;/N' \
409 -e 's/^\([ ]*\*[ ]*typedef unsigned int size_t;\n[ ]*\*\/\)/\1\
410#ifndef __SIZE_TYPE__\
411#define __SIZE_TYPE__ long unsigned int\
412#endif\
413typedef __SIZE_TYPE__ size_t;\
414/' \
6c8ceeae 415 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
224b1df0
ILT
416#ifndef __SIZE_TYPE__\
417#define __SIZE_TYPE__ long unsigned int\
d4c60bd6
ILT
418#endif
419' \
6c8ceeae
JM
420 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
421 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
422#ifndef __PTRDIFF_TYPE__\
423#define __PTRDIFF_TYPE__ long int\
424#endif
425' \
426 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
427 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
428#ifndef __WCHAR_TYPE__\
429#define __WCHAR_TYPE__ int\
99934aed
RK
430#endif\
431#ifndef __cplusplus
432' \
433 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/a\
6c8ceeae
JM
434#endif
435' \
436 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
437 ${LIB}/$file > ${LIB}/${file}.sed
cd3383a3
RS
438 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
439 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
440 rm ${LIB}/$file
7a0934e7
ILT
441 else
442 # Find any include directives that use "file".
443 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
444 dir=`echo $file | sed -e s'|/[^/]*$||'`
445 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
446 done
cd3383a3
RS
447 fi
448 fi
449done
450
f5963e61
JL
451# Fix #defines under Alpha OSF/1:
452# The following files contain '#pragma extern_prefix "_FOO"' followed by
453# a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
454# statements is to reduce namespace pollution. While these macros work
455# properly in most cases, they don't allow you to take a pointer to the
456# "something" being modified. To get around this limitation, change these
457# statements to be of the form '#define something _FOOsomething'.
458for file in libgen.h dirent.h ftw.h grp.h ndbm.h pthread.h pwd.h signal.h standards.h stdlib.h string.h stropts.h time.h unistd.h
459do
460 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
461 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
462 chmod +w ${LIB}/$file 2>/dev/null
463 chmod a+r ${LIB}/$file 2>/dev/null
464 fi
465
466 if [ -r ${LIB}/$file ]; then
467 echo Fixing $file extern_prefix
468 sed -e 's/^[ ]*#[ ]*define[ ]*\([^(]*\)\(([^)]*)\)[ ]*\(_.\)\1\2[ ]*$/#define \1 \3\1/' ${LIB}/$file > ${LIB}/${file}.sed
469 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
470 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
471 rm ${LIB}/$file
472 else
473 # Find any include directives that use "file".
474 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
475 dir=`echo $file | sed -e s'|/[^/]*$||'`
476 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
477 done
478 fi
479 fi
480done
481
c61a25b1
DM
482# Fix one other error in this file: a mismatched quote not inside a C comment.
483file=sundev/vuid_event.h
484if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
485 mkdir ${LIB}/sundev 2>/dev/null
486 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
487 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 488 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
489fi
490
491if [ -r ${LIB}/$file ]; then
492 echo Fixing $file comment
ffc47266
JW
493 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
494 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 495 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 496 rm ${LIB}/$file
7a0934e7
ILT
497 else
498 # Find any include directives that use "file".
499 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
500 dir=`echo $file | sed -e s'|/[^/]*$||'`
501 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
502 done
c61a25b1
DM
503 fi
504fi
505
4ba0ff2d
JW
506# Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
507file=sunwindow/win_cursor.h
508if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
509# mkdir ${LIB}/sunwindow 2>/dev/null
510 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
511 chmod +w ${LIB}/$file 2>/dev/null
512fi
513if [ -r ${LIB}/$file ]; then
514 echo Fixing $file
515 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
516 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
517 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
518 rm ${LIB}/$file
7a0934e7
ILT
519 else
520 # Find any include directives that use "file".
521 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
522 dir=`echo $file | sed -e s'|/[^/]*$||'`
523 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
524 done
4ba0ff2d
JW
525 fi
526fi
527file=sunwindow/win_lock.h
528if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
529# mkdir ${LIB}/sunwindow 2>/dev/null
530 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
531 chmod +w ${LIB}/$file 2>/dev/null
532fi
533if [ -r ${LIB}/$file ]; then
534 echo Fixing $file
535 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
536 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
537 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
538 rm ${LIB}/$file
7a0934e7
ILT
539 else
540 # Find any include directives that use "file".
541 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
542 dir=`echo $file | sed -e s'|/[^/]*$||'`
543 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
544 done
4ba0ff2d
JW
545 fi
546fi
547
6dc42e49 548# Fix this Sun file to avoid interfering with stddef.h.
c61a25b1
DM
549file=sys/stdtypes.h
550if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
551 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
552 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 553 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
554fi
555
556if [ -r ${LIB}/$file ]; then
557 echo Fixing $file
daa4489f 558sed -e '/[ ]size_t.*;/i\
ffc47266 559#ifndef _GCC_SIZE_T\
d4c60bd6
ILT
560#define _GCC_SIZE_T
561' \
daa4489f 562 -e '/[ ]size_t.*;/a\
d4c60bd6
ILT
563#endif
564' \
daa4489f 565 -e '/[ ]ptrdiff_t.*;/i\
ffc47266 566#ifndef _GCC_PTRDIFF_T\
d4c60bd6
ILT
567#define _GCC_PTRDIFF_T
568' \
daa4489f 569 -e '/[ ]ptrdiff_t.*;/a\
d4c60bd6
ILT
570#endif
571' \
daa4489f 572 -e '/[ ]wchar_t.*;/i\
ffc47266 573#ifndef _GCC_WCHAR_T\
d4c60bd6
ILT
574#define _GCC_WCHAR_T
575' \
daa4489f 576 -e '/[ ]wchar_t.*;/a\
d4c60bd6
ILT
577#endif
578' ${LIB}/$file > ${LIB}/${file}.sed
ffc47266 579 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
87394941
ILT
580 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
581 rm ${LIB}/$file
7a0934e7
ILT
582 else
583 # Find any include directives that use "file".
584 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
585 dir=`echo $file | sed -e s'|/[^/]*$||'`
586 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
587 done
87394941
ILT
588 fi
589fi
590
591# Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
592# in cc1plus.
593file=stdlib.h
594if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
595 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
596 chmod +w ${LIB}/$file 2>/dev/null
597 chmod a+r ${LIB}/$file 2>/dev/null
598fi
599
600if [ -r ${LIB}/$file ]; then
601 echo Fixing $file
19571479
RS
602 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
603 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
87394941
ILT
604 ${LIB}/$file > ${LIB}/${file}.sed
605 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 606 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 607 rm ${LIB}/$file
7a0934e7
ILT
608 else
609 # Find any include directives that use "file".
610 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
611 dir=`echo $file | sed -e s'|/[^/]*$||'`
612 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
613 done
614 fi
615fi
616
617# Fix this ARM/RISCiX file where ___type is a Compiler hint that is specific to
618# the Norcroft compiler.
619file=X11/Intrinsic.h
620if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
621 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
622 chmod +w ${LIB}/$file 2>/dev/null
623 chmod a+r ${LIB}/$file 2>/dev/null
624fi
625
626if [ -r ${LIB}/$file ]; then
627 echo Fixing $file
628 sed -e "s/___type p_type/p_type/" \
629 ${LIB}/$file > ${LIB}/${file}.sed
630 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
631 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
632 rm ${LIB}/$file
633 else
634 # Find any include directives that use "file".
635 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
636 dir=`echo $file | sed -e s'|/[^/]*$||'`
637 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
638 done
c61a25b1
DM
639 fi
640fi
641
fd9287ae 642# Fix this file to avoid interfering with stddef.h, but don't mistakenly
a6e9783c
JW
643# match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
644# set) size_t.
c61a25b1
DM
645file=sys/types.h
646if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
647 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
648 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 649 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
650fi
651
652if [ -r ${LIB}/$file ]; then
653 echo Fixing $file
b7bb5c98 654sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\
ffc47266 655#ifndef _GCC_SIZE_T\
d4c60bd6
ILT
656#define _GCC_SIZE_T
657' \
b7bb5c98 658 -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/a\
d4c60bd6
ILT
659#endif
660' ${LIB}/$file > ${LIB}/${file}.sed
ffc47266 661 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 662 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 663 rm ${LIB}/$file
7a0934e7
ILT
664 else
665 # Find any include directives that use "file".
666 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
667 dir=`echo $file | sed -e s'|/[^/]*$||'`
668 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
669 done
c61a25b1
DM
670 fi
671fi
672
94e21bd7
DE
673# Fix HP's use of ../machine/inline.h to refer to
674# /usr/include/machine/inline.h
675file=sys/spinlock.h
e03bb072 676if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
94e21bd7
DE
677 cp $file ${LIB}/$file
678fi
679if [ -r ${LIB}/$file ] ; then
680 echo Fixing $file
681 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
682 -e 's,"../machine/psl.h",<machine/psl.h>,' \
683 ${LIB}/$file > ${LIB}/${file}.sed
684 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
685 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
686 rm ${LIB}/$file
7a0934e7
ILT
687 else
688 # Find any include directives that use "file".
689 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
690 dir=`echo $file | sed -e s'|/[^/]*$||'`
691 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
692 done
94e21bd7
DE
693 fi
694fi
695
08455880
TW
696# Fix an error in this file: the #if says _cplusplus, not the double
697# underscore __cplusplus that it should be
698file=tinfo.h
699if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
700 mkdir ${LIB}/rpcsvc 2>/dev/null
701 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
702 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 703 chmod a+r ${LIB}/$file 2>/dev/null
08455880
TW
704fi
705
706if [ -r ${LIB}/$file ]; then
707 echo Fixing $file, __cplusplus macro
708 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
709 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
710 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
711 rm ${LIB}/$file
7a0934e7
ILT
712 else
713 # Find any include directives that use "file".
714 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
715 dir=`echo $file | sed -e s'|/[^/]*$||'`
716 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
717 done
08455880
TW
718 fi
719fi
720
c61a25b1
DM
721# Fix an error in this file: a missing semi-colon at the end of the statsswtch
722# structure definition.
723file=rpcsvc/rstat.h
724if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
725 mkdir ${LIB}/rpcsvc 2>/dev/null
726 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
727 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 728 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
729fi
730
731if [ -r ${LIB}/$file ]; then
732 echo Fixing $file, definition of statsswtch
ffc47266
JW
733 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
734 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 735 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 736 rm ${LIB}/$file
7a0934e7
ILT
737 else
738 # Find any include directives that use "file".
739 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
740 dir=`echo $file | sed -e s'|/[^/]*$||'`
741 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
742 done
c61a25b1
DM
743 fi
744fi
745
746# Fix an error in this file: a missing semi-colon at the end of the nodeent
747# structure definition.
748file=netdnet/dnetdb.h
749if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
750 mkdir ${LIB}/netdnet 2>/dev/null
751 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
752 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 753 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
754fi
755
756if [ -r ${LIB}/$file ]; then
757 echo Fixing $file, definition of nodeent
ffc47266
JW
758 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
759 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 760 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 761 rm ${LIB}/$file
7a0934e7
ILT
762 else
763 # Find any include directives that use "file".
764 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
765 dir=`echo $file | sed -e s'|/[^/]*$||'`
766 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
767 done
c61a25b1
DM
768 fi
769fi
770
771# Check for bad #ifdef line (in Ultrix 4.1)
772file=sys/file.h
773if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
774 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
775 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 776 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
777fi
778
779if [ -r ${LIB}/$file ]; then
780 echo Fixing $file, bad \#ifdef line
ffc47266
JW
781 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
782 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 783 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 784 rm ${LIB}/$file
7a0934e7
ILT
785 else
786 # Find any include directives that use "file".
787 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
788 dir=`echo $file | sed -e s'|/[^/]*$||'`
789 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
790 done
c61a25b1
DM
791 fi
792fi
793
76af0b13
RK
794# Check for (...) in C++ code in HP/UX sys/file.h.
795file=sys/file.h
796if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
797 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
798 chmod +w ${LIB}/$file 2>/dev/null
799 chmod a+r ${LIB}/$file 2>/dev/null
800fi
801
802if [ -r ${LIB}/$file ]; then
803 if egrep HPUX_SOURCE ${LIB}/$file > /dev/null; then
804 echo Fixing $file, use of '(...)'
805 sed -e 's/(\.\.\.)/(struct file * ...)/' ${LIB}/$file > ${LIB}/${file}.sed
806 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
807 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
808 rm ${LIB}/$file
809 else
810 # Find any include directives that use "file".
811 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
812 dir=`echo $file | sed -e s'|/[^/]*$||'`
813 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
814 done
815 fi
816 fi
817fi
818
c61a25b1 819# Check for superfluous `static' (in Ultrix 4.2)
46eeda17 820# On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken.
c61a25b1
DM
821file=machine/cpu.h
822if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
823 mkdir ${LIB}/machine 2>/dev/null
824 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
825 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 826 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
827fi
828
829if [ -r ${LIB}/$file ]; then
46eeda17
DE
830 echo Fixing $file, superfluous static and broken includes of other files.
831 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' \
832 -e 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/' \
833 -e 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/' \
834 ${LIB}/$file > ${LIB}/${file}.sed
ffc47266 835 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 836 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1
DM
837 rm ${LIB}/$file
838 else
7a0934e7
ILT
839 # Find any include directives that use "file".
840 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
841 dir=`echo $file | sed -e s'|/[^/]*$||'`
842 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
843 done
c61a25b1 844# This file has an alternative name, mips/cpu.h. Fix that name, too.
1f1ff018 845 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
c61a25b1 846 mkdir ${LIB}/mips 2>&-
46eeda17
DE
847# Don't remove the file first, they may be the same file!
848 ln ${LIB}/$file ${LIB}/mips/cpu.h > /dev/null 2>&1
c61a25b1
DM
849 fi
850 fi
851fi
852
75251fe0 853# Incorrect sprintf declaration in X11/Xmu.h
c61a25b1
DM
854file=X11/Xmu.h
855if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
856 mkdir ${LIB}/X11 2>/dev/null
857 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
858 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 859 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
860fi
861
862if [ -r ${LIB}/$file ]; then
863 echo Fixing $file sprintf declaration
ffc47266
JW
864 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
865extern char * sprintf();\
8739838d 866#endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
ffc47266 867 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
c61a25b1 868 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 869 rm ${LIB}/$file
7a0934e7
ILT
870 else
871 # Find any include directives that use "file".
872 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
873 dir=`echo $file | sed -e s'|/[^/]*$||'`
874 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
875 done
c61a25b1
DM
876 fi
877fi
878
3a6aca8e
RS
879# Incorrect sprintf declaration in X11/Xmu/Xmu.h
880# (It's not clear whether the right file name is this or X11/Xmu.h.)
881file=X11/Xmu/Xmu.h
882if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
883 mkdir ${LIB}/X11/Xmu 2>/dev/null
884 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
885 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 886 chmod a+r ${LIB}/$file 2>/dev/null
3a6aca8e
RS
887fi
888
889if [ -r ${LIB}/$file ]; then
890 echo Fixing $file sprintf declaration
ffc47266
JW
891 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
892extern char * sprintf();\
8739838d 893#endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
ffc47266 894 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3a6aca8e 895 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
3a6aca8e 896 rm ${LIB}/$file
7a0934e7
ILT
897 else
898 # Find any include directives that use "file".
899 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
900 dir=`echo $file | sed -e s'|/[^/]*$||'`
901 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
902 done
3a6aca8e
RS
903 fi
904fi
905
c61a25b1
DM
906# Check for missing ';' in struct
907file=netinet/ip.h
908if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
909 mkdir ${LIB}/netinet 2>/dev/null
910 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
911 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 912 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
913fi
914
915if [ -r ${LIB}/$file ]; then
916 echo Fixing $file
917 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
918 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
919 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 920 rm -f ${LIB}/$file
7a0934e7
ILT
921 else
922 # Find any include directives that use "file".
923 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
924 dir=`echo $file | sed -e s'|/[^/]*$||'`
925 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
926 done
c61a25b1
DM
927 fi
928fi
929
75251fe0 930# Fix the CAT macro in SunOS memvar.h.
c61a25b1
DM
931file=pixrect/memvar.h
932if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
933 mkdir ${LIB}/pixrect 2>/dev/null
934 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
935 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 936 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
937fi
938
939if [ -r ${LIB}/$file ]; then
940 echo Fixing $file
941 sed -e '/^#define.CAT(a,b)/ i\
942#ifdef __STDC__ \
943#define CAT(a,b) a##b\
944#else
945/^#define.CAT(a,b)/ a\
946#endif
947' ${LIB}/$file > ${LIB}/${file}.sed
948 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
949 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 950 rm -f ${LIB}/$file
7a0934e7
ILT
951 else
952 # Find any include directives that use "file".
953 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
954 dir=`echo $file | sed -e s'|/[^/]*$||'`
955 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
956 done
c61a25b1
DM
957 fi
958fi
959
960# Check for yet more missing ';' in struct (in SunOS 4.0.x)
961file=rpcsvc/rusers.h
962if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
963 mkdir ${LIB}/rpcsvc 2>/dev/null
964 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
965 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 966 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
967fi
968
969if [ -r ${LIB}/$file ]; then
970 echo Fixing $file
971 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
972 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
973 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 974 rm -f ${LIB}/$file
7a0934e7
ILT
975 else
976 # Find any include directives that use "file".
977 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
978 dir=`echo $file | sed -e s'|/[^/]*$||'`
979 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
980 done
c61a25b1
DM
981 fi
982fi
983
984# Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
c87e58bb 985# Also wrap protection around size_t for m88k-sysv3 systems.
c61a25b1
DM
986file=stdlib.h
987if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
988 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
989 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 990 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
991fi
992
993if [ -r ${LIB}/$file ]; then
994 echo Fixing $file
e5e809f4
JL
995 if grep _GCC_SIZE_T ${LIB}/$file >/dev/null
996 then size_t_pattern='<<< do not double-wrap the size_t typedef >>>'
997 else size_t_pattern='typedef[ a-zA-Z_]*[ ]size_t[ ]*;'
998 fi
c61a25b1 999 sed -e 's/int abort/void abort/g' \
25f75d8a 1000 -e 's/int free/void free/g' \
c3647fe0
RK
1001 -e 's/char[ ]*\*[ ]*calloc/void \* calloc/g' \
1002 -e 's/char[ ]*\*[ ]*malloc/void \* malloc/g' \
1003 -e 's/char[ ]*\*[ ]*realloc/void \* realloc/g' \
1004 -e 's/int[ ][ ]*exit/void exit/g' \
e5e809f4 1005 -e "/$size_t_pattern/"'i\
c87e58bb 1006#ifndef _GCC_SIZE_T\
d4c60bd6
ILT
1007#define _GCC_SIZE_T
1008' \
e5e809f4 1009 -e "/$size_t_pattern/"'a\
d4c60bd6
ILT
1010#endif
1011' \
c87e58bb 1012 ${LIB}/$file > ${LIB}/${file}.sed
c61a25b1
DM
1013 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1014 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 1015 rm -f ${LIB}/$file
7a0934e7
ILT
1016 else
1017 # Find any include directives that use "file".
1018 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1019 dir=`echo $file | sed -e s'|/[^/]*$||'`
1020 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1021 done
c61a25b1
DM
1022 fi
1023fi
1024
460d7c18 1025# Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
9cd03bdd 1026# Also fix return type of {m,re}alloc in <malloc.h> on sysV68
460d7c18
TG
1027file=malloc.h
1028if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1029 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1030 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 1031 chmod a+r ${LIB}/$file 2>/dev/null
460d7c18
TG
1032fi
1033
1034if [ -r ${LIB}/$file ]; then
1035 echo Fixing $file
350027ec 1036 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
12fe670b 1037 -e 's/int[ ][ ]*free/void free/g' \
9cd03bdd
RK
1038 -e 's/char\([ ]*\*[ ]*malloc\)/void\1/g' \
1039 -e 's/char\([ ]*\*[ ]*realloc\)/void\1/g' \
460d7c18
TG
1040 ${LIB}/$file > ${LIB}/${file}.sed
1041 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1042 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
460d7c18 1043 rm -f ${LIB}/$file
7a0934e7
ILT
1044 else
1045 # Find any include directives that use "file".
1046 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1047 dir=`echo $file | sed -e s'|/[^/]*$||'`
1048 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1049 done
460d7c18
TG
1050 fi
1051fi
1052
c61a25b1
DM
1053# Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
1054file=hsfs/hsfs_spec.h
1055if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1056 mkdir ${LIB}/hsfs 2>/dev/null
1057 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1058 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 1059 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
1060fi
1061
1062if [ -r ${LIB}/$file ]; then
1063 echo Fixing $file
1064 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
78c5c646
RS
1065 ${LIB}/$file > ${LIB}/${file}.
1066 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
c61a25b1 1067 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 1068 rm -f ${LIB}/$file
7a0934e7
ILT
1069 else
1070 # Find any include directives that use "file".
1071 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1072 dir=`echo $file | sed -e s'|/[^/]*$||'`
1073 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1074 done
c61a25b1
DM
1075 fi
1076fi
1077
1078# Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
1079file=hsfs/hsnode.h
1080if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1081 mkdir ${LIB}/hsfs 2>/dev/null
1082 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1083 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 1084 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
1085fi
1086
1087if [ -r ${LIB}/$file ]; then
1088 echo Fixing $file
1089 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
1090 ${LIB}/$file > ${LIB}/${file}.sed
1091 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1092 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 1093 rm -f ${LIB}/$file
7a0934e7
ILT
1094 else
1095 # Find any include directives that use "file".
1096 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1097 dir=`echo $file | sed -e s'|/[^/]*$||'`
1098 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1099 done
c61a25b1
DM
1100 fi
1101fi
1102
1103# Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
1104file=hsfs/iso_spec.h
1105if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1106 mkdir ${LIB}/hsfs 2>/dev/null
1107 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1108 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 1109 chmod a+r ${LIB}/$file 2>/dev/null
c61a25b1
DM
1110fi
1111
1112if [ -r ${LIB}/$file ]; then
1113 echo Fixing $file
1114 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
1115 ${LIB}/$file > ${LIB}/${file}.sed
1116 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1117 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
c61a25b1 1118 rm -f ${LIB}/$file
7a0934e7
ILT
1119 else
1120 # Find any include directives that use "file".
1121 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1122 dir=`echo $file | sed -e s'|/[^/]*$||'`
1123 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1124 done
c61a25b1
DM
1125 fi
1126fi
1127
75251fe0
DM
1128# Incorrect #include in Sony News-OS 3.2.
1129file=machine/machparam.h
1130if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1131 mkdir ${LIB}/machine 2>/dev/null
1132 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1133 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 1134 chmod a+r ${LIB}/$file 2>/dev/null
75251fe0
DM
1135fi
1136
1137if [ -r ${LIB}/$file ]; then
1138 echo Fixing $file, incorrect \#include
1139 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
78c5c646
RS
1140 ${LIB}/$file > ${LIB}/${file}.
1141 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
75251fe0 1142 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
75251fe0 1143 rm -f ${LIB}/$file
7a0934e7
ILT
1144 else
1145 # Find any include directives that use "file".
1146 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1147 dir=`echo $file | sed -e s'|/[^/]*$||'`
1148 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1149 done
75251fe0
DM
1150 fi
1151fi
1152
1153# Multiline comment after typedef on IRIX 4.0.1.
1154file=sys/types.h
1155if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1156 mkdir ${LIB}/sys 2>/dev/null
1157 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1158 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 1159 chmod a+r ${LIB}/$file 2>/dev/null
75251fe0
DM
1160fi
1161
1162if [ -r ${LIB}/$file ]; then
1163 echo Fixing $file, comment in the middle of \#ifdef
1164 sed -e 's@type of the result@type of the result */@' \
1165 -e 's@of the sizeof@/* of the sizeof@' \
1166 ${LIB}/$file > ${LIB}/${file}.sed
1167 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1168 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
75251fe0 1169 rm -f ${LIB}/$file
7a0934e7
ILT
1170 else
1171 # Find any include directives that use "file".
1172 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1173 dir=`echo $file | sed -e s'|/[^/]*$||'`
1174 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1175 done
75251fe0
DM
1176 fi
1177fi
1178
2a46424a
ILT
1179# Turning // comments into /* */ comments trashes this IRIX 4.0.1
1180# header file, which embeds // comments inside multi-line /* */
1181# comments. If this looks like the IRIX header file, we refix it by
1182# just throwing away the // comments.
1183file=fam.h
1184if [ -r ${LIB}/$file ]; then
1185 if egrep indigo.esd ${LIB}/$file > /dev/null; then
1186 echo Fixing $file, overeager sed script
1187 rm ${LIB}/$file
1188 sed -e 's|//.*$||g' $file > ${LIB}/$file
1189 chmod +w ${LIB}/$file 2>/dev/null
1190 chmod a+r ${LIB}/$file 2>/dev/null
1191 fi
1192fi
1193
d6b3cb10
ILT
1194# There is a similar problem with the VxWorks drv/netif/if_med.h file.
1195file=drv/netif/if_med.h
1196if [ -r ${LIB}/$file ]; then
1197 if egrep 'Wind River' ${LIB}/$file > /dev/null; then
1198 echo Fixing $file, overeager sed script
1199 rm ${LIB}/$file
1200 sed -e 's|//.*$||g' $file > ${LIB}/$file
1201 chmod +w ${LIB}/$file 2>/dev/null
1202 chmod a+r ${LIB}/$file 2>/dev/null
1203 fi
1204fi
1205
f5963e61 1206# And also with the HP-UX 10 and HP-UX 11 sys/pci.h file
a94729bc
PH
1207file=sys/pci.h
1208if [ -r ${LIB}/$file ]; then
1209 if egrep 'System Private Structures' ${LIB}/$file > /dev/null; then
1210 echo Fixing $file, overeager sed script
1211 rm ${LIB}/$file
1212 sed -e 's|//.*$||g' $file > ${LIB}/$file
1213 chmod +w ${LIB}/$file 2>/dev/null
1214 chmod a+r ${LIB}/$file 2>/dev/null
1215 fi
1216fi
1217
f5963e61
JL
1218# And also with a few more HP-UX 11 headers which are only broken
1219# after they are "fixed".
1220file=sys/ki_iface.h
1221if [ -r ${LIB}/$file ]; then
1222 if egrep 'These definitions are for HP Internal developers' ${LIB}/$file > /dev/null; then
1223 echo Fixing $file, overeager sed script
1224 rm ${LIB}/$file
1225 fi
1226fi
1227
1228file=sys/ki.h
1229if [ -r ${LIB}/$file ]; then
1230 if egrep '11.00 HP-UX LP64' ${LIB}/$file > /dev/null; then
1231 echo Fixing $file, overeager sed script
1232 rm ${LIB}/$file
1233 fi
1234fi
1235
1236file=sys/ki_calls.h
1237if [ -r ${LIB}/$file ]; then
1238 if egrep 'KI_MAX_PROCS is an arbitrary number' ${LIB}/$file > /dev/null; then
1239 echo Fixing $file, overeager sed script
1240 rm ${LIB}/$file
1241 fi
1242fi
1243
1244file=sys/ki_defs.h
1245if [ -r ${LIB}/$file ] ; then
1246 if egrep 'Kernel Instrumentation Definitions' ${LIB}/$file > /dev/null; then
1247 echo Fixing $file, overeager sed script
1248 rm ${LIB}/$file
1249 fi
1250fi
1251
1252file=sys/time.h
1253if [ -r ${LIB}/$file ] ; then
1254 if egrep 'For CASPEC, look in' ${LIB}/$file > /dev/null; then
1255 echo Fixing $file, overeager sed script
1256 rm ${LIB}/$file
1257 fi
1258fi
1259
8bfed528
RS
1260# Some IRIX header files contains the string "//"
1261for file in elf_abi.h elf.h; do
1262 if [ -r ${LIB}/$file ]; then
1263 echo Fixing $file, overeager sed script
1264 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
1265 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1266 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1267 rm -f ${LIB}/$file
7a0934e7
ILT
1268 else
1269 # Find any include directives that use "file".
1270 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1271 dir=`echo $file | sed -e s'|/[^/]*$||'`
1272 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1273 done
8bfed528 1274 fi
7313c84b 1275 fi
8bfed528 1276done
7313c84b 1277
3b0ad9f9
RK
1278# IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
1279# previous definition.
1280file=rpc/auth.h
1281if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1282 mkdir ${LIB}/rpc 2>/dev/null
1283 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1284 chmod +w ${LIB}/$file 2>/dev/null
1285 chmod a+r ${LIB}/$file 2>/dev/null
1286fi
1287
1288if [ -r ${LIB}/$file ]; then
1289 echo Fixing $file, undefined type
1290 sed -e '/authdes_create.*struct sockaddr/i\
d4c60bd6
ILT
1291struct sockaddr;
1292' \
3b0ad9f9
RK
1293 ${LIB}/$file > ${LIB}/$file.sed
1294 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1295 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1296 rm -f ${LIB}/$file
7a0934e7
ILT
1297 else
1298 # Find any include directives that use "file".
1299 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1300 dir=`echo $file | sed -e s'|/[^/]*$||'`
1301 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1302 done
3b0ad9f9
RK
1303 fi
1304fi
1305
1306# IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
1307# definition.
1308file=rpc/xdr.h
1309if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1310 mkdir ${LIB}/rpc 2>/dev/null
1311 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1312 chmod +w ${LIB}/$file 2>/dev/null
1313 chmod a+r ${LIB}/$file 2>/dev/null
1314fi
1315
1316if [ -r ${LIB}/$file ]; then
1317 echo Fixing $file, undefined type
1318 sed -e '/xdrstdio_create.*struct __file_s/i\
d4c60bd6
ILT
1319struct __file_s;
1320' \
3b0ad9f9
RK
1321 ${LIB}/$file > ${LIB}/$file.sed
1322 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1323 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1324 rm -f ${LIB}/$file
7a0934e7
ILT
1325 else
1326 # Find any include directives that use "file".
1327 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1328 dir=`echo $file | sed -e s'|/[^/]*$||'`
1329 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1330 done
3b0ad9f9
RK
1331 fi
1332fi
1333
0ff76398
JW
1334# Same problem with a file from SunOS 4.1.3 : a header file containing
1335# the string "//" embedded in "/**/"
1336file=sbusdev/audiovar.h
1337if [ -r ${LIB}/$file ]; then
1338 echo Fixing $file, overeager sed script
1339 rm ${LIB}/$file
1340 sed -e 's|//.*$||g' $file > ${LIB}/$file
1341 chmod +w ${LIB}/$file 2>/dev/null
1342 chmod a+r ${LIB}/$file 2>/dev/null
1343fi
1344
4d449554
JW
1345# Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
1346# declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
1347# many other systems have similar text but correct versions of the file.
1348# To ensure only Sun's is fixed, we grep for a likely unique string.
f0f50f84 1349# Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
4d449554 1350file=memory.h
f0f50f84 1351if [ -r $file ] && egrep '/\* @\(#\)(head/memory.h 50.1 |memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 )\*/' $file > /dev/null; then
6a25991d 1352 if [ ! -r ${LIB}/$file ]; then
4d449554
JW
1353 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1354 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 1355 chmod a+r ${LIB}/$file 2>/dev/null
4d449554
JW
1356 fi
1357 if [ -r ${LIB}/$file ]; then
1358 echo Replacing $file
1359 cat > ${LIB}/$file << EOF
1360/* This file was generated by fixincludes */
1361#ifndef __memory_h__
1362#define __memory_h__
1363
1364#ifdef __STDC__
1365extern void *memccpy();
1366extern void *memchr();
1367extern void *memcpy();
1368extern void *memset();
1369#else
1370extern char *memccpy();
1371extern char *memchr();
1372extern char *memcpy();
1373extern char *memset();
1374#endif /* __STDC__ */
1375
1376extern int memcmp();
1377
eb13d323 1378#endif /* __memory_h__ */
4d449554
JW
1379EOF
1380 fi
1381fi
1382
ce805568
RK
1383# Fix return type of fread and fwrite on sysV68
1384file=stdio.h
1385if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1386 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1387 chmod +w ${LIB}/$file 2>/dev/null
1388 chmod a+r ${LIB}/$file 2>/dev/null
1389fi
1390
1391if [ -r ${LIB}/$file ]; then
1392 echo Fixing $file, fread and fwrite return type
1393 sed -e 's/^\(extern int fclose(), fflush()\), \(fread(), fwrite()\)\(.*\)$/extern unsigned int \2;\
1394\1\3/' \
1395 ${LIB}/$file > ${LIB}/${file}.sed
1396 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1397 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1398 rm -f ${LIB}/$file
1399 else
1400 # Find any include directives that use "file".
1401 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1402 dir=`echo $file | sed -e s'|/[^/]*$||'`
1403 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1404 done
1405 fi
1406fi
1407
1485e7c1 1408# parameters not const on DECstation Ultrix V4.0 and OSF/1.
7d349561
JW
1409file=stdio.h
1410if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1411 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1412 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 1413 chmod a+r ${LIB}/$file 2>/dev/null
7d349561
JW
1414fi
1415
1416if [ -r ${LIB}/$file ]; then
1417 echo Fixing $file, non-const arg
1418 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
1419 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
1420 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
1421 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
1422 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
1423 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
1424 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
1485e7c1
RK
1425 -e 's@popen(char \*, char \*);@popen(const char *, const char *);@' \
1426 -e 's@tempnam(char\*,char\*);@tempnam(const char*,const char*);@' \
7d349561
JW
1427 ${LIB}/$file > ${LIB}/${file}.sed
1428 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1429 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
7d349561 1430 rm -f ${LIB}/$file
7a0934e7
ILT
1431 else
1432 # Find any include directives that use "file".
1433 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1434 dir=`echo $file | sed -e s'|/[^/]*$||'`
1435 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1436 done
7d349561
JW
1437 fi
1438fi
1439
f45a4d6a 1440# parameters conflict with C++ new on rs/6000
255fccf3
PB
1441for file in stdio.h unistd.h ; do
1442 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1443 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1444 chmod +w ${LIB}/$file 2>/dev/null
1445 fi
1446
1447 if [ -r ${LIB}/$file ]; then
1448 echo Fixing $file, parameter name conflicts
1449 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
1450 ${LIB}/$file > ${LIB}/${file}.sed
1451 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1452 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1453 rm -f ${LIB}/$file
7a0934e7
ILT
1454 else
1455 # Find any include directives that use "file".
1456 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1457 dir=`echo $file | sed -e s'|/[^/]*$||'`
1458 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1459 done
255fccf3
PB
1460 fi
1461 fi
1462done
1463
1464# function class(double x) conflicts with C++ keyword on rs/6000
1465file=math.h
f45a4d6a
JW
1466if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1467 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1468 chmod +w ${LIB}/$file 2>/dev/null
255fccf3 1469 chmod a+r ${LIB}/$file 2>/dev/null
f45a4d6a
JW
1470fi
1471
1472if [ -r ${LIB}/$file ]; then
ded732a0 1473 if grep '[^a-zA-Z_]class[(]' ${LIB}/$file >/dev/null; then
255fccf3
PB
1474 echo Fixing $file
1475 sed -e '/class[(]/i\
d4c60bd6
ILT
1476#ifndef __cplusplus
1477' \
255fccf3 1478 -e '/class[(]/a\
d4c60bd6
ILT
1479#endif
1480' ${LIB}/$file > ${LIB}/${file}.sed
255fccf3
PB
1481 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1482 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1483 rm ${LIB}/$file
7a0934e7
ILT
1484 else
1485 # Find any include directives that use "file".
1486 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1487 dir=`echo $file | sed -e s'|/[^/]*$||'`
1488 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1489 done
255fccf3
PB
1490 fi
1491 fi
1492fi
1493
e50ea3d0
RS
1494# Wrong fchmod prototype on RS/6000.
1495file=sys/stat.h
1496if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1497 mkdir ${LIB}/sys 2>/dev/null
1498 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1499 chmod +w ${LIB}/$file 2>/dev/null
1500 chmod a+r ${LIB}/$file 2>/dev/null
1501fi
1502
1503if [ -r ${LIB}/$file ]; then
1504 echo Fixing $file, fchmod prototype
1505 sed -e 's/fchmod(char \*/fchmod(int/' \
1506 ${LIB}/$file > ${LIB}/$file.sed
1507 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1508 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1509 rm -f ${LIB}/$file
7a0934e7
ILT
1510 else
1511 # Find any include directives that use "file".
1512 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1513 dir=`echo $file | sed -e s'|/[^/]*$||'`
1514 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1515 done
e50ea3d0
RS
1516 fi
1517fi
1518
266f3aac
ILT
1519# There are several name conflicts with C++ reserved words in X11
1520# header files. These are fixed in some versions, so don't do the
1521# fixes if we find __cplusplus in the file. These were found on the
1522# RS/6000.
1523
1524# class in X11/ShellP.h
1525file=X11/ShellP.h
1526if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1527 mkdir ${LIB}/sys 2>/dev/null
1528 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1529 chmod +w ${LIB}/$file 2>/dev/null
1530 chmod a+r ${LIB}/$file 2>/dev/null
1531fi
1532
1533if [ -r ${LIB}/$file ]; then
1534 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1535 true;
1536 else
1537 echo Fixing $file, field class
1538 sed -e '/char [*]class;/i\
1539#ifdef __cplusplus\
1540 char *c_class;\
d4c60bd6
ILT
1541#else
1542' \
266f3aac 1543 -e '/char [*]class;/a\
d4c60bd6
ILT
1544#endif
1545' ${LIB}/$file > ${LIB}/${file}.sed
266f3aac
ILT
1546 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1547 fi
1548 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1549 rm -f ${LIB}/$file
7a0934e7
ILT
1550 else
1551 # Find any include directives that use "file".
1552 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1553 dir=`echo $file | sed -e s'|/[^/]*$||'`
1554 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1555 done
266f3aac
ILT
1556 fi
1557fi
1558# new in Xm/Traversal.h
1559file=Xm/Traversal.h
1560if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1561 mkdir ${LIB}/sys 2>/dev/null
1562 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1563 chmod +w ${LIB}/$file 2>/dev/null
1564 chmod a+r ${LIB}/$file 2>/dev/null
1565fi
1566
1567if [ -r ${LIB}/$file ]; then
1568 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1569 true;
1570 else
dd22b925 1571 echo Fixing $file, uses of new
266f3aac
ILT
1572 sed -e '/Widget old, new;/i\
1573#ifdef __cplusplus\
1574 Widget old, c_new;\
d4c60bd6
ILT
1575#else
1576' \
266f3aac 1577 -e '/Widget old, new;/a\
d4c60bd6
ILT
1578#endif
1579' \
dd22b925 1580 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
266f3aac
ILT
1581 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1582 fi
1583 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1584 rm -f ${LIB}/$file
7a0934e7
ILT
1585 else
1586 # Find any include directives that use "file".
1587 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1588 dir=`echo $file | sed -e s'|/[^/]*$||'`
1589 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1590 done
266f3aac
ILT
1591 fi
1592fi
1593# class in Xm/BaseClassI.h
1594file=Xm/BaseClassI.h
1595if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1596 mkdir ${LIB}/sys 2>/dev/null
1597 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1598 chmod +w ${LIB}/$file 2>/dev/null
1599 chmod a+r ${LIB}/$file 2>/dev/null
1600fi
1601
1602if [ -r ${LIB}/$file ]; then
1603 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1604 true;
1605 else
1606 echo Fixing $file, prototype parameter name
1607 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1608 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1609 fi
1610 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1611 rm -f ${LIB}/$file
7a0934e7
ILT
1612 else
1613 # Find any include directives that use "file".
1614 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1615 dir=`echo $file | sed -e s'|/[^/]*$||'`
1616 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1617 done
266f3aac
ILT
1618 fi
1619fi
1620
e12c22a6
RK
1621# NeXT 3.2 adds const prefix to some math functions. These conflict
1622# with the built-in functions.
1623file=ansi/math.h
1624if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1625 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1626 chmod +w ${LIB}/$file 2>/dev/null
1627fi
1628if [ -r ${LIB}/$file ]; then
1629 echo Fixing $file
26a20dde
ILT
1630 sed -e '/^extern.*double.*__const__.*sqrt(/s/__const__//' \
1631 -e '/^extern.*double.*__const__.*fabs(/s/__const__//' \
1632 -e '/^extern.*double.*__const__.*cos(/s/__const__//' \
3ed18aeb 1633 -e '/^extern.*double.*__const__.*hypot(/s/__const__//' \
e12c22a6
RK
1634 -e '/^extern.*double.*__const__.*sin(/s/__const__//' ${LIB}/$file > ${LIB}/${file}.sed
1635 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1636 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1637 rm -f ${LIB}/$file
1638 else
1639 # Find any include directives that use "file".
1640 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1641 dir=`echo $file | sed -e s'|/[^/]*$||'`
1642 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1643 done
1644 fi
1645fi
1646
1647# NeXT 3.2 uses the word "template" as a parameter for some
1648# functions. GCC reports an invalid use of a reserved key word
1649# with the built-in functions. NeXT 3.2 includes the keyword
1650# volatile in the prototype for abort(). This conflicts with
1651# the built-in definition.
1652file=bsd/libc.h
1653if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1654 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1655 chmod +w ${LIB}/$file 2>/dev/null
1656fi
1657if [ -r ${LIB}/$file ]; then
1658 echo Fixing $file
1659 sed -e '/\(.*template\)/s/template//' \
1660 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1661 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1662 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1663 rm -f ${LIB}/$file
1664 else
1665 # Find any include directives that use "file".
1666 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1667 dir=`echo $file | sed -e s'|/[^/]*$||'`
1668 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1669 done
1670 fi
1671fi
1672
1673# NeXT 3.2 includes the keyword volatile in the abort() and
1674# exit() function prototypes. That conflicts with the
1675# built-in functions.
1676file=ansi/stdlib.h
1677if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1678 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1679 chmod +w ${LIB}/$file 2>/dev/null
1680fi
1681if [ -r ${LIB}/$file ]; then
1682 echo Fixing $file
1683 sed -e '/extern.*volatile.*void.*exit/s/volatile//' \
1684 -e '/extern.*volatile.*void.*abort/s/volatile//' ${LIB}/$file > ${LIB}/${file}.sed
1685 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1cd0a8ed
RO
1686 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1687 rm -f ${LIB}/$file
1688 else
1689 # Find any include directives that use "file".
1690 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1691 dir=`echo $file | sed -e s'|/[^/]*$||'`
1692 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1693 done
1694 fi
1695fi
1696
1697# sys/utsname.h on Ultrix V4.[35] puts the declaration of uname before the
1698# definition of struct utsname, so the prototype (added by fixproto) causes
1699# havoc.
1700file=sys/utsname.h
1701if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1702 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1703 chmod +w ${LIB}/$file 2>/dev/null
1704fi
1705
1706if [ -r ${LIB}/$file ] \
1707 && grep 'ULTRIX' ${LIB}/$file >/dev/null; then
1708 echo Fixing $file, uname declaration
1709 sed -e '/^[ ]*extern[ ]*int[ ]*uname();$/i\
1710struct utsname;
1711'\
1712 ${LIB}/$file > ${LIB}/${file}.sed
1713 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
e12c22a6
RK
1714 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1715 rm -f ${LIB}/$file
1716 else
1717 # Find any include directives that use "file".
1718 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1719 dir=`echo $file | sed -e s'|/[^/]*$||'`
1720 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1721 done
1722 fi
1723fi
266f3aac 1724
f8e7d8e7
RK
1725# sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition
1726# of struct rusage, so the prototype (added by fixproto) causes havoc.
1727file=sys/wait.h
1728if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1729 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1730 chmod +w ${LIB}/$file 2>/dev/null
1731fi
1732
1733if [ -r ${LIB}/$file ] \
1734 && grep 'bos325,' ${LIB}/$file >/dev/null; then
1735 echo Fixing $file, wait3 declaration
1736 sed -e '/^extern pid_t wait3();$/i\
1737struct rusage;
1738'\
1739 ${LIB}/$file > ${LIB}/${file}.sed
1740 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1741 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1742 rm -f ${LIB}/$file
1743 else
1744 # Find any include directives that use "file".
1745 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1746 dir=`echo $file | sed -e s'|/[^/]*$||'`
1747 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1748 done
1749 fi
1750fi
1751
08432663
RS
1752# NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1753# Note that version 3 of the NeXT system has wait.h in a different directory,
1754# so that this code won't do anything. But wait.h in version 3 has a
1755# conditional, so it doesn't need this fix. So everything is okay.
255fccf3
PB
1756file=sys/wait.h
1757if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1758 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1759 chmod +w ${LIB}/$file 2>/dev/null
1760fi
1761
1762if [ -r ${LIB}/$file ] \
1763 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1764 echo Fixing $file, bad wait formal
1765 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
f45a4d6a
JW
1766 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1767 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1768 rm -f ${LIB}/$file
7a0934e7
ILT
1769 else
1770 # Find any include directives that use "file".
1771 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1772 dir=`echo $file | sed -e s'|/[^/]*$||'`
1773 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1774 done
f45a4d6a
JW
1775 fi
1776fi
1777
1ac7d389 1778# Don't use or define the name va_list in stdio.h.
5560c9b3 1779# This is for ANSI and also to interoperate properly with gcc's varargs.h.
1ac7d389
RS
1780file=stdio.h
1781if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1782 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1783 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 1784 chmod a+r ${LIB}/$file 2>/dev/null
1ac7d389
RS
1785fi
1786
1787if [ -r ${LIB}/$file ]; then
1788 echo Fixing $file, use of va_list
1789 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
29421402
ILT
1790 if egrep "__need___va_list" ${LIB}/$file >/dev/null 2>&1; then
1791 touch ${LIB}/${file}.sed
1792 else
1793 (echo "#define __need___va_list"
1794 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1795 fi
1ac7d389 1796 # Use __gnuc_va_list in arg types in place of va_list.
d5891360
JW
1797 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1798 # trailing parentheses and semicolon save all other systems from this.
1ac7d389
RS
1799 # Define __va_list__ (something harmless and unused) instead of va_list.
1800 # Don't claim to have defined va_list.
1801 sed -e 's@ va_list @ __gnuc_va_list @' \
8befb954 1802 -e 's@ va_list)@ __gnuc_va_list)@' \
e3124505 1803 -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \
d5891360 1804 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1ac7d389 1805 -e 's@ va_list@ __va_list__@' \
be71bebd 1806 -e 's@\*va_list@*__va_list__@' \
0f20ebd1 1807 -e 's@ __va_list)@ __gnuc_va_list)@' \
29421402 1808 -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \
75d98655 1809 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1ac7d389 1810 -e 's@VA_LIST@DUMMY_VA_LIST@' \
29421402 1811 -e 's@_Va_LIST@_VA_LIST@' \
1ac7d389
RS
1812 ${LIB}/$file >> ${LIB}/${file}.sed
1813
1814 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1815 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1ac7d389 1816 rm -f ${LIB}/$file
7a0934e7
ILT
1817 else
1818 # Find any include directives that use "file".
1819 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1820 dir=`echo $file | sed -e s'|/[^/]*$||'`
1821 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1822 done
1ac7d389
RS
1823 fi
1824fi
1825
e63c1d35
RS
1826# Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1827file=ansi_compat.h
1828if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1829 if grep -s ULTRIX $file; then
1830 echo "/* This file intentionally left blank. */" > $LIB/$file
1831 fi
1832fi
1833
a1eb0286 1834# parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
28bbe06b 1835# also get rid of bogus inline definitions in HP-UX 8.0
7d349561
JW
1836file=math.h
1837if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1838 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1839 chmod +w ${LIB}/$file 2>/dev/null
2e4cd151 1840 chmod a+r ${LIB}/$file 2>/dev/null
7d349561
JW
1841fi
1842
1843if [ -r ${LIB}/$file ]; then
1844 echo Fixing $file, non-const arg
a1eb0286 1845 sed -e 's@atof(\([ ]*char[ ]*\*[^)]*\))@atof(const \1)@' \
ee3ac81d 1846 -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \
e6093ed4
RS
1847 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1848 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1849 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
7d349561 1850 ${LIB}/$file > ${LIB}/${file}.sed
73b73053
RK
1851 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1852 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1853 rm -f ${LIB}/$file
1854 else
1855 # Find any include directives that use "file".
1856 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1857 dir=`echo $file | sed -e s'|/[^/]*$||'`
1858 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1859 done
1860 fi
1861fi
1862
1863# fix bogus recursive stdlib.h in NEWS-OS 4.0C
1864file=stdlib.h
1865if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1866 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1867 chmod +w ${LIB}/$file 2>/dev/null
1868 chmod a+r ${LIB}/$file 2>/dev/null
1869fi
1870
1871if [ -r ${LIB}/$file ]; then
1872 echo Fixing $file, recursive inclusion
1873 sed -e '/^#include <stdlib.h>/i\
1874#if 0
1875' \
1876 -e '/^#include <stdlib.h>/a\
1877#endif
1878' \
1879 ${LIB}/$file > ${LIB}/${file}.sed
7d349561
JW
1880 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1881 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
7d349561 1882 rm -f ${LIB}/$file
7a0934e7
ILT
1883 else
1884 # Find any include directives that use "file".
1885 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1886 dir=`echo $file | sed -e s'|/[^/]*$||'`
1887 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1888 done
7d349561
JW
1889 fi
1890fi
1891
e50ea3d0
RS
1892# Avoid nested comments on Ultrix 4.3.
1893file=rpc/svc.h
1894if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1895 mkdir ${LIB}/rpc 2>/dev/null
1896 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1897 chmod +w ${LIB}/$file 2>/dev/null
1898 chmod a+r ${LIB}/$file 2>/dev/null
1899fi
1900
1901if [ -r ${LIB}/$file ]; then
1902 echo Fixing $file, nested comment
1903 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1904 ${LIB}/$file > ${LIB}/$file.sed
1905 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1906 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1907 rm -f ${LIB}/$file
7a0934e7
ILT
1908 else
1909 # Find any include directives that use "file".
1910 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1911 dir=`echo $file | sed -e s'|/[^/]*$||'`
1912 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1913 done
e50ea3d0
RS
1914 fi
1915fi
1916
a6642da8
JW
1917# This file in RISC/os uses /**/ to concatenate two tokens.
1918file=bsd43/bsd43_.h
1919if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1920 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1921 chmod +w ${LIB}/$file 2>/dev/null
1922 chmod a+r ${LIB}/$file 2>/dev/null
1923fi
1924if [ -r ${LIB}/$file ]; then
1925 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1926 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1927 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1928 rm -f ${LIB}/$file
7a0934e7
ILT
1929 else
1930 # Find any include directives that use "file".
1931 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1932 dir=`echo $file | sed -e s'|/[^/]*$||'`
1933 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1934 done
a6642da8
JW
1935 fi
1936fi
1937
3b0ad9f9
RK
1938file=rpc/rpc.h
1939if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1940 mkdir ${LIB}/rpc 2>/dev/null
1941 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1942 chmod +w ${LIB}/$file 2>/dev/null
1943 chmod a+r ${LIB}/$file 2>/dev/null
1944fi
1945
1946if [ -r ${LIB}/$file ]; then
1947 echo Fixing $file, nested comment
1948 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1949 ${LIB}/$file > ${LIB}/$file.sed
1950 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1951 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1952 rm -f ${LIB}/$file
7a0934e7
ILT
1953 else
1954 # Find any include directives that use "file".
1955 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1956 dir=`echo $file | sed -e s'|/[^/]*$||'`
1957 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1958 done
3b0ad9f9
RK
1959 fi
1960fi
1961
ffc1e7b2
DE
1962# rpc/types.h on OSF1/2.0 is not C++ ready, even though NO_IMPLICIT_EXTERN_C
1963# is defined for the alpha. The problem is the declaration of malloc.
1964file=rpc/types.h
ffc1e7b2
DE
1965if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1966 mkdir ${LIB}/rpc 2>/dev/null
1967 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1968 chmod +w ${LIB}/$file 2>/dev/null
1969 chmod a+r ${LIB}/$file 2>/dev/null
1970fi
1971if [ -r ${LIB}/$file ]; then
1972 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1; then
1973 true
1974 else
1975 echo Fixing $file
1976 echo '#ifdef __cplusplus
1977extern "C" {
1978#endif' > ${LIB}/${file}.sed
1979 cat ${LIB}/${file} >> ${LIB}/${file}.sed
1980 echo '#ifdef __cplusplus
1981}
1982#endif' >> ${LIB}/${file}.sed
1983 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1984 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1985 rm -f ${LIB}/$file
1986 else
1987 # Find any include directives that use "file".
1988 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1989 dir=`echo $file | sed -e s'|/[^/]*$||'`
1990 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
1991 done
1992 fi
1993 fi
1994fi
1995
6ef797ea
RS
1996# In limits.h, put #ifndefs around things that are supposed to be defined
1997# in float.h to avoid redefinition errors if float.h is included first.
c49c4803
ILT
1998# On HP/UX this patch does not work, because on HP/UX limits.h uses
1999# multi line comments and the inserted #endif winds up inside the
2000# comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
2001# we find a #ifndef FLT_MIN we assume that all the required #ifndefs
2002# are there, and we do not add them ourselves.
e5e809f4 2003# Also fix a nested comment problem in sys/limits.h on Motorola sysV68 R3V7.1
e50ea3d0
RS
2004for file in limits.h sys/limits.h; do
2005 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2006 mkdir ${LIB}/sys 2>/dev/null
2007 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2008 chmod +w ${LIB}/$file 2>/dev/null
2009 chmod a+r ${LIB}/$file 2>/dev/null
2010 fi
6ef797ea 2011
e50ea3d0
RS
2012 if [ -r ${LIB}/$file ]; then
2013 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
2014 true
2015 else
2016 echo Fixing $file
2017 sed -e '/[ ]FLT_MIN[ ]/i\
d4c60bd6
ILT
2018#ifndef FLT_MIN
2019'\
e50ea3d0 2020 -e '/[ ]FLT_MIN[ ]/a\
d4c60bd6
ILT
2021#endif
2022'\
e50ea3d0 2023 -e '/[ ]FLT_MAX[ ]/i\
d4c60bd6
ILT
2024#ifndef FLT_MAX
2025'\
e50ea3d0 2026 -e '/[ ]FLT_MAX[ ]/a\
d4c60bd6
ILT
2027#endif
2028'\
e50ea3d0 2029 -e '/[ ]FLT_DIG[ ]/i\
d4c60bd6
ILT
2030#ifndef FLT_DIG
2031'\
e50ea3d0 2032 -e '/[ ]FLT_DIG[ ]/a\
d4c60bd6
ILT
2033#endif
2034'\
e50ea3d0 2035 -e '/[ ]DBL_MIN[ ]/i\
d4c60bd6
ILT
2036#ifndef DBL_MIN
2037'\
e50ea3d0 2038 -e '/[ ]DBL_MIN[ ]/a\
d4c60bd6
ILT
2039#endif
2040'\
e50ea3d0 2041 -e '/[ ]DBL_MAX[ ]/i\
d4c60bd6
ILT
2042#ifndef DBL_MAX
2043'\
e50ea3d0 2044 -e '/[ ]DBL_MAX[ ]/a\
d4c60bd6
ILT
2045#endif
2046'\
e50ea3d0 2047 -e '/[ ]DBL_DIG[ ]/i\
d4c60bd6
ILT
2048#ifndef DBL_DIG
2049'\
e50ea3d0 2050 -e '/[ ]DBL_DIG[ ]/a\
d4c60bd6
ILT
2051#endif
2052'\
e5e809f4 2053 -e '/^\(\/\*#define HUGE_VAL 3\.[0-9e+]* *\)\/\*/s//\1/'\
e50ea3d0
RS
2054 ${LIB}/$file > ${LIB}/${file}.sed
2055 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2056 fi
2057 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2058 echo Deleting ${LIB}/$file\; no fixes were needed.
2059 rm -f ${LIB}/$file
7a0934e7
ILT
2060 else
2061 # Find any include directives that use "file".
2062 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2063 dir=`echo $file | sed -e s'|/[^/]*$||'`
2064 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2065 done
e50ea3d0 2066 fi
6ef797ea 2067 fi
e50ea3d0 2068done
6ef797ea 2069
303b6ca3
JW
2070# In math.h, put #ifndefs around things that might be defined in a gcc
2071# specific math-*.h file.
2072file=math.h
2073if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2074 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2075 chmod +w ${LIB}/$file 2>/dev/null
2076 chmod a+r ${LIB}/$file 2>/dev/null
2077fi
2078
2079if [ -r ${LIB}/$file ]; then
2080 echo Fixing $file
2081 sed -e '/define[ ]HUGE_VAL[ ]/i\
d4c60bd6
ILT
2082#ifndef HUGE_VAL
2083'\
303b6ca3 2084 -e '/define[ ]HUGE_VAL[ ]/a\
d4c60bd6
ILT
2085#endif
2086'\
303b6ca3
JW
2087 ${LIB}/$file > ${LIB}/${file}.sed
2088 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
09130b78
BC
2089
2090 # In addition, copy the definition of DBL_MAX from float.h
2091 # if math.h requires one. The Lynx math.h requires it.
2092 if egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file >/dev/null 2>&1; then
2093 if egrep '#define[ ]+DBL_MAX[ ]+' $file >/dev/null 2>&1; then
2094 true;
2095 else
2096 dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null`
2097 if [ "$dbl_max_def" != "" ]; then
2098 dbl_max_def=`echo $dbl_max_def | sed 's/.*define[ ]*DBL_MAX[ ]*//'`
2099 sed -e "/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/" \
2100 ${LIB}/$file > ${LIB}/${file}.sed
d67342cd 2101 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
09130b78
BC
2102 fi
2103 fi
2104 fi
86bb0d5f 2105
303b6ca3
JW
2106 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2107 echo Deleting ${LIB}/$file\; no fixes were needed.
2108 rm -f ${LIB}/$file
7a0934e7
ILT
2109 else
2110 # Find any include directives that use "file".
2111 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2112 dir=`echo $file | sed -e s'|/[^/]*$||'`
2113 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2114 done
303b6ca3
JW
2115 fi
2116fi
2117
f90ac35b
RK
2118# Remove erroneous parentheses in sym.h on Alpha OSF/1.
2119file=sym.h
2120if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2121 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2122 chmod +w ${LIB}/$file 2>/dev/null
2123 chmod a+r ${LIB}/$file 2>/dev/null
2124fi
2125
2126if [ -r ${LIB}/$file ]; then
2127 echo Fixing $file
2128 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
2129 ${LIB}/$file > ${LIB}/${file}.sed
2130 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2131 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2132 rm -f ${LIB}/$file
7a0934e7
ILT
2133 else
2134 # Find any include directives that use "file".
2135 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2136 dir=`echo $file | sed -e s'|/[^/]*$||'`
2137 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2138 done
f90ac35b
RK
2139 fi
2140fi
2141
586c5437
RK
2142# Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
2143# in string.h on sysV68
09130b78 2144# Correct the return type for strlen in string.h on Lynx.
787e63c8 2145# Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
1485e7c1 2146# Add missing const for strdup on OSF/1 V3.0.
7567d496 2147# On sysV88 layout is slightly different.
09130b78
BC
2148file=string.h
2149if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2150 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2151 chmod +w ${LIB}/$file 2>/dev/null
2152 chmod a+r ${LIB}/$file 2>/dev/null
2153fi
2154
2155if [ -r ${LIB}/$file ]; then
586c5437 2156 echo Fixing $file, mem{ccpy,chr,cpy,set} and str{len,spn,cspn} return value
09130b78 2157 sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \
787e63c8 2158 -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \
1485e7c1 2159 -e 's/strdup(char \*s1);/strdup(const char *s1);/' \
586c5437
RK
2160 -e '/^extern char$/N' \
2161 -e 's/^extern char\(\n \*memccpy(),\)$/extern void\1/'\
2162 -e '/^ strncmp(),$/N'\
2163 -e 's/^\( strncmp()\),\n\( strlen(),\)$/\1;\
2164extern unsigned int\
2165\2/'\
7567d496
MH
2166 -e '/^extern int$/N'\
2167 -e 's/^extern int\(\n strlen(),\)/extern size_t\1/' \
09130b78
BC
2168 ${LIB}/$file > ${LIB}/${file}.sed
2169 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2170 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2171 rm -f ${LIB}/$file
7a0934e7
ILT
2172 else
2173 # Find any include directives that use "file".
2174 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2175 dir=`echo $file | sed -e s'|/[^/]*$||'`
2176 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2177 done
09130b78
BC
2178 fi
2179fi
2180
7374f95a
JW
2181# Correct the return type for strlen in strings.h in SunOS 4.
2182file=strings.h
2183if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2184 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2185 chmod +w ${LIB}/$file 2>/dev/null
2186 chmod a+r ${LIB}/$file 2>/dev/null
2187fi
2188
2189if [ -r ${LIB}/$file ]; then
2190 echo Fixing $file
2191 sed -e 's/int[ ]*strlen();/__SIZE_TYPE__ strlen();/' \
2192 ${LIB}/$file > ${LIB}/${file}.sed
2193 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2194 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2195 rm -f ${LIB}/$file
2196 else
2197 # Find any include directives that use "file".
2198 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2199 dir=`echo $file | sed -e s'|/[^/]*$||'`
2200 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2201 done
2202 fi
2203fi
2204
09130b78
BC
2205# Delete the '#define void int' line from curses.h on Lynx
2206file=curses.h
2207if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2208 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2209 chmod +w ${LIB}/$file 2>/dev/null
2210 chmod a+r ${LIB}/$file 2>/dev/null
2211fi
2212
2213if [ -r ${LIB}/$file ]; then
2214 echo Fixing $file
26dac810 2215 sed -e '/#[ ]*define[ ][ ]*void[ ]int/d' \
09130b78
BC
2216 ${LIB}/$file > ${LIB}/${file}.sed
2217 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
0323c178
ILT
2218 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2219 rm -f ${LIB}/$file
2220 else
2221 # Find any include directives that use "file".
2222 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2223 dir=`echo $file | sed -e s'|/[^/]*$||'`
2224 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2225 done
2226 fi
2227fi
2228
2229# Fix `typedef struct term;' on hppa1.1-hp-hpux9.
2230file=curses.h
2231if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2232 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2233 chmod +w ${LIB}/$file 2>/dev/null
2234 chmod a+r ${LIB}/$file 2>/dev/null
2235fi
2236
2237if [ -r ${LIB}/$file ]; then
2238 echo Fixing $file
2239 sed -e 's/^[ ]*typedef[ ][ ]*\(struct[ ][ ]*term[ ]*;[ ]*\)$/\1/' \
2240 ${LIB}/$file > ${LIB}/${file}.sed
2241 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
7a0934e7
ILT
2242 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2243 rm -f ${LIB}/$file
2244 else
2245 # Find any include directives that use "file".
2246 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2247 dir=`echo $file | sed -e s'|/[^/]*$||'`
2248 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2249 done
09130b78
BC
2250 fi
2251fi
2252
e53076d6 2253# For C++, avoid any typedef or macro definition of bool, and use the
884ba59a
BK
2254# built in type instead. HP/UX 10.20, at least, also has it
2255# in curses_colr/curses.h.
2256for file in curses.h curses_colr/curses.h ; do
2257 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2258 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2259 chmod +w ${LIB}/$file 2>/dev/null
2260 chmod a+r ${LIB}/$file 2>/dev/null
2261 fi
2262 if [ -r ${LIB}/$file ] && egrep bool ${LIB}/$file >/dev/null 2>&1; then
2263 echo Fixing $file, typedef or macro for bool is invalid in C++
e53076d6 2264 sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\
2dbb8078
RK
2265#ifndef __cplusplus
2266'\
e53076d6 2267 -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\
2dbb8078
RK
2268#endif
2269'\
897746d8 2270 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/i\
2dbb8078
RK
2271#ifndef __cplusplus
2272'\
897746d8 2273 -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/a\
2dbb8078
RK
2274#endif
2275'\
e53076d6
ILT
2276 ${LIB}/$file > ${LIB}/${file}.sed
2277 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2278 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2279 rm -f ${LIB}/$file
7a0934e7
ILT
2280 else
2281 # Find any include directives that use "file".
2282 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2283 dir=`echo $file | sed -e s'|/[^/]*$||'`
2284 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2285 done
e53076d6
ILT
2286 fi
2287 fi
2288done
2289
1daf7029
RS
2290# Fix incorrect S_IF* definitions on m88k-sysv3.
2291file=sys/stat.h
2292if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2293 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2294 chmod +w ${LIB}/$file 2>/dev/null
2295 chmod a+r ${LIB}/$file 2>/dev/null
2296fi
2297
2298if [ -r ${LIB}/$file ]; then
2299 echo Fixing $file
2300 sed -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(S_IF[A-Z][A-Z][A-Z][A-Z]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
2301 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
2302 ${LIB}/$file > ${LIB}/${file}.sed
2303 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2304 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2305 rm -f ${LIB}/$file
7a0934e7
ILT
2306 else
2307 # Find any include directives that use "file".
2308 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2309 dir=`echo $file | sed -e s'|/[^/]*$||'`
2310 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2311 done
1daf7029
RS
2312 fi
2313fi
2314
a26fd165
MH
2315# Fix nested comments in Motorola's <limits.h> and <sys/limits.h>
2316for file in limits.h sys/limits.h; do
2317 if [ $target_canonical = m88k-motorola-sysv3 -o \
2318 $target_canonical = m68k-motorola-sysv ]; then
2319
2320 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2321 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2322 chmod +w ${LIB}/$file 2>/dev/null
2323 chmod a+r ${LIB}/$file 2>/dev/null
2324 fi
2325
2326 if [ -r ${LIB}/$file ]; then
2327 echo "Fixing nested comments in Motorola's $file"
2328 sed \
2329 -e 's@^\(#undef[ ][ ]*PIPE_BUF[ ]*/\* max # bytes atomic in write to a\)$@\1 */@' \
2330 -e 's@\(/\*#define HUGE_VAL 3.40282346638528860e+38 \)\(/\*error value returned by Math lib\*/\)$@\1*/ \2@' \
2331 < ${LIB}/$file > ${LIB}/${file}.sed
2332 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2333 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2334 rm -f ${LIB}/$file
2335 fi
2336 fi
2337 fi
2338done
2339
639010af 2340# Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
e50ea3d0
RS
2341for file in stdio.h stdlib.h; do
2342 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2343 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2344 chmod +w ${LIB}/$file 2>/dev/null
2345 chmod a+r ${LIB}/$file 2>/dev/null
2346 fi
2347
2348 if [ -r ${LIB}/$file ]; then
2349 echo Fixing $file, getopt declaration
639010af 2350 sed -e 's/getopt(int, char \*\[\],[ ]*char \*)/getopt(int, char *const[], const char *)/' \
e50ea3d0
RS
2351 ${LIB}/$file > ${LIB}/${file}.sed
2352 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2353 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2354 rm -f ${LIB}/$file
7a0934e7
ILT
2355 else
2356 # Find any include directives that use "file".
2357 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
5169bda7
JW
2358 dir=`echo $file | sed -e s'|/[^/]*$||'`
2359 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2360 done
2361 fi
2362 fi
2363done
2364
2365# Fix __page_size* declarations in pthread.h AIX 4.1.[34].
2366# The original ones fail if uninitialized externs are not common.
2367# This is the default for all ANSI standard C++ compilers.
2368for file in pthread.h; do
2369 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2370 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2371 chmod +w ${LIB}/$file 2>/dev/null
2372 chmod a+r ${LIB}/$file 2>/dev/null
2373 fi
2374
2375 if [ -r ${LIB}/$file ]; then
2376 echo Fixing $file, __page_size* declarations
2377 sed -e 's/^int __page_size/extern int __page_size/' \
2378 ${LIB}/$file > ${LIB}/${file}.sed
2379 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2380 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2381 rm -f ${LIB}/$file
2382 else
2383 # Find any include directives that use "file".
2384 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
7a0934e7
ILT
2385 dir=`echo $file | sed -e s'|/[^/]*$||'`
2386 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2387 done
e50ea3d0
RS
2388 fi
2389 fi
2390done
2391
315198ab
RS
2392# Determine if we're on Interactive Unix 2.2 or later, in which case we
2393# need to fix some additional files. This is the same test for ISC that
2394# Autoconf uses.
2395if test -d /etc/conf/kconfig.d \
2396 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
2397 echo "Fixing ISC __STDC__ goof in several files..."
2398 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
2399 echo $name
2400 if test -r ${LIB}/$name; then
2401 file=${LIB}/$name
2402 else
2403 file=${INPUT}/$name
2404 fi
2405 # On Interactive 2.2, certain traditional Unix definitions
2406 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
2407 # defined, not just if _POSIX_SOURCE is defined. This makes it
2408 # impossible to compile any nontrivial program except with -posix.
2409 sed \
2410's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
2411 < $file > ${LIB}/$name.
2412 mv ${LIB}/$name. ${LIB}/$name
2413 done
2414
2415 echo "Fixing ISC fmod declaration"
2416 # This one's already been fixed for other things.
2417 file=${LIB}/math.h
2418 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
2419 mv $file. $file
2420
2421 echo "Fixing nested comments in ISC <sys/limits.h>"
2422 file=sys/limits.h
2423 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
2424 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
2425fi
2426
3b8b3c98
JW
2427# These files in Sun OS 4.x use /**/ to concatenate tokens.
2428for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
2429 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
2430 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
19571479
RS
2431do
2432 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2433 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2434 chmod +w ${LIB}/$file 2>/dev/null
2435 chmod a+r ${LIB}/$file 2>/dev/null
2436 fi
2437
2438 if [ -r ${LIB}/$file ]; then
2439 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2440 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2441 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2442 rm -f ${LIB}/$file
7a0934e7
ILT
2443 else
2444 # Find any include directives that use "file".
2445 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2446 dir=`echo $file | sed -e s'|/[^/]*$||'`
2447 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2448 done
19571479
RS
2449 fi
2450 fi
2451done
2452
2453# These files in ARM/RISCiX use /**/ to concatenate tokens.
2454for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
1f10df15 2455 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
3b8b3c98
JW
2456do
2457 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2458 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2459 chmod +w ${LIB}/$file 2>/dev/null
2460 chmod a+r ${LIB}/$file 2>/dev/null
2461 fi
2462
2463 if [ -r ${LIB}/$file ]; then
2464 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
2465 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2466 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2467 rm -f ${LIB}/$file
7a0934e7
ILT
2468 else
2469 # Find any include directives that use "file".
2470 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2471 dir=`echo $file | sed -e s'|/[^/]*$||'`
2472 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2473 done
3b8b3c98
JW
2474 fi
2475 fi
2476done
2477
7567d496
MH
2478# libm.a on m88k-motorola-sysv3 contains a stupid optimization for function
2479# hypot(), which returns the second argument without even looking at its value
2480# if the other is 0.0
ade7386a
MH
2481# Another drawback is that fix-header doesn't fix fabs' prototype, and I have
2482# no idea why.
7567d496
MH
2483file=math.h
2484if [ $target_canonical = m88k-motorola-sysv3 ]; then
2485 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2486 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2487 chmod +w ${LIB}/$file 2>/dev/null
2488 chmod a+r ${LIB}/$file 2>/dev/null
2489 fi
2490
2491 if [ -r ${LIB}/$file ]; then
ade7386a
MH
2492 echo Fixing $file, fabs/hypot definition
2493 sed \
2494 -e 's/extern double floor(), ceil(), fmod(), fabs();/extern double floor(), ceil(), fmod(), fabs _PARAMS((double));/' \
2495 -e '/^extern double hypot();$/a\
7567d496
MH
2496\/* Workaround a stupid Motorola optimization if one\
2497 of x or y is 0.0 and the other is negative! *\/\
2498#ifdef __STDC__\
2499static __inline__ double fake_hypot (double x, double y)\
2500#else\
2501static __inline__ double fake_hypot (x, y)\
2502 double x, y;\
2503#endif\
2504{\
2505 return fabs (hypot (x, y));\
2506}\
2507#define hypot fake_hypot
2508' \
2509 ${LIB}/$file > ${LIB}/${file}.sed
2510 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2511 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2512 rm -f ${LIB}/$file
2513 fi
2514 fi
2515fi
2516
68f6ed7f
JM
2517# math.h on SunOS 4 puts the declaration of matherr before the definition
2518# of struct exception, so the prototype (added by fixproto) causes havoc.
2519file=math.h
2520if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2521 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2522 chmod +w ${LIB}/$file 2>/dev/null
2523 chmod a+r ${LIB}/$file 2>/dev/null
2524fi
2525
2526if [ -r ${LIB}/$file ]; then
2527 echo Fixing $file, matherr declaration
2528 sed -e '/^struct exception/,$b' \
2529 -e '/matherr/i\
2530struct exception;
2531'\
2532 ${LIB}/$file > ${LIB}/${file}.sed
2533 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2534 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2535 rm -f ${LIB}/$file
7a0934e7
ILT
2536 else
2537 # Find any include directives that use "file".
2538 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2539 dir=`echo $file | sed -e s'|/[^/]*$||'`
2540 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2541 done
68f6ed7f
JM
2542 fi
2543fi
2544
7a790837 2545# sys/mman.h on HP/UX is not C++ ready, even though
86944ea4 2546# NO_IMPLICIT_EXTERN_C is defined on HP/UX.
7a790837 2547for file in sys/mman.h; do
86944ea4
ILT
2548 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2549 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2550 chmod +w ${LIB}/$file 2>/dev/null
2551 chmod a+r ${LIB}/$file 2>/dev/null
2552 fi
86bb0d5f 2553
86944ea4
ILT
2554 if [ -r ${LIB}/$file ]; then
2555 if egrep '"C"' ${LIB}/$file >/dev/null 2>&1 \
2556 || egrep '__BEGIN_DECLS' ${LIB}/$file >/dev/null 2>&1; then
2557 true
2558 else
2559 echo Fixing $file
2560 echo '#ifdef __cplusplus
86bb0d5f
ILT
2561extern "C" {
2562#endif' > ${LIB}/${file}.sed
86944ea4
ILT
2563 cat ${LIB}/${file} >> ${LIB}/${file}.sed
2564 echo '#ifdef __cplusplus
86bb0d5f
ILT
2565}
2566#endif' >> ${LIB}/${file}.sed
86944ea4
ILT
2567 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2568 fi
86bb0d5f
ILT
2569 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2570 rm -f ${LIB}/$file
7a0934e7
ILT
2571 else
2572 # Find any include directives that use "file".
2573 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
86944ea4
ILT
2574 dir=`echo $file | sed -e s'|/[^/]*$||'`
2575 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
7a0934e7 2576 done
86bb0d5f
ILT
2577 fi
2578 fi
86944ea4 2579done
86bb0d5f 2580
4e373a59
ILT
2581# Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
2582file=unistd.h
2583if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2584 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2585 chmod +w ${LIB}/$file 2>/dev/null
2586 chmod a+r ${LIB}/$file 2>/dev/null
2587fi
2588
2589if [ -r ${LIB}/$file ]; then
2590 echo Fixing $file, sbrk declaration
2591 sed -e 's/char\([ ]*\*[ ]*sbrk[ ]*(\)/void\1/' \
2592 ${LIB}/$file > ${LIB}/${file}.sed
2593 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2594 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
e5b3d86a 2595 rm -f ${LIB}/$file
7a0934e7
ILT
2596 else
2597 # Find any include directives that use "file".
2598 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2599 dir=`echo $file | sed -e s'|/[^/]*$||'`
2600 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2601 done
e5b3d86a
JM
2602 fi
2603fi
2604
21f891de
RO
2605# Fix <c_asm.h> on Digital UNIX V4.0:
2606# It contains a prototype for a DEC C internal asm() function, clashing with
2607# gcc's asm keyword. So protect this with __DECC.
2608file=c_asm.h
2609if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2610 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2611 chmod +w ${LIB}/$file 2>/dev/null
2612 chmod a+r ${LIB}/$file 2>/dev/null
2613fi
2614
2615if [ -r ${LIB}/$file ]; then
2616 echo Fixing $file
2617 sed -e '/^[ ]*float[ ]*fasm/i\
2618#ifdef __DECC
2619' \
2620 -e '/^[ ]*#[ ]*pragma[ ]*intrinsic([ ]*dasm/a\
2621#endif
2622' ${LIB}/$file > ${LIB}/${file}.sed
2623 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2624 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2625 rm ${LIB}/$file
2626 else
2627 # Find any include directives that use "file".
2628 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2629 dir=`echo $file | sed -e s'|/[^/]*$||'`
2630 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2631 done
2632 fi
2633fi
2634
bb7c21a5
ILT
2635# This file on SunOS 4 has a very large macro. When the sed loop
2636# tries pull it in, it overflows the pattern space size of the SunOS
2637# sed (GNU sed does not have this problem). Since the file does not
2638# require fixing, we remove it from the fixed directory.
2639file=sundev/ipi_error.h
2640if [ -r ${LIB}/$file ]; then
2641 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
2642 rm -f ${LIB}/$file
2643fi
2644
bc026668
ILT
2645# Put cpp wrappers around these include files to avoid redeclaration
2646# errors during multiple inclusion on m88k-tektronix-sysv3.
2647for file in time.h sys/time.h ; do
29421402
ILT
2648 if egrep '#ifndef' $file >/dev/null 2>&1; then
2649 true
2650 else
2651 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2652 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2653 chmod +w ${LIB}/$file 2>/dev/null
2654 fi
2655 if [ -r ${LIB}/$file ]; then
2656 echo Fixing $file, to protect against multiple inclusion.
2657 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'`
2658 (echo "#ifndef __GCC_GOT_${cpp_wrapper}_"
2659 echo "#define __GCC_GOT_${cpp_wrapper}_"
2660 cat ${LIB}/${file}
2661 echo '#endif /* !_GCC_GOT_'${cpp_wrapper}_' */') > ${LIB}/${file}.new
2662 rm -f ${LIB}/$file; mv ${LIB}/${file}.new ${LIB}/$file
2663 fi
bc026668
ILT
2664 fi
2665done
2666
26dac810
ILT
2667# Fix fcntl prototype in fcntl.h on LynxOS.
2668file=fcntl.h
2669if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2670 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2671 chmod +w ${LIB}/$file 2>/dev/null
2672 chmod a+r ${LIB}/$file 2>/dev/null
2673fi
2674
2675if [ -r ${LIB}/$file ]; then
2676 echo Fixing $file, fcntl declaration
2677 sed -e 's/\(fcntl.*(int, int, \)int)/\1...)/' \
2678 ${LIB}/$file > ${LIB}/${file}.sed
2679 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2680 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2681 rm -f ${LIB}/$file
7a0934e7
ILT
2682 else
2683 # Find any include directives that use "file".
2684 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2685 dir=`echo $file | sed -e s'|/[^/]*$||'`
2686 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2687 done
26dac810
ILT
2688 fi
2689fi
2690
e571db98
ILT
2691# Fix definitions of macros used by va-i960.h in VxWorks header file.
2692file=arch/i960/archI960.h
2693if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2694 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2695 chmod +w ${LIB}/$file 2>/dev/null
2696 chmod a+r ${LIB}/$file 2>/dev/null
2697fi
2698
2699if [ -r ${LIB}/$file ]; then
2700 echo Fixing $file
2701 sed -e 's/__vsiz/__vxvsiz/' -e 's/__vali/__vxvali/' \
2702 -e s'/__vpad/__vxvpad/' -e 's/__alignof__/__vxalignof__/' \
2703 ${LIB}/$file > ${LIB}/${file}.sed
2704 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2705 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2706 rm -f ${LIB}/$file
2707 else
2708 # Find any include directives that use "file".
2709 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2710 dir=`echo $file | sed -e s'|/[^/]*$||'`
2711 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2712 done
2713 fi
2714fi
2715
2716# Make VxWorks header which is almost gcc ready fully gcc ready.
2717file=types/vxTypesBase.h
2718if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2719 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2720 chmod +w ${LIB}/$file 2>/dev/null
2721 chmod a+r ${LIB}/$file 2>/dev/null
2722fi
2723
2724if [ -r ${LIB}/$file ]; then
2725 echo Fixing $file
2726 sed -e 's/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/#if 1/' \
2727 -e '/[ ]size_t/i\
2728#ifndef _GCC_SIZE_T\
2729#define _GCC_SIZE_T
2730' \
2731 -e '/[ ]size_t/a\
2732#endif
2733' \
2734 -e '/[ ]ptrdiff_t/i\
2735#ifndef _GCC_PTRDIFF_T\
2736#define _GCC_PTRDIFF_T
2737' \
2738 -e '/[ ]ptrdiff_t/a\
2739#endif
2740' \
2741 -e '/[ ]wchar_t/i\
2742#ifndef _GCC_WCHAR_T\
2743#define _GCC_WCHAR_T
2744' \
2745 -e '/[ ]wchar_t/a\
2746#endif
2747' \
2748 ${LIB}/$file > ${LIB}/${file}.sed
2749 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2750 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2751 rm -f ${LIB}/$file
2752 else
2753 # Find any include directives that use "file".
2754 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2755 dir=`echo $file | sed -e s'|/[^/]*$||'`
2756 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2757 done
2758 fi
2759fi
2760
2761# Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
2762file=sys/stat.h
2763if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2764 mkdir ${LIB}/sys 2>/dev/null
2765 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2766 chmod +w ${LIB}/$file 2>/dev/null
2767 chmod a+r ${LIB}/$file 2>/dev/null
2768fi
2769
2770if [ -r ${LIB}/$file ]; then
2771 if egrep '#include' ${LIB}/$file >/dev/null 2>&1; then
2772 :
2773 else
2774 if egrep 'ULONG' ${LIB}/$file >/dev/null 2>&1 \
2775 && [ -r types/vxTypesOld.h ]; then
2776 echo Fixing $file
2777 sed -e '/#define[ ][ ]*__INCstath/a\
2778#include <types/vxTypesOld.h>
2779' \
2780 ${LIB}/$file > ${LIB}/${file}.sed
2781 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2782 fi
2783 fi
2784 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2785 rm -f ${LIB}/$file
2786 else
2787 # Find any include directives that use "file".
2788 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2789 dir=`echo $file | sed -e s'|/[^/]*$||'`
2790 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2791 done
2792 fi
2793fi
2794
2795# Fix VxWorks <time.h> to not require including <vxTypes.h>.
2796file=time.h
2797if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2798 mkdir ${LIB}/sys 2>/dev/null
2799 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2800 chmod +w ${LIB}/$file 2>/dev/null
2801 chmod a+r ${LIB}/$file 2>/dev/null
2802fi
2803
2804if [ -r ${LIB}/$file ]; then
2805 if egrep 'uint_t[ ][ ]*_clocks_per_sec' ${LIB}/$file >/dev/null 2>&1; then
2806 echo Fixing $file
2807 sed -e 's/uint_t/unsigned int/' ${LIB}/$file > ${LIB}/${file}.sed
2aecf81d
JL
2808 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2809 fi
2810 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2811 rm -f ${LIB}/$file
2812 else
2813 # Find any include directives that use "file".
2814 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2815 dir=`echo $file | sed -e s'|/[^/]*$||'`
2816 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2817 done
2818 fi
2819fi
2820
2821# Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
2822file=sys/time.h
2823if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2824 mkdir ${LIB}/sys 2>/dev/null
2825 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2826 chmod +w ${LIB}/$file 2>/dev/null
2827 chmod a+r ${LIB}/$file 2>/dev/null
2828fi
2829
2830if [ -r ${LIB}/$file ]; then
2831 if egrep '^extern struct sigevent;' ${LIB}/$file >/dev/null 2>&1; then
2832 echo Fixing $file
2833 sed -e 's/^extern struct sigevent;/struct sigevent;/' ${LIB}/$file > ${LIB}/${file}.sed
e571db98
ILT
2834 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2835 fi
34f1bdc7
ILT
2836 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2837 rm -f ${LIB}/$file
2838 else
2839 # Find any include directives that use "file".
2840 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2841 dir=`echo $file | sed -e s'|/[^/]*$||'`
2842 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2843 done
2844 fi
2845fi
2846
2847# Another bad dependency in VxWorks 5.2 <time.h>.
2848file=time.h
2849if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2850 mkdir ${LIB}/sys 2>/dev/null
2851 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2852 chmod +w ${LIB}/$file 2>/dev/null
2853 chmod a+r ${LIB}/$file 2>/dev/null
2854fi
2855
2856if [ -r ${LIB}/$file ]; then
2857 if egrep VOIDFUNCPTR ${LIB}/$file >/dev/null 2>&1; then
2858 if [ -r vxWorks.h ]; then
2859 echo Fixing $file
2860 sed -e '/VOIDFUNCPTR/i\
2861#ifndef __gcc_VOIDFUNCPTR_defined\
2862#ifdef __cplusplus\
2863typedef void (*__gcc_VOIDFUNCPTR) (...);\
2864#else\
2865typedef void (*__gcc_VOIDFUNCPTR) ();\
2866#endif\
2867#define __gcc_VOIDFUNCPTR_defined\
2868#endif
2869' \
2870 -e 's/VOIDFUNCPTR/__gcc_VOIDFUNCPTR/g' \
2871 ${LIB}/$file > ${LIB}/${file}.sed
2872 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2873 fi
2874 fi
e571db98
ILT
2875 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2876 rm -f ${LIB}/$file
2877 else
2878 # Find any include directives that use "file".
2879 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2880 dir=`echo $file | sed -e s'|/[^/]*$||'`
2881 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2882 done
2883 fi
2884fi
2885
973fa691
RK
2886# This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89; gcc
2887# doesn't understand it.
2888file=sys/param.h
2889if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2890 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2891 chmod +w ${LIB}/$file 2>/dev/null
2892 chmod a+r ${LIB}/$file 2>/dev/null
2893fi
2894
2895if [ -r ${LIB}/$file ]; then
2896 echo "Fixing __asm directive in sys/param.h"
2897 sed -e 's|#ifndef NOINLINE|#if !defined(NOINLINE) \&\& !defined(__GNUC__)|' \
2898 ${LIB}/$file > ${LIB}/${file}.sed
2899 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2900 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2901 rm -f ${LIB}/$file
cf0a001c
ILT
2902 else
2903 # Find any include directives that use "file".
2904 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2905 dir=`echo $file | sed -e s'|/[^/]*$||'`
2906 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2907 done
973fa691
RK
2908 fi
2909fi
e571db98 2910
cf0a001c
ILT
2911# signal.h on SunOS defines signal using (), which causes trouble when
2912# compiling with g++ -pedantic.
2913for file in signal.h sys/signal.h; do
2914 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2915 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2916 chmod +w ${LIB}/$file 2>/dev/null
2917 chmod a+r ${LIB}/$file 2>/dev/null
2918 fi
2919
2920 if [ -r ${LIB}/$file ]; then
2921 echo "Checking for bad C++ prototype in $file"
2922 sed -e '/^void (\*signal())();$/i\
2923 #ifdef __cplusplus\
2924 void (*signal(...))(...);\
2925 #else
2926 ' \
2927 -e '/^void (\*signal())();$/a\
2928 #endif
2929 ' \
2930 ${LIB}/$file > ${LIB}/${file}.sed
2931 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2932 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2933 rm -f ${LIB}/$file
2934 else
2935 # Find any include directives that use "file".
2936 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2937 dir=`echo $file | sed -e s'|/[^/]*$||'`
2938 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2939 done
2940 fi
2941 fi
2942done
2943
c7c27cd3
ILT
2944# sys/signal.h on some versions of AIX uses volatile in the typedef of
2945# sig_atomic_t, which causes gcc to generate a warning about duplicate
2946# volatile when a sig_atomic_t variable is declared volatile, as
2947# required by ANSI C.
2948file=sys/signal.h
2949if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2950 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2951 chmod +w ${LIB}/$file 2>/dev/null
2952 chmod a+r ${LIB}/$file 2>/dev/null
2953fi
2954
2955if [ -r ${LIB}/$file ]; then
2956 echo "Checking for duplicate volatile in sys/signal.h"
2957 sed -e 's/typedef volatile int sig_atomic_t/typedef int sig_atomic_t/' \
2958 ${LIB}/$file > ${LIB}/${file}.sed
2959 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
ded732a0
ILT
2960 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
2961 rm -f ${LIB}/$file
2962 else
2963 # Find any include directives that use "file".
2964 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
2965 dir=`echo $file | sed -e s'|/[^/]*$||'`
2966 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
2967 done
2968 fi
2969fi
2970
2971# Some math.h files define struct exception, which conflicts with
2972# the class exception defined in the C++ file std/stdexcept.h. We
2973# redefine it to __math_exception. This is not a great fix, but I
2974# haven't been able to think of anything better.
2975file=math.h
2976if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
2977 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
2978 chmod +w ${LIB}/$file 2>/dev/null
2979 chmod a+r ${LIB}/$file 2>/dev/null
2980fi
2981
2982if [ -r ${LIB}/$file ]; then
2983 echo Fixing $file, exception
2984 sed -e '/struct exception/i\
2985#ifdef __cplusplus\
2986#define exception __math_exception\
e95f0195
TV
2987#endif
2988'\
ded732a0
ILT
2989 -e '/struct exception/a\
2990#ifdef __cplusplus\
2991#undef exception\
e95f0195
TV
2992#endif
2993' ${LIB}/$file > ${LIB}/${file}.sed
ded732a0
ILT
2994 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
2995 if egrep 'matherr()' ${LIB}/$file >/dev/null 2>&1; then
2996 sed -e '/matherr/i\
2997#ifdef __cplusplus\
2998#define exception __math_exception\
e95f0195
TV
2999#endif
3000'\
ded732a0
ILT
3001 -e '/matherr/a\
3002#ifdef __cplusplus\
3003#undef exception\
e95f0195
TV
3004#endif
3005' ${LIB}/$file > ${LIB}/${file}.sed
ded732a0
ILT
3006 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3007 fi
c7c27cd3
ILT
3008 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
3009 rm -f ${LIB}/$file
3010 else
3011 # Find any include directives that use "file".
3012 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3013 dir=`echo $file | sed -e s'|/[^/]*$||'`
3014 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3015 done
3016 fi
3017fi
3018
7f3feeea
DF
3019# rpc/auth.h on SunOS needs prototypes for its AUTH->auth_ops function pointers
3020# Similarly for
3021# rpc/clnt.h CLIENT->clnt_ops
3022# rpc/svc.h SVCXPRT->xp_ops
3023# rpc/xdr.h XDR->xdr_ops
3024for file in rpc/auth.h rpc/clnt.h rpc/svc.h rpc/xdr.h; do
3025 # each file has a different name to replace, so if you add a file to
3026 # that list please update the following case statement.
3027 case "$file" in
3028 rpc/auth.h)
3029 prefix="ah_"
3030 ;;
3031 rpc/clnt.h)
3032 prefix="cl_"
3033 ;;
3034 rpc/svc.h)
3035 prefix="xp_"
3036 ;;
3037 rpc/xdr.h)
3038 prefix="x_"
3039 ;;
3040 *)
3041 # Oh Oh, we shouldn't be here
3042 exit 1;
3043 ;;
3044 esac
e08cb549 3045
7f3feeea
DF
3046 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
3047 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
3048 chmod +w ${LIB}/$file 2>/dev/null
3049 chmod a+r ${LIB}/$file 2>/dev/null
3050 fi
3051
3052 if [ -r ${LIB}/$file ]; then
3053 echo "Checking for needed C++ prototype in $file"
3054 sed -e 's/^\(.*\)\*\('$prefix'.*\)();\(.*\)/\
e08cb549
BK
3055#ifdef __cplusplus\
3056\1*\2(...);\3\
3057#else\
3058\1*\2();\3\
3059#endif/g' \
3060 $LIB/$file > ${LIB}/${file}.sed
3061
7f3feeea
DF
3062 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3063 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
3064 rm -f ${LIB}/$file
3065 else
3066 # Find any include directives that use "file".
3067 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
e08cb549
BK
3068 dir=`echo $file | sed -e s'|/[^/]*$||'`
3069 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
7f3feeea
DF
3070 done
3071 fi
e08cb549 3072 fi
7f3feeea 3073done
e08cb549 3074
09817d8c 3075# sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
e5e809f4 3076# defining regex.h types. This causes C++ library build and usage failures.
09817d8c
JW
3077# Fixing this correctly requires checking and modifying 3 files.
3078for file in reg_types.h regex.h sys/lc_core.h; do
3079 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
3080 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
3081 chmod +w ${LIB}/$file 2>/dev/null
3082 chmod a+r ${LIB}/$file 2>/dev/null
3083 fi
3084done
3085if [ -r ${LIB}/reg_types.h ]; then
3086 if egrep '} regex_t;' ${LIB}/reg_types.h >/dev/null 2>&1; then
3087 if [ -r ${LIB}/sys/lc_core.h ]; then
3088 if egrep ' regex_t ' ${LIB}/sys/lc_core.h >/dev/null 2>&1; then
3089 if [ -r ${LIB}/regex.h ]; then
3090 if egrep '__regex_t' ${LIB}/regex.h >/dev/null 2>&1; then
3091 true;
3092 else
3093 echo Fixing reg_types.h, regex.h, sys/lc_core.h
3094 for file in reg_types.h sys/lc_core.h; do
3095 sed -e 's/regex_t/__regex_t/g' \
3096 -e 's/regoff_t/__regoff_t/g' \
3097 -e 's/regmatch_t/__regmatch_t/g' \
3098 ${LIB}/$file > ${LIB}/${file}.sed
3099 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3100 done
3101 sed -e '/#include <reg_types.h>/a\
3102typedef __regex_t regex_t;\
3103typedef __regoff_t regoff_t;\
3104typedef __regmatch_t regmatch_t;\
3105' \
3106 ${LIB}/regex.h > ${LIB}/regex.h.sed
3107 rm -f ${LIB}/regex.h; mv ${LIB}/regex.h.sed ${LIB}/regex.h
3108 fi
3109 fi
3110 fi
3111 fi
3112 fi
3113fi
3114for file in reg_types.h regex.h sys/lc_core.h; do
3115 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
3116 rm -f ${LIB}/$file
3117 else
3118 # Find any include directives that use "file".
3119 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3120 dir=`echo $file | sed -e s'|/[^/]*$||'`
3121 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3122 done
3123 fi
3124done
3125
6313a654
BK
3126# AIX headers define NULL to be cast to a void pointer, which is illegal
3127# in ANSI C++.
171e10fe 3128for file in curses.h dbm.h locale.h stdio.h stdlib.h string.h time.h unistd.h sys/dir.h sys/param.h sys/types.h ; do
6313a654
BK
3129 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
3130 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
3131 chmod +w ${LIB}/$file 2>/dev/null
3132 chmod a+r ${LIB}/$file 2>/dev/null
3133 fi
3134
3135 if [ -r ${LIB}/$file ]; then
3136 if egrep '#.*define.*NULL.*void' ${LIB}/$file >/dev/null 2>&1; then
3137 echo "Fixing $file, bad NULL macro"
3138 sed -e 's/^#[ ]*define[ ]*NULL[ ]*((void[ ]*\*)0)/#define NULL 0/' \
3139 ${LIB}/$file > ${LIB}/${file}.sed
3140 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
3141 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
3142 rm -f ${LIB}/$file
3143 else
3144 # Find any include directives that use "file".
3145 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3146 dir=`echo $file | sed -e s'|/[^/]*$||'`
3147 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3148 done
3149 fi
3150 fi
3151 fi
3152done
3153
e9a25f70
JL
3154# HPUX 10.x sys/param.h defines MAXINT which clashes with values.h
3155file=sys/param.h
3156base=`basename $file`
3157if [ -r ${LIB}/$file ]; then
3158 file_to_fix=${LIB}/$file
3159else
3160 if [ -r ${INPUT}/$file ]; then
3161 file_to_fix=${INPUT}/$file
3162 else
3163 file_to_fix=""
3164 fi
3165fi
3166if [ \! -z "$file_to_fix" ]; then
3167 echo Checking $file_to_fix
9bb5394e 3168 sed -e '/^#[ ]*define[ ]*MAXINT[ ]/i\
e9a25f70
JL
3169#ifndef MAXINT
3170'\
9bb5394e 3171 -e '/^#[ ]*define[ ]*MAXINT[ ]/a\
e9a25f70
JL
3172#endif
3173' $file_to_fix > /tmp/$base
3174 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
3175 true
3176 else
3177 echo Fixed $file_to_fix
3178 rm -f ${LIB}/$file
3179 cp /tmp/$base ${LIB}/$file
3180 chmod a+r ${LIB}/$file
3181 # Find any include directives that use "file".
3182 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3183 dir=`echo $file | sed -e s'|/[^/]*$||'`
3184 required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
3185 done
3186 fi
3187 rm -f /tmp/$base
3188fi
3189
3190
ce942994
ILT
3191# This loop does not appear to do anything, because it uses file
3192# rather than $file when setting target. It also appears to be
3193# unnecessary, since the main loop processes symbolic links.
3194#if $LINKS; then
3195# echo 'Making internal symbolic non-directory links'
3196# cd ${INPUT}
3197# files=`find . -type l -print`
3198# for file in $files; do
3199# dest=`ls -ld $file | sed -n 's/.*-> //p'`
3200# if expr "$dest" : '[^/].*' > /dev/null; then
3201# target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
3202# if [ -f $target ]; then
3203# ln -s $dest ${LIB}/$file >/dev/null 2>&1
3204# fi
3205# fi
3206# done
3207#fi
c61a25b1 3208
8f8470e0
RS
3209# Make sure that any include files referenced using double quotes
3210# exist in the fixed directory. This comes last since otherwise
3211# we might end up deleting some of these files "because they don't
3212# need any change."
98068ba2
ILT
3213set x $required
3214shift
3215while [ $# != 0 ]; do
8f8470e0 3216 newreq=
8f8470e0
RS
3217 while [ $# != 0 ]; do
3218 # $1 is the directory to copy from, $2 is the unfixed file,
3219 # $3 is the fixed file name.
3220 cd ${INPUT}
3221 cd $1
3222 if [ -r $2 ] && [ ! -r $3 ]; then
3223 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
3224 chmod +w $3 2>/dev/null
3225 chmod a+r $3 2>/dev/null
3226 echo Copied $2
3227 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
3228 dir=`echo $2 | sed -e s'|/[^/]*$||'`
3229 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
3230 newreq="$newreq $1 $dir/$include $dir2/$include"
3231 done
3232 fi
3233 shift; shift; shift
3234 done
98068ba2
ILT
3235 set x $newreq
3236 shift
8f8470e0
RS
3237done
3238
25e51a69
ILT
3239echo 'Cleaning up DONE files.'
3240cd $LIB
dca82465 3241find . -name DONE -exec rm -f '{}' ';'
db27aeec 3242
bf8b268a
ILT
3243echo 'Removing unneeded directories:'
3244cd $LIB
a718fe31 3245files=`find . -type d \! -name '.' -print | sort -r`
bf8b268a
ILT
3246for file in $files; do
3247 rmdir $LIB/$file > /dev/null 2>&1
3248done
3249
c3c55f86
BK
3250# # # # # # # # # # # # # # # # # # # # #
3251#
3252# End of for INPUT directories
3253#
3254done
3255#
3256# # # # # # # # # # # # # # # # # # # # #
3257
3258cd $ORIGDIR
3259rm -f include/assert.h
3260cp ${srcdir}/assert.h include/assert.h || exit 1
3261chmod a+r include/assert.h
e9a25f70 3262
c61a25b1 3263exit 0
This page took 1.00568 seconds and 5 git commands to generate.