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