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