]> gcc.gnu.org Git - gcc.git/blob - gcc/fixincludes
Fix uses of new in Xm/Traversal.h.
[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 elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
70 rm -f /tmp/ShouldNotExist
71 LINKS=true
72 else
73 LINKS=false
74 fi
75
76 echo Finding directories and links to directories
77 cd ${INPUT}
78 # Find all directories and all symlinks that point to directories.
79 # Put the list in $files.
80 # Each time we find a symlink, add it to newdirs
81 # so that we do another find within the dir the link points to.
82 # Note that $files may have duplicates in it;
83 # later parts of this file are supposed to ignore them.
84 dirs="."
85 levels=2
86 while [ -n "$dirs" ] && [ $levels -gt 0 ]
87 do
88 levels=`expr $levels - 1`
89 newdirs=
90 for d in $dirs
91 do
92 echo " Searching $INPUT/$d"
93 if [ "$d" != . ]
94 then
95 d=$d/.
96 fi
97
98 # Find all directories under $d, relative to $d, excluding $d itself.
99 files="$files `find $d -type d -print | \
100 sed -e '/\/\.$/d' -e '/^\.$/d'`"
101 # Find all links to directories.
102 # Using `-exec test -d' in find fails on some systems,
103 # and trying to run test via sh fails on others,
104 # so this is the simplest alternative left.
105 # First find all the links, then test each one.
106 theselinks=
107 $LINKS && \
108 theselinks=`find $d -type l -print`
109 for d1 in $theselinks --dummy--
110 do
111 # If the link points to a directory,
112 # add that dir to $newdirs
113 if [ -d $d1 ]
114 then
115 newdirs="$newdirs $d1"
116 fi
117 done
118 done
119
120 files="$files $newdirs"
121 dirs="$newdirs"
122 done
123
124 dirs=
125 echo "All directories (including links to directories):"
126 echo $files
127
128 for file in $files; do
129 rm -rf $LIB/$file
130 if [ ! -d $LIB/$file ]
131 then mkdir $LIB/$file
132 fi
133 done
134 mkdir $LIB/root
135
136 # treetops gets an alternating list
137 # of old directories to copy
138 # and the new directories to copy to.
139 treetops="${INPUT} ${LIB}"
140
141 if $LINKS; then
142 echo 'Making symbolic directory links'
143 for file in $files; do
144 dest=`ls -ld $file | sed -n 's/.*-> //p'`
145 if [ "$dest" ]; then
146 cwd=`${PWDCMD}`
147 # In case $dest is relative, get to $file's dir first.
148 cd ${INPUT}
149 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
150 # Check that the target directory exists.
151 # Redirections changed to avoid bug in sh on Ultrix.
152 (cd $dest) > /dev/null 2>&1
153 if [ $? = 0 ]; then
154 cd $dest
155 # X gets the dir that the link actually leads to.
156 x=`${PWDCMD}`
157 # If a link points to ., make a similar link to .
158 if [ $x = $INPUT ]; then
159 echo $file '->' . ': Making link'
160 rm -fr ${LIB}/$file > /dev/null 2>&1
161 ln -s . ${LIB}/$file > /dev/null 2>&1
162 # If link leads back into ${INPUT},
163 # make a similar link here.
164 elif expr $x : "${INPUT}/.*" > /dev/null; then
165 # Y gets the actual target dir name, relative to ${INPUT}.
166 y=`echo $x | sed -n "s&${INPUT}/&&p"`
167 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
168 dots=`echo "$file" |
169 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
170 echo $file '->' $dots$y ': Making link'
171 rm -fr ${LIB}/$file > /dev/null 2>&1
172 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
173 else
174 # If the link is to a dir $target outside ${INPUT},
175 # repoint the link at ${INPUT}/root$target
176 # and process $target into ${INPUT}/root$target
177 # treat this directory as if it actually contained the files.
178 echo $file '->' root$x ': Making link'
179 if [ -d $LIB/root$x ]
180 then true
181 else
182 dirname=root$x/
183 dirmade=.
184 cd $LIB
185 while [ x$dirname != x ]; do
186 component=`echo $dirname | sed -e 's|/.*$||'`
187 mkdir $component >/dev/null 2>&1
188 cd $component
189 dirmade=$dirmade/$component
190 dirname=`echo $dirname | sed -e 's|[^/]*/||'`
191 done
192 fi
193 # Duplicate directory structure created in ${LIB}/$file in new
194 # root area.
195 for file2 in $files; do
196 case $file2 in
197 $file/./*)
198 dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"`
199 echo "Duplicating ${file}'s ${dupdir}"
200 if [ -d ${dupdir} ]
201 then true
202 else
203 mkdir ${dupdir}
204 fi
205 ;;
206 *)
207 ;;
208 esac
209 done
210 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
211 dots=`echo "$file" |
212 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
213 rm -fr ${LIB}/$file > /dev/null 2>&1
214 ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1
215 treetops="$treetops $x ${LIB}/root$x"
216 fi
217 fi
218 cd $cwd
219 fi
220 done
221 fi
222
223 required=
224 set x $treetops
225 shift
226 while [ $# != 0 ]; do
227 # $1 is an old directory to copy, and $2 is the new directory to copy to.
228 cd ${INPUT}
229 cd $1
230 # The same dir can appear more than once in treetops.
231 # There's no need to scan it more than once.
232 if [ -f $2/DONE ]
233 then
234 files=
235 else
236 touch $2/DONE
237 echo Fixing directory $1 into $2
238 # Check .h files which are symlinks as well as those which are files.
239 # A link to a header file will not be processed by anything but this.
240 if $LINKS; then
241 files=`find . -name '*.h' \( -type f -o -type l \) -print`
242 else
243 files=`find . -name '*.h' -type f -print`
244 fi
245 echo Checking header files
246 fi
247 # Note that BSD43_* are used on recent MIPS systems.
248 for file in $files; do
249 # This call to egrep is essential, since checking a file with egrep
250 # is much faster than actually trying to fix it.
251 # It is also essential that most files *not* match!
252 # Thus, matching every #endif is unacceptable.
253 # But the argument to egrep must be kept small, or many versions of egrep
254 # won't be able to handle it.
255 #
256 # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment
257 # following #else or #endif because some buggy egreps think [^/] matches
258 # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'.
259 #
260 # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier
261 # following #if or #elif that is not surrounded by __. The `a-ce-km-z'
262 # in this pattern lacks `d' and `l'; this means we don't worry about
263 # identifiers starting with `d' or `l'. This is OK, since none of the
264 # identifiers below start with `d' or `l'. It also greatly improves
265 # performance, since many files contain lines of the form `#if ... defined ...'
266 # or `#if lint'.
267 if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-zA-Z][a-zA-Z0-9]' $file >/dev/null; then
268 if [ -r $file ]; then
269 cp $file $2/$file >/dev/null 2>&1 \
270 || echo "Can't copy $file"
271 chmod +w $2/$file
272 chmod a+r $2/$file
273 # Here is how the sed commands in braces work.
274 # (It doesn't work to put the comments inside the sed commands.)
275 # Surround each word with spaces, to simplify matching below.
276 # ANSIfy each pre-ANSI machine-dependent symbol
277 # by surrounding it with __ __.
278 # Remove the spaces that we inserted around each word.
279 sed -e '
280 :loop
281 /\\$/ N
282 /\\$/ b loop
283 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
284 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
285 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
286 s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1%
287 s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1%
288 /\/\/[^*]/ s|//\(.*\)$|/*\1*/|
289 /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/
290 /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/
291 /#define._IO/ s/'\''\([cgxtf]\)'\''/\1/g
292 /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g
293 /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
294 /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/
295 /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g
296 /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g
297 /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g
298 /#[el]*if/{
299 s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
300
301 s/ bsd4\([0-9]\) / __bsd4\1__ /g
302 s/ _*host_mips / __host_mips__ /g
303 s/ _*i386 / __i386__ /g
304 s/ is68k / __is68k__ /g
305 s/ m68k / __m68k__ /g
306 s/ mc680\([0-9]\)0 / __mc680\10__ /g
307 s/ _*mips / __mips__ /g
308 s/ news\([0-9]*\) / __news\1__ /g
309 s/ ns32000 / __ns32000__ /g
310 s/ pyr / __pyr__ /g
311 s/ sony_news / __sony_news__ /g
312 s/ sparc / __sparc__ /g
313 s/ sun\([a-z0-9]*\) / __sun\1__ /g
314 s/ unix / __unix__ /g
315 s/ vax / __vax__ /g
316 s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
317 s/ _*R\([34]\)000 / __R\1000__ /g
318 s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
319
320 s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
321 }
322 /^#define.NULL[ ]/ i\
323 #undef NULL
324 ' $2/$file > $2/$file.
325 mv $2/$file. $2/$file
326 if cmp $file $2/$file >/dev/null 2>&1; then
327 rm $2/$file
328 else
329 echo Fixed $file
330 # Find any include directives that use "file".
331 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $2/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
332 dir=`echo $file | sed -e s'|/[^/]*$||'`
333 required="$required $1 $dir/$include $2/$dir/$include"
334 done
335 fi
336 fi
337 fi
338 done
339 shift; shift
340 done
341
342 cd ${INPUT}
343
344 # Install the proper definition of size_t in header files that it comes from.
345 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
346 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
347 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
348 chmod +w ${LIB}/$file 2>/dev/null
349 chmod a+r ${LIB}/$file 2>/dev/null
350 fi
351
352 if [ -r ${LIB}/$file ]; then
353 echo Fixing size_t in $file
354 sed -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
355 #ifndef __SIZE_TYPE__\
356 #define __SIZE_TYPE__ long unsigned int\
357 #endif' \
358 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' ${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 done
365
366 # Fix one other error in this file: a mismatched quote not inside a C comment.
367 file=sundev/vuid_event.h
368 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
369 mkdir ${LIB}/sundev 2>/dev/null
370 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
371 chmod +w ${LIB}/$file 2>/dev/null
372 chmod a+r ${LIB}/$file 2>/dev/null
373 fi
374
375 if [ -r ${LIB}/$file ]; then
376 echo Fixing $file comment
377 sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
378 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
379 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
380 rm ${LIB}/$file
381 fi
382 fi
383
384 # Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
385 file=sunwindow/win_cursor.h
386 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
387 # mkdir ${LIB}/sunwindow 2>/dev/null
388 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
389 chmod +w ${LIB}/$file 2>/dev/null
390 fi
391 if [ -r ${LIB}/$file ]; then
392 echo Fixing $file
393 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
394 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
395 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
396 rm ${LIB}/$file
397 fi
398 fi
399 file=sunwindow/win_lock.h
400 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
401 # mkdir ${LIB}/sunwindow 2>/dev/null
402 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
403 chmod +w ${LIB}/$file 2>/dev/null
404 fi
405 if [ -r ${LIB}/$file ]; then
406 echo Fixing $file
407 sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed
408 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
409 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
410 rm ${LIB}/$file
411 fi
412 fi
413
414 # Fix this Sun file to avoid interfering with stddef.h.
415 file=sys/stdtypes.h
416 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
417 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
418 chmod +w ${LIB}/$file 2>/dev/null
419 chmod a+r ${LIB}/$file 2>/dev/null
420 fi
421
422 if [ -r ${LIB}/$file ]; then
423 echo Fixing $file
424 sed -e '/[ ]size_t.*;/i\
425 #ifndef _GCC_SIZE_T\
426 #define _GCC_SIZE_T' \
427 -e '/[ ]size_t.*;/a\
428 #endif' \
429 -e '/[ ]ptrdiff_t.*;/i\
430 #ifndef _GCC_PTRDIFF_T\
431 #define _GCC_PTRDIFF_T' \
432 -e '/[ ]ptrdiff_t.*;/a\
433 #endif' \
434 -e '/[ ]wchar_t.*;/i\
435 #ifndef _GCC_WCHAR_T\
436 #define _GCC_WCHAR_T' \
437 -e '/[ ]wchar_t.*;/a\
438 #endif' ${LIB}/$file > ${LIB}/${file}.sed
439 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
440 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
441 rm ${LIB}/$file
442 fi
443 fi
444
445 # Fix this ARM/RISCiX file to avoid interfering with the use of __wchar_t
446 # in cc1plus.
447 file=stdlib.h
448 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
449 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
450 chmod +w ${LIB}/$file 2>/dev/null
451 chmod a+r ${LIB}/$file 2>/dev/null
452 fi
453
454 if [ -r ${LIB}/$file ]; then
455 echo Fixing $file
456 sed -e "s/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
457 -e "s/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/" \
458 ${LIB}/$file > ${LIB}/${file}.sed
459 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
460 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
461 rm ${LIB}/$file
462 fi
463 fi
464
465 # Fix this file to avoid interfering with stddef.h, but don't mistakenly
466 # match ssize_t present in AIX for the ps/2, or typedefs which use (but do not
467 # set) size_t.
468 file=sys/types.h
469 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
470 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
471 chmod +w ${LIB}/$file 2>/dev/null
472 chmod a+r ${LIB}/$file 2>/dev/null
473 fi
474
475 if [ -r ${LIB}/$file ]; then
476 echo Fixing $file
477 sed -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
478 #ifndef _GCC_SIZE_T\
479 #define _GCC_SIZE_T' \
480 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/a\
481 #endif' ${LIB}/$file > ${LIB}/${file}.sed
482 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
483 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
484 rm ${LIB}/$file
485 fi
486 fi
487
488 # Fix HP's use of ../machine/inline.h to refer to
489 # /usr/include/machine/inline.h
490 file=sys/spinlock.h
491 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
492 cp $file ${LIB}/$file
493 fi
494 if [ -r ${LIB}/$file ] ; then
495 echo Fixing $file
496 sed -e 's,"../machine/inline.h",<machine/inline.h>,' \
497 -e 's,"../machine/psl.h",<machine/psl.h>,' \
498 ${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 # Fix an error in this file: the #if says _cplusplus, not the double
506 # underscore __cplusplus that it should be
507 file=tinfo.h
508 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
509 mkdir ${LIB}/rpcsvc 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
512 chmod a+r ${LIB}/$file 2>/dev/null
513 fi
514
515 if [ -r ${LIB}/$file ]; then
516 echo Fixing $file, __cplusplus macro
517 sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
518 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
519 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
520 rm ${LIB}/$file
521 fi
522 fi
523
524 # Fix an error in this file: a missing semi-colon at the end of the statsswtch
525 # structure definition.
526 file=rpcsvc/rstat.h
527 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
528 mkdir ${LIB}/rpcsvc 2>/dev/null
529 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
530 chmod +w ${LIB}/$file 2>/dev/null
531 chmod a+r ${LIB}/$file 2>/dev/null
532 fi
533
534 if [ -r ${LIB}/$file ]; then
535 echo Fixing $file, definition of statsswtch
536 sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
537 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
538 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
539 rm ${LIB}/$file
540 fi
541 fi
542
543 # Fix an error in this file: a missing semi-colon at the end of the nodeent
544 # structure definition.
545 file=netdnet/dnetdb.h
546 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
547 mkdir ${LIB}/netdnet 2>/dev/null
548 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
549 chmod +w ${LIB}/$file 2>/dev/null
550 chmod a+r ${LIB}/$file 2>/dev/null
551 fi
552
553 if [ -r ${LIB}/$file ]; then
554 echo Fixing $file, definition of nodeent
555 sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
556 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
557 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
558 rm ${LIB}/$file
559 fi
560 fi
561
562 # Check for bad #ifdef line (in Ultrix 4.1)
563 file=sys/file.h
564 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
565 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
566 chmod +w ${LIB}/$file 2>/dev/null
567 chmod a+r ${LIB}/$file 2>/dev/null
568 fi
569
570 if [ -r ${LIB}/$file ]; then
571 echo Fixing $file, bad \#ifdef line
572 sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
573 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
574 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
575 rm ${LIB}/$file
576 fi
577 fi
578
579 # Check for superfluous `static' (in Ultrix 4.2)
580 file=machine/cpu.h
581 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
582 mkdir ${LIB}/machine 2>/dev/null
583 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
584 chmod +w ${LIB}/$file 2>/dev/null
585 chmod a+r ${LIB}/$file 2>/dev/null
586 fi
587
588 if [ -r ${LIB}/$file ]; then
589 echo Fixing $file, superfluous static
590 sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed
591 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
592 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
593 rm ${LIB}/$file
594 else
595 # This file has an alternative name, mips/cpu.h. Fix that name, too.
596 if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then
597 mkdir ${LIB}/mips 2>&-
598 ln ${LIB}/$file ${LIB}/mips/cpu.h
599 fi
600 fi
601 fi
602
603 # Incorrect sprintf declaration in X11/Xmu.h
604 file=X11/Xmu.h
605 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
606 mkdir ${LIB}/X11 2>/dev/null
607 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
608 chmod +w ${LIB}/$file 2>/dev/null
609 chmod a+r ${LIB}/$file 2>/dev/null
610 fi
611
612 if [ -r ${LIB}/$file ]; then
613 echo Fixing $file sprintf declaration
614 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
615 extern char * sprintf();\
616 #endif /* !defined __STDC__ */,' ${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 ${LIB}/$file
620 fi
621 fi
622
623 # Incorrect sprintf declaration in X11/Xmu/Xmu.h
624 # (It's not clear whether the right file name is this or X11/Xmu.h.)
625 file=X11/Xmu/Xmu.h
626 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
627 mkdir ${LIB}/X11/Xmu 2>/dev/null
628 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
629 chmod +w ${LIB}/$file 2>/dev/null
630 chmod a+r ${LIB}/$file 2>/dev/null
631 fi
632
633 if [ -r ${LIB}/$file ]; then
634 echo Fixing $file sprintf declaration
635 sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
636 extern char * sprintf();\
637 #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed
638 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
639 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
640 rm ${LIB}/$file
641 fi
642 fi
643
644 # Check for missing ';' in struct
645 file=netinet/ip.h
646 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
647 mkdir ${LIB}/netinet 2>/dev/null
648 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
649 chmod +w ${LIB}/$file 2>/dev/null
650 chmod a+r ${LIB}/$file 2>/dev/null
651 fi
652
653 if [ -r ${LIB}/$file ]; then
654 echo Fixing $file
655 sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
656 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
657 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
658 rm -f ${LIB}/$file
659 fi
660 fi
661
662 # Fix the CAT macro in SunOS memvar.h.
663 file=pixrect/memvar.h
664 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
665 mkdir ${LIB}/pixrect 2>/dev/null
666 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
667 chmod +w ${LIB}/$file 2>/dev/null
668 chmod a+r ${LIB}/$file 2>/dev/null
669 fi
670
671 if [ -r ${LIB}/$file ]; then
672 echo Fixing $file
673 sed -e '/^#define.CAT(a,b)/ i\
674 #ifdef __STDC__ \
675 #define CAT(a,b) a##b\
676 #else
677 /^#define.CAT(a,b)/ a\
678 #endif
679 ' ${LIB}/$file > ${LIB}/${file}.sed
680 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
681 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
682 rm -f ${LIB}/$file
683 fi
684 fi
685
686 # Check for yet more missing ';' in struct (in SunOS 4.0.x)
687 file=rpcsvc/rusers.h
688 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
689 mkdir ${LIB}/rpcsvc 2>/dev/null
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 '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
698 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
699 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
700 rm -f ${LIB}/$file
701 fi
702 fi
703
704 # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
705 # Also wrap protection around size_t for m88k-sysv3 systems.
706 file=stdlib.h
707 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
708 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
709 chmod +w ${LIB}/$file 2>/dev/null
710 chmod a+r ${LIB}/$file 2>/dev/null
711 fi
712
713 if [ -r ${LIB}/$file ]; then
714 echo Fixing $file
715 sed -e 's/int abort/void abort/g' \
716 -e 's/int free/void free/g' \
717 -e 's/char \* calloc/void \* calloc/g' \
718 -e 's/char \* malloc/void \* malloc/g' \
719 -e 's/char \* realloc/void \* realloc/g' \
720 -e 's/int exit/void exit/g' \
721 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\
722 #ifndef _GCC_SIZE_T\
723 #define _GCC_SIZE_T' \
724 -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\
725 #endif' \
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 rm -f ${LIB}/$file
730 fi
731 fi
732
733 # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
734 file=malloc.h
735 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
736 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
737 chmod +w ${LIB}/$file 2>/dev/null
738 chmod a+r ${LIB}/$file 2>/dev/null
739 fi
740
741 if [ -r ${LIB}/$file ]; then
742 echo Fixing $file
743 sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \
744 -e 's/int[ ][ ]*free/void free/g' \
745 ${LIB}/$file > ${LIB}/${file}.sed
746 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
747 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
748 rm -f ${LIB}/$file
749 fi
750 fi
751
752 # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
753 file=hsfs/hsfs_spec.h
754 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
755 mkdir ${LIB}/hsfs 2>/dev/null
756 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
757 chmod +w ${LIB}/$file 2>/dev/null
758 chmod a+r ${LIB}/$file 2>/dev/null
759 fi
760
761 if [ -r ${LIB}/$file ]; then
762 echo Fixing $file
763 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
764 ${LIB}/$file > ${LIB}/${file}.
765 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
766 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
767 rm -f ${LIB}/$file
768 fi
769 fi
770
771 # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
772 file=hsfs/hsnode.h
773 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
774 mkdir ${LIB}/hsfs 2>/dev/null
775 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
776 chmod +w ${LIB}/$file 2>/dev/null
777 chmod a+r ${LIB}/$file 2>/dev/null
778 fi
779
780 if [ -r ${LIB}/$file ]; then
781 echo Fixing $file
782 sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
783 ${LIB}/$file > ${LIB}/${file}.sed
784 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
785 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
786 rm -f ${LIB}/$file
787 fi
788 fi
789
790 # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
791 file=hsfs/iso_spec.h
792 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
793 mkdir ${LIB}/hsfs 2>/dev/null
794 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
795 chmod +w ${LIB}/$file 2>/dev/null
796 chmod a+r ${LIB}/$file 2>/dev/null
797 fi
798
799 if [ -r ${LIB}/$file ]; then
800 echo Fixing $file
801 sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
802 ${LIB}/$file > ${LIB}/${file}.sed
803 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
804 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
805 rm -f ${LIB}/$file
806 fi
807 fi
808
809 # Incorrect #include in Sony News-OS 3.2.
810 file=machine/machparam.h
811 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
812 mkdir ${LIB}/machine 2>/dev/null
813 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
814 chmod +w ${LIB}/$file 2>/dev/null
815 chmod a+r ${LIB}/$file 2>/dev/null
816 fi
817
818 if [ -r ${LIB}/$file ]; then
819 echo Fixing $file, incorrect \#include
820 sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
821 ${LIB}/$file > ${LIB}/${file}.
822 rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file
823 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
824 rm -f ${LIB}/$file
825 fi
826 fi
827
828 # Multiline comment after typedef on IRIX 4.0.1.
829 file=sys/types.h
830 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
831 mkdir ${LIB}/sys 2>/dev/null
832 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
833 chmod +w ${LIB}/$file 2>/dev/null
834 chmod a+r ${LIB}/$file 2>/dev/null
835 fi
836
837 if [ -r ${LIB}/$file ]; then
838 echo Fixing $file, comment in the middle of \#ifdef
839 sed -e 's@type of the result@type of the result */@' \
840 -e 's@of the sizeof@/* of the sizeof@' \
841 ${LIB}/$file > ${LIB}/${file}.sed
842 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
843 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
844 rm -f ${LIB}/$file
845 fi
846 fi
847
848 # Turning // comments into /* */ comments trashes this IRIX 4.0.1
849 # header file, which embeds // comments inside multi-line /* */
850 # comments. If this looks like the IRIX header file, we refix it by
851 # just throwing away the // comments.
852 file=fam.h
853 if [ -r ${LIB}/$file ]; then
854 if egrep indigo.esd ${LIB}/$file > /dev/null; then
855 echo Fixing $file, overeager sed script
856 rm ${LIB}/$file
857 sed -e 's|//.*$||g' $file > ${LIB}/$file
858 chmod +w ${LIB}/$file 2>/dev/null
859 chmod a+r ${LIB}/$file 2>/dev/null
860 fi
861 fi
862
863 # Some IRIX header files contains the string "//"
864 for file in elf_abi.h elf.h; do
865 if [ -r ${LIB}/$file ]; then
866 echo Fixing $file, overeager sed script
867 sed -e 's|"/\*"\*/|"//"|' ${LIB}/$file > ${LIB}/${file}.sed
868 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
869 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
870 rm -f ${LIB}/$file
871 fi
872 fi
873 done
874
875 # IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr in prototype without
876 # previous definition.
877 file=rpc/auth.h
878 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
879 mkdir ${LIB}/rpc 2>/dev/null
880 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
881 chmod +w ${LIB}/$file 2>/dev/null
882 chmod a+r ${LIB}/$file 2>/dev/null
883 fi
884
885 if [ -r ${LIB}/$file ]; then
886 echo Fixing $file, undefined type
887 sed -e '/authdes_create.*struct sockaddr/i\
888 struct sockaddr;' \
889 ${LIB}/$file > ${LIB}/$file.sed
890 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
891 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
892 rm -f ${LIB}/$file
893 fi
894 fi
895
896 # IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s in prototype without previous
897 # definition.
898 file=rpc/xdr.h
899 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
900 mkdir ${LIB}/rpc 2>/dev/null
901 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
902 chmod +w ${LIB}/$file 2>/dev/null
903 chmod a+r ${LIB}/$file 2>/dev/null
904 fi
905
906 if [ -r ${LIB}/$file ]; then
907 echo Fixing $file, undefined type
908 sed -e '/xdrstdio_create.*struct __file_s/i\
909 struct __file_s;' \
910 ${LIB}/$file > ${LIB}/$file.sed
911 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
912 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
913 rm -f ${LIB}/$file
914 fi
915 fi
916
917 # Same problem with a file from SunOS 4.1.3 : a header file containing
918 # the string "//" embedded in "/**/"
919 file=sbusdev/audiovar.h
920 if [ -r ${LIB}/$file ]; then
921 echo Fixing $file, overeager sed script
922 rm ${LIB}/$file
923 sed -e 's|//.*$||g' $file > ${LIB}/$file
924 chmod +w ${LIB}/$file 2>/dev/null
925 chmod a+r ${LIB}/$file 2>/dev/null
926 fi
927
928 # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
929 # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
930 # many other systems have similar text but correct versions of the file.
931 # To ensure only Sun's is fixed, we grep for a likely unique string.
932 file=memory.h
933 if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then
934 if [ ! -r ${LIB}/$file ]; then
935 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
936 chmod +w ${LIB}/$file 2>/dev/null
937 chmod a+r ${LIB}/$file 2>/dev/null
938 fi
939 if [ -r ${LIB}/$file ]; then
940 echo Replacing $file
941 cat > ${LIB}/$file << EOF
942 /* This file was generated by fixincludes */
943 #ifndef __memory_h__
944 #define __memory_h__
945
946 #ifdef __STDC__
947 extern void *memccpy();
948 extern void *memchr();
949 extern void *memcpy();
950 extern void *memset();
951 #else
952 extern char *memccpy();
953 extern char *memchr();
954 extern char *memcpy();
955 extern char *memset();
956 #endif /* __STDC__ */
957
958 extern int memcmp();
959
960 #endif /* __memory_h__ */
961 EOF
962 fi
963 fi
964
965 # parameters not const on DECstation Ultrix V4.0.
966 file=stdio.h
967 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
968 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
969 chmod +w ${LIB}/$file 2>/dev/null
970 chmod a+r ${LIB}/$file 2>/dev/null
971 fi
972
973 if [ -r ${LIB}/$file ]; then
974 echo Fixing $file, non-const arg
975 sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
976 -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
977 -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
978 -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
979 -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
980 -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
981 -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
982 ${LIB}/$file > ${LIB}/${file}.sed
983 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
984 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
985 rm -f ${LIB}/$file
986 fi
987 fi
988
989 # parameters conflict with C++ new on rs/6000
990 for file in stdio.h unistd.h ; do
991 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
992 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
993 chmod +w ${LIB}/$file 2>/dev/null
994 fi
995
996 if [ -r ${LIB}/$file ]; then
997 echo Fixing $file, parameter name conflicts
998 sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \
999 ${LIB}/$file > ${LIB}/${file}.sed
1000 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1001 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1002 rm -f ${LIB}/$file
1003 fi
1004 fi
1005 done
1006
1007 # function class(double x) conflicts with C++ keyword on rs/6000
1008 file=math.h
1009 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1010 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1011 chmod +w ${LIB}/$file 2>/dev/null
1012 chmod a+r ${LIB}/$file 2>/dev/null
1013 fi
1014
1015 if [ -r ${LIB}/$file ]; then
1016 if grep 'class[(]' ${LIB}/$file >/dev/null; then
1017 echo Fixing $file
1018 sed -e '/class[(]/i\
1019 #ifndef __cplusplus' \
1020 -e '/class[(]/a\
1021 #endif' ${LIB}/$file > ${LIB}/${file}.sed
1022 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1023 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1024 rm ${LIB}/$file
1025 fi
1026 fi
1027 fi
1028
1029 # Wrong fchmod prototype on RS/6000.
1030 file=sys/stat.h
1031 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1032 mkdir ${LIB}/sys 2>/dev/null
1033 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1034 chmod +w ${LIB}/$file 2>/dev/null
1035 chmod a+r ${LIB}/$file 2>/dev/null
1036 fi
1037
1038 if [ -r ${LIB}/$file ]; then
1039 echo Fixing $file, fchmod prototype
1040 sed -e 's/fchmod(char \*/fchmod(int/' \
1041 ${LIB}/$file > ${LIB}/$file.sed
1042 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1043 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1044 rm -f ${LIB}/$file
1045 fi
1046 fi
1047
1048 # There are several name conflicts with C++ reserved words in X11
1049 # header files. These are fixed in some versions, so don't do the
1050 # fixes if we find __cplusplus in the file. These were found on the
1051 # RS/6000.
1052
1053 # class in X11/ShellP.h
1054 file=X11/ShellP.h
1055 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1056 mkdir ${LIB}/sys 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
1059 chmod a+r ${LIB}/$file 2>/dev/null
1060 fi
1061
1062 if [ -r ${LIB}/$file ]; then
1063 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1064 true;
1065 else
1066 echo Fixing $file, field class
1067 sed -e '/char [*]class;/i\
1068 #ifdef __cplusplus\
1069 char *c_class;\
1070 #else' \
1071 -e '/char [*]class;/a\
1072 #endif' ${LIB}/$file > ${LIB}/${file}.sed
1073 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1074 fi
1075 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1076 rm -f ${LIB}/$file
1077 fi
1078 fi
1079 # new in Xm/Traversal.h
1080 file=Xm/Traversal.h
1081 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1082 mkdir ${LIB}/sys 2>/dev/null
1083 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1084 chmod +w ${LIB}/$file 2>/dev/null
1085 chmod a+r ${LIB}/$file 2>/dev/null
1086 fi
1087
1088 if [ -r ${LIB}/$file ]; then
1089 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1090 true;
1091 else
1092 echo Fixing $file, uses of new
1093 sed -e '/Widget old, new;/i\
1094 #ifdef __cplusplus\
1095 Widget old, c_new;\
1096 #else' \
1097 -e '/Widget old, new;/a\
1098 #endif' \
1099 -e 's/Widget new,/Widget c_new,/g' ${LIB}/$file > ${LIB}/${file}.sed
1100 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1101 fi
1102 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1103 rm -f ${LIB}/$file
1104 fi
1105 fi
1106 # class in Xm/BaseClassI.h
1107 file=Xm/BaseClassI.h
1108 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1109 mkdir ${LIB}/sys 2>/dev/null
1110 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1111 chmod +w ${LIB}/$file 2>/dev/null
1112 chmod a+r ${LIB}/$file 2>/dev/null
1113 fi
1114
1115 if [ -r ${LIB}/$file ]; then
1116 if grep __cplusplus ${LIB}/$file >/dev/null 2>/dev/null; then
1117 true;
1118 else
1119 echo Fixing $file, prototype parameter name
1120 sed -e 's/ class[)]/ c_class)/g' ${LIB}/$file > ${LIB}/${file}.sed
1121 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1122 fi
1123 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1124 rm -f ${LIB}/$file
1125 fi
1126 fi
1127
1128
1129 # NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
1130 # Note that version 3 of the NeXT system has wait.h in a different directory,
1131 # so that this code won't do anything. But wait.h in version 3 has a
1132 # conditional, so it doesn't need this fix. So everything is okay.
1133 file=sys/wait.h
1134 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1135 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1136 chmod +w ${LIB}/$file 2>/dev/null
1137 fi
1138
1139 if [ -r ${LIB}/$file ] \
1140 && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then
1141 echo Fixing $file, bad wait formal
1142 sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed
1143 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1144 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1145 rm -f ${LIB}/$file
1146 fi
1147 fi
1148
1149 # Don't use or define the name va_list in stdio.h.
1150 # This is for ANSI and also to interoperate properly with gvarargs.h.
1151 file=stdio.h
1152 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1153 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1154 chmod +w ${LIB}/$file 2>/dev/null
1155 chmod a+r ${LIB}/$file 2>/dev/null
1156 fi
1157
1158 if [ -r ${LIB}/$file ]; then
1159 echo Fixing $file, use of va_list
1160 # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
1161 (echo "#define __need___va_list"
1162 echo "#include <stdarg.h>") > ${LIB}/${file}.sed
1163 # Use __gnuc_va_list in arg types in place of va_list.
1164 # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
1165 # trailing parentheses and semicolon save all other systems from this.
1166 # Define __va_list__ (something harmless and unused) instead of va_list.
1167 # Don't claim to have defined va_list.
1168 sed -e 's@ va_list @ __gnuc_va_list @' \
1169 -e 's@ va_list)@ __gnuc_va_list)@' \
1170 -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
1171 -e 's@ va_list@ __va_list__@' \
1172 -e 's@\*va_list@*__va_list__@' \
1173 -e 's@ __va_list)@ __gnuc_va_list)@' \
1174 -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
1175 -e 's@VA_LIST@DUMMY_VA_LIST@' \
1176 -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
1177 ${LIB}/$file >> ${LIB}/${file}.sed
1178
1179 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1180 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1181 rm -f ${LIB}/$file
1182 fi
1183 fi
1184
1185 # Cancel out ansi_compat.h on Ultrix. Replace it with empty file.
1186 file=ansi_compat.h
1187 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1188 if grep -s ULTRIX $file; then
1189 echo "/* This file intentionally left blank. */" > $LIB/$file
1190 fi
1191 fi
1192
1193 # parameter to atof not const on DECstation Ultrix V4.0.
1194 # also get rid of bogus inline definitions in HP-UX 8.0
1195 file=math.h
1196 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1197 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1198 chmod +w ${LIB}/$file 2>/dev/null
1199 chmod a+r ${LIB}/$file 2>/dev/null
1200 fi
1201
1202 if [ -r ${LIB}/$file ]; then
1203 echo Fixing $file, non-const arg
1204 sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
1205 -e 's@inline int abs(int [a-z][a-z]*) {.*}@@' \
1206 -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \
1207 -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \
1208 -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \
1209 ${LIB}/$file > ${LIB}/${file}.sed
1210 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1211 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1212 rm -f ${LIB}/$file
1213 fi
1214 fi
1215
1216 # Avoid nested comments on Ultrix 4.3.
1217 file=rpc/svc.h
1218 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1219 mkdir ${LIB}/rpc 2>/dev/null
1220 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1221 chmod +w ${LIB}/$file 2>/dev/null
1222 chmod a+r ${LIB}/$file 2>/dev/null
1223 fi
1224
1225 if [ -r ${LIB}/$file ]; then
1226 echo Fixing $file, nested comment
1227 sed -e 's@^\( \* int protocol; \)/\*@\1*/ /*@' \
1228 ${LIB}/$file > ${LIB}/$file.sed
1229 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1230 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1231 rm -f ${LIB}/$file
1232 fi
1233 fi
1234
1235 # This file in RISC/os uses /**/ to concatenate two tokens.
1236 file=bsd43/bsd43_.h
1237 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1238 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1239 chmod +w ${LIB}/$file 2>/dev/null
1240 chmod a+r ${LIB}/$file 2>/dev/null
1241 fi
1242 if [ -r ${LIB}/$file ]; then
1243 sed -e 's|/\*\*/|##|' ${LIB}/$file > ${LIB}/${file}.sed
1244 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1245 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1246 rm -f ${LIB}/$file
1247 fi
1248 fi
1249
1250 file=rpc/rpc.h
1251 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1252 mkdir ${LIB}/rpc 2>/dev/null
1253 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1254 chmod +w ${LIB}/$file 2>/dev/null
1255 chmod a+r ${LIB}/$file 2>/dev/null
1256 fi
1257
1258 if [ -r ${LIB}/$file ]; then
1259 echo Fixing $file, nested comment
1260 sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \
1261 ${LIB}/$file > ${LIB}/$file.sed
1262 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1263 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1264 rm -f ${LIB}/$file
1265 fi
1266 fi
1267
1268 # In limits.h, put #ifndefs around things that are supposed to be defined
1269 # in float.h to avoid redefinition errors if float.h is included first.
1270 # On HP/UX this patch does not work, because on HP/UX limits.h uses
1271 # multi line comments and the inserted #endif winds up inside the
1272 # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if
1273 # we find a #ifndef FLT_MIN we assume that all the required #ifndefs
1274 # are there, and we do not add them ourselves.
1275 for file in limits.h sys/limits.h; do
1276 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1277 mkdir ${LIB}/sys 2>/dev/null
1278 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1279 chmod +w ${LIB}/$file 2>/dev/null
1280 chmod a+r ${LIB}/$file 2>/dev/null
1281 fi
1282
1283 if [ -r ${LIB}/$file ]; then
1284 if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then
1285 true
1286 else
1287 echo Fixing $file
1288 sed -e '/[ ]FLT_MIN[ ]/i\
1289 #ifndef FLT_MIN'\
1290 -e '/[ ]FLT_MIN[ ]/a\
1291 #endif'\
1292 -e '/[ ]FLT_MAX[ ]/i\
1293 #ifndef FLT_MAX'\
1294 -e '/[ ]FLT_MAX[ ]/a\
1295 #endif'\
1296 -e '/[ ]FLT_DIG[ ]/i\
1297 #ifndef FLT_DIG'\
1298 -e '/[ ]FLT_DIG[ ]/a\
1299 #endif'\
1300 -e '/[ ]DBL_MIN[ ]/i\
1301 #ifndef DBL_MIN'\
1302 -e '/[ ]DBL_MIN[ ]/a\
1303 #endif'\
1304 -e '/[ ]DBL_MAX[ ]/i\
1305 #ifndef DBL_MAX'\
1306 -e '/[ ]DBL_MAX[ ]/a\
1307 #endif'\
1308 -e '/[ ]DBL_DIG[ ]/i\
1309 #ifndef DBL_DIG'\
1310 -e '/[ ]DBL_DIG[ ]/a\
1311 #endif'\
1312 ${LIB}/$file > ${LIB}/${file}.sed
1313 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1314 fi
1315 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1316 echo Deleting ${LIB}/$file\; no fixes were needed.
1317 rm -f ${LIB}/$file
1318 fi
1319 fi
1320 done
1321
1322 # In math.h, put #ifndefs around things that might be defined in a gcc
1323 # specific math-*.h file.
1324 file=math.h
1325 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1326 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1327 chmod +w ${LIB}/$file 2>/dev/null
1328 chmod a+r ${LIB}/$file 2>/dev/null
1329 fi
1330
1331 if [ -r ${LIB}/$file ]; then
1332 echo Fixing $file
1333 sed -e '/define[ ]HUGE_VAL[ ]/i\
1334 #ifndef HUGE_VAL'\
1335 -e '/define[ ]HUGE_VAL[ ]/a\
1336 #endif'\
1337 ${LIB}/$file > ${LIB}/${file}.sed
1338 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1339 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1340 echo Deleting ${LIB}/$file\; no fixes were needed.
1341 rm -f ${LIB}/$file
1342 fi
1343 fi
1344
1345 # Remove erroneous parentheses in sym.h on Alpha OSF/1.
1346 file=sym.h
1347 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1348 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1349 chmod +w ${LIB}/$file 2>/dev/null
1350 chmod a+r ${LIB}/$file 2>/dev/null
1351 fi
1352
1353 if [ -r ${LIB}/$file ]; then
1354 echo Fixing $file
1355 sed -e 's/#ifndef(__mips64)/#ifndef __mips64/' \
1356 ${LIB}/$file > ${LIB}/${file}.sed
1357 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1358 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1359 rm -f ${LIB}/$file
1360 fi
1361 fi
1362
1363 # Fix incorrect S_IF* definitions on m88k-sysv3.
1364 file=sys/stat.h
1365 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1366 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1367 chmod +w ${LIB}/$file 2>/dev/null
1368 chmod a+r ${LIB}/$file 2>/dev/null
1369 fi
1370
1371 if [ -r ${LIB}/$file ]; then
1372 echo Fixing $file
1373 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)/' \
1374 -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \
1375 ${LIB}/$file > ${LIB}/${file}.sed
1376 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1377 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1378 rm -f ${LIB}/$file
1379 fi
1380 fi
1381
1382 # Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1.
1383 for file in stdio.h stdlib.h; do
1384 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1385 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1386 chmod +w ${LIB}/$file 2>/dev/null
1387 chmod a+r ${LIB}/$file 2>/dev/null
1388 fi
1389
1390 if [ -r ${LIB}/$file ]; then
1391 echo Fixing $file, getopt declaration
1392 sed -e 's/getopt(int, char \*\[\],char \*)/getopt(int, char *const[], const char *)/' \
1393 ${LIB}/$file > ${LIB}/${file}.sed
1394 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1395 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1396 rm -f ${LIB}/$file
1397 fi
1398 fi
1399 done
1400
1401 # These two files on SunOS 4 are included by other files
1402 # in the same directory, using "...". So we must make sure they exist
1403 # in the same directory as the other fixed files.
1404 if [ -r ${INPUT}/multimedia/audio_errno.h ]
1405 then
1406 ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null
1407 fi
1408 if [ -r ${INPUT}/multimedia/audio_hdr.h ]
1409 then
1410 ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null
1411 fi
1412
1413 # Determine if we're on Interactive Unix 2.2 or later, in which case we
1414 # need to fix some additional files. This is the same test for ISC that
1415 # Autoconf uses.
1416 if test -d /etc/conf/kconfig.d \
1417 && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then
1418 echo "Fixing ISC __STDC__ goof in several files..."
1419 for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do
1420 echo $name
1421 if test -r ${LIB}/$name; then
1422 file=${LIB}/$name
1423 else
1424 file=${INPUT}/$name
1425 fi
1426 # On Interactive 2.2, certain traditional Unix definitions
1427 # (notably getc and putc in stdio.h) are omitted if __STDC__ is
1428 # defined, not just if _POSIX_SOURCE is defined. This makes it
1429 # impossible to compile any nontrivial program except with -posix.
1430 sed \
1431 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \
1432 < $file > ${LIB}/$name.
1433 mv ${LIB}/$name. ${LIB}/$name
1434 done
1435
1436 echo "Fixing ISC fmod declaration"
1437 # This one's already been fixed for other things.
1438 file=${LIB}/math.h
1439 sed 's/fmod(double)/fmod(double, double)/' <$file >$file.
1440 mv $file. $file
1441
1442 echo "Fixing nested comments in ISC <sys/limits.h>"
1443 file=sys/limits.h
1444 sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file.
1445 sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file
1446 fi
1447
1448 # These files in Sun OS 4.x use /**/ to concatenate tokens.
1449 for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \
1450 sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \
1451 sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h;
1452 do
1453 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1454 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1455 chmod +w ${LIB}/$file 2>/dev/null
1456 chmod a+r ${LIB}/$file 2>/dev/null
1457 fi
1458
1459 if [ -r ${LIB}/$file ]; then
1460 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1461 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1462 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1463 rm -f ${LIB}/$file
1464 fi
1465 fi
1466 done
1467
1468 # These files in ARM/RISCiX use /**/ to concatenate tokens.
1469 for file in arm/as_support.h arm/mc_type.h arm/xcb.h dev/chardefmac.h \
1470 dev/ps_irq.h dev/screen.h dev/scsi.h sys/tty.h Xm.acorn/XmP.h
1471 do
1472 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
1473 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
1474 chmod +w ${LIB}/$file 2>/dev/null
1475 chmod a+r ${LIB}/$file 2>/dev/null
1476 fi
1477
1478 if [ -r ${LIB}/$file ]; then
1479 sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed
1480 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1481 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
1482 rm -f ${LIB}/$file
1483 fi
1484 fi
1485 done
1486
1487 # This file on SunOS 4 has a very large macro. When the sed loop
1488 # tries pull it in, it overflows the pattern space size of the SunOS
1489 # sed (GNU sed does not have this problem). Since the file does not
1490 # require fixing, we remove it from the fixed directory.
1491 file=sundev/ipi_error.h
1492 if [ -r ${LIB}/$file ]; then
1493 echo "Removing incorrect fix to SunOS <sundev/ipi_error.h>"
1494 rm -f ${LIB}/$file
1495 fi
1496
1497 echo 'Removing unneeded directories:'
1498 cd $LIB
1499 files=`find . -type d -print | sort -r`
1500 for file in $files; do
1501 rmdir $LIB/$file > /dev/null 2>&1
1502 done
1503
1504 if $LINKS; then
1505 echo 'Making internal symbolic non-directory links'
1506 cd ${INPUT}
1507 files=`find . -type l -print`
1508 for file in $files; do
1509 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1510 if expr "$dest" : '[^/].*' > /dev/null; then
1511 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1512 if [ -f $target ]; then
1513 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1514 fi
1515 fi
1516 done
1517 fi
1518
1519 # Make sure that any include files referenced using double quotes
1520 # exist in the fixed directory. This comes last since otherwise
1521 # we might end up deleting some of these files "because they don't
1522 # need any change."
1523 while [ -n "$required" ]; do
1524 newreq=
1525 set x $required
1526 shift
1527 while [ $# != 0 ]; do
1528 # $1 is the directory to copy from, $2 is the unfixed file,
1529 # $3 is the fixed file name.
1530 cd ${INPUT}
1531 cd $1
1532 if [ -r $2 ] && [ ! -r $3 ]; then
1533 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2"
1534 chmod +w $3 2>/dev/null
1535 chmod a+r $3 2>/dev/null
1536 echo Copied $2
1537 for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
1538 dir=`echo $2 | sed -e s'|/[^/]*$||'`
1539 dir2=`echo $3 | sed -e s'|/[^/]*$||'`
1540 newreq="$newreq $1 $dir/$include $dir2/$include"
1541 done
1542 fi
1543 shift; shift; shift
1544 done
1545 required=$newreq
1546 done
1547
1548 echo 'Cleaning up DONE files.'
1549 cd $LIB
1550 find . -name DONE -exec rm -f '{}' ';'
1551
1552 exit 0
This page took 0.148502 seconds and 6 git commands to generate.