]>
Commit | Line | Data |
---|---|---|
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 | ||
cc08b87d ILT |
8 | # Command to run gcc. |
9 | GCCCMD=${4-${GCCCMD-gcc}} | |
10 | ||
b7b62369 RS |
11 | # Directory where gcc sources (and sometimes special include files) live. |
12 | # fixincludes doesn't use this, but fixinc.svr4 does, and I want to make | |
13 | # sure somebody doesn't try to use arg3 for something incompatible. -- gumby | |
14 | SRCDIR=${3-${SRCDIR-.}} | |
15 | ||
c61a25b1 DM |
16 | # Directory containing the original header files. |
17 | # (This was named INCLUDES, but that conflicts with a name in Makefile.in.) | |
18 | INPUT=${2-${INPUT-/usr/include}} | |
19 | ||
ffc47266 JW |
20 | # Directory in which to store the results. |
21 | LIB=${1?"fixincludes: output directory not specified"} | |
c61a25b1 | 22 | |
4ed15f9d RS |
23 | # Define PWDCMD as a command to use to get the working dir |
24 | # in the form that we want. | |
25 | PWDCMD=pwd | |
26 | case "`pwd`" in | |
27 | //*) | |
28 | # On an Apollo, discard everything before `/usr'. | |
d45ceebe | 29 | PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'" |
4ed15f9d RS |
30 | ;; |
31 | esac | |
32 | ||
631e21eb DE |
33 | # Original directory. |
34 | ORIGDIR=`${PWDCMD}` | |
35 | ||
c61a25b1 DM |
36 | # Make sure it exists. |
37 | if [ ! -d $LIB ]; then | |
38 | mkdir $LIB || exit 1 | |
39 | fi | |
40 | ||
e1fa48b5 RS |
41 | # Make LIB absolute only if needed to avoid problems with the amd. |
42 | case $LIB in | |
43 | /*) | |
44 | ;; | |
45 | *) | |
46 | cd $LIB; LIB=`${PWDCMD}` | |
47 | ;; | |
48 | esac | |
c61a25b1 | 49 | |
8befb954 RS |
50 | # Make SRCDIR absolute only if needed to avoid problems with the amd. |
51 | cd $ORIGDIR | |
52 | case $SRCDIR in | |
53 | /*) | |
54 | ;; | |
55 | *) | |
56 | cd $SRCDIR; SRCDIR=`${PWDCMD}` | |
57 | ;; | |
58 | esac | |
59 | ||
c61a25b1 DM |
60 | # Fail if no arg to specify a directory for the output. |
61 | if [ x$1 = x ] | |
62 | then echo fixincludes: no output directory specified | |
63 | exit 1 | |
64 | fi | |
65 | ||
1ac7d389 | 66 | echo Building fixed headers in ${LIB} |
c61a25b1 DM |
67 | |
68 | # Determine whether this system has symbolic links. | |
69 | if ln -s X $LIB/ShouldNotExist 2>/dev/null; then | |
70 | rm -f $LIB/ShouldNotExist | |
0fa2faf0 RS |
71 | LINKS=true |
72 | elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then | |
73 | rm -f /tmp/ShouldNotExist | |
c61a25b1 DM |
74 | LINKS=true |
75 | else | |
76 | LINKS=false | |
77 | fi | |
78 | ||
1ac7d389 | 79 | echo Finding directories and links to directories |
c61a25b1 | 80 | cd ${INPUT} |
3308e40a | 81 | # Find all directories and all symlinks that point to directories. |
f1f1ae8e RS |
82 | # Put the list in $files. |
83 | # Each time we find a symlink, add it to newdirs | |
84 | # so that we do another find within the dir the link points to. | |
85 | # Note that $files may have duplicates in it; | |
86 | # later parts of this file are supposed to ignore them. | |
87 | dirs="." | |
fd297e33 RS |
88 | levels=2 |
89 | while [ -n "$dirs" ] && [ $levels -gt 0 ] | |
f1f1ae8e | 90 | do |
fd297e33 | 91 | levels=`expr $levels - 1` |
f1f1ae8e | 92 | newdirs= |
fd297e33 | 93 | for d in $dirs |
f1f1ae8e | 94 | do |
1ac7d389 | 95 | echo " Searching $INPUT/$d" |
f1f1ae8e RS |
96 | if [ "$d" != . ] |
97 | then | |
98 | d=$d/. | |
99 | fi | |
100 | ||
fd297e33 | 101 | # Find all directories under $d, relative to $d, excluding $d itself. |
165b3941 RS |
102 | files="$files `find $d -type d -print | \ |
103 | sed -e '/\/\.$/d' -e '/^\.$/d'`" | |
104 | # Find all links to directories. | |
105 | # Using `-exec test -d' in find fails on some systems, | |
106 | # and trying to run test via sh fails on others, | |
107 | # so this is the simplest alternative left. | |
108 | # First find all the links, then test each one. | |
109 | theselinks= | |
f1f1ae8e | 110 | $LINKS && \ |
165b3941 RS |
111 | theselinks=`find $d -type l -print` |
112 | for d1 in $theselinks --dummy-- | |
113 | do | |
1ac7d389 RS |
114 | # If the link points to a directory, |
115 | # add that dir to $newdirs | |
165b3941 RS |
116 | if [ -d $d1 ] |
117 | then | |
118 | newdirs="$newdirs $d1" | |
119 | fi | |
120 | done | |
f1f1ae8e RS |
121 | done |
122 | ||
89ccb80f | 123 | files="$files $newdirs" |
f1f1ae8e | 124 | dirs="$newdirs" |
f1f1ae8e RS |
125 | done |
126 | ||
127 | dirs= | |
1ac7d389 | 128 | echo "All directories (including links to directories):" |
f1f1ae8e RS |
129 | echo $files |
130 | ||
c61a25b1 DM |
131 | for file in $files; do |
132 | rm -rf $LIB/$file | |
133 | if [ ! -d $LIB/$file ] | |
134 | then mkdir $LIB/$file | |
135 | fi | |
136 | done | |
1ac7d389 | 137 | mkdir $LIB/root |
c61a25b1 DM |
138 | |
139 | # treetops gets an alternating list | |
140 | # of old directories to copy | |
141 | # and the new directories to copy to. | |
142 | treetops="${INPUT} ${LIB}" | |
143 | ||
144 | if $LINKS; then | |
1ac7d389 | 145 | echo 'Making symbolic directory links' |
c61a25b1 DM |
146 | for file in $files; do |
147 | dest=`ls -ld $file | sed -n 's/.*-> //p'` | |
148 | if [ "$dest" ]; then | |
4ed15f9d | 149 | cwd=`${PWDCMD}` |
c61a25b1 DM |
150 | # In case $dest is relative, get to $file's dir first. |
151 | cd ${INPUT} | |
152 | cd `echo ./$file | sed -n 's&[^/]*$&&p'` | |
153 | # Check that the target directory exists. | |
154 | # Redirections changed to avoid bug in sh on Ultrix. | |
155 | (cd $dest) > /dev/null 2>&1 | |
156 | if [ $? = 0 ]; then | |
157 | cd $dest | |
158 | # X gets the dir that the link actually leads to. | |
4ed15f9d | 159 | x=`${PWDCMD}` |
1ac7d389 RS |
160 | # If a link points to ., make a similar link to . |
161 | if [ $x = $INPUT ]; then | |
162 | echo $file '->' . ': Making link' | |
163 | rm -fr ${LIB}/$file > /dev/null 2>&1 | |
164 | ln -s . ${LIB}/$file > /dev/null 2>&1 | |
c61a25b1 DM |
165 | # If link leads back into ${INPUT}, |
166 | # make a similar link here. | |
1ac7d389 | 167 | elif expr $x : "${INPUT}/.*" > /dev/null; then |
c61a25b1 DM |
168 | # Y gets the actual target dir name, relative to ${INPUT}. |
169 | y=`echo $x | sed -n "s&${INPUT}/&&p"` | |
884caf18 PE |
170 | # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. |
171 | dots=`echo "$file" | | |
172 | sed -e 's@^./@@' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` | |
173 | echo $file '->' $dots$y ': Making link' | |
c61a25b1 | 174 | rm -fr ${LIB}/$file > /dev/null 2>&1 |
884caf18 | 175 | ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 |
c61a25b1 | 176 | else |
1ac7d389 RS |
177 | # If the link is to a dir $target outside ${INPUT}, |
178 | # repoint the link at ${INPUT}/root$target | |
179 | # and process $target into ${INPUT}/root$target | |
c61a25b1 | 180 | # treat this directory as if it actually contained the files. |
1ac7d389 RS |
181 | echo $file '->' root$x ': Making link' |
182 | if [ -d $LIB/root$x ] | |
183 | then true | |
184 | else | |
185 | dirname=root$x/ | |
186 | dirmade=. | |
187 | cd $LIB | |
188 | while [ x$dirname != x ]; do | |
189 | component=`echo $dirname | sed -e 's|/.*$||'` | |
190 | mkdir $component >/dev/null 2>&1 | |
191 | cd $component | |
192 | dirmade=$dirmade/$component | |
193 | dirname=`echo $dirname | sed -e 's|[^/]*/||'` | |
194 | done | |
195 | fi | |
f744b2ce RS |
196 | # Duplicate directory structure created in ${LIB}/$file in new |
197 | # root area. | |
198 | for file2 in $files; do | |
199 | case $file2 in | |
638fa106 | 200 | $file/./*) |
f744b2ce RS |
201 | dupdir=${LIB}/root$x/`echo $file2 | sed -n "s|^${file}/||p"` |
202 | echo "Duplicating ${file}'s ${dupdir}" | |
203 | if [ -d ${dupdir} ] | |
204 | then true | |
205 | else | |
206 | mkdir ${dupdir} | |
207 | fi | |
208 | ;; | |
638fa106 BK |
209 | *) |
210 | ;; | |
f744b2ce RS |
211 | esac |
212 | done | |
884caf18 PE |
213 | # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. |
214 | dots=`echo "$file" | | |
215 | sed -e 's@^./@@' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` | |
1ac7d389 | 216 | rm -fr ${LIB}/$file > /dev/null 2>&1 |
884caf18 | 217 | ln -s ${dots}root$x ${LIB}/$file > /dev/null 2>&1 |
1ac7d389 | 218 | treetops="$treetops $x ${LIB}/root$x" |
c61a25b1 DM |
219 | fi |
220 | fi | |
221 | cd $cwd | |
222 | fi | |
223 | done | |
224 | fi | |
225 | ||
25e51a69 ILT |
226 | set x $treetops |
227 | shift | |
c61a25b1 DM |
228 | while [ $# != 0 ]; do |
229 | # $1 is an old directory to copy, and $2 is the new directory to copy to. | |
c61a25b1 DM |
230 | cd ${INPUT} |
231 | cd $1 | |
1ac7d389 RS |
232 | # The same dir can appear more than once in treetops. |
233 | # There's no need to scan it more than once. | |
234 | if [ -f $2/DONE ] | |
235 | then | |
236 | files= | |
237 | else | |
238 | touch $2/DONE | |
239 | echo Fixing directory $1 into $2 | |
8c31e6b6 RS |
240 | # Check .h files which are symlinks as well as those which are files. |
241 | # A link to a header file will not be processed by anything but this. | |
73bdfabc RS |
242 | if $LINKS; then |
243 | files=`find . -name '*.h' \( -type f -o -type l \) -print` | |
244 | else | |
245 | files=`find . -name '*.h' -type f -print` | |
246 | fi | |
1ac7d389 RS |
247 | echo Checking header files |
248 | fi | |
c61a25b1 DM |
249 | # Note that BSD43_* are used on recent MIPS systems. |
250 | for file in $files; do | |
251 | # This call to egrep is essential, since checking a file with egrep | |
252 | # is much faster than actually trying to fix it. | |
3308e40a RS |
253 | # It is also essential that most files *not* match! |
254 | # Thus, matching every #endif is unacceptable. | |
c61a25b1 DM |
255 | # But the argument to egrep must be kept small, or many versions of egrep |
256 | # won't be able to handle it. | |
25e51a69 ILT |
257 | # |
258 | # We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment | |
259 | # following #else or #endif because some buggy egreps think [^/] matches | |
260 | # newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'. | |
261 | # | |
262 | # We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier | |
263 | # following #if or #elif that is not surrounded by __. The `a-ce-km-z' | |
264 | # in this pattern lacks `d' and `l'; this means we don't worry about | |
265 | # identifiers starting with `d' or `l'. This is OK, since none of the | |
266 | # identifiers below start with `d' or `l'. It also greatly improves | |
267 | # performance, since many files contain lines of the form `#if ... defined ...' | |
268 | # or `#if lint'. | |
269 | 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 | |
c61a25b1 DM |
270 | if [ -r $file ]; then |
271 | cp $file $2/$file >/dev/null 2>&1 \ | |
272 | || echo "Can't copy $file" | |
273 | chmod +w $2/$file | |
2e4cd151 | 274 | chmod a+r $2/$file |
8caf703c RS |
275 | # Here is how the sed commands in braces work. |
276 | # (It doesn't work to put the comments inside the sed commands.) | |
277 | # Surround each word with spaces, to simplify matching below. | |
278 | # ANSIfy each pre-ANSI machine-dependent symbol | |
279 | # by surrounding it with __ __. | |
280 | # Remove the spaces that we inserted around each word. | |
c61a25b1 DM |
281 | sed -e ' |
282 | :loop | |
283 | /\\$/ N | |
284 | /\\$/ b loop | |
20c74d5e PE |
285 | s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1% |
286 | s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1% | |
287 | s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1% | |
ec4738c0 RS |
288 | s%^\([ ]*#[ ]*endif\)[ ]*\*[^/].*%\1% |
289 | s%^\([ ]*#[ ]*endif\)[ ]*[^/* ].*%\1% | |
883bc780 | 290 | /\/\/[^*]/ s|//\(.*\)$|/*\1*/| |
2a46424a | 291 | /[ ]_IO[A-Z]*[ ]*(/ s/\(_IO[A-Z]*[ ]*(\)\(.\),/\1'\''\2'\'',/ |
c61a25b1 | 292 | /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/ |
0ef87f39 | 293 | /#define._IO/ s/'\''\([cgxt]\)'\''/\1/g |
25e51a69 | 294 | /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g |
d7c768e7 RS |
295 | /[^A-Z0-9_]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/ |
296 | /[^A-Z0-9]_CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/ | |
c87e58bb RS |
297 | /#define[ ]*[ ]CTRL/ s/'\''\([cgx]\)'\''/\1/g |
298 | /#define[ ]*[ ]_CTRL/ s/'\''\([cgx]\)'\''/\1/g | |
a2790172 | 299 | /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g |
25e51a69 | 300 | /#[el]*if/{ |
25e51a69 ILT |
301 | s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g |
302 | ||
25e51a69 ILT |
303 | s/ bsd4\([0-9]\) / __bsd4\1__ /g |
304 | s/ _*i386 / __i386__ /g | |
305 | s/ is68k / __is68k__ /g | |
306 | s/ m68k / __m68k__ /g | |
307 | s/ mc680\([0-9]\)0 / __mc680\10__ /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 | ||
25e51a69 ILT |
317 | s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g |
318 | } | |
45b33951 | 319 | /^#define.NULL[ ]/ i\ |
c61a25b1 | 320 | #undef NULL |
78c5c646 RS |
321 | ' $2/$file > $2/$file. |
322 | mv $2/$file. $2/$file | |
c61a25b1 | 323 | if cmp $file $2/$file >/dev/null 2>&1; then |
c61a25b1 | 324 | rm $2/$file |
b52a4b72 RS |
325 | else |
326 | echo Fixed $file | |
c61a25b1 DM |
327 | fi |
328 | fi | |
329 | fi | |
330 | done | |
331 | shift; shift | |
332 | done | |
333 | ||
334 | cd ${INPUT} | |
335 | ||
cd3383a3 | 336 | # Install the proper definition of size_t in header files that it comes from. |
1f1ff018 | 337 | for file in sys/types.h stdlib.h sys/stdtypes.h; do |
cd3383a3 RS |
338 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then |
339 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
340 | chmod +w ${LIB}/$file 2>/dev/null | |
341 | chmod a+r ${LIB}/$file 2>/dev/null | |
342 | fi | |
343 | ||
344 | if [ -r ${LIB}/$file ]; then | |
345 | echo Fixing $file comment | |
cc08b87d | 346 | # Get the definition of __SIZE_TYPE__, if any. |
cd3383a3 | 347 | # (This file must be called something.c). |
cc08b87d ILT |
348 | echo "__SIZE_TYPE__" > ${LIB}/types.c |
349 | foo=`${GCCCMD} -E -P ${LIB}/types.c` | |
631e21eb | 350 | rm -f ${LIB}/types.c |
cd3383a3 | 351 | # Default to our preferred type. |
cc08b87d | 352 | if [ "$foo" = __SIZE_TYPE__ ]; then foo="unsigned long int"; fi |
cd3383a3 RS |
353 | sed -e "s/typedef[ a-z_]*[ ]size_t/typedef $foo size_t/" ${LIB}/$file > ${LIB}/${file}.sed |
354 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
355 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
356 | rm ${LIB}/$file | |
357 | fi | |
358 | fi | |
359 | done | |
360 | ||
c61a25b1 DM |
361 | # Fix one other error in this file: a mismatched quote not inside a C comment. |
362 | file=sundev/vuid_event.h | |
363 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
364 | mkdir ${LIB}/sundev 2>/dev/null | |
365 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
366 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 367 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
368 | fi |
369 | ||
370 | if [ -r ${LIB}/$file ]; then | |
371 | echo Fixing $file comment | |
ffc47266 JW |
372 | sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed |
373 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 374 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
375 | rm ${LIB}/$file |
376 | fi | |
377 | fi | |
378 | ||
4ba0ff2d JW |
379 | # Fix these Sun OS files to avoid an invalid identifier in an #ifdef. |
380 | file=sunwindow/win_cursor.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 | file=sunwindow/win_lock.h | |
395 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
396 | # mkdir ${LIB}/sunwindow 2>/dev/null | |
397 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
398 | chmod +w ${LIB}/$file 2>/dev/null | |
399 | fi | |
400 | if [ -r ${LIB}/$file ]; then | |
401 | echo Fixing $file | |
402 | sed -e "s/ecd.cursor/ecd_cursor/" ${LIB}/$file > ${LIB}/${file}.sed | |
403 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
404 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
405 | rm ${LIB}/$file | |
406 | fi | |
407 | fi | |
408 | ||
6dc42e49 | 409 | # Fix this Sun file to avoid interfering with stddef.h. |
c61a25b1 DM |
410 | file=sys/stdtypes.h |
411 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
412 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
413 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 414 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
415 | fi |
416 | ||
417 | if [ -r ${LIB}/$file ]; then | |
418 | echo Fixing $file | |
daa4489f | 419 | sed -e '/[ ]size_t.*;/i\ |
ffc47266 JW |
420 | #ifndef _GCC_SIZE_T\ |
421 | #define _GCC_SIZE_T' \ | |
daa4489f | 422 | -e '/[ ]size_t.*;/a\ |
ffc47266 | 423 | #endif' \ |
daa4489f | 424 | -e '/[ ]ptrdiff_t.*;/i\ |
ffc47266 JW |
425 | #ifndef _GCC_PTRDIFF_T\ |
426 | #define _GCC_PTRDIFF_T' \ | |
daa4489f | 427 | -e '/[ ]ptrdiff_t.*;/a\ |
ffc47266 | 428 | #endif' \ |
daa4489f | 429 | -e '/[ ]wchar_t.*;/i\ |
ffc47266 JW |
430 | #ifndef _GCC_WCHAR_T\ |
431 | #define _GCC_WCHAR_T' \ | |
daa4489f | 432 | -e '/[ ]wchar_t.*;/a\ |
ffc47266 JW |
433 | #endif' ${LIB}/$file > ${LIB}/${file}.sed |
434 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 435 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
436 | rm ${LIB}/$file |
437 | fi | |
438 | fi | |
439 | ||
fd9287ae JW |
440 | # Fix this file to avoid interfering with stddef.h, but don't mistakenly |
441 | # match e.g. ssize_t present in AIX for the ps/2. | |
c61a25b1 DM |
442 | file=sys/types.h |
443 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
444 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
445 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 446 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
447 | fi |
448 | ||
449 | if [ -r ${LIB}/$file ]; then | |
450 | echo Fixing $file | |
590d6f8e | 451 | sed -e '/[ ]size_t.*;/i\ |
ffc47266 JW |
452 | #ifndef _GCC_SIZE_T\ |
453 | #define _GCC_SIZE_T' \ | |
590d6f8e | 454 | -e '/[ ]size_t.*;/a\ |
ffc47266 JW |
455 | #endif' ${LIB}/$file > ${LIB}/${file}.sed |
456 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 457 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
458 | rm ${LIB}/$file |
459 | fi | |
460 | fi | |
461 | ||
94e21bd7 DE |
462 | # Fix HP's use of ../machine/inline.h to refer to |
463 | # /usr/include/machine/inline.h | |
464 | file=sys/spinlock.h | |
465 | if [ ! -r ${LIB}/$file ] ; then | |
466 | cp $file ${LIB}/$file | |
467 | fi | |
468 | if [ -r ${LIB}/$file ] ; then | |
469 | echo Fixing $file | |
470 | sed -e 's,"../machine/inline.h",<machine/inline.h>,' \ | |
471 | -e 's,"../machine/psl.h",<machine/psl.h>,' \ | |
472 | ${LIB}/$file > ${LIB}/${file}.sed | |
473 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
474 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
475 | rm ${LIB}/$file | |
476 | fi | |
477 | fi | |
478 | ||
08455880 TW |
479 | # Fix an error in this file: the #if says _cplusplus, not the double |
480 | # underscore __cplusplus that it should be | |
481 | file=tinfo.h | |
482 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
483 | mkdir ${LIB}/rpcsvc 2>/dev/null | |
484 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
485 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 486 | chmod a+r ${LIB}/$file 2>/dev/null |
08455880 TW |
487 | fi |
488 | ||
489 | if [ -r ${LIB}/$file ]; then | |
490 | echo Fixing $file, __cplusplus macro | |
491 | sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed | |
492 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
493 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
494 | rm ${LIB}/$file | |
495 | fi | |
496 | fi | |
497 | ||
c61a25b1 DM |
498 | # Fix an error in this file: a missing semi-colon at the end of the statsswtch |
499 | # structure definition. | |
500 | file=rpcsvc/rstat.h | |
501 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
502 | mkdir ${LIB}/rpcsvc 2>/dev/null | |
503 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
504 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 505 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
506 | fi |
507 | ||
508 | if [ -r ${LIB}/$file ]; then | |
509 | echo Fixing $file, definition of statsswtch | |
ffc47266 JW |
510 | sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed |
511 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 512 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
513 | rm ${LIB}/$file |
514 | fi | |
515 | fi | |
516 | ||
517 | # Fix an error in this file: a missing semi-colon at the end of the nodeent | |
518 | # structure definition. | |
519 | file=netdnet/dnetdb.h | |
520 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
521 | mkdir ${LIB}/netdnet 2>/dev/null | |
522 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
523 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 524 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
525 | fi |
526 | ||
527 | if [ -r ${LIB}/$file ]; then | |
528 | echo Fixing $file, definition of nodeent | |
ffc47266 JW |
529 | sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed |
530 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 531 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
532 | rm ${LIB}/$file |
533 | fi | |
534 | fi | |
535 | ||
536 | # Check for bad #ifdef line (in Ultrix 4.1) | |
537 | file=sys/file.h | |
538 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
539 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
540 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 541 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
542 | fi |
543 | ||
544 | if [ -r ${LIB}/$file ]; then | |
545 | echo Fixing $file, bad \#ifdef line | |
ffc47266 JW |
546 | sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed |
547 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 548 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
549 | rm ${LIB}/$file |
550 | fi | |
551 | fi | |
552 | ||
553 | # Check for superfluous `static' (in Ultrix 4.2) | |
554 | file=machine/cpu.h | |
555 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
556 | mkdir ${LIB}/machine 2>/dev/null | |
557 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
558 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 559 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
560 | fi |
561 | ||
562 | if [ -r ${LIB}/$file ]; then | |
563 | echo Fixing $file, superfluous static | |
ffc47266 JW |
564 | sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed |
565 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
c61a25b1 | 566 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
567 | rm ${LIB}/$file |
568 | else | |
569 | # This file has an alternative name, mips/cpu.h. Fix that name, too. | |
1f1ff018 | 570 | if cmp machine/cpu.h mips/cpu.h > /dev/null 2>&1; then |
c61a25b1 DM |
571 | mkdir ${LIB}/mips 2>&- |
572 | ln ${LIB}/$file ${LIB}/mips/cpu.h | |
573 | fi | |
574 | fi | |
575 | fi | |
576 | ||
75251fe0 | 577 | # Incorrect sprintf declaration in X11/Xmu.h |
c61a25b1 DM |
578 | file=X11/Xmu.h |
579 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
580 | mkdir ${LIB}/X11 2>/dev/null | |
581 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
582 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 583 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
584 | fi |
585 | ||
586 | if [ -r ${LIB}/$file ]; then | |
587 | echo Fixing $file sprintf declaration | |
ffc47266 JW |
588 | sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\ |
589 | extern char * sprintf();\ | |
8739838d | 590 | #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed |
ffc47266 | 591 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
c61a25b1 | 592 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
593 | rm ${LIB}/$file |
594 | fi | |
595 | fi | |
596 | ||
3a6aca8e RS |
597 | # Incorrect sprintf declaration in X11/Xmu/Xmu.h |
598 | # (It's not clear whether the right file name is this or X11/Xmu.h.) | |
599 | file=X11/Xmu/Xmu.h | |
600 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
601 | mkdir ${LIB}/X11/Xmu 2>/dev/null | |
602 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
603 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 604 | chmod a+r ${LIB}/$file 2>/dev/null |
3a6aca8e RS |
605 | fi |
606 | ||
607 | if [ -r ${LIB}/$file ]; then | |
608 | echo Fixing $file sprintf declaration | |
ffc47266 JW |
609 | sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\ |
610 | extern char * sprintf();\ | |
8739838d | 611 | #endif /* !defined __STDC__ */,' ${LIB}/$file > ${LIB}/${file}.sed |
ffc47266 | 612 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
3a6aca8e | 613 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
3a6aca8e RS |
614 | rm ${LIB}/$file |
615 | fi | |
616 | fi | |
617 | ||
c61a25b1 DM |
618 | # Check for missing ';' in struct |
619 | file=netinet/ip.h | |
620 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
621 | mkdir ${LIB}/netinet 2>/dev/null | |
622 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
623 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 624 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
625 | fi |
626 | ||
627 | if [ -r ${LIB}/$file ]; then | |
628 | echo Fixing $file | |
629 | sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed | |
630 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
631 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
632 | rm -f ${LIB}/$file |
633 | fi | |
634 | fi | |
635 | ||
75251fe0 | 636 | # Fix the CAT macro in SunOS memvar.h. |
c61a25b1 DM |
637 | file=pixrect/memvar.h |
638 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
639 | mkdir ${LIB}/pixrect 2>/dev/null | |
640 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
641 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 642 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
643 | fi |
644 | ||
645 | if [ -r ${LIB}/$file ]; then | |
646 | echo Fixing $file | |
647 | sed -e '/^#define.CAT(a,b)/ i\ | |
648 | #ifdef __STDC__ \ | |
649 | #define CAT(a,b) a##b\ | |
650 | #else | |
651 | /^#define.CAT(a,b)/ a\ | |
652 | #endif | |
653 | ' ${LIB}/$file > ${LIB}/${file}.sed | |
654 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
655 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
656 | rm -f ${LIB}/$file |
657 | fi | |
658 | fi | |
659 | ||
660 | # Check for yet more missing ';' in struct (in SunOS 4.0.x) | |
661 | file=rpcsvc/rusers.h | |
662 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
663 | mkdir ${LIB}/rpcsvc 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 | |
2e4cd151 | 666 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
667 | fi |
668 | ||
669 | if [ -r ${LIB}/$file ]; then | |
670 | echo Fixing $file | |
671 | sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed | |
672 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
673 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
674 | rm -f ${LIB}/$file |
675 | fi | |
676 | fi | |
677 | ||
678 | # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1. | |
c87e58bb | 679 | # Also wrap protection around size_t for m88k-sysv3 systems. |
c61a25b1 DM |
680 | file=stdlib.h |
681 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
682 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
683 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 684 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
685 | fi |
686 | ||
687 | if [ -r ${LIB}/$file ]; then | |
688 | echo Fixing $file | |
689 | sed -e 's/int abort/void abort/g' \ | |
25f75d8a RS |
690 | -e 's/int free/void free/g' \ |
691 | -e 's/char \* calloc/void \* calloc/g' \ | |
692 | -e 's/char \* malloc/void \* malloc/g' \ | |
693 | -e 's/char \* realloc/void \* realloc/g' \ | |
c87e58bb | 694 | -e 's/int exit/void exit/g' \ |
a3f6caa7 | 695 | -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\ |
c87e58bb RS |
696 | #ifndef _GCC_SIZE_T\ |
697 | #define _GCC_SIZE_T' \ | |
a3f6caa7 | 698 | -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\ |
c87e58bb RS |
699 | #endif' \ |
700 | ${LIB}/$file > ${LIB}/${file}.sed | |
c61a25b1 DM |
701 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
702 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
703 | rm -f ${LIB}/$file |
704 | fi | |
705 | fi | |
706 | ||
460d7c18 TG |
707 | # Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1. |
708 | file=malloc.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 | |
2e4cd151 | 712 | chmod a+r ${LIB}/$file 2>/dev/null |
460d7c18 TG |
713 | fi |
714 | ||
715 | if [ -r ${LIB}/$file ]; then | |
716 | echo Fixing $file | |
350027ec | 717 | sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \ |
12fe670b | 718 | -e 's/int[ ][ ]*free/void free/g' \ |
460d7c18 TG |
719 | ${LIB}/$file > ${LIB}/${file}.sed |
720 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
721 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
460d7c18 TG |
722 | rm -f ${LIB}/$file |
723 | fi | |
724 | fi | |
725 | ||
c61a25b1 DM |
726 | # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1. |
727 | file=hsfs/hsfs_spec.h | |
728 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
729 | mkdir ${LIB}/hsfs 2>/dev/null | |
730 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
731 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 732 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
733 | fi |
734 | ||
735 | if [ -r ${LIB}/$file ]; then | |
736 | echo Fixing $file | |
737 | sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \ | |
78c5c646 RS |
738 | ${LIB}/$file > ${LIB}/${file}. |
739 | rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file | |
c61a25b1 | 740 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
c61a25b1 DM |
741 | rm -f ${LIB}/$file |
742 | fi | |
743 | fi | |
744 | ||
745 | # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1. | |
746 | file=hsfs/hsnode.h | |
747 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
748 | mkdir ${LIB}/hsfs 2>/dev/null | |
749 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
750 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 751 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
752 | fi |
753 | ||
754 | if [ -r ${LIB}/$file ]; then | |
755 | echo Fixing $file | |
756 | sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \ | |
757 | ${LIB}/$file > ${LIB}/${file}.sed | |
758 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
759 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
760 | rm -f ${LIB}/$file |
761 | fi | |
762 | fi | |
763 | ||
764 | # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1. | |
765 | file=hsfs/iso_spec.h | |
766 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
767 | mkdir ${LIB}/hsfs 2>/dev/null | |
768 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
769 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 770 | chmod a+r ${LIB}/$file 2>/dev/null |
c61a25b1 DM |
771 | fi |
772 | ||
773 | if [ -r ${LIB}/$file ]; then | |
774 | echo Fixing $file | |
775 | sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \ | |
776 | ${LIB}/$file > ${LIB}/${file}.sed | |
777 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
778 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
c61a25b1 DM |
779 | rm -f ${LIB}/$file |
780 | fi | |
781 | fi | |
782 | ||
75251fe0 DM |
783 | # Incorrect #include in Sony News-OS 3.2. |
784 | file=machine/machparam.h | |
785 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
786 | mkdir ${LIB}/machine 2>/dev/null | |
787 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
788 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 789 | chmod a+r ${LIB}/$file 2>/dev/null |
75251fe0 DM |
790 | fi |
791 | ||
792 | if [ -r ${LIB}/$file ]; then | |
793 | echo Fixing $file, incorrect \#include | |
794 | sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \ | |
78c5c646 RS |
795 | ${LIB}/$file > ${LIB}/${file}. |
796 | rm -f ${LIB}/$file; mv ${LIB}/${file}. ${LIB}/$file | |
75251fe0 | 797 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
75251fe0 DM |
798 | rm -f ${LIB}/$file |
799 | fi | |
800 | fi | |
801 | ||
802 | # Multiline comment after typedef on IRIX 4.0.1. | |
803 | file=sys/types.h | |
804 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
805 | mkdir ${LIB}/sys 2>/dev/null | |
806 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
807 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 808 | chmod a+r ${LIB}/$file 2>/dev/null |
75251fe0 DM |
809 | fi |
810 | ||
811 | if [ -r ${LIB}/$file ]; then | |
812 | echo Fixing $file, comment in the middle of \#ifdef | |
813 | sed -e 's@type of the result@type of the result */@' \ | |
814 | -e 's@of the sizeof@/* of the sizeof@' \ | |
815 | ${LIB}/$file > ${LIB}/${file}.sed | |
816 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
817 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
75251fe0 DM |
818 | rm -f ${LIB}/$file |
819 | fi | |
820 | fi | |
821 | ||
2a46424a ILT |
822 | # Turning // comments into /* */ comments trashes this IRIX 4.0.1 |
823 | # header file, which embeds // comments inside multi-line /* */ | |
824 | # comments. If this looks like the IRIX header file, we refix it by | |
825 | # just throwing away the // comments. | |
826 | file=fam.h | |
827 | if [ -r ${LIB}/$file ]; then | |
828 | if egrep indigo.esd ${LIB}/$file > /dev/null; then | |
829 | echo Fixing $file, overeager sed script | |
830 | rm ${LIB}/$file | |
831 | sed -e 's|//.*$||g' $file > ${LIB}/$file | |
832 | chmod +w ${LIB}/$file 2>/dev/null | |
833 | chmod a+r ${LIB}/$file 2>/dev/null | |
834 | fi | |
835 | fi | |
836 | ||
7313c84b ILT |
837 | # Another IRIX 4.0.1 header file contains the string "//" |
838 | file=elf_abi.h | |
839 | if [ -r ${LIB}/$file ]; then | |
840 | echo Fixing $file, overeager sed script | |
841 | sed -e 's|"/\*"\*/|"//"|' ${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 | ||
0ff76398 JW |
848 | # Same problem with a file from SunOS 4.1.3 : a header file containing |
849 | # the string "//" embedded in "/**/" | |
850 | file=sbusdev/audiovar.h | |
851 | if [ -r ${LIB}/$file ]; then | |
852 | echo Fixing $file, overeager sed script | |
853 | rm ${LIB}/$file | |
854 | sed -e 's|//.*$||g' $file > ${LIB}/$file | |
855 | chmod +w ${LIB}/$file 2>/dev/null | |
856 | chmod a+r ${LIB}/$file 2>/dev/null | |
857 | fi | |
858 | ||
4d449554 JW |
859 | # Fix non-ANSI memcpy declaration that conflicts with gcc's builtin |
860 | # declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because | |
861 | # many other systems have similar text but correct versions of the file. | |
862 | # To ensure only Sun's is fixed, we grep for a likely unique string. | |
863 | file=memory.h | |
6a25991d RS |
864 | if [ -r $file ] && egrep '/\* @\(#\)memory\.h 1\.[2-4] 8./../.. SMI; from S5R2 1\.2 \*/' $file > /dev/null; then |
865 | if [ ! -r ${LIB}/$file ]; then | |
4d449554 JW |
866 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" |
867 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 868 | chmod a+r ${LIB}/$file 2>/dev/null |
4d449554 JW |
869 | fi |
870 | if [ -r ${LIB}/$file ]; then | |
871 | echo Replacing $file | |
872 | cat > ${LIB}/$file << EOF | |
873 | /* This file was generated by fixincludes */ | |
874 | #ifndef __memory_h__ | |
875 | #define __memory_h__ | |
876 | ||
877 | #ifdef __STDC__ | |
878 | extern void *memccpy(); | |
879 | extern void *memchr(); | |
880 | extern void *memcpy(); | |
881 | extern void *memset(); | |
882 | #else | |
883 | extern char *memccpy(); | |
884 | extern char *memchr(); | |
885 | extern char *memcpy(); | |
886 | extern char *memset(); | |
887 | #endif /* __STDC__ */ | |
888 | ||
889 | extern int memcmp(); | |
890 | ||
eb13d323 | 891 | #endif /* __memory_h__ */ |
4d449554 JW |
892 | EOF |
893 | fi | |
894 | fi | |
895 | ||
7d349561 JW |
896 | # parameters not const on DECstation Ultrix V4.0. |
897 | file=stdio.h | |
898 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
899 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
900 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 901 | chmod a+r ${LIB}/$file 2>/dev/null |
7d349561 JW |
902 | fi |
903 | ||
904 | if [ -r ${LIB}/$file ]; then | |
905 | echo Fixing $file, non-const arg | |
906 | sed -e 's@perror( char \*__s );@perror( const char *__s );@' \ | |
907 | -e 's@fputs( char \*__s,@fputs( const char *__s,@' \ | |
908 | -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \ | |
909 | -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \ | |
910 | -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \ | |
911 | -e 's@scanf( char \*__format,@scanf( const char *__format,@' \ | |
912 | -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \ | |
913 | ${LIB}/$file > ${LIB}/${file}.sed | |
914 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
915 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
7d349561 JW |
916 | rm -f ${LIB}/$file |
917 | fi | |
918 | fi | |
919 | ||
f45a4d6a | 920 | # parameters conflict with C++ new on rs/6000 |
255fccf3 PB |
921 | for file in stdio.h unistd.h ; do |
922 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
923 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
924 | chmod +w ${LIB}/$file 2>/dev/null | |
925 | fi | |
926 | ||
927 | if [ -r ${LIB}/$file ]; then | |
928 | echo Fixing $file, parameter name conflicts | |
929 | sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \ | |
930 | ${LIB}/$file > ${LIB}/${file}.sed | |
931 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
932 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
933 | rm -f ${LIB}/$file | |
934 | fi | |
935 | fi | |
936 | done | |
937 | ||
938 | # function class(double x) conflicts with C++ keyword on rs/6000 | |
939 | file=math.h | |
f45a4d6a JW |
940 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then |
941 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
942 | chmod +w ${LIB}/$file 2>/dev/null | |
255fccf3 | 943 | chmod a+r ${LIB}/$file 2>/dev/null |
f45a4d6a JW |
944 | fi |
945 | ||
946 | if [ -r ${LIB}/$file ]; then | |
255fccf3 PB |
947 | if grep 'class[(]' ${LIB}/$file >/dev/null; then |
948 | echo Fixing $file | |
949 | sed -e '/class[(]/i\ | |
950 | #ifndef __cplusplus' \ | |
951 | -e '/class[(]/a\ | |
952 | #endif' ${LIB}/$file > ${LIB}/${file}.sed | |
953 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
954 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
955 | rm ${LIB}/$file | |
956 | fi | |
957 | fi | |
958 | fi | |
959 | ||
960 | # NeXT defines 'int wait(union wait*)', which conflicts with Posix.1. | |
961 | file=sys/wait.h | |
962 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
963 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
964 | chmod +w ${LIB}/$file 2>/dev/null | |
965 | fi | |
966 | ||
967 | if [ -r ${LIB}/$file ] \ | |
968 | && grep 'wait[(]union wait' ${LIB}/$file >/dev/null; then | |
969 | echo Fixing $file, bad wait formal | |
970 | sed -e 's@wait(union wait@wait(void@' ${LIB}/$file > ${LIB}/${file}.sed | |
f45a4d6a JW |
971 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file |
972 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
973 | rm -f ${LIB}/$file | |
974 | fi | |
975 | fi | |
976 | ||
1ac7d389 RS |
977 | # Don't use or define the name va_list in stdio.h. |
978 | # This is for ANSI and also to interoperate properly with gvarargs.h. | |
979 | file=stdio.h | |
980 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
981 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
982 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 983 | chmod a+r ${LIB}/$file 2>/dev/null |
1ac7d389 RS |
984 | fi |
985 | ||
986 | if [ -r ${LIB}/$file ]; then | |
987 | echo Fixing $file, use of va_list | |
988 | # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list | |
989 | (echo "#define __need___va_list" | |
990 | echo "#include <stdarg.h>") > ${LIB}/${file}.sed | |
991 | # Use __gnuc_va_list in arg types in place of va_list. | |
d5891360 JW |
992 | # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the |
993 | # trailing parentheses and semicolon save all other systems from this. | |
1ac7d389 RS |
994 | # Define __va_list__ (something harmless and unused) instead of va_list. |
995 | # Don't claim to have defined va_list. | |
996 | sed -e 's@ va_list @ __gnuc_va_list @' \ | |
8befb954 | 997 | -e 's@ va_list)@ __gnuc_va_list)@' \ |
d5891360 | 998 | -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \ |
1ac7d389 | 999 | -e 's@ va_list@ __va_list__@' \ |
be71bebd | 1000 | -e 's@\*va_list@*__va_list__@' \ |
75d98655 | 1001 | -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \ |
1ac7d389 | 1002 | -e 's@VA_LIST@DUMMY_VA_LIST@' \ |
75d98655 | 1003 | -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \ |
1ac7d389 RS |
1004 | ${LIB}/$file >> ${LIB}/${file}.sed |
1005 | ||
1006 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1007 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1ac7d389 RS |
1008 | rm -f ${LIB}/$file |
1009 | fi | |
1010 | fi | |
1011 | ||
e63c1d35 RS |
1012 | # Cancel out ansi_compat.h on Ultrix. Replace it with empty file. |
1013 | file=ansi_compat.h | |
1014 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1015 | if grep -s ULTRIX $file; then | |
1016 | echo "/* This file intentionally left blank. */" > $LIB/$file | |
1017 | fi | |
1018 | fi | |
1019 | ||
7d349561 | 1020 | # parameter to atof not const on DECstation Ultrix V4.0. |
28bbe06b | 1021 | # also get rid of bogus inline definitions in HP-UX 8.0 |
7d349561 JW |
1022 | file=math.h |
1023 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1024 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1025 | chmod +w ${LIB}/$file 2>/dev/null | |
2e4cd151 | 1026 | chmod a+r ${LIB}/$file 2>/dev/null |
7d349561 JW |
1027 | fi |
1028 | ||
1029 | if [ -r ${LIB}/$file ]; then | |
1030 | echo Fixing $file, non-const arg | |
1031 | sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \ | |
28bbe06b RS |
1032 | -e 's@inline int abs(int d) { return (d>0)?d:-d; }@@' \ |
1033 | -e 's@inline double abs(double d) { return fabs(d); }@@' \ | |
7d349561 JW |
1034 | ${LIB}/$file > ${LIB}/${file}.sed |
1035 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1036 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
7d349561 JW |
1037 | rm -f ${LIB}/$file |
1038 | fi | |
1039 | fi | |
1040 | ||
6ef797ea RS |
1041 | # In limits.h, put #ifndefs around things that are supposed to be defined |
1042 | # in float.h to avoid redefinition errors if float.h is included first. | |
c49c4803 ILT |
1043 | # On HP/UX this patch does not work, because on HP/UX limits.h uses |
1044 | # multi line comments and the inserted #endif winds up inside the | |
1045 | # comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if | |
1046 | # we find a #ifndef FLT_MIN we assume that all the required #ifndefs | |
1047 | # are there, and we do not add them ourselves. | |
6ef797ea RS |
1048 | file=limits.h |
1049 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1050 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1051 | chmod +w ${LIB}/$file 2>/dev/null | |
1052 | chmod a+r ${LIB}/$file 2>/dev/null | |
1053 | fi | |
1054 | ||
1055 | if [ -r ${LIB}/$file ]; then | |
c49c4803 ILT |
1056 | if egrep 'ifndef[ ]+FLT_MIN' ${LIB}/$file >/dev/null; then |
1057 | true | |
1058 | else | |
1059 | echo Fixing $file | |
1060 | sed -e '/[ ]FLT_MIN[ ]/i\ | |
6ef797ea | 1061 | #ifndef FLT_MIN'\ |
c49c4803 | 1062 | -e '/[ ]FLT_MIN[ ]/a\ |
6ef797ea | 1063 | #endif'\ |
c49c4803 | 1064 | -e '/[ ]FLT_MAX[ ]/i\ |
6ef797ea | 1065 | #ifndef FLT_MAX'\ |
c49c4803 | 1066 | -e '/[ ]FLT_MAX[ ]/a\ |
6ef797ea | 1067 | #endif'\ |
c49c4803 | 1068 | -e '/[ ]FLT_DIG[ ]/i\ |
6ef797ea | 1069 | #ifndef FLT_DIG'\ |
c49c4803 | 1070 | -e '/[ ]FLT_DIG[ ]/a\ |
6ef797ea | 1071 | #endif'\ |
c49c4803 | 1072 | -e '/[ ]DBL_MIN[ ]/i\ |
6ef797ea | 1073 | #ifndef DBL_MIN'\ |
c49c4803 | 1074 | -e '/[ ]DBL_MIN[ ]/a\ |
6ef797ea | 1075 | #endif'\ |
c49c4803 | 1076 | -e '/[ ]DBL_MAX[ ]/i\ |
6ef797ea | 1077 | #ifndef DBL_MAX'\ |
c49c4803 | 1078 | -e '/[ ]DBL_MAX[ ]/a\ |
6ef797ea | 1079 | #endif'\ |
c49c4803 | 1080 | -e '/[ ]DBL_DIG[ ]/i\ |
6ef797ea | 1081 | #ifndef DBL_DIG'\ |
c49c4803 | 1082 | -e '/[ ]DBL_DIG[ ]/a\ |
6ef797ea | 1083 | #endif'\ |
c49c4803 ILT |
1084 | ${LIB}/$file > ${LIB}/${file}.sed |
1085 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1086 | fi | |
6ef797ea RS |
1087 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then |
1088 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
1089 | rm -f ${LIB}/$file | |
1090 | fi | |
1091 | fi | |
1092 | ||
303b6ca3 JW |
1093 | # In math.h, put #ifndefs around things that might be defined in a gcc |
1094 | # specific math-*.h file. | |
1095 | file=math.h | |
1096 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1097 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1098 | chmod +w ${LIB}/$file 2>/dev/null | |
1099 | chmod a+r ${LIB}/$file 2>/dev/null | |
1100 | fi | |
1101 | ||
1102 | if [ -r ${LIB}/$file ]; then | |
1103 | echo Fixing $file | |
1104 | sed -e '/define[ ]HUGE_VAL[ ]/i\ | |
1105 | #ifndef HUGE_VAL'\ | |
1106 | -e '/define[ ]HUGE_VAL[ ]/a\ | |
1107 | #endif'\ | |
1108 | ${LIB}/$file > ${LIB}/${file}.sed | |
1109 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1110 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1111 | echo Deleting ${LIB}/$file\; no fixes were needed. | |
1112 | rm -f ${LIB}/$file | |
1113 | fi | |
1114 | fi | |
1115 | ||
5959a6cd RS |
1116 | # These two files on SunOS 4 are included by other files |
1117 | # in the same directory, using "...". So we must make sure they exist | |
cd10f7b6 RS |
1118 | # in the same directory as the other fixed files. |
1119 | if [ -r ${INPUT}/multimedia/audio_errno.h ] | |
5959a6cd | 1120 | then |
cd10f7b6 | 1121 | ln -s ${INPUT}/multimedia/audio_errno.h ${LIB}/multimedia 2>/dev/null |
5959a6cd | 1122 | fi |
cd10f7b6 | 1123 | if [ -r ${INPUT}/multimedia/audio_hdr.h ] |
5959a6cd | 1124 | then |
cd10f7b6 | 1125 | ln -s ${INPUT}/multimedia/audio_hdr.h ${LIB}/multimedia 2>/dev/null |
5959a6cd RS |
1126 | fi |
1127 | ||
315198ab RS |
1128 | # Determine if we're on Interactive Unix 2.2 or later, in which case we |
1129 | # need to fix some additional files. This is the same test for ISC that | |
1130 | # Autoconf uses. | |
1131 | if test -d /etc/conf/kconfig.d \ | |
1132 | && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1; then | |
1133 | echo "Fixing ISC __STDC__ goof in several files..." | |
1134 | for name in stdio.h math.h ctype.h sys/limits.h sys/fcntl.h sys/dirent.h; do | |
1135 | echo $name | |
1136 | if test -r ${LIB}/$name; then | |
1137 | file=${LIB}/$name | |
1138 | else | |
1139 | file=${INPUT}/$name | |
1140 | fi | |
1141 | # On Interactive 2.2, certain traditional Unix definitions | |
1142 | # (notably getc and putc in stdio.h) are omitted if __STDC__ is | |
1143 | # defined, not just if _POSIX_SOURCE is defined. This makes it | |
1144 | # impossible to compile any nontrivial program except with -posix. | |
1145 | sed \ | |
1146 | 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \ | |
1147 | < $file > ${LIB}/$name. | |
1148 | mv ${LIB}/$name. ${LIB}/$name | |
1149 | done | |
1150 | ||
1151 | echo "Fixing ISC fmod declaration" | |
1152 | # This one's already been fixed for other things. | |
1153 | file=${LIB}/math.h | |
1154 | sed 's/fmod(double)/fmod(double, double)/' <$file >$file. | |
1155 | mv $file. $file | |
1156 | ||
1157 | echo "Fixing nested comments in ISC <sys/limits.h>" | |
1158 | file=sys/limits.h | |
1159 | sed '/CHILD_MAX/s,/\* Max, Max,' < ${INPUT}/$file >${LIB}/$file. | |
1160 | sed '/OPEN_MAX/s,/\* Max, Max,' < ${LIB}/$file. >${LIB}/$file | |
1161 | fi | |
1162 | ||
3b8b3c98 JW |
1163 | # These files in Sun OS 4.x use /**/ to concatenate tokens. |
1164 | for file in sparc/asm_linkage.h sun3/asm_linkage.h sun3x/asm_linkage.h \ | |
1165 | sun4/asm_linkage.h sun4c/asm_linkage.h sun4m/asm_linkage.h \ | |
1166 | sun4c/debug/asm_linkage.h sun4m/debug/asm_linkage.h; | |
1167 | do | |
1168 | if [ -r $file ] && [ ! -r ${LIB}/$file ]; then | |
1169 | cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" | |
1170 | chmod +w ${LIB}/$file 2>/dev/null | |
1171 | chmod a+r ${LIB}/$file 2>/dev/null | |
1172 | fi | |
1173 | ||
1174 | if [ -r ${LIB}/$file ]; then | |
1175 | sed -e 's|/\*\*/|##|g' ${LIB}/$file > ${LIB}/${file}.sed | |
1176 | rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file | |
1177 | if cmp $file ${LIB}/$file >/dev/null 2>&1; then | |
1178 | rm -f ${LIB}/$file | |
1179 | fi | |
1180 | fi | |
1181 | done | |
1182 | ||
c61a25b1 DM |
1183 | echo 'Removing unneeded directories:' |
1184 | cd $LIB | |
1185 | files=`find . -type d -print | sort -r` | |
1186 | for file in $files; do | |
1187 | rmdir $LIB/$file > /dev/null 2>&1 | |
1188 | done | |
1189 | ||
1190 | if $LINKS; then | |
1191 | echo 'Making internal symbolic non-directory links' | |
1192 | cd ${INPUT} | |
1193 | files=`find . -type l -print` | |
1194 | for file in $files; do | |
1195 | dest=`ls -ld $file | sed -n 's/.*-> //p'` | |
1196 | if expr "$dest" : '[^/].*' > /dev/null; then | |
1197 | target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"` | |
1198 | if [ -f $target ]; then | |
1199 | ln -s $dest ${LIB}/$file >/dev/null 2>&1 | |
1200 | fi | |
1201 | fi | |
1202 | done | |
1203 | fi | |
1204 | ||
25e51a69 ILT |
1205 | echo 'Cleaning up DONE files.' |
1206 | cd $LIB | |
1207 | find . -name DONE -exec rm -f {} ';' | |
db27aeec | 1208 | |
c61a25b1 | 1209 | exit 0 |