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