]> gcc.gnu.org Git - gcc.git/blame - gcc/fixincludes
(build_unary_op): Call pedantic_lvalue_warning
[gcc.git] / gcc / fixincludes
CommitLineData
c61a25b1
DM
1#! /bin/sh
2# Install modified versions of certain ANSI-incompatible system header files
3# which are fixed to work correctly with ANSI C
4# and placed in a directory that GNU C will search.
5
6# See README-fixinc for more information.
7
b7b62369
RS
8# Directory where gcc sources (and sometimes special include files) live.
9# fixincludes doesn't use this, but fixinc.svr4 does, and I want to make
10# sure somebody doesn't try to use arg3 for something incompatible. -- gumby
11SRCDIR=${3-${SRCDIR-.}}
12
c61a25b1
DM
13# Directory containing the original header files.
14# (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
15INPUT=${2-${INPUT-/usr/include}}
16
17# This prevents /bin/ex from failing if the current terminal type is
18# unrecognizable.
19TERM=unknown
20export TERM
3911abb2
RS
21# This prevents two problems:
22# Either ex might find a .exrc file and get confused,
23# or ex might complain if the EXINIT variable is invalid.
24# We know there is no .exrc in the GCC source.
3e398742
RS
25# `set' is a no-op ex command.
26EXINIT=set
04b5ab57 27export EXINIT
c61a25b1 28
4ed15f9d
RS
29# Define PWDCMD as a command to use to get the working dir
30# in the form that we want.
31PWDCMD=pwd
32case "`pwd`" in
33//*)
34 # On an Apollo, discard everything before `/usr'.
35 PWDCMD="(pwd) | sed -e 's,.*/usr/,/usr/,'"
36 ;;
37esac
38
c61a25b1 39# Directory in which to store the results.
4eb6de22 40LIB=${1?"fixincludes: output directory not specified"}
c61a25b1
DM
41
42# Make sure it exists.
43if [ ! -d $LIB ]; then
44 mkdir $LIB || exit 1
45fi
46
47# Make LIB absolute.
4ed15f9d 48cd $LIB; LIB=`${PWDCMD}`
c61a25b1
DM
49
50# Fail if no arg to specify a directory for the output.
51if [ x$1 = x ]
52then echo fixincludes: no output directory specified
53exit 1
54fi
55
1ac7d389 56echo Building fixed headers in ${LIB}
c61a25b1
DM
57
58# Determine whether this system has symbolic links.
59if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
60 rm -f $LIB/ShouldNotExist
61 LINKS=true
62else
63 LINKS=false
64fi
65
1ac7d389 66echo Finding directories and links to directories
c61a25b1 67cd ${INPUT}
3308e40a 68# Find all directories and all symlinks that point to directories.
f1f1ae8e
RS
69# Put the list in $files.
70# Each time we find a symlink, add it to newdirs
71# so that we do another find within the dir the link points to.
72# Note that $files may have duplicates in it;
73# later parts of this file are supposed to ignore them.
74dirs="."
fd297e33
RS
75levels=2
76while [ -n "$dirs" ] && [ $levels -gt 0 ]
f1f1ae8e 77do
fd297e33 78 levels=`expr $levels - 1`
f1f1ae8e 79 newdirs=
fd297e33 80 for d in $dirs
f1f1ae8e 81 do
1ac7d389 82 echo " Searching $INPUT/$d"
f1f1ae8e
RS
83 if [ "$d" != . ]
84 then
85 d=$d/.
86 fi
87
fd297e33 88 # Find all directories under $d, relative to $d, excluding $d itself.
165b3941
RS
89 files="$files `find $d -type d -print | \
90 sed -e '/\/\.$/d' -e '/^\.$/d'`"
91 # Find all links to directories.
92 # Using `-exec test -d' in find fails on some systems,
93 # and trying to run test via sh fails on others,
94 # so this is the simplest alternative left.
95 # First find all the links, then test each one.
96 theselinks=
f1f1ae8e 97 $LINKS && \
165b3941
RS
98 theselinks=`find $d -type l -print`
99 for d1 in $theselinks --dummy--
100 do
1ac7d389
RS
101 # If the link points to a directory,
102 # add that dir to $newdirs
165b3941
RS
103 if [ -d $d1 ]
104 then
105 newdirs="$newdirs $d1"
106 fi
107 done
f1f1ae8e
RS
108 done
109
89ccb80f 110 files="$files $newdirs"
f1f1ae8e 111 dirs="$newdirs"
f1f1ae8e
RS
112done
113
114dirs=
1ac7d389 115echo "All directories (including links to directories):"
f1f1ae8e
RS
116echo $files
117
c61a25b1
DM
118for file in $files; do
119 rm -rf $LIB/$file
120 if [ ! -d $LIB/$file ]
121 then mkdir $LIB/$file
122 fi
123done
1ac7d389 124mkdir $LIB/root
c61a25b1
DM
125
126# treetops gets an alternating list
127# of old directories to copy
128# and the new directories to copy to.
129treetops="${INPUT} ${LIB}"
130
131if $LINKS; then
1ac7d389 132 echo 'Making symbolic directory links'
c61a25b1
DM
133 for file in $files; do
134 dest=`ls -ld $file | sed -n 's/.*-> //p'`
135 if [ "$dest" ]; then
4ed15f9d 136 cwd=`${PWDCMD}`
c61a25b1
DM
137 # In case $dest is relative, get to $file's dir first.
138 cd ${INPUT}
139 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
140 # Check that the target directory exists.
141 # Redirections changed to avoid bug in sh on Ultrix.
142 (cd $dest) > /dev/null 2>&1
143 if [ $? = 0 ]; then
144 cd $dest
145 # X gets the dir that the link actually leads to.
4ed15f9d 146 x=`${PWDCMD}`
1ac7d389
RS
147 # If a link points to ., make a similar link to .
148 if [ $x = $INPUT ]; then
149 echo $file '->' . ': Making link'
150 rm -fr ${LIB}/$file > /dev/null 2>&1
151 ln -s . ${LIB}/$file > /dev/null 2>&1
c61a25b1
DM
152 # If link leads back into ${INPUT},
153 # make a similar link here.
1ac7d389 154 elif expr $x : "${INPUT}/.*" > /dev/null; then
c61a25b1
DM
155 # Y gets the actual target dir name, relative to ${INPUT}.
156 y=`echo $x | sed -n "s&${INPUT}/&&p"`
157 echo $file '->' $y ': Making link'
158 rm -fr ${LIB}/$file > /dev/null 2>&1
159 ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
160 else
1ac7d389
RS
161 # If the link is to a dir $target outside ${INPUT},
162 # repoint the link at ${INPUT}/root$target
163 # and process $target into ${INPUT}/root$target
c61a25b1 164 # treat this directory as if it actually contained the files.
1ac7d389
RS
165 echo $file '->' root$x ': Making link'
166 if [ -d $LIB/root$x ]
167 then true
168 else
169 dirname=root$x/
170 dirmade=.
171 cd $LIB
172 while [ x$dirname != x ]; do
173 component=`echo $dirname | sed -e 's|/.*$||'`
174 mkdir $component >/dev/null 2>&1
175 cd $component
176 dirmade=$dirmade/$component
177 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
178 done
179 fi
180 rm -fr ${LIB}/$file > /dev/null 2>&1
181 ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1
182 treetops="$treetops $x ${LIB}/root$x"
c61a25b1
DM
183 fi
184 fi
185 cd $cwd
186 fi
187 done
188fi
189
190set - $treetops
191while [ $# != 0 ]; do
192 # $1 is an old directory to copy, and $2 is the new directory to copy to.
c61a25b1
DM
193 cd ${INPUT}
194 cd $1
1ac7d389
RS
195# The same dir can appear more than once in treetops.
196# There's no need to scan it more than once.
197 if [ -f $2/DONE ]
198 then
199 files=
200 else
201 touch $2/DONE
202 echo Fixing directory $1 into $2
8c31e6b6
RS
203# Check .h files which are symlinks as well as those which are files.
204# A link to a header file will not be processed by anything but this.
73bdfabc
RS
205 if $LINKS; then
206 files=`find . -name '*.h' \( -type f -o -type l \) -print`
207 else
208 files=`find . -name '*.h' -type f -print`
209 fi
1ac7d389
RS
210 echo Checking header files
211 fi
c61a25b1
DM
212# Note that BSD43_* are used on recent MIPS systems.
213 for file in $files; do
214# This call to egrep is essential, since checking a file with egrep
215# is much faster than actually trying to fix it.
3308e40a
RS
216# It is also essential that most files *not* match!
217# Thus, matching every #endif is unacceptable.
c61a25b1
DM
218# But the argument to egrep must be kept small, or many versions of egrep
219# won't be able to handle it.
75251fe0 220# rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail.
ab94876e 221 if egrep '//|[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then
c61a25b1
DM
222 echo Fixing $file
223 if [ -r $file ]; then
224 cp $file $2/$file >/dev/null 2>&1 \
225 || echo "Can't copy $file"
226 chmod +w $2/$file
75251fe0
DM
227# Following two lines removed.
228# s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
229# s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
230
c61a25b1
DM
231 sed -e '
232 :loop
233 /\\$/ N
234 /\\$/ b loop
ab94876e 235 /\/\// s|//\(.*\)$|/*\1*/|
c61a25b1
DM
236 /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
237 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
e029fa05 238 /#define._IO/ s/'\''x'\''/x/g
c61a25b1 239 /#define.BSD43__IO/ s/'\''x'\''/x/g
e029fa05 240 /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
c61a25b1
DM
241 /#define.CTRL/ s/'\''c'\''/c/g
242 /#define._CTRL/ s/'\''c'\''/c/g
243 /#define.BSD43_CTRL/ s/'\''c'\''/c/g
e029fa05 244 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
c61a25b1 245 /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g
e029fa05 246 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
c61a25b1
DM
247 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
248 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
249 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
250 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
251 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
252 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
253 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
254 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
45b33951 255 /^#define.NULL[ ]/ i\
c61a25b1
DM
256 #undef NULL
257 ' $2/$file > $2/$file.sed
258 mv $2/$file.sed $2/$file
259 if cmp $file $2/$file >/dev/null 2>&1; then
260 echo Deleting $2/$file\; no fixes were needed.
261 rm $2/$file
262 fi
263 fi
264 fi
265 done
266 shift; shift
267done
268
269cd ${INPUT}
270
271# Fix one other error in this file: a mismatched quote not inside a C comment.
272file=sundev/vuid_event.h
273if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
274 mkdir ${LIB}/sundev 2>/dev/null
275 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
276 chmod +w ${LIB}/$file 2>/dev/null
277fi
278
279if [ -r ${LIB}/$file ]; then
280 echo Fixing $file comment
281 ex ${LIB}/$file <<EOF
282 g/doesn't/s/doesn't/does not/
283 wq
284EOF
285 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
286 echo Deleting ${LIB}/$file\; no fixes were needed.
287 rm ${LIB}/$file
288 fi
289fi
290
6dc42e49 291# Fix this Sun file to avoid interfering with stddef.h.
c61a25b1
DM
292file=sys/stdtypes.h
293if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
294 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
295 chmod +w ${LIB}/$file 2>/dev/null
296fi
297
298if [ -r ${LIB}/$file ]; then
299 echo Fixing $file
300 ex ${LIB}/$file <<EOF
301 /size_t.*;/
302 i
3308e40a
RS
303#ifndef _GCC_SIZE_T
304#define _GCC_SIZE_T
c61a25b1
DM
305.
306 /size_t/+1
307 i
308#endif
309.
310 /ptrdiff_t.*;/
311 i
3308e40a
RS
312#ifndef _GCC_PTRDIFF_T
313#define _GCC_PTRDIFF_T
c61a25b1
DM
314.
315 /ptrdiff_t/+1
316 i
317#endif
318.
319 /wchar_t.*;/
320 i
3308e40a
RS
321#ifndef _GCC_WCHAR_T
322#define _GCC_WCHAR_T
c61a25b1
DM
323.
324 /wchar_t/+1
325 i
326#endif
327.
328 wq
329EOF
330 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
331 echo Deleting ${LIB}/$file\; no fixes were needed.
332 rm ${LIB}/$file
333 fi
334fi
335
6dc42e49 336# Fix this file to avoid interfering with stddef.h.
c61a25b1
DM
337file=sys/types.h
338if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
339 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
340 chmod +w ${LIB}/$file 2>/dev/null
341fi
342
343if [ -r ${LIB}/$file ]; then
344 echo Fixing $file
345 ex ${LIB}/$file <<EOF
45b33951 346 /typedef.*size_t.*;/
c61a25b1 347 i
3308e40a
RS
348#ifndef _GCC_SIZE_T
349#define _GCC_SIZE_T
c61a25b1
DM
350.
351 /size_t/+1
352 i
353#endif
354.
355 wq
356EOF
357 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
358 echo Deleting ${LIB}/$file\; no fixes were needed.
359 rm ${LIB}/$file
360 fi
361fi
362
363# Fix an error in this file: a missing semi-colon at the end of the statsswtch
364# structure definition.
365file=rpcsvc/rstat.h
366if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
367 mkdir ${LIB}/rpcsvc 2>/dev/null
368 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
369 chmod +w ${LIB}/$file 2>/dev/null
370fi
371
372if [ -r ${LIB}/$file ]; then
373 echo Fixing $file, definition of statsswtch
374 ex ${LIB}/$file <<EOF
375 g/boottime$/s//&;/
376 wq
377EOF
378 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
379 echo Deleting ${LIB}/$file\; no fixes were needed.
380 rm ${LIB}/$file
381 fi
382fi
383
384# Fix an error in this file: a missing semi-colon at the end of the nodeent
385# structure definition.
386file=netdnet/dnetdb.h
387if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
388 mkdir ${LIB}/netdnet 2>/dev/null
389 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
390 chmod +w ${LIB}/$file 2>/dev/null
391fi
392
393if [ -r ${LIB}/$file ]; then
394 echo Fixing $file, definition of nodeent
395 ex ${LIB}/$file <<EOF
45b33951 396 g/char.*na_addr *$/s//&;/
c61a25b1
DM
397 wq
398EOF
399 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
400 echo Deleting ${LIB}/$file\; no fixes were needed.
401 rm ${LIB}/$file
402 fi
403fi
404
405# Check for bad #ifdef line (in Ultrix 4.1)
406file=sys/file.h
407if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
408 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
409 chmod +w ${LIB}/$file 2>/dev/null
410fi
411
412if [ -r ${LIB}/$file ]; then
413 echo Fixing $file, bad \#ifdef line
414 ex ${LIB}/$file <<EOF
415 g/^#ifdef KERNEL && !defined/
416 s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
417 wq
418EOF
419 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
420 echo Deleting ${LIB}/$file\; no fixes were needed.
421 rm ${LIB}/$file
422 fi
423fi
424
75251fe0
DM
425# Remove nested comments created by #endifs in a comment (Ultrix 4.1)
426# Only needed if commenting out junk after #endif.
427#file=signal.h
428#if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
429# cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
430# chmod +w ${LIB}/$file 2>/dev/null
431#fi
432#
433#if [ -r ${LIB}/$file ]; then
434# echo Fixing $file, nested comments
435# sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
436# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
437# if cmp $file ${LIB}/$file >/dev/null 2>&1; then
438# echo Deleting ${LIB}/$file\; no fixes were needed.
439# rm -f ${LIB}/$file
440# fi
441#fi
442
c61a25b1
DM
443# Check for superfluous `static' (in Ultrix 4.2)
444file=machine/cpu.h
445if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
446 mkdir ${LIB}/machine 2>/dev/null
447 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
448 chmod +w ${LIB}/$file 2>/dev/null
449fi
450
451if [ -r ${LIB}/$file ]; then
452 echo Fixing $file, superfluous static
453 ex ${LIB}/$file <<EOF
454 g/^static struct tlb_pid_state/
455 s/static//
456 wq
457EOF
458 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
459 echo Deleting ${LIB}/$file\; no fixes were needed.
460 rm ${LIB}/$file
461 else
462# This file has an alternative name, mips/cpu.h. Fix that name, too.
463 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
464 mkdir ${LIB}/mips 2>&-
465 ln ${LIB}/$file ${LIB}/mips/cpu.h
466 fi
467 fi
468fi
469
75251fe0 470# Incorrect sprintf declaration in X11/Xmu.h
c61a25b1
DM
471file=X11/Xmu.h
472if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
473 mkdir ${LIB}/X11 2>/dev/null
474 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
475 chmod +w ${LIB}/$file 2>/dev/null
476fi
477
478if [ -r ${LIB}/$file ]; then
479 echo Fixing $file sprintf declaration
480 ex ${LIB}/$file <<EOF
481 /^extern char \* sprintf();$/c
482#ifndef __STDC__
483extern char * sprintf();
484#endif /* !defined __STDC__ */
485.
486 wq
487EOF
488 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
489 echo Deleting ${LIB}/$file\; no fixes were needed.
490 rm ${LIB}/$file
491 fi
492fi
493
3a6aca8e
RS
494# Incorrect sprintf declaration in X11/Xmu/Xmu.h
495# (It's not clear whether the right file name is this or X11/Xmu.h.)
496file=X11/Xmu/Xmu.h
497if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
498 mkdir ${LIB}/X11/Xmu 2>/dev/null
499 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
500 chmod +w ${LIB}/$file 2>/dev/null
501fi
502
503if [ -r ${LIB}/$file ]; then
504 echo Fixing $file sprintf declaration
505 ex ${LIB}/$file <<EOF
506 /^extern char \* sprintf();$/c
507#ifndef __STDC__
508extern char * sprintf();
509#endif /* !defined __STDC__ */
510.
511 wq
512EOF
513 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
514 echo Deleting ${LIB}/$file\; no fixes were needed.
515 rm ${LIB}/$file
516 fi
517fi
518
c61a25b1
DM
519# Check for missing ';' in struct
520file=netinet/ip.h
521if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
522 mkdir ${LIB}/netinet 2>/dev/null
523 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
524 chmod +w ${LIB}/$file 2>/dev/null
525fi
526
527if [ -r ${LIB}/$file ]; then
528 echo Fixing $file
529 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
530 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
531 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
532 echo Deleting ${LIB}/$file\; no fixes were needed.
533 rm -f ${LIB}/$file
534 fi
535fi
536
75251fe0 537# Fix the CAT macro in SunOS memvar.h.
c61a25b1
DM
538file=pixrect/memvar.h
539if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
540 mkdir ${LIB}/pixrect 2>/dev/null
541 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
542 chmod +w ${LIB}/$file 2>/dev/null
543fi
544
545if [ -r ${LIB}/$file ]; then
546 echo Fixing $file
547 sed -e '/^#define.CAT(a,b)/ i\
548#ifdef __STDC__ \
549#define CAT(a,b) a##b\
550#else
551/^#define.CAT(a,b)/ a\
552#endif
553' ${LIB}/$file > ${LIB}/${file}.sed
554 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
555 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
556 echo Deleting ${LIB}/$file\; no fixes were needed.
557 rm -f ${LIB}/$file
558 fi
559fi
560
561# Check for yet more missing ';' in struct (in SunOS 4.0.x)
562file=rpcsvc/rusers.h
563if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
564 mkdir ${LIB}/rpcsvc 2>/dev/null
565 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
566 chmod +w ${LIB}/$file 2>/dev/null
567fi
568
569if [ -r ${LIB}/$file ]; then
570 echo Fixing $file
571 sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
572 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
573 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
574 echo Deleting ${LIB}/$file\; no fixes were needed.
575 rm -f ${LIB}/$file
576 fi
577fi
578
579# Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
580file=stdlib.h
581if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
582 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
583 chmod +w ${LIB}/$file 2>/dev/null
584fi
585
586if [ -r ${LIB}/$file ]; then
587 echo Fixing $file
588 sed -e 's/int abort/void abort/g' \
25f75d8a
RS
589 -e 's/int free/void free/g' \
590 -e 's/char \* calloc/void \* calloc/g' \
591 -e 's/char \* malloc/void \* malloc/g' \
592 -e 's/char \* realloc/void \* realloc/g' \
c61a25b1
DM
593 -e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.sed
594 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
595 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
596 echo Deleting ${LIB}/$file\; no fixes were needed.
597 rm -f ${LIB}/$file
598 fi
599fi
600
460d7c18
TG
601# Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
602file=malloc.h
603if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
604 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
605 chmod +w ${LIB}/$file 2>/dev/null
606fi
607
608if [ -r ${LIB}/$file ]; then
609 echo Fixing $file
350027ec 610 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
12fe670b 611 -e 's/int[ ][ ]*free/void free/g' \
460d7c18
TG
612 ${LIB}/$file > ${LIB}/${file}.sed
613 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
614 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
615 echo Deleting ${LIB}/$file\; no fixes were needed.
616 rm -f ${LIB}/$file
617 fi
618fi
619
620
c61a25b1
DM
621# Fix bogus comment in <locale.h> on SunOS 4.1.
622file=locale.h
623if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
624 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
625 chmod +w ${LIB}/$file 2>/dev/null
626fi
627
628if [ -r ${LIB}/$file ]; then
629 echo Fixing $file
630 sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
631 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
632 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
633 echo Deleting ${LIB}/$file\; no fixes were needed.
634 rm -f ${LIB}/$file
635 fi
636fi
637
638# Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
639file=hsfs/hsfs_spec.h
640if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
641 mkdir ${LIB}/hsfs 2>/dev/null
642 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
643 chmod +w ${LIB}/$file 2>/dev/null
644fi
645
646if [ -r ${LIB}/$file ]; then
647 echo Fixing $file
648 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
649 ${LIB}/$file > ${LIB}/${file}.sed
650 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
651 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
652 echo Deleting ${LIB}/$file\; no fixes were needed.
653 rm -f ${LIB}/$file
654 fi
655fi
656
657# Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
658file=hsfs/hsnode.h
659if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
660 mkdir ${LIB}/hsfs 2>/dev/null
661 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
662 chmod +w ${LIB}/$file 2>/dev/null
663fi
664
665if [ -r ${LIB}/$file ]; then
666 echo Fixing $file
667 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
668 ${LIB}/$file > ${LIB}/${file}.sed
669 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
670 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
671 echo Deleting ${LIB}/$file\; no fixes were needed.
672 rm -f ${LIB}/$file
673 fi
674fi
675
676# Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
677file=hsfs/iso_spec.h
678if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
679 mkdir ${LIB}/hsfs 2>/dev/null
680 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
681 chmod +w ${LIB}/$file 2>/dev/null
682fi
683
684if [ -r ${LIB}/$file ]; then
685 echo Fixing $file
686 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
687 ${LIB}/$file > ${LIB}/${file}.sed
688 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
689 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
690 echo Deleting ${LIB}/$file\; no fixes were needed.
691 rm -f ${LIB}/$file
692 fi
693fi
694
75251fe0
DM
695# Incorrect #include in Sony News-OS 3.2.
696file=machine/machparam.h
697if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
698 mkdir ${LIB}/machine 2>/dev/null
699 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
700 chmod +w ${LIB}/$file 2>/dev/null
701fi
702
703if [ -r ${LIB}/$file ]; then
704 echo Fixing $file, incorrect \#include
705 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
706 ${LIB}/$file > ${LIB}/${file}.sed
707 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
708 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
709 echo Deleting ${LIB}/$file\; no fixes were needed.
710 rm -f ${LIB}/$file
711 fi
712fi
713
714# Multiline comment after typedef on IRIX 4.0.1.
715file=sys/types.h
716if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
717 mkdir ${LIB}/sys 2>/dev/null
718 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
719 chmod +w ${LIB}/$file 2>/dev/null
720fi
721
722if [ -r ${LIB}/$file ]; then
723 echo Fixing $file, comment in the middle of \#ifdef
724 sed -e 's@type of the result@type of the result */@' \
725 -e 's@of the sizeof@/* of the sizeof@' \
726 ${LIB}/$file > ${LIB}/${file}.sed
727 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
728 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
729 echo Deleting ${LIB}/$file\; no fixes were needed.
730 rm -f ${LIB}/$file
731 fi
732fi
733
4d449554
JW
734# Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
735# declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
736# many other systems have similar text but correct versions of the file.
737# To ensure only Sun's is fixed, we grep for a likely unique string.
738file=memory.h
8c31e6b6 739if egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
4d449554
JW
740 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
741 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
742 chmod +w ${LIB}/$file 2>/dev/null
743 fi
744 if [ -r ${LIB}/$file ]; then
745 echo Replacing $file
746 cat > ${LIB}/$file << EOF
747/* This file was generated by fixincludes */
748#ifndef __memory_h__
749#define __memory_h__
750
751#ifdef __STDC__
752extern void *memccpy();
753extern void *memchr();
754extern void *memcpy();
755extern void *memset();
756#else
757extern char *memccpy();
758extern char *memchr();
759extern char *memcpy();
760extern char *memset();
761#endif /* __STDC__ */
762
763extern int memcmp();
764
765#endif __memory_h__
766EOF
767 fi
768fi
769
7d349561
JW
770# parameters not const on DECstation Ultrix V4.0.
771file=stdio.h
772if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
773 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
774 chmod +w ${LIB}/$file 2>/dev/null
775fi
776
777if [ -r ${LIB}/$file ]; then
778 echo Fixing $file, non-const arg
779 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
780 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
781 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
782 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
783 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
784 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
785 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
786 ${LIB}/$file > ${LIB}/${file}.sed
787 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
788 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
789 echo Deleting ${LIB}/$file\; no fixes were needed.
790 rm -f ${LIB}/$file
791 fi
792fi
793
1ac7d389
RS
794# Don't use or define the name va_list in stdio.h.
795# This is for ANSI and also to interoperate properly with gvarargs.h.
796file=stdio.h
797if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
798 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
799 chmod +w ${LIB}/$file 2>/dev/null
800fi
801
802if [ -r ${LIB}/$file ]; then
803 echo Fixing $file, use of va_list
804 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
805 (echo "#define __need___va_list"
806 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
807 # Use __gnuc_va_list in arg types in place of va_list.
808 # Define __va_list__ (something harmless and unused) instead of va_list.
809 # Don't claim to have defined va_list.
810 sed -e 's@ va_list @ __gnuc_va_list @' \
811 -e 's@ va_list@ __va_list__@' \
be71bebd 812 -e 's@\*va_list@*__va_list__@' \
1ac7d389
RS
813 -e 's@VA_LIST@DUMMY_VA_LIST@' \
814 ${LIB}/$file >> ${LIB}/${file}.sed
815
816 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
817 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
818 echo Deleting ${LIB}/$file\; no fixes were needed.
819 rm -f ${LIB}/$file
820 fi
821fi
822
e63c1d35
RS
823# Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
824file=ansi_compat.h
825if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
826 if grep -s ULTRIX $file; then
827 echo "/* This file intentionally left blank. */" > $LIB/$file
828 fi
829fi
830
7d349561 831# parameter to atof not const on DECstation Ultrix V4.0.
28bbe06b 832# also get rid of bogus inline definitions in HP-UX 8.0
7d349561
JW
833file=math.h
834if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
835 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
836 chmod +w ${LIB}/$file 2>/dev/null
837fi
838
839if [ -r ${LIB}/$file ]; then
840 echo Fixing $file, non-const arg
841 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
28bbe06b
RS
842 -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \
843 -e 's@inline double abs(double d) { return fabs(d); }@@' \
7d349561
JW
844 ${LIB}/$file > ${LIB}/${file}.sed
845 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
846 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
847 echo Deleting ${LIB}/$file\; no fixes were needed.
848 rm -f ${LIB}/$file
849 fi
850fi
851
5959a6cd
RS
852# These two files on SunOS 4 are included by other files
853# in the same directory, using "...". So we must make sure they exist
cd10f7b6
RS
854# in the same directory as the other fixed files.
855if [ -r ${INPUT}/multimedia/audio_errno.h ]
5959a6cd 856then
cd10f7b6 857 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
5959a6cd 858fi
cd10f7b6 859if [ -r ${INPUT}/multimedia/audio_hdr.h ]
5959a6cd 860then
cd10f7b6 861 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
5959a6cd
RS
862fi
863
c61a25b1
DM
864echo 'Removing unneeded directories:'
865cd $LIB
866files=`find . -type d -print | sort -r`
867for file in $files; do
868 rmdir $LIB/$file > /dev/null 2>&1
869done
870
871if $LINKS; then
872 echo 'Making internal symbolic non-directory links'
873 cd ${INPUT}
874 files=`find . -type l -print`
875 for file in $files; do
876 dest=`ls -ld $file | sed -n 's/.*-> //p'`
877 if expr "$dest" : '[^/].*' > /dev/null; then
878 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
879 if [ -f $target ]; then
880 ln -s $dest ${LIB}/$file >/dev/null 2>&1
881 fi
882 fi
883 done
884fi
885
886exit 0
This page took 0.177175 seconds and 5 git commands to generate.