1: 2# Glenn Fowler 3# AT&T Research 4# 5# @(#)pp.probe (AT&T Research) 2012-02-29 6# 7# C probe for libpp 8# 9# NOTE: C.probe must be included or .'d here 10# 11 12ppdef=$dir/pp.def 13ppkey=$dir/pp.key 14ppsym=$dir/ppsym 15for f in $ppdef $ppkey $ppsym 16do test -f $f || { echo "$0: $f: not found" >&4; exit 1 ;} 17done 18 19sed -e "/^#/d" -e "s/[ ].*//" < $ppdef > all.pp 20 21system= 22release= 23version= 24architecture= 25cpu= 26model= 27machine= 28undef_predef= 29 30# 31# path cleanup 32# 33 34for i in stdinclude usrinclude 35do eval o='$'$i 36 v=$o 37 case $v in 38 *//*) v=`echo $v | sed 's,///*,/,g'` ;; 39 esac 40 if (test . -ef "`pwd`") 41 then k= 42 for x in $v 43 do case $x in 44 */../*|*/..) 45 case $x in 46 /*) a=/ ;; 47 *) a= ;; 48 esac 49 IFS=/ 50 set '' $x 51 IFS=$ifs 52 r= 53 for d 54 do r="$d $r" 55 done 56 p= 57 g= 58 for d in $r 59 do case $d in 60 ..) g="$g $d" ;; 61 *) case $g in 62 '') case $p in 63 '') p=$d ;; 64 *) p=$d/$p ;; 65 esac 66 ;; 67 *) set $g 68 shift 69 g=$* 70 ;; 71 esac 72 ;; 73 esac 74 done 75 case $a in 76 '') for d in $g 77 do p=$d/$p 78 done 79 ;; 80 *) p=$a$p 81 ;; 82 esac 83 case $p in 84 /) continue ;; 85 esac 86 test $x -ef $p && x=$p 87 ;; 88 esac 89 k="$k $x" 90 done 91 set '' $k 92 shift 93 v=$1 94 case $# in 95 0) ;; 96 *) shift 97 while : 98 do case $# in 99 0) break ;; 100 esac 101 k= 102 for d 103 do for j in $v 104 do test $d -ef $j && continue 2 105 done 106 k="$k $d" 107 done 108 set '' $k 109 case $# in 110 1) break ;; 111 esac 112 shift 113 v="$v $1" 114 shift 115 done 116 ;; 117 esac 118 fi 119 case $v in 120 $o) ;; 121 *) eval $i='$'v ;; 122 esac 123done 124 125id="::IDENT::`date`::IDENT::" 126echo '#assert test(ok) 127#if #test(ok) 128#else 129( 130#endif' > assert.$src 131echo '#ifdef __BASE_FILE__ 132int ok; 133#else 134( 135#endif' > basefile.$src 136cat > catlit1.i <<'!' 137char test[] = "te" 138"st"; 139! 140cat > catlit2.i <<'!' 141char test[] = "te\ 142st"; 143! 144echo '#define g(a,b) a ## b 145volatile int a; 146const int g(x,y)=1; 147extern int c(int);' > compat.$src 148echo > cpp.$src 149echo "#defincl <x.h>" > defincl.$src 150echo 'int a$b;' > dollar.$src 151echo "#eject" > eject.$src 152echo "#if 0 153( 154#else if 1 155int x; 156#else 157( 158#endif" > elseif.$src 159echo "#define _CAT(a,b,c) a##b##c 160#define hdra hdrx 161#define hdr _CAT(<,hdra,.h>) 162#include hdr" > hdra.$src 163echo "#define _XAT(a,b,c) a##b##c 164#define _CAT(a,b,c) _XAT(a,b,c) 165#define hdra hdrx 166#define hdr _CAT(<,hdra,.h>) 167#include hdr" > hdrx.$src 168echo "int f(){return 0;}" > hdrx.h 169echo "#ident \"$id\"" > ident.$src 170echo "#import \"import.h\"" > import.$src 171echo "int aaa;" > import.h 172echo "#include <inc_next.h>" > inc_next.$src 173mkdir inc0 inc1 174echo "#include_next <inc_next.h>" > inc0/inc_next.h 175echo 'char s[] = "INCLUDE_NEXT";' > inc1/inc_next.h 176echo '# 1 "linefile.i" 177 178# 1 "linefile.i" 179 180int i;' > linefile1.i 181echo '# 1 "linefile.i" 182 183# 1 184 185int i;' > linefile2.i 186echo "int i = 0;" > lineid1.i 187echo '# 1 "t.c" 188int i = 0;' > lineid2.i 189echo '# 1 "t.c" 190int i = 0;' > lineid3.$src 191echo "#include <stdio.h>" > linetype.$src 192echo '#include <sys/types.h> 193main() 194{ 195 return sizeof(LONGLONG) != 8; 196}' > longlong.$src 197echo '#include "once.h" 198#include "once.h"' > once.$src 199echo '#ifdef once 200allmultiple 201#else 202#define once 203#endif' > once.h 204echo "extern int a,b;int f(){return a + = b;}" > opspace.$src 205echo "int f(){return(0);} // ((" > pluscom.$src 206echo "class x {int n;} m;" > plusplus.$src 207echo > preinc.$src 208echo '// splice \ 209( 210int x = 1;' > plusspl.$src 211echo "int stdc_default_value = __STDC__ ;" > stdc.$src 212echo 'char xxx[] = "abc 213(";' > span.$src 214echo '#define g(a,b) a\ 215b 216int ab,xy; 217#define xy XY 218char* g(x,y);' > splice.$src 219{ 220echo 'int a\ ' 221echo 'b = 1;' 222} > splicesp.$src 223echo '#define g(a,b) a/**/b 224int g(x,y)=1;' > trans.$src 225echo '#define m 65 226#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 65 227#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 64 228#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 63 229#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 62 230#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 61 231#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 60 232#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 59 233#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 58 234#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 57 235#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 56 236#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 55 237#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 54 238#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 53 239#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 52 240#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 51 241#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50 242#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 49 243#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 48 244#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 47 245#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 46 246#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 45 247#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 44 248#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 43 249#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 42 250#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 41 251#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 40 252#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 39 253#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 38 254#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 37 255#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 36 256#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 35 257#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 34 258#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 33 259#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 32 260#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 31 261#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 30 262#define xxxxxxxxxxxxxxxxxxxxxxxxxxxxx 29 263#define xxxxxxxxxxxxxxxxxxxxxxxxxxxx 28 264#define xxxxxxxxxxxxxxxxxxxxxxxxxxx 27 265#define xxxxxxxxxxxxxxxxxxxxxxxxxx 26 266#define xxxxxxxxxxxxxxxxxxxxxxxxx 25 267#define xxxxxxxxxxxxxxxxxxxxxxxx 24 268#define xxxxxxxxxxxxxxxxxxxxxxx 23 269#define xxxxxxxxxxxxxxxxxxxxxx 22 270#define xxxxxxxxxxxxxxxxxxxxx 21 271#define xxxxxxxxxxxxxxxxxxxx 20 272#define xxxxxxxxxxxxxxxxxxx 19 273#define xxxxxxxxxxxxxxxxxx 18 274#define xxxxxxxxxxxxxxxxx 17 275#define xxxxxxxxxxxxxxxx 16 276#define xxxxxxxxxxxxxxx 15 277#define xxxxxxxxxxxxxx 14 278#define xxxxxxxxxxxxx 13 279#define xxxxxxxxxxxx 12 280#define xxxxxxxxxxx 11 281#define xxxxxxxxxx 10 282#define xxxxxxxxx 9 283#define xxxxxxxx 8 284#define xxxxxxx 7 285#define xxxxxx 6 286#define xxxxx 5 287#define xxxx 4 288#define xxx 3 289#define xx 2 290#define x 1 291#if xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx != m 292xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 293#endif' > truncate.$src 294cat > zeof.c <<'!' 295char* foo = "az"; 296! 297 298allmultiple= 299assert= 300basefile= 301compatibility=1 302defincl= 303dollar= 304eject= 305elseif= 306headerexpand= 307headerexpandall= 308hostedtransition= 309ident= 310import= 311include_next= 312linefile= 313lineid= 314linetype= 315nocatliteral= 316opspace= 317pluscom= 318plusplus= 319plussplice= 320redef= 321reguard= 322reserved= 323spaceout= 324splicecat= 325splicespace= 326strict= 327stringspan= 328transition= 329truncate= 330zeof= 331 332$cc -c assert.$src && assert=1 333 334$cc -c basefile.$src && basefile=__BASE_FILE__ 335 336if $cc -E defincl.$src 337then case "`$cc -E defincl.$src | grep -c 'defincl'`" in 338 0) defincl=1 ;; 339 esac 340fi 341 342if $cc -c catlit1.i 2>e 343then if $cc -c catlit2.i 2>f 344 then if test `wc -c < f` -gt `wc -c < e` 345 then nocatliteral=1 346 fi 347 else nocatliteral=1 348 fi 349fi 350 351$cc -c dollar.$src && dollar=1 352 353$cc -c elseif.$src && elseif=1 354 355if $cc -I. -c hdra.$src 356then headerexpandall=1 357elif $cc -I. -c hdrx.$src 358then headerexpand=1 359fi 360 361if $cc -E eject.$src 362then case "`$cc -E eject.$src | grep -c 'eject'`" in 363 0) eject=1 ;; 364 esac 365fi 366 367$cc -S ident.$src && grep "$id" ident.s && ident=1 368 369{ $cc -E import.$src | grep aaa ;} && import=1 370 371{ $cc -E -Iinc0 -Iinc1 inc_next.$src | grep INCLUDE_NEXT ;} && include_next=1 372 373if $cc -c linefile1.i 374then $cc -c linefile2.i 375 case $? in 376 0) ;; 377 *) linefile=1 ;; 378 esac 379fi 380 381if $cc -c lineid1.i 2>b 382then $cc -c lineid2.i 2>e 383 c=$? 384else $cc -c lineid3.c 2>e 385 c=$? 386fi 387case $c in 3880) case `wc -l < b` in 389 `wc -l < e`) ;; 390 *) lineid=line ;; 391 esac 392 ;; 393*) lineid=line 394 ;; 395esac 396 397if $cc -E linetype.$src | grep '^[ ]*#[ ]*[0123456789]*[ ]*".*"[ ]*[12]' > linetype 398then if grep '^[ ]*#[ ]*[0123456789]*[ ]*".*"[ ]*[12][ ][ ]*3' linetype 399 then linetype=2 400 else linetype=1 401 fi 402fi 403 404{ $cc -E once.$src | grep allmultiple ;} && allmultiple=1 405 406$cc -c plusplus.$src && plusplus=1 407 408$cc -c span.$src && stringspan=1 409 410$cc -c splice.$src && splicecat=1 411 412$cc -c splicesp.$src && splicespace=1 413 414exec < $ppkey 415while read keyword type alternate comment 416do case $keyword in 417 .) break ;; 418 ""|"#") continue ;; 419 esac 420 case $type in 421 ""|".") type= ;; 422 *) type="=$type" ;; 423 esac 424 for pre in '' _ __ 425 do for suf in '' _ __ 426 do case $suf in 427 '') sep= ;; 428 *) sep=. ;; 429 esac 430 case ,,$alternate, in 431 *,$pre$sep$suf,*) 432 key=$pre$keyword$suf 433 undef="$undef $key" 434 echo "int f(){ 435 int $key = 0; 436 return $key; 437} 438#undef $key 439int g(){ 440 int $key = 0; 441 return $key; 442}" > key.$src 443 $cc -c key.$src >/dev/null 2>&1 || reserved="$reserved $key$type" 444 ;; 445 esac 446 done 447 done 448done 449 450$cc -c opspace.$src && opspace=1 451 452case $plusplus in 453"") $cc -c compat.$src && compatibility= 454 $cc -c pluscom.$src && pluscom=1 455 ;; 456esac 457case $plusplus$pluscom in 458?*) $cc -c plusspl.$src || plussplice=1 ;; 459esac 460case $plusplus in 461?*) mkdir reguard 462 cd reguard 463 echo '#include "ptrone.h" 464#include "ptrdef.h" 465int main () { return gt(2,1) + gt(2.0,1.0); }' > ptr.$src 466 echo '#include "ptrone.h" 467template<class T> int gt(T a, T b) { return a > b; }' > ptrdef.$src 468 echo 'template<class T> int gt(T a, T b);' > ptrdef.h 469 echo '/* empty */' > ptrone.h 470 if $cc -E ptr.$src > x.i && $cc x.i 471 then echo '#ifndef _PTRONE_H 472#define _PTRONE_H 473static int xxx; 474#endif' > ptrone.h 475 if $cc -E ptr.$src > x.i && echo "#define _PTRONE_H" >> x.i && $cc x.i 476 then reguard=1 477 fi 478 fi 479 cd .. 480 rm -rf reguard 481 ;; 482esac 483 484stdc=`$cc -E stdc.$src | sed -e '/stdc_default_value/!d' -e 's/.*=[ ]*//' -e 's/[ ]*;.*//'` 485case $stdc in 4860) $cc -c trans.$src && transition=1 ;; 487[0123456789]*) ;; 488*) stdc= ;; 489esac 490 491truncate=`$cc -E truncate.$src | grep '^[ ]*[0123456789]'` 492$cc -c zeof.c || zeof=1 493 494echo "$predef" >> all.pp 495{ 496 case $ppopt$ppenv in 497 ?*) ppcmd=cpp 498 ppdir=. 499 eval $ppenv '$'cc -Dmycpp -E '$'ppopt cpp.$src 500 ;; 501 esac 502 eval set x $probe_verbose 503 shift 504 x= 505 for o in "$@" 506 do set x `$cc $o -c cpp.$src 2>&1` 507 while : 508 do shift 509 case $# in 510 0) break ;; 511 esac 512 case $1 in 513 *[\\/]rm) 514 ;; 515 [\\/]*) case " $x " in 516 *" $1 "*) ;; 517 *) test -x $1 && x="$x $1" ;; 518 esac 519 ;; 520 esac 521 done 522 case $x in 523 ?*) for f in $x 524 do cp $f x && chmod u+w x && strip x && f=x 525 $ppsym < $f 526 done 527 break 528 ;; 529 esac 530 done 531} 3>&- 3>&1 >/dev/null | 532 sed -e '/^ppsymbol$/d' -e '/^.$/d' -e '/^..$/d' -e '/[ABCDEFGHIJKLMNOPQRSTUVWXYZ].*[abcdefghijklmnopqrstuvwxyz]/d' -e '/[abcdefghijklmnopqrstuvwxyz].*[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/d' | 533 cat - all.pp | 534 sort -u | 535 { 536 for i in 0 1 2 3 4 5 537 do echo "struct { char* name; long value; } predef[] = {" > cpp$i.$src 538 done 539 while read sym junk 540 do case $sym in 541 _*) set 0 ${sym} 542 ;; 543 *_) continue 544 ;; 545 [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*) 546 set 1 ${sym} 2 _${sym} 3 _${sym}_ 4 __${sym} 5 __${sym}__ 547 ;; 548 *) continue 549 ;; 550 esac 551 while : 552 do case $# in 553 0|1) break ;; 554 esac 555 { 556 echo "#ifdef $2" 557 echo "\"$2\" , (long) $2 -1," 558 echo "#endif" 559 } >> cpp$1.$src 560 shift 561 shift 562 done 563 done 564 for i in 0 1 2 3 4 5 565 do echo "\"\", 0 };" >> cpp$i.$src 566 done 567 } 568preval="`for i in 0 1 2 3 4 5;do $cc -E cpp$i.$src;done | sed -e '/\".*\".*,.*,/!d' -e 's/[^\"]*\"\\([^\"]*\\)\"[ ]*,[ ]*([ ]*long[ ]*)[ ]*\\(.*\\)[ ]*-[ ]*1[ ]*,[ ]*\$/\\1 \\2 =/g' -e '/\\(^[^ ]*\\) \1 *=$/d'` `$cc -dM -E stdc.$src | sed -e '/[ ]*#[ ]*define/!d' -e '/\"/d' -e 's/[ ]*#[ ]*define[ ]*\\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*([^)]*)\\)[ ]*\\(.*\\)/\\1 \\2 =/' -e 's/[ ]*#[ ]*define[ ]*\\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*\\)[ ]*\\(.*\\)/\\1 \\2 =/'`" 569 print -r "$preval" > /tmp/probe/preval 570 571for i in bufld namei quota reboot utsname vfs 572do echo "#include <sys/$i.h>" > t.$src 573 if $cc -E t.$src 574 then x=1 575 else x=0 576 fi 577 eval sys_$i=$x 578done 579 580echo "char* fun() { return (char*)__FUNCTION__; } 581int main() { return !fun(); }" > fun.$src 582rm -f fun.exe 583if $cc -o fun.exe fun.$src && test -x fun.exe 584then undef_predef="$undef_predef __FUNCTION__" 585fi 586 587case "`grep -c '__STDC__[-0 ]*[=!]=[ ]*0' $usrinclude/stdio.h 2>/dev/null`" in 5880) ;; 589*) hostedtransition=1 ;; 590esac 591 592mapinclude= 593for i in builtins 594do echo "#include <$i.h>" > t.$src 595 if $cc -E t.$src 596 then mapinclude="$mapinclude <$i.h>=\".\"" 597 fi 598done 599 600# 601# the payoff 602# 603 604exec >&3 605 606case "$compatibility:$transition:$dollar" in 607::) strict=1 ;; 608esac 609case $version_stamp in 610?*) echo "/* $version_stamp" ;; 611*) echo "/* $cc" ;; 612esac 613echo "*/" 614case $plusplus:$stdc in 6151:?*) preval="$preval = __STDC__ $stdc =" 616 redef="$redef __STDC__" 617 ;; 618esac 619ppbuiltin=0 620set x $preval 621shift 622case $# in 6230) ;; 624*) echo 625 echo "#pragma pp:predefined" 626 predef= 627 while : 628 do case $# in 629 0) break ;; 630 esac 631 m=$1 632 shift 633 case $m in 634 *'('*) i=`echo "$m" | sed 's,(.*,,'` ;; 635 *) i=$m ;; 636 esac 637 predef="$predef 638$i" 639 eval predef_$i=0 640 while : 641 do case $1 in 642 '=') break ;; 643 *) shift ;; 644 esac 645 done 646 while : 647 do case $1 in 648 '=') shift ;; 649 *) break ;; 650 esac 651 done 652 done 653 for i in $undef 654 do case " $redef " in 655 *" $i "*) ;; 656 *) eval predef_$i=3 ;; 657 esac 658 done 659 set $preval 660 while : 661 do case $# in 662 0) break ;; 663 esac 664 m=$1 665 shift 666 case $m in 667 *'('*) i=`echo "$m" | sed 's,(.*,,'` ;; 668 *) i=$m ;; 669 esac 670 case $i in 671 '=') continue ;; 672 esac 673 v= 674 while : 675 do case $1 in 676 '=') break ;; 677 esac 678 v="$v $1" 679 shift 680 done 681 while : 682 do case $1 in 683 '=') shift ;; 684 *) break ;; 685 esac 686 done 687 case $i in 688 __LCC__)strict=2 ;; 689 _*) ;; 690 *) eval j=\$predef_$i 691 case $j in 692 0) eval predef_$i=1 693 echo "#define $m$v" 694 case $strict in 695 1) strict= ;; 696 esac 697 ;; 698 esac 699 ;; 700 esac 701 done 702 nopredef=0 703 while : 704 do set $preval 705 while : 706 do case $# in 707 0) break ;; 708 esac 709 m=$1 710 shift 711 case $m in 712 *'('*) i=`echo "$m" | sed 's,(.*,,'` ;; 713 *) i=$m ;; 714 esac 715 v= 716 while : 717 do case $1 in 718 '=') break ;; 719 esac 720 v="$v $1" 721 shift 722 done 723 while : 724 do case $1 in 725 '=') shift ;; 726 *) break ;; 727 esac 728 done 729 case $m in 730 __*_BIT__|__*_DIG__|__*_MIN__|__*_MAX__|__*_TYPE__|*_FLT_*|*_DBL_*|*_LDBL_*) 731 case $nopredef in 732 0) nopredef=1 733 continue 734 ;; 735 1) continue 736 ;; 737 esac 738 ;; 739 esac 740 case $nopredef in 741 2) ;; 742 *) case $v in 743 ' '*' '*) 744 nopredef=1 745 continue 746 ;; 747 ' '[0123456789]*|' '"'"*"'"*) 748 ;; 749 *) case $1 in 750 _*) ;; 751 *) nopredef=1 752 continue 753 ;; 754 esac 755 ;; 756 esac 757 ;; 758 esac 759 eval j=\$predef_$i 760 case $j in 761 0) case $ppbuiltin in 762 2) echo "#pragma pp:builtin" 763 ppbuiltin=1 764 ;; 765 esac 766 eval predef_$i=2 767 echo "#define $m$v" 768 ;; 769 1) case $m in 770 $i) eval predef_$i=2 771 eval j=\$predef___${i}__ 772 case $j in 773 [12]) ;; 774 *) case $ppbuiltin in 775 2) echo "#pragma pp:builtin" 776 ppbuiltin=1 777 ;; 778 esac 779 eval predef___${i}__=2 780 echo "#define __${i}__$v" 781 ;; 782 esac 783 ;; 784 esac 785 ;; 786 esac 787 done 788 case $nopredef in 789 2) break ;; 790 esac 791 echo "#pragma pp:nopredefined" 792 case $nopredef in 793 0) break ;; 794 esac 795 ppbuiltin=2 796 nopredef=2 797 done 798 ;; 799esac 800case $basefile in 801?*) case $ppbuiltin in 802 0|2) ppbuiltin=1 803 echo "#pragma pp:builtin" 804 ;; 805 esac 806 echo "#define $basefile #(BASE)" 807 ;; 808esac 809case $ppbuiltin in 8101) echo "#pragma pp:nobuiltin" ;; 811esac 812 813eval set x $probe_longlong 814shift 815x= 816for o in "$@" 817do rm -f longlong.$exe 818 if $cc -DLONGLONG="$o" -o longlong.$exe longlong.$src && 819 ./longlong.$exe 820 then x=1 821 break 822 fi 823done 824case $x in 825'') eval set x $probe_longlong_t 826 shift 827 for o in "$@" 828 do rm -f longlong.$exe 829 if $cc -DLONGLONG="$o" -o longlong.$exe longlong.$src && 830 ./longlong.$exe 831 then echo "#define <long long> $o" 832 break 833 fi 834 done 835 ;; 836esac 837 838echo 839for i in `echo "$predef" | sed -e 's/^__*\(.*\)_*\$/\1/' -e '/^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*[0123456789][abcdefghijklmnopqrstuvwxyz0123456789]*\$/!d'` `echo "$predef" | sed -e 's/^__*\(.*\)_*\$/\1/' -e '/^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*\$/!d'` 840do case $i in 841 *ix) ;; 842 *) architecture=$i 843 break 844 ;; 845 esac 846done 847for i in `sed -e '/^#/d' -e '/:architecture:/!d' -e 's/[ ].*//' < $ppdef` 848do eval j="\" \$predef_$i \$predef__${i} \$predef__${i}_ \$predef___${i} \$predef___${i}__ \"" 849 case $j in 850 *" 2 "*)architecture=$i 851 break 852 ;; 853 esac 854done 855for i in `sed -e '/^#/d' -e '/:machine:/!d' -e 's/[ ].*//' < $ppdef` 856do eval j="\" \$predef_$i \$predef__${i} \$predef__${i}_ \$predef___${i} \$predef___${i}__ \"" 857 case $j in 858 *" 2 "*)machine="$machine $i" ;; 859 esac 860done 861case $sys_bufld$sys_reboot$sys_utsname in 8621??) release=research 863 version=9 864 ;; 86501?) release=bsd 866 case $sys_quota in 867 0) case $sys_vfs in 868 0) version=4.1 869 ;; 870 esac 871 ;; 872 1) case $sys_namei in 873 0) version=4.2 874 ;; 875 1) version=4.3 876 ;; 877 esac 878 ;; 879 esac 880 ;; 881001) release=V 882 ;; 883esac 884for i in `sed -e '/^#/d' -e '/:release:/!d' -e 's/[ ].*//' < $ppdef` 885do eval j=\$predef_$i 886 case $j in 887 2) release="$release $i" ;; 888 esac 889done 890for i in `sed -e '/^#/d' -e '/:system:/!d' -e 's/[ ].*//' < $ppdef` 891do eval j=\$predef_$i 892 case $j in 893 2) system="$system $i" ;; 894 esac 895done 896case $release in 897topix) release="$release V" 898 ;; 899esac 900case $assert in 901?*) for i in $predef 902 do case $i in 903 _*|*_) ;; 904 *) for p in architecture cpu machine system 905 do echo "#if #$p($i) 906eval \"case \\\" \$$p \\\" in *\\\" $i \\\"*) ;; *) $p=\\\"$i \$$p\\\" ;; esac\" 907: avoid string literal concatenation 908#endif" 909 done 910 ;; 911 esac 912 done > t.$src 913 eval "`$cc -E t.$src`" 914 set x x $prepred 915 while : 916 do shift 917 shift 918 case $# in 919 [01]) break ;; 920 esac 921 eval " 922 case \" \$$1 \" in 923 *\" $2 \"*) ;; 924 *) $1=\"$2 \$$1\" ;; 925 esac 926 " 927 done 928 ;; 929esac 930case $system in 931"") system=unix ;; 932esac 933case $architecture in 934ibm|uts|u370) model=370 935 architecture=ibm 936 ;; 937m*68*) architecture=m68000 938 for i in $predef 939 do case $i in 940 m*68*[123456789][0123456789]) 941 model=`echo $i | sed 's/.*\(..\)/\1/'` 942 break 943 ;; 944 esac 945 done 946 ;; 947u3b?*) model=`echo $architecture | sed 's/u3b//'` 948 architecture=3b 949 ;; 950u3b) case $model in 951 "") model=20 ;; 952 esac 953 architecture=3b 954 ;; 955vax[0123456789]*) 956 model=`echo $architecture | sed 's/vax//'` 957 architecture=vax 958 ;; 959hp[0123456789]*s[0123456789]) 960 case $release in 961 [abcdefghijklmnopqrstuvwxyz]*.[abcdefghijklmnopqrstuvwxyz]*.*) 962 version=$release 963 release=V 964 ;; 965 esac 966 architecture="$architecture `echo $architecture | sed 's/s.*//'`" 967 ;; 968esac 969case $hosttype in 970*.*) i=`echo $hosttype | sed -e 's,.*\.,,'` ;; 971*) i=$hosttype ;; 972esac 973case $i in 974unknown);; 975?*) case " $architecture " in 976 *" $i "*) ;; 977 *) architecture="$architecture $i" ;; 978 esac 979 ;; 980esac 981case $architecture in 982"") echo "$cc: warning: architecture not determined" >&4 983 set x $machine 984 architecture=$2 985 ;; 986esac 987echo "#define #hosttype($hosttype)" 988for i in $system 989do echo "#define #system($i)" 990done 991case $release in 992"") echo "#define #release()" ;; 993*) for i in $release 994 do echo "#define #release($i)" 995 case $i in 996 V) echo "#define #release(system5)" ;; # compatibility 997 esac 998 done 999 ;; 1000esac 1001echo "#define #version($version)" 1002case $architecture in 1003"") echo "#define #architecture()" ;; 1004*) for i in `echo $architecture | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` 1005 do echo "#define #architecture($i)" 1006 done 1007 ;; 1008esac 1009echo "#define #model($model)" 1010case $machine in 1011"") case $architecture:$model in 1012 ?*:?*) set x $architecture; machine="$2/$model $architecture" ;; 1013 *) machine=$architecture ;; 1014 esac 1015 ;; 1016*) machine="$machine $architecture" 1017 ;; 1018esac 1019case $machine in 1020"") echo "#define #machine()" ;; 1021*) j= 1022 for i in `echo $machine | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` 1023 do case " $i " in 1024 *" $j "*) 1025 ;; 1026 *) j="$j $i" 1027 echo "#define #machine($i)" 1028 ;; 1029 esac 1030 done 1031 ;; 1032esac 1033for i in $cpu 1034do echo "#define #cpu($i)" 1035done 1036echo "#define #addressing()" 1037for i in $ATTRIBUTES 1038do eval d=\$$i 1039 n=`echo $i | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` 1040 echo "#define #$n($d)" 1041done 1042case $stdc in 1043?*) echo "#define #dialect(ansi)" ;; 1044esac 1045case $plusplus in 1046?*) echo "#define #dialect(C++)" ;; 1047esac 1048case $hosted in 1049"") echo "#define #dialect(cross)" ;; 1050esac 1051case $so:$dynamic:$static in 1052::) ;; 1053*) echo "#define #dialect(dynamic)" ;; 1054esac 1055echo 1056case $undef_predef in 1057?*) for m in $undef_predef 1058 do echo "#undef $m" 1059 done 1060 echo 1061 ;; 1062esac 1063case $plusplus in 1064?*) echo "#pragma pp:plusplus" ;; 1065esac 1066case $reserved in 1067?*) echo "#pragma pp:reserved" $reserved ;; 1068esac 1069case $nocatliteral in 1070?*) echo "#pragma pp:nocatliteral" ;; 1071esac 1072case $opspace in 1073?*) echo "#pragma pp:opspace" ;; 1074esac 1075case $pluscom in 1076?*) echo "#pragma pp:pluscomment" ;; 1077esac 1078case $plussplice in 1079?*) echo "#pragma pp:plussplice" ;; 1080esac 1081case $reguard in 1082?*) echo "#pragma pp:reguard" ;; 1083esac 1084case $splicecat in 1085?*) echo "#pragma pp:splicecat" ;; 1086esac 1087case $splicespace in 1088?*) echo "#pragma pp:splicespace" ;; 1089esac 1090case $stringspan in 1091?*) echo "#pragma pp:stringspan" ;; 1092esac 1093case $stdc in 1094"") echo "#pragma pp:compatibility" 1095 ;; 10960) echo "#pragma pp:transition" 1097 ;; 10981) case $strict in 1099 ?*) echo "#pragma pp:strict" ;; 1100 esac 1101 ;; 1102esac 1103case $hostedtransition in 11041) echo "#pragma pp:hostedtransition" ;; 1105esac 1106case $stdc in 1107?*) case $ppopt$ppenv in 1108 "") spaceout=1 1109 echo "#pragma pp:spaceout" 1110 ;; 1111 esac 1112 ;; 1113esac 1114case $truncate in 1115?*) echo "#pragma pp:truncate $truncate" ;; 1116esac 1117case $zeof in 1118?*) echo "#pragma pp:zeof" ;; 1119esac 1120case $dollar in 11211) echo '#pragma pp:id "$"' ;; 1122esac 1123cdir=-I+C 1124hdir=-I+H 1125set x $stdinclude 1126while : 1127do shift 1128 case $# in 1129 0) break ;; 1130 esac 1131 case $1 in 1132 $cdir|$hdir) 1133 ;; 1134 -I+C) cdir=$1 1135 echo "#pragma pp:nocdir" 1136 ;; 1137 -I-C) cdir=$1 1138 echo "#pragma pp:cdir" 1139 ;; 1140 -I+H) hdir=$1 1141 echo "#pragma pp:nohostdir" 1142 ;; 1143 -I-H) hdir=$1 1144 echo "#pragma pp:hostdir" 1145 ;; 1146 -I*) ;; 1147 *) echo "#pragma pp:include \"$1\"" 1148 ;; 1149 esac 1150done 1151case $usrinclude in 1152/usr/include) 1153 ;; 1154?*) echo "#pragma pp:standard \"$usrinclude\"" 1155 ;; 1156esac 1157case $plusplus in 1158?*) case $usrinclude in 1159 ?*) if grep plusplus $usrinclude/ctype.h >/dev/null 2>&1 1160 then echo '#pragma pp:nocdir "-"' 1161 fi 1162 ;; 1163 esac 1164 ;; 1165esac 1166case $mapinclude in 1167?*) echo "#pragma pp:mapinclude hosted$mapinclude" ;; 1168esac 1169case $linefile in 1170?*) echo "#pragma pp:linefile" ;; 1171esac 1172case $lineid in 1173?*) echo "#pragma pp:lineid line" ;; 1174esac 1175case $linetype in 11761) echo "#pragma pp:linetype" ;; 1177?*) echo "#pragma pp:linetype $linetype" ;; 1178esac 1179case $allmultiple in 1180"") echo "#pragma pp:noallmultiple" ;; 1181esac 1182case $defincl in 11831) echo '#pragma pp:map "/#(pragma )?defincl>/"' ;; 1184esac 1185case $eject in 11861) echo '#pragma pp:map "/#(pragma )?eject>/"' ;; 1187esac 1188case $elseif in 11891) echo "#pragma pp:elseif" ;; 1190esac 1191case $headerexpand in 11921) echo "#pragma pp:headerexpand" ;; 1193esac 1194case $headerexpandall in 11951) echo "#pragma pp:headerexpandall" ;; 1196esac 1197case $ident in 11981) echo '#pragma pp:map "/#(pragma )?ident>/" "/#(pragma )?/###/"' ;; 1199*) echo '#pragma pp:map "/#(pragma )?ident>/"' ;; 1200esac 1201case $import in 12021) echo '#pragma pp:map "/#(pragma )?import>/" "/#(pragma )?import(.*)/__STDPP__IMPORT__(\2)/" 1203#macdef __STDPP__IMPORT__(x) 1204#pragma pp:noallmultiple 1205#include x 1206#pragma pp:allmultiple 1207#endmac' ;; 1208esac 1209case $include_next in 12101) echo '#pragma pp:map "/#include_next>/" ",[^\<]*\<,#include <.../,"' ;; 1211esac 1212echo '#pragma pp:map "/#pragma lint:/" ",#pragma lint:(.*),##/*\1*/,u"' 1213echo '#pragma pp:map "/#(pragma )?sccs>/"' 1214 1215case $stdc:$spaceout in 12161:) case ' '$reserved' ' in 1217 *' 'asm' '*|*' 'asm=*) 1218 echo "#macdef asm" 1219 echo "#pragma pp:spaceout" 1220 echo "#undef asm" 1221 echo "asm" 1222 echo "#endmac" 1223 ;; 1224 esac 1225 ;; 1226esac 1227 1228if $cc -E preinc.$src > preinc.out 1229then for f in `sed -e 's,\\\\,/,g' -e 's,"[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]:/,"/,g' -e '/^#[line ]*[0123456789][0123456789]*[ ][ ]*"[\\/]/!d' -e 's/^#[line ]*[0123456789][0123456789]*[ ][ ]*".*[\\/]\(.*\)".*/\1/' preinc.out | sort -u` 1230 do case $f in 1231 *preinc.$src*) 1232 ;; 1233 *) echo "#include <$f>" 1234 ;; 1235 esac 1236 done 1237fi 1238