|
|
1.1 ! root 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: # This works properly on a Sun in system version 3.4; ! 6: # for other versions, you had better check. ! 7: ! 8: # See README-fixinc for more information. ! 9: ! 10: # Directory containing the original header files. ! 11: # (This was named INCLUDES, but that conflicts with a name in Makefile.in.) ! 12: INPUT=${2-${INPUT-/usr/include}} ! 13: ! 14: # This prevents /bin/ex from failing if the current terminal type is ! 15: # unrecognizable. ! 16: TERM=unknown ! 17: export TERM ! 18: ! 19: # Directory in which to store the results. ! 20: LIB=${1-${LIB-/usr/local/lib/gcc-include}} ! 21: ! 22: # Make sure it exists. ! 23: if [ ! -d $LIB ]; then ! 24: mkdir $LIB || exit 1 ! 25: fi ! 26: ! 27: # Make LIB absolute. ! 28: cd $LIB; LIB=`pwd` ! 29: ! 30: # Fail if no arg to specify a directory for the output. ! 31: if [ x$1 = x ] ! 32: then echo fixincludes: no output directory specified ! 33: exit 1 ! 34: fi ! 35: ! 36: echo 'Building fixincludes in ' ${LIB} ! 37: ! 38: # Determine whether this system has symbolic links. ! 39: if ln -s X $LIB/ShouldNotExist 2>/dev/null; then ! 40: rm -f $LIB/ShouldNotExist ! 41: LINKS=true ! 42: else ! 43: LINKS=false ! 44: fi ! 45: ! 46: echo 'Making directories:' ! 47: cd ${INPUT} ! 48: if $LINKS; then ! 49: files=`ls -LR | sed -n s/:$//p` ! 50: else ! 51: files=`find . -type d -print | sed '/^.$/d'` ! 52: fi ! 53: for file in $files; do ! 54: rm -rf $LIB/$file ! 55: if [ ! -d $LIB/$file ] ! 56: then mkdir $LIB/$file ! 57: fi ! 58: done ! 59: ! 60: # treetops gets an alternating list ! 61: # of old directories to copy ! 62: # and the new directories to copy to. ! 63: treetops="${INPUT} ${LIB}" ! 64: ! 65: if $LINKS; then ! 66: echo 'Making internal symbolic directory links' ! 67: for file in $files; do ! 68: dest=`ls -ld $file | sed -n 's/.*-> //p'` ! 69: if [ "$dest" ]; then ! 70: cwd=`pwd` ! 71: # In case $dest is relative, get to $file's dir first. ! 72: cd ${INPUT} ! 73: cd `echo ./$file | sed -n 's&[^/]*$&&p'` ! 74: # Check that the target directory exists. ! 75: # Redirections changed to avoid bug in sh on Ultrix. ! 76: (cd $dest) > /dev/null 2>&1 ! 77: if [ $? = 0 ]; then ! 78: cd $dest ! 79: # X gets the dir that the link actually leads to. ! 80: x=`pwd` ! 81: # If link leads back into ${INPUT}, ! 82: # make a similar link here. ! 83: if expr $x : "${INPUT}/.*" > /dev/null; then ! 84: # Y gets the actual target dir name, relative to ${INPUT}. ! 85: y=`echo $x | sed -n "s&${INPUT}/&&p"` ! 86: echo $file '->' $y ': Making link' ! 87: rm -fr ${LIB}/$file > /dev/null 2>&1 ! 88: ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1 ! 89: else ! 90: # If the link is to outside ${INPUT}, ! 91: # treat this directory as if it actually contained the files. ! 92: # This line used to have $dest instead of $x. ! 93: # $dest seemed to be wrong for links found in subdirectories ! 94: # of ${INPUT}. Does this change break anything? ! 95: treetops="$treetops $x ${LIB}/$file" ! 96: fi ! 97: fi ! 98: cd $cwd ! 99: fi ! 100: done ! 101: fi ! 102: ! 103: set - $treetops ! 104: while [ $# != 0 ]; do ! 105: # $1 is an old directory to copy, and $2 is the new directory to copy to. ! 106: echo "Finding header files in $1:" ! 107: cd ${INPUT} ! 108: cd $1 ! 109: files=`find . -name '*.h' -type f -print` ! 110: echo 'Checking header files:' ! 111: # Note that BSD43_* are used on recent MIPS systems. ! 112: for file in $files; do ! 113: # This call to egrep is essential, since checking a file with egrep ! 114: # is much faster than actually trying to fix it. ! 115: # But the argument to egrep must be kept small, or many versions of egrep ! 116: # won't be able to handle it. ! 117: if egrep '[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then ! 118: echo Fixing $file ! 119: if [ -r $file ]; then ! 120: cp $file $2/$file >/dev/null 2>&1 \ ! 121: || echo "Can't copy $file" ! 122: chmod +w $2/$file ! 123: sed -e ' ! 124: :loop ! 125: /\\$/ N ! 126: /\\$/ b loop ! 127: /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/ ! 128: /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/ ! 129: /#define._IO/ s/'\''x'\''/x/g ! 130: /#define.BSD43__IO/ s/'\''x'\''/x/g ! 131: /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/ ! 132: /#define.CTRL/ s/'\''c'\''/c/g ! 133: /#define._CTRL/ s/'\''c'\''/c/g ! 134: /#define.BSD43_CTRL/ s/'\''c'\''/c/g ! 135: /#[a-z]*if.*[ (]m68k/ s/m68k/__m68k__/g ! 136: /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g ! 137: /#[a-z]*if.*[ (]i386/ s/i386/__i386__/g ! 138: /#[a-z]*if.*[ (]sparc/ s/sparc/__sparc__/g ! 139: /#[a-z]*if.*[ (]mc68000/ s/mc68000/__mc68000__/g ! 140: /#[a-z]*if.*[ (]vax/ s/vax/__vax__/g ! 141: /#[a-z]*if.*[ (]sun3x/ s/sun3x/__sun3x__/g ! 142: /#[a-z]*if.*[ (]sun3/ s/sun3/__sun3__/g ! 143: /#[a-z]*if.*[ (]sun2/ s/sun2/__sun2__/g ! 144: /#[a-z]*if.*[ (]sun4c/ s/sun4c/__sun4c__/g ! 145: /#[a-z]*if.*[ (]sun4/ s/sun4/__sun4__/g ! 146: /#[a-z]*if.*[ (]sun/ s/sun/__sun__/g ! 147: /#[a-z]*if.*[ (]ns32000/ s/ns32000/__ns32000__/g ! 148: /#[a-z]*if.*[ (]pyr/ s/pyr/__pyr__/g ! 149: /#[a-z]*if.*[ (]is68k/ s/is68k/__is68k__/g ! 150: /#[a-z]*if.*[ (]sun386/ s/sun386/__sun386__/g ! 151: /#define.NULL[ ]/ i\ ! 152: #undef NULL ! 153: ' $2/$file > $2/$file.sed ! 154: mv $2/$file.sed $2/$file ! 155: if cmp $file $2/$file >/dev/null 2>&1; then ! 156: echo Deleting $2/$file\; no fixes were needed. ! 157: rm $2/$file ! 158: fi ! 159: fi ! 160: fi ! 161: done ! 162: shift; shift ! 163: done ! 164: ! 165: cd ${INPUT} ! 166: ! 167: # Fix one other error in this file: a mismatched quote not inside a C comment. ! 168: file=sundev/vuid_event.h ! 169: if [ -r $file ]; then ! 170: if [ ! -r ${LIB}/$file ]; then ! 171: cp $file ${LIB}/$file >/dev/null 2>&1 \ ! 172: || echo "Can't copy $file" ! 173: chmod +w ${LIB}/$file ! 174: fi ! 175: fi ! 176: ! 177: if [ -r ${LIB}/$file ]; then ! 178: echo Fixing $file comment ! 179: ex ${LIB}/$file <<EOF ! 180: g/doesn't/s/doesn't/does not/ ! 181: wq ! 182: EOF ! 183: if cmp $file ${LIB}/$file >/dev/null 2>&1; then ! 184: echo Deleting ${LIB}/$file\; no fixes were needed. ! 185: rm ${LIB}/$file ! 186: fi ! 187: fi ! 188: ! 189: # Fix this Sun file to avoid intefering with stddef.h. ! 190: ! 191: file=sys/stdtypes.h ! 192: if [ -r $file ]; then ! 193: if [ ! -r ${LIB}/$file ]; then ! 194: cp $file ${LIB}/$file >/dev/null 2>&1 \ ! 195: || echo "Can't copy $file" ! 196: chmod +w ${LIB}/$file ! 197: fi ! 198: fi ! 199: ! 200: if [ -r ${LIB}/$file ]; then ! 201: echo Fixing $file comment ! 202: ex ${LIB}/$file <<EOF ! 203: /size_t.*;/ ! 204: i ! 205: #ifndef _SIZE_T ! 206: #define _SIZE_T ! 207: . ! 208: /size_t/+1 ! 209: i ! 210: #endif ! 211: . ! 212: /ptrdiff_t.*;/ ! 213: i ! 214: #ifndef _PTRDIFF_T ! 215: #define _PTRDIFF_T ! 216: . ! 217: /ptrdiff_t/+1 ! 218: i ! 219: #endif ! 220: . ! 221: /wchar_t.*;/ ! 222: i ! 223: #ifndef _WCHAR_T ! 224: #define _WCHAR_T ! 225: . ! 226: /wchar_t/+1 ! 227: i ! 228: #endif ! 229: . ! 230: wq ! 231: EOF ! 232: if cmp $file ${LIB}/$file >/dev/null 2>&1; then ! 233: echo Deleting ${LIB}/$file\; no fixes were needed. ! 234: rm ${LIB}/$file ! 235: fi ! 236: fi ! 237: ! 238: # Fix this file to avoid intefering with stddef.h. ! 239: ! 240: file=sys/types.h ! 241: if [ -r $file ]; then ! 242: if [ ! -r ${LIB}/$file ]; then ! 243: cp $file ${LIB}/$file >/dev/null 2>&1 \ ! 244: || echo "Can't copy $file" ! 245: chmod +w ${LIB}/$file ! 246: fi ! 247: fi ! 248: ! 249: if [ -r ${LIB}/$file ]; then ! 250: echo Fixing $file comment ! 251: ex ${LIB}/$file <<EOF ! 252: /size_t.*;/ ! 253: i ! 254: #ifndef _SIZE_T ! 255: #define _SIZE_T ! 256: . ! 257: /size_t/+1 ! 258: i ! 259: #endif ! 260: . ! 261: wq ! 262: EOF ! 263: if cmp $file ${LIB}/$file >/dev/null 2>&1; then ! 264: echo Deleting ${LIB}/$file\; no fixes were needed. ! 265: rm ${LIB}/$file ! 266: fi ! 267: fi ! 268: ! 269: # Fix an error in this file: a missing semi-colon at the end of the statsswtch ! 270: # structure definition. ! 271: file=rpcsvc/rstat.h ! 272: if [ -r $file ]; then ! 273: if [ ! -r ${LIB}/$file ]; then ! 274: cp $file ${LIB}/$file >/dev/null 2>&1 \ ! 275: || echo "Can't copy $file" ! 276: chmod +w ${LIB}/$file ! 277: fi ! 278: fi ! 279: ! 280: if [ -r ${LIB}/$file ]; then ! 281: echo Fixing $file, definition of statsswtch ! 282: ex ${LIB}/$file <<EOF ! 283: g/boottime$/s//&;/ ! 284: wq ! 285: EOF ! 286: if cmp $file ${LIB}/$file >/dev/null 2>&1; then ! 287: echo Deleting ${LIB}/$file\; no fixes were needed. ! 288: rm ${LIB}/$file ! 289: fi ! 290: fi ! 291: ! 292: # Fix an error in this file: a missing semi-colon at the end of the nodeent ! 293: # structure definition. ! 294: file=netdnet/dnetdb.h ! 295: if [ -r $file ]; then ! 296: if [ ! -r ${LIB}/$file ]; then ! 297: cp $file ${LIB}/$file >/dev/null 2>&1 \ ! 298: || echo "Can't copy $file" ! 299: chmod +w ${LIB}/$file ! 300: fi ! 301: fi ! 302: ! 303: if [ -r ${LIB}/$file ]; then ! 304: echo Fixing $file, definition of nodeent ! 305: ex ${LIB}/$file <<EOF ! 306: g/na_addr/s//&;/ ! 307: wq ! 308: EOF ! 309: if cmp $file ${LIB}/$file >/dev/null 2>&1; then ! 310: echo Deleting ${LIB}/$file\; no fixes were needed. ! 311: rm ${LIB}/$file ! 312: fi ! 313: fi ! 314: ! 315: # Check for bad #ifdef line (in Ultrix 4.1) ! 316: ! 317: file=sys/file.h ! 318: if [ -r $file ]; then ! 319: if [ ! -r ${LIB}/$file ]; then ! 320: mkdir ${LIB}/rpcsvc 2>&- ! 321: cp $file ${LIB}/$file >/dev/null 2>&1 \ ! 322: || echo "Can't copy $file" ! 323: chmod +w ${LIB}/$file ! 324: fi ! 325: fi ! 326: ! 327: if [ -r ${LIB}/$file ]; then ! 328: echo Fixing $file, bad \#ifdef line ! 329: ex ${LIB}/$file <<EOF ! 330: g/^#ifdef KERNEL && !defined/ ! 331: s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/ ! 332: wq ! 333: EOF ! 334: if cmp $file ${LIB}/$file >/dev/null 2>&1; then ! 335: echo Deleting ${LIB}/$file\; no fixes were needed. ! 336: rm ${LIB}/$file ! 337: fi ! 338: fi ! 339: ! 340: # Check for superfluous `static' (in Ultrix 4.2) ! 341: ! 342: file=machine/cpu.h ! 343: if [ -r $file ]; then ! 344: if [ ! -r ${LIB}/$file ]; then ! 345: mkdir ${LIB}/machine 2>&- ! 346: cp $file ${LIB}/$file >/dev/null 2>&1 \ ! 347: || echo "Can't copy $file" ! 348: chmod +w ${LIB}/$file ! 349: fi ! 350: fi ! 351: ! 352: if [ -r ${LIB}/$file ]; then ! 353: echo Fixing $file, superfluous static ! 354: ex ${LIB}/$file <<EOF ! 355: g/^static struct tlb_pid_state/ ! 356: s/static// ! 357: wq ! 358: EOF ! 359: if cmp $file ${LIB}/$file >/dev/null 2>&1; then ! 360: echo Deleting ${LIB}/$file\; no fixes were needed. ! 361: rm ${LIB}/$file ! 362: else ! 363: # This file has an alternative name, mips/cpu.h. Fix that name, too. ! 364: if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then ! 365: mkdir ${LIB}/mips 2>&- ! 366: ln ${LIB}/$file ${LIB}/mips/cpu.h ! 367: fi ! 368: fi ! 369: fi ! 370: ! 371: # Deal with yet another challenge, this in X11/Xmu.h ! 372: file=X11/Xmu.h ! 373: if [ -r $file ]; then ! 374: if [ ! -r ${LIB}/$file ]; then ! 375: mkdir ${LIB}/X11 2>&- ! 376: cp $file ${LIB}/$file >/dev/null 2>&1 \ ! 377: || echo "Can't copy $file" ! 378: chmod +w ${LIB}/$file ! 379: fi ! 380: fi ! 381: ! 382: if [ -r ${LIB}/$file ]; then ! 383: echo Fixing $file sprintf declaration ! 384: ex ${LIB}/$file <<EOF ! 385: /^extern char \* sprintf();$/c ! 386: #ifndef __STDC__ ! 387: extern char * sprintf(); ! 388: #endif /* !defined __STDC__ */ ! 389: . ! 390: wq ! 391: EOF ! 392: if cmp $file ${LIB}/$file >/dev/null 2>&1; then ! 393: echo Deleting ${LIB}/$file\; no fixes were needed. ! 394: rm ${LIB}/$file ! 395: fi ! 396: fi ! 397: ! 398: # Check for missing ';' in struct ! 399: ! 400: file=netinet/ip.h ! 401: if [ -r $file ]; then ! 402: if [ ! -r ${LIB}/$file ]; then ! 403: mkdir ${LIB}/netinet 2>&- ! 404: sed -e '/^struct/,/^};/s/}$/};/' $file > ${LIB}/$file ! 405: cmp $file ${LIB}/$file >/dev/null 2>&1 && rm -f ${LIB}/$file ! 406: fi ! 407: fi ! 408: ! 409: # Fix the CAT macro in memvar.h. ! 410: ! 411: file=pixrect/memvar.h ! 412: if [ -r $file ]; then ! 413: if [ ! -r ${LIB}/$file ]; then ! 414: mkdir ${LIB}/pixrect 2>&- ! 415: sed -e '/^#define.CAT(a,b)/ i\ ! 416: #ifdef __STDC__ \ ! 417: #define CAT(a,b) a##b\ ! 418: #else ! 419: /^#define.CAT(a,b)/ a\ ! 420: #endif ! 421: ' $file > ${LIB}/$file ! 422: cmp $file ${LIB}/$file >/dev/null 2>&1 && rm -f ${LIB}/$file ! 423: fi ! 424: fi ! 425: ! 426: # Check for yet more missing ';' in struct (in SunOS 4.0.x) ! 427: ! 428: file=rpcsvc/rusers.h ! 429: if [ -r $file ]; then ! 430: if [ ! -r ${LIB}/$file ]; then ! 431: mkdir ${LIB}/rpcsvc 2>&- ! 432: sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' $file > ${LIB}/$file ! 433: cmp $file ${LIB}/$file >/dev/null 2>&1 && rm -f ${LIB}/$file ! 434: fi ! 435: fi ! 436: ! 437: # Fix return type of exit and abort in <stdlib.h> on SunOS 4.1. ! 438: ! 439: file=stdlib.h ! 440: base=`basename $file` ! 441: if [ -r ${LIB}/$file ]; then ! 442: file_to_fix=${LIB}/$file ! 443: else ! 444: if [ -r ${INPUT}/$file ]; then ! 445: file_to_fix=${INPUT}/$file ! 446: else ! 447: file_to_fix="" ! 448: fi ! 449: fi ! 450: if [ \! -z "$file_to_fix" ]; then ! 451: echo Checking $file_to_fix ! 452: sed 's/int abort/void abort/g' $file_to_fix \ ! 453: | sed 's/int exit/void exit/g' > /tmp/$base ! 454: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ ! 455: echo No change needed in $file_to_fix ! 456: else ! 457: echo Fixed $file_to_fix ! 458: rm -f ${LIB}/$file ! 459: cp /tmp/$base ${LIB}/$file ! 460: fi ! 461: rm -f /tmp/$base ! 462: fi ! 463: ! 464: # Fix bogus comment in <locale.h> on SunOS 4.1. ! 465: ! 466: file=locale.h ! 467: base=`basename $file` ! 468: if [ -r ${LIB}/$file ]; then ! 469: file_to_fix=${LIB}/$file ! 470: else ! 471: if [ -r ${INPUT}/$file ]; then ! 472: file_to_fix=${INPUT}/$file ! 473: else ! 474: file_to_fix="" ! 475: fi ! 476: fi ! 477: if [ \! -z "$file_to_fix" ]; then ! 478: echo Checking $file_to_fix ! 479: sed 's%#endif / \*%#endif /\* %g' $file_to_fix > /tmp/$base ! 480: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ ! 481: echo No change needed in $file_to_fix ! 482: else ! 483: echo Fixed $file_to_fix ! 484: rm -f ${LIB}/$file ! 485: cp /tmp/$base ${LIB}/$file ! 486: fi ! 487: rm -f /tmp/$base ! 488: fi ! 489: ! 490: # Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1. ! 491: ! 492: file=hsfs/hsfs_spec.h ! 493: base=`basename $file` ! 494: if [ -r ${LIB}/$file ]; then ! 495: file_to_fix=${LIB}/$file ! 496: echo Checking $file_to_fix ! 497: sed 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' $file_to_fix > /tmp/$base ! 498: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ ! 499: echo No change needed in $file_to_fix ! 500: else ! 501: echo Fixed $file_to_fix ! 502: rm -f ${LIB}/$file ! 503: cp /tmp/$base ${LIB}/$file ! 504: fi ! 505: rm -f /tmp/$base ! 506: fi ! 507: ! 508: # Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1. ! 509: ! 510: file=hsfs/hsnode.h ! 511: base=`basename $file` ! 512: if [ -r ${LIB}/$file ]; then ! 513: file_to_fix=${LIB}/$file ! 514: echo Checking $file_to_fix ! 515: sed 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' $file_to_fix > /tmp/$base ! 516: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ ! 517: echo No change needed in $file_to_fix ! 518: else ! 519: echo Fixed $file_to_fix ! 520: rm -f ${LIB}/$file ! 521: cp /tmp/$base ${LIB}/$file ! 522: fi ! 523: rm -f /tmp/$base ! 524: fi ! 525: ! 526: # Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1. ! 527: ! 528: file=hsfs/iso_spec.h ! 529: base=`basename $file` ! 530: if [ -r ${LIB}/$file ]; then ! 531: file_to_fix=${LIB}/$file ! 532: echo Checking $file_to_fix ! 533: sed 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' $file_to_fix > /tmp/$base ! 534: if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ ! 535: echo No change needed in $file_to_fix ! 536: else ! 537: echo Fixed $file_to_fix ! 538: rm -f ${LIB}/$file ! 539: cp /tmp/$base ${LIB}/$file ! 540: fi ! 541: rm -f /tmp/$base ! 542: fi ! 543: ! 544: echo 'Removing unneeded directories:' ! 545: cd $LIB ! 546: files=`find . -type d -print | sort -r` ! 547: for file in $files; do ! 548: rmdir $LIB/$file > /dev/null 2>&1 ! 549: done ! 550: ! 551: if $LINKS; then ! 552: echo 'Making internal symbolic non-directory links' ! 553: cd ${INPUT} ! 554: files=`find . -type l -print` ! 555: for file in $files; do ! 556: dest=`ls -ld $file | sed -n 's/.*-> //p'` ! 557: if expr "$dest" : '[^/].*' > /dev/null; then ! 558: target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"` ! 559: if [ -f $target ]; then ! 560: ln -s $dest ${LIB}/$file >/dev/null 2>&1 ! 561: fi ! 562: fi ! 563: done ! 564: fi ! 565: ! 566: exit 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.