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