iffe.sh 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401
  1. ########################################################################
  2. # #
  3. # This software is part of the ast package #
  4. # Copyright (c) 1994-2012 AT&T Intellectual Property #
  5. # Copyright (c) 2020-2022 Contributors to ksh 93u+m #
  6. # and is licensed under the #
  7. # Eclipse Public License, Version 2.0 #
  8. # #
  9. # A copy of the License is available at #
  10. # https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html #
  11. # (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) #
  12. # #
  13. # Glenn Fowler <gsf@research.att.com> #
  14. # Martijn Dekker <martijn@inlv.org> #
  15. # Johnothan King <johnothanking@protonmail.com> #
  16. # #
  17. ########################################################################
  18. # Glenn Fowler & Phong Vo
  19. # AT&T Research
  20. #
  21. # test if feature exists
  22. # this script is written to make it through POSIX sh variants
  23. #
  24. # NOTE: .exe a.out suffix and [\\/] in path patterns for DOS/NT
  25. case ${ZSH_VERSION+z} in
  26. z) emulate ksh ;;
  27. *) (command set -o posix) 2>/dev/null && set -o posix ;;
  28. esac
  29. case $HOSTTYPE in
  30. ibm.*) unset LIBPATH ;; # AIX: avoid failure to link to libiconv
  31. esac
  32. set -o noglob
  33. command=iffe
  34. version=2022-01-09
  35. compile() # $cc ...
  36. {
  37. "$@" 2>$tmp.err
  38. _compile_status=$?
  39. if test -s $tmp.err
  40. then cat $tmp.err >&2
  41. fi
  42. if test "$_compile_status" -gt 128
  43. then echo "$command: $@" >&$stderr
  44. cat $tmp.err >&$stderr
  45. sig=$(kill -l "$_compile_status")
  46. case $sig in
  47. [!0-9]?*)
  48. echo "$command: $1: terminated by SIG$sig" ;;
  49. *) echo "$command: $1: fatal interruption ($_compile_status)" ;;
  50. esac >&$stderr
  51. exit $_compile_status
  52. fi
  53. return $_compile_status
  54. }
  55. is_hdr() # [ - ] [ file.c ] hdr
  56. {
  57. case $1 in
  58. -) _is_hdr_flag=-; shift ;;
  59. *) _is_hdr_flag= ;;
  60. esac
  61. case $1 in
  62. *.c) _is_hdr_file=$1; shift ;;
  63. *) _is_hdr_file=$tmp.c ;;
  64. esac
  65. is hdr $1
  66. compile $cc -c $_is_hdr_file <&$nullin >&$nullout 2>$tmp.e
  67. _is_hdr_status=$?
  68. case $_is_hdr_status in
  69. 0) if test -s $tmp.e
  70. then case $(grep '#.*error' $tmp.e) in
  71. ?*) _is_hdr_status=1 ;;
  72. esac
  73. fi
  74. ;;
  75. esac
  76. case $_is_hdr_status in
  77. 0) success $_is_hdr_flag
  78. ;;
  79. *) case $debug in
  80. 3) cat $tmp.e >&$stderr ;;
  81. esac
  82. failure $_is_hdr_flag
  83. ;;
  84. esac
  85. return $_is_hdr_status
  86. }
  87. pkg() # package
  88. {
  89. case $1 in
  90. '') # Determine default system path, store in $pth.
  91. pth=$(
  92. PATH=/run/current-system/sw/bin:/usr/xpg7/bin:/usr/xpg6/bin:/usr/xpg4/bin:/bin:/usr/bin:$PATH
  93. exec getconf PATH 2>/dev/null
  94. )
  95. case $pth in
  96. '' | [!/]* | *:[!/]* | *: )
  97. pth="/bin /usr/bin /sbin /usr/sbin" ;;
  98. *:*) pth=$(echo "$pth" | sed 's/:/ /g') ;;
  99. esac
  100. # Fix for NixOS. Not all POSIX standard utilities come with the default system,
  101. # e.g. 'bc', 'file', 'vi'. The command that NixOS recommends to get missing
  102. # utilities, e.g. 'nix-env -iA nixos.bc', installs them in a default profile
  103. # directory that is not in $(getconf PATH). So add this path to the standard path.
  104. # See: https://github.com/NixOS/nixpkgs/issues/65512
  105. if test -e /etc/NIXOS &&
  106. nix_profile_dir=/nix/var/nix/profiles/default/bin &&
  107. test -d "$nix_profile_dir"
  108. then case " $pth " in
  109. *" $nix_profile_dir "* )
  110. # nothing to do
  111. ;;
  112. * ) # insert the default profile directory as the second entry
  113. pth=$(
  114. set $pth
  115. one=$1
  116. shift
  117. echo "$one $nix_profile_dir${1+ }$@"
  118. ) ;;
  119. esac
  120. fi
  121. # Fix for AIX. At least as of version 7.1, the system default 'find', 'diff -u' and 'patch' utilities
  122. # are broken and/or non-compliant in ways that make them incompatible with POSIX 2018. However, GNU
  123. # utilities are commonly installed in /opt/freeware/bin, and under standard names (no g- prefix).
  124. if test -d /opt/freeware/bin
  125. then case $(uname) in
  126. AIX ) pth="/opt/freeware/bin $pth" ;;
  127. esac
  128. fi
  129. return
  130. ;;
  131. '<') shift
  132. ;;
  133. *) return
  134. ;;
  135. esac
  136. case $1 in
  137. X|X11*) i="openwin"
  138. case $1 in
  139. X) set X11 ;;
  140. esac
  141. case $1 in
  142. X11) case $# in
  143. 1) set $1 6 5 4 ;;
  144. esac
  145. ;;
  146. esac
  147. ;;
  148. *) i=
  149. ;;
  150. esac
  151. pth="{ usr . - . contrib local $i - . share - . lib - $1"
  152. i=$1
  153. while :
  154. do shift
  155. case $# in
  156. 0) break ;;
  157. esac
  158. case $1 in
  159. '>') shift; break ;;
  160. esac
  161. pth="$pth ${i}R$1 ${i}.$1"
  162. done
  163. pth="$pth . } $*"
  164. }
  165. show_test()
  166. {
  167. case $shell in
  168. ksh) print -n - "$command: test: $* ..." ;;
  169. *) printf '%s: test: %s ...' "$command" "$*" ;;
  170. esac
  171. case $debug in
  172. 0) ;;
  173. *) echo ;; # when debugging, add newline before compiler error messages
  174. esac
  175. } >&$stderr
  176. is() # op name
  177. {
  178. case $verbose in
  179. 1) case $complete in
  180. 1) failure ;;
  181. esac
  182. oo=$1
  183. shift
  184. case $1 in
  185. ?*) yy=is
  186. ii=$1
  187. complete=1
  188. case $oo in
  189. cmd) mm="a command" ;;
  190. dat) mm="a library data symbol" ;;
  191. dfn) mm="a macro with extractable value" ;;
  192. exp) mm="true" ;;
  193. hdr) mm="a header" ;;
  194. id) mm="an identifier" ;;
  195. lcl) mm="a native header" ;;
  196. key) mm="a reserved keyword" ;;
  197. lib) mm="a library function" ;;
  198. LIB) case $2 in
  199. "") mm="a library" ;;
  200. *) ii=$*; mm="a library group" ;;
  201. esac
  202. ;;
  203. mac) mm="a macro" ;;
  204. mem) mm="a member of $2" ;;
  205. mth) mm="a math library symbol" ;;
  206. nos) mm="a non-opaque struct" ;;
  207. npt) mm="a symbol that needs a prototype" ;;
  208. num) mm="a numeric constant or enum" ;;
  209. nxt) mm="an include path for the native header" ;;
  210. opt) mm="set in \$PACKAGE_OPTIONS" ;;
  211. pth) mm="a file" ;;
  212. run) yy="capture output of" mm= ;;
  213. siz) mm="a type with known size" ;;
  214. sym) mm="a typed variable" ;;
  215. sys) mm="a system header" ;;
  216. typ) mm="a type or typedef" ;;
  217. val) yy="determine" mm="value" ;;
  218. *) yy= mm= ;;
  219. esac
  220. case $ii in
  221. [abcdefghijklmnopqrstuvwxyz]*[abcdefghijklmnopqrstuvwxyz]'{') ii="$ii ... }end" ;;
  222. esac
  223. show_test $yy $ii $mm
  224. complete=1
  225. ;;
  226. esac
  227. ;;
  228. esac
  229. }
  230. success()
  231. {
  232. case $1 in
  233. -) shift
  234. ;;
  235. *) case $result in
  236. UNKNOWN) result=SUCCESS ;;
  237. esac
  238. case $1 in
  239. +) return ;;
  240. esac
  241. ;;
  242. esac
  243. case $complete:$verbose in
  244. 1:1) case $suspended in
  245. 1) suspended=0
  246. show_test $yy $ii $mm
  247. ;;
  248. esac
  249. complete=0
  250. case $# in
  251. 0) mm="yes" ;;
  252. *) mm="'$*'" ;;
  253. esac
  254. case $debug in
  255. 0) echo " $mm" >&$stderr ;;
  256. *) echo "$command: ... $mm" >&$stderr ;;
  257. esac
  258. ;;
  259. esac
  260. }
  261. failure()
  262. {
  263. case $1 in
  264. -) shift ;;
  265. *) result=FAILURE
  266. case $1 in
  267. +) return ;;
  268. esac
  269. ;;
  270. esac
  271. case $complete:$verbose in
  272. 1:1) case $suspended in
  273. 1) suspended=0
  274. show_test $yy $ii $mm
  275. ;;
  276. esac
  277. complete=0
  278. case $group in
  279. '') case $# in
  280. 0) mm="no" ;;
  281. *) mm=$* ;;
  282. esac
  283. ;;
  284. *) mm=
  285. ;;
  286. esac
  287. case $debug in
  288. 0) echo " $mm" >&$stderr ;;
  289. *) echo "$command: ... $mm" >&$stderr ;;
  290. esac
  291. ;;
  292. esac
  293. }
  294. # report
  295. #
  296. # - ignore global status
  297. # -0 normal sense
  298. # -1 inverted sense if ! def
  299. # status test status 0:success *:failure
  300. # success success comment
  301. # failure failure comment
  302. # default default setting comment
  303. #
  304. # globals
  305. #
  306. # $not invert test sense
  307. # $M test variable
  308. # $m test macro
  309. # $v default macro
  310. report() # [-] [-0] [-1] status value success failure default
  311. {
  312. case $1 in
  313. -) _report_ignore=$1
  314. shift
  315. ;;
  316. *) _report_ignore=
  317. ;;
  318. esac
  319. _report_not=$not
  320. case $1 in
  321. -0) shift
  322. ;;
  323. -1) shift
  324. case $def in
  325. ''|-) case $_report_not in
  326. 1) _report_not= ;;
  327. *) _report_not=1 ;;
  328. esac
  329. ;;
  330. esac
  331. ;;
  332. esac
  333. _report_status=$1
  334. case $_report_ignore:$_report_status in
  335. -:*) ;;
  336. *:0) success $_report_ignore
  337. ;;
  338. *) failure $_report_ignore
  339. case $group in
  340. ?*) return ;;
  341. esac
  342. ;;
  343. esac
  344. _report_value=$2
  345. case $_report_not in
  346. 1) case $_report_status in
  347. 0) _report_status=1 ;;
  348. *) _report_status=0 ;;
  349. esac
  350. _report_success=$4
  351. _report_failure=$3
  352. ;;
  353. *) _report_success=$3
  354. _report_failure=$4
  355. ;;
  356. esac
  357. _report_default=$5
  358. case $_report_status in
  359. 0) case $M in
  360. *-*) ;;
  361. *) usr="$usr$nl#define $m $_report_value"
  362. case $_report_success in
  363. ''|-) ;;
  364. *) case $define in
  365. 1) echo "#define $m $_report_value /* $_report_success */" ;;
  366. n) echo "$m=$_report_value"
  367. esac
  368. ;;
  369. esac
  370. eval $m=\'$_report_value\'
  371. ;;
  372. esac
  373. ;;
  374. *) case $M in
  375. *-*) ;;
  376. *) case $_report_failure in
  377. ''|-) ;;
  378. *) case $define$all$config$undef in
  379. 1?1?|1??1)echo "#undef $m /* $_report_failure */" ;;
  380. 11??) echo "#define $m 0 /* $_report_failure */" ;;
  381. n1?1) echo "$m=" ;;
  382. n1??) echo "$m=0" ;;
  383. esac
  384. ;;
  385. esac
  386. case $_report_default in
  387. ''|-) ;;
  388. *) case $define$set in
  389. 1?*) echo "#define $v $set /* $_report_default */" ;;
  390. n?*) echo "$v=$set" ;;
  391. esac
  392. ;;
  393. esac
  394. eval $m=0
  395. ;;
  396. esac
  397. ;;
  398. esac
  399. }
  400. noisy()
  401. {
  402. case $complete:$verbose in
  403. 1:1) suspended=1
  404. echo >&$stderr
  405. ;;
  406. esac
  407. }
  408. copy() # "output-file" "data-that-must-not-be-processed-by-echo"
  409. {
  410. # Some ksh88 clones (pdksh, mksh) lack 'printf' as a built-in utility, so if a
  411. # ksh-type shell was detected, use the 'print' built-in for better performance.
  412. case $1 in
  413. -) case $shell in
  414. ksh) print -r - "$2"
  415. ;;
  416. *) printf '%s\n' "$2"
  417. ;;
  418. esac
  419. ;;
  420. *) case $shell in
  421. ksh) print -r - "$2"
  422. ;;
  423. *) printf '%s\n' "$2"
  424. ;;
  425. esac > "$1"
  426. ;;
  427. esac
  428. }
  429. # verify that cc is a C compiler
  430. checkcc()
  431. {
  432. # check for local package root directories
  433. case $PACKAGE_PATH in
  434. ?*) for i in $(echo $PACKAGE_PATH | sed 's,:, ,g')
  435. do if test -d $i/include
  436. then cc="$cc -I$i/include"
  437. occ="$occ -I$i/include"
  438. fi
  439. if test -d $i/lib
  440. then cc="$cc -L$i/lib"
  441. occ="$occ -L$i/lib"
  442. for y in $libpaths
  443. do eval $y=\"\$$y:\$i/lib\$${y}_default\"
  444. eval export $y
  445. done
  446. fi
  447. done
  448. ;;
  449. esac
  450. echo "int i = 1;" > $tmp.c
  451. if compile $cc -c $tmp.c <&$nullin >&$nullout
  452. then echo "(;" > $tmp.c
  453. if compile $cc -c $tmp.c <&$nullin >&$nullout
  454. then cctest="should not compile '(;'"
  455. fi
  456. else cctest="should compile 'int i = 1;'"
  457. fi
  458. case $cctest in
  459. "") cctest=0
  460. ;;
  461. *) echo "$command: $cc: not a C compiler: $cctest" >&$stderr
  462. exit 1
  463. ;;
  464. esac
  465. }
  466. execute()
  467. {
  468. case $verbose in
  469. 0) noteout=$nullout ;;
  470. *) noteout=$stderr ;;
  471. esac
  472. if test "" != "$cross"
  473. then crossexec $cross "$@" 9>&$noteout
  474. _execute_=$?
  475. elif test -d /NextDeveloper
  476. then "$@" <&$nullin >&$nullout 9>&$noteout
  477. _execute_=$?
  478. "$@" <&$nullin | cat
  479. else "$@" 9>&$noteout
  480. _execute_=$?
  481. fi
  482. return $_execute_
  483. }
  484. exclude()
  485. {
  486. case $excludes in
  487. '') return 0 ;;
  488. esac
  489. for _exclude_var
  490. do eval _exclude_old=\$$_exclude_var
  491. case $_exclude_old in
  492. *" -I"*);;
  493. *) continue ;;
  494. esac
  495. _exclude_new=
  496. _exclude_sep=
  497. for _exclude_arg in $_exclude_old
  498. do _exclude_skip=
  499. for _exclude_dir in $excludes
  500. do case $_exclude_arg in
  501. -I$_exclude_dir|-I*/$_exclude_dir)
  502. _exclude_skip=1
  503. break;
  504. ;;
  505. esac
  506. done
  507. case $_exclude_skip in
  508. '') _exclude_new="$_exclude_new$_exclude_sep$_exclude_arg"
  509. _exclude_sep=" "
  510. ;;
  511. esac
  512. done
  513. eval $_exclude_var=\$_exclude_new
  514. case $debug in
  515. 0) ;;
  516. *) echo $command: exclude $_exclude_var: "$_exclude_old => $_exclude_new" >&$stderr
  517. ;;
  518. esac
  519. done
  520. }
  521. all=0
  522. apis=
  523. binding="-dy -dn -Bdynamic -Bstatic -Wl,-ashared -Wl,-aarchive -call_shared -non_shared '' -static"
  524. complete=0
  525. config=0
  526. defhdr=
  527. define=1
  528. explicit=0
  529. iff=
  530. usr=
  531. cross=
  532. debug=0
  533. deflib=
  534. dir=FEATURE
  535. excludes=
  536. executable="test -x"
  537. exists="test -e"
  538. gothdr=
  539. gotlib=
  540. idno=
  541. idyes=
  542. ifs=${IFS-'
  543. '}
  544. in=
  545. includes=
  546. intrinsic=
  547. libpaths="DYLD_LIBRARY_PATH LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARY64_PATH LIBPATH SHLIB_PATH"
  548. DYLD_LIBRARY_PATH_default=:/lib:/usr/lib
  549. LD_LIBRARY_PATH_default=:/lib:/usr/lib
  550. LD_LIBRARYN32_PATH_default=:/lib32:/usr/lib32
  551. LD_LIBRARY64_PATH_default=:/lib64:/usr/lib64
  552. LIBPATH_default=:/lib:/usr/lib
  553. SHLIB_PATH_default=:/shlib:/usr/shlib:/lib:/usr/lib
  554. nl="
  555. "
  556. optimize=1
  557. occ=cc
  558. one=
  559. out=
  560. puthdr=
  561. putlib=
  562. pragma=
  563. shell=posix
  564. case $(eval 'PATH=/dev/null && let i=93-5 && typeset -u v=ksh$i && print -r - "$v"' 2>/dev/null) in
  565. KSH88) shell=ksh ;; # also pdksh, mksh, zsh
  566. esac
  567. reallystatic=
  568. reallystatictest=
  569. regress=
  570. static=.
  571. statictest=
  572. case $COTEMP in
  573. "") case $HOSTNAME in
  574. ""|?|??|???|????|????)
  575. tmp=${HOSTNAME}
  576. ;;
  577. *) tmp=${HOSTNAME%${HOSTNAME#????}}
  578. ;;
  579. esac
  580. tmp=${tmp}$$
  581. ;;
  582. *) tmp=x${COTEMP}
  583. ;;
  584. esac
  585. COTEMP=${tmp}
  586. export COTEMP
  587. case $tmp in
  588. ./*) ;;
  589. ??????????*)
  590. tmp=${tmp%${tmp#?????????}}
  591. ;;
  592. ?????????)
  593. ;;
  594. ????????)
  595. tmp=F$tmp
  596. ;;
  597. esac
  598. case $tmp in
  599. ./*) ;;
  600. *) tmp=./$tmp ;;
  601. esac
  602. undef=0
  603. verbose=0
  604. vers=
  605. # options -- `-' for output to stdout otherwise usage
  606. case $1 in
  607. -) out=-; shift ;;
  608. esac
  609. set=
  610. case $( (getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null ) in
  611. 0123) USAGE=$'
  612. [-?
  613. @(#)$Id: iffe (ksh 93u+m) '${version}$' $
  614. ]
  615. [-author?Glenn Fowler <gsf@research.att.com>]
  616. [-author?Phong Vo <kpv@research.att.com>]
  617. [-copyright?(c) 1994-2012 AT&T Intellectual Property]
  618. [-copyright?(c) 2020-2021 Contributors to https://github.com/ksh93/ksh]
  619. [-license?https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html]
  620. [+NAME?iffe - C compilation environment feature probe]
  621. [+DESCRIPTION?\biffe\b is a command interpreter that probes the C
  622. compilation environment for features. A feature is any file, option
  623. or symbol that controls or is controlled by the C compiler. \biffe\b
  624. tests features by generating and compiling C programs and observing
  625. the behavior of the C compiler and generated programs.]
  626. [+?\biffe\b statements are line oriented. Statements may appear in the
  627. operand list with the \b:\b operand or \bnewline\b as the line
  628. delimiter. The standard input is read if there are no command
  629. line statements or if \afile\a\b.iffe\b is omitted.]
  630. [+?Though similar in concept to \bautoconf\b(1) and \bconfig\b(1), there
  631. are fundamental differences. The latter tend to generate global
  632. headers accessed by all components in a package, whereas \biffe\b is
  633. aimed at localized, self contained feature testing.]
  634. [+?Output is generated in \bFEATURE/\b\atest\a by default, where \atest\a is
  635. the base name of \afile\a\b.iffe\b or the \biffe\b \brun\b
  636. file operand. Output is first generated in a temporary file; the
  637. output file is updated if it does not exist or if the temporary file
  638. is different. If the first operand is \b-\b then the output is written
  639. to the standard output and no update checks are done.]
  640. [+?Files with suffixes \b.iffe\b and \b.iff\b are assumed to contain
  641. \biffe\b statements.]
  642. [a:all?Define failed test macros \b0\b. By default only successful test macros
  643. are defined \b1\b.]
  644. [c:cc?Sets the C compiler name and flags to be used in the feature
  645. tests.]:[C-compiler-name [C-compiler-flags ...]]]
  646. [C:config?Generate \bconfig\b(1) style \aHAVE_\a* macro names. This implies
  647. \b--undef\b. Since \bconfig\b(1) has inconsistent naming conventions,
  648. the \bexp\b op may be needed to translate from the (consistent)
  649. \biffe\b names. Unless otherwise noted a \bconfig\b macro name
  650. is the \biffe\b macro name prefixed with \bHAVE\b and converted to
  651. upper case. \b--config\b is set by default if the command arguments
  652. contain a \brun\b op on an input file with the base name \bconfig\b.]
  653. [d:debug?Sets the debug level. Level 0 inhibits most
  654. error messages, level 1 shows compiler messages, and
  655. level 2 traces internal \biffe\b \bsh\b(1) actions and does
  656. not remove core dumps on exit.]#[level]
  657. [D:define?Successful test macro definitions are emitted. This is the default.]
  658. [E:explicit?Disable implicit test output.]
  659. [F:features?Sets the feature test header to \ahdr\a. This header typically
  660. defines *_SOURCE feature test macros.]:[hdr:=NONE]
  661. [i:input?Sets the input file name to \afile\a, which
  662. must contain \biffe\b statements.]:[file]
  663. [I:include?Adds \b-I\b\adir\a to the C compiler flags.]:[dir]
  664. [L:library?Adds \b-L\b\adir\a to the C compiler flags.]:[dir]
  665. [n:name-value?Output \aname\a=\avalue\a assignments only.]
  666. [N!:optimize?\b--nooptimize\b disables compiler optimization options.]
  667. [o:output?Sets the output file name to \afile\a.]:[file]
  668. [O:stdio?Sets the standard io header to \ahdr\a.]:[hdr:=stdio.h]
  669. [e:package?Obsolete; ignored.]
  670. [p:prototyped?Obsolete; ignored.]
  671. [P:pragma?Emits \b#pragma\b \atext\a at the top of the output file.]:[text]
  672. [r:regress?Massage output for regression testing.]
  673. [s:shell?Sets the internal shell name to \aname\a. Used for debugging
  674. Bourne shell compatibility (otherwise \biffe\b uses \aksh\a constructs
  675. if available). The supported names are \bksh\b, \bbsh\b, \bbash\b, and
  676. \bosh\b. \bosh\b forces the \bread -r\b compatibility read command to
  677. be compiled and used instead of \bread -r\b. The default is determined
  678. by probing the shell at startup.]:[name]
  679. [S:static?Sets the C compiler flags that force static linking. If not set
  680. then \biffe\b probes the compiler to determine the flags. \biffe\b
  681. must use static linking (no dlls) because on some systems missing
  682. library symbols are only detected when referenced at runtime from
  683. dynamically linked executables.]:[flags]
  684. [u:undef?\b#undef\b failed test macros. By default only successful test macros
  685. are defined \b1\b.]
  686. [v:verbose?Produce a message line on the standard error for each test as
  687. it is performed.]
  688. [x:cross?Some tests compile an executable (\ba.out\b) and then run it.
  689. If the C compiler is a cross compiler and the executable format is
  690. incompatible with the execution environment then the generated
  691. executables must be run in a different environment, possibly on
  692. another host. \acrosstype\a is the HOSTTYPE for generated executables
  693. (the \bpackage\b(1) command generates a consistent HOSTTYPE namespace).
  694. Generated executables are run via \bcrossexec\b(1) with \acrosstype\a
  695. as the first argument. \bcrossexec\b supports remote execution for
  696. cross-compiled executables. See \bcrossexec\b(1) for
  697. details.]:[crosstype]
  698. [X:exclude?Removes \b-I\b\adir\a and \b-I\b*/\adir\a C compiler flags.]:[dir]
  699. [ - ] [ file.iffe | statement [ : statement ... ] ]
  700. [+SYNTAX?\biffe\b input consists of a sequence of statement lines. Statements
  701. that span more than one line contain \abegin\a\b{\b as the last
  702. operand (where \abegin\a is command specific) and zero
  703. or more data lines terminated by a line containing
  704. \b}end\b as the first operand. The statement syntax is:
  705. [\aname\a \b=\b]] [\b!\b]] \atest\a[,\atest\a...]] [\b-\b]]
  706. [\aarg\a[,\aarg\a...]]]] [\aprereq\a ...]]
  707. [\abegin\a{ ... |\bend\b ...]] [= [\adefault\a]]]].
  708. \atest\as and \aarg\as may be combined, separated by commas, to perform
  709. a set of tests on a set of arguments. \aname\a \b=\b before \atest\a
  710. overrides the default test variable and macro name, and \b-\b after
  711. \atest\a performs the test but does not define the test variable and
  712. macro values. \b!\b before \atest\a inverts the test sense for \bif\b,
  713. \belif\b, and \byes{\b and \bno{\b blocks.]
  714. [+?\aprereq\as are used when applying the features tests and may be
  715. combinations of:]{
  716. [+compiler options?\b-D\b*, \b-L\b*, etc.]
  717. [+library references?\b-l\b*, *\b.a\b, etc. \b_LIB_\b\aname\a
  718. is defined to be 1 if \b-l\b\aname\a is a library.]
  719. [+header references?*\b.h\b. \a_dir_name\a is defined to be 1
  720. if \adir/name\a\b.h\b is a header, or if \adir\a is
  721. omitted, \b_hdr_\b\aname\a is defined to be 1 if
  722. \aname\a\b.h\b is a header.]
  723. [+-?Prereq grouping mark; prereqs before the first \b-\b are
  724. passed to all feature tests. Subsequent groups
  725. are attempted in left-to-right order until the first
  726. successful group is found.]
  727. }
  728. [+?\abegin\a\b{\b ... \b}end\b delimit multiline code blocks that override
  729. or augment the default code provided by \biffe\b. User supplied code
  730. blocks should be compatible with the C89/C90 C language
  731. standard for maximal portability. Test code may call the function
  732. \bNOTE("...")\b to emit short text in \b--verbose\b output; only one
  733. \bNOTE()\b should be called per test for readability. In addition to
  734. all macro definitions generated by previous tests, all generated
  735. code contains the following at the top:]{
  736. [+ ?/* AST backwards compatibility macros */]
  737. [+ ?#define _NIL_(x) ((x)0)]
  738. [+ ?#define _STD_ 1]
  739. [+ ?#define _ARG_(x) x]
  740. [+ ?#define _VOID_ void]
  741. [+ ?#define _BEGIN_EXTERNS_]
  742. [+ ?#define _END_EXTERNS_]
  743. [+ ?/* if/when available, "$INSTALLROOT/src/lib/libast/FEATURE/standards" is included here */]
  744. [+ ?/* then <stdio.h> is included, unless this was disabled using the "stdio" option */]
  745. }
  746. [+?= \adefault\a may be specified for the \bkey\b, \blib\b, \bmac\b, \bmth\b
  747. and \btyp\b tests. If the test fails for \aarg\a then
  748. \b#define\b \aarg\a \adefault\a is emitted. \bkey\b accepts multiple
  749. \b= \b\adefault\a values; the first valid one is used.]
  750. [+?Each test statement generates a portion of a C language header that contains
  751. macro definitions, comments, and other text corresponding to the feature
  752. tests. \b#ifndef _def_\b\aname\a\b_\b\adirectory\a ...
  753. \b#endif\b guards the generated header from multiple \b#include\bs,
  754. where \aname\a is determined by either the \brun\b statement input file
  755. name if any, or the first \atest\a in the first statement, and \adirectory\a
  756. is the basename component of either the \brun\b statement file, if any,
  757. or the current working directory. The output file name is determined
  758. in this order:]{
  759. [+-?If the first command line operand is \b-\b then the output
  760. is written to the standard output.]
  761. [+--output=\afile\a?Output is \afile\a.]
  762. [+set out \afile\a?Output is \afile\a.]
  763. [+[run]] [\adirectory\a/]]\abase\a[\a.suffix\a]]?Output is
  764. \bFEATURE/\b\abase\a.]
  765. }
  766. [+?Generated \biffe\b headers are often referenced in C source as:
  767. \b#include "FEATURE/\b\afile\a". The \bnmake\b(1) base rules contain
  768. metarules for generating \bFEATURE/\b\afile\a from
  769. \bfeatures/\b\afile\a[\asuffix\a]], where \asuffix\a may be omitted,
  770. \b.c\b, or \b.sh\b (see the \brun\b test below). Because
  771. \b#include\b prerequisites are automatically detected, \bnmake\b(1)
  772. ensures that all prerequisite \biffe\b headers are generated before
  773. compilation. Note that the directories are deliberately named
  774. \bFEATURE\b and \bfeatures\b to keep case-ignorant file systems
  775. happy.]
  776. [+?The feature tests are:]{
  777. [+# \acomment\a?Comment line - ignored.]
  778. [+api \aname\a \aYYYYMMDD\a \asymbol ...\a?Emit API compatibility tests
  779. for \aname\a and \b#define\b \asymbol\a \asymbol\a_\aYYYYMMDD\a
  780. when \aNAME\a_API is >= \aYYYYMMDD\a (\aNAME\a is \aname\a
  781. converted to upper case). If \aNAME\a_API is not defined
  782. then \asymbol\a maps to the newest \aYYYYMMDD\a for \aname\a.]
  783. [+define \aname\a [ (\aarg,...\a) ]] [ \avalue\a ]]?Emit a macro
  784. \b#define\b for \aname\a if it is not already defined. The
  785. definition is passed to subsequent tests.]
  786. [+extern \aname\a \atype\a [ (\aarg,...\a) | [\adimension\a]] ]]?Emit
  787. an \bextern\b prototype for \aname\a if one is not already
  788. defined. The prototype is passed to subsequent tests.]
  789. [+header \aheader\a?Emit \b#include <\b\aheader\a\b>\b if \aheader\a
  790. exists. The \b#include\b is passed to subsequent tests.]
  791. [+print \atext\a?Copy \atext\a to the output file. \atext\a is passed
  792. to subsequent tests.]
  793. [+reference \aheader\a?If \aheader\a exists then add \b#include\b
  794. \aheader\a to subsequent tests.]
  795. [+ver \aname\a \aYYYYMMDD\a?\b#define\b \aNAME\a_VERSION \aYYYYMMDD\a
  796. (\aNAME\a is \aname\a converted to upper case).]
  797. [+cmd \aname\a?Defines \b_cmd_\b\aname\a if \aname\a is an executable
  798. in one of the standard system directories
  799. (as output by \bgetconf PATH\b).
  800. \b_\b\adirectory\a\b_\b\aname\a is defined for \adirectory\a
  801. in which \aname\a is found (with \b/\b translated to \b_\b).]
  802. [+dat \aname\a?Defines \b_dat_\b\aname\a if \aname\a is a data symbol
  803. in the default libraries.]
  804. [+def \aname\a?Equivalent to \bcmd,dat,hdr,key,lib,mth,sys,typ\b
  805. \aname\a.]
  806. [+dfn \aname\a?If \aname\a is a macro in the candidate headers then
  807. a \b#define\b \aname\a \avalue\a statement is output for the
  808. \avalue\a defined in the headers. The definition is \b#ifndef\b
  809. guarded.]
  810. [+exp \aname\a \aexpression\a?If \aexpression\a is a \"...\" string
  811. then \aname\a is defined to be the string, else if the
  812. \bexpr\b(1) evaluation of \aexpression\a is not 0 then \aname\a
  813. is defined to be 1, otherwise \aname\a is defined to be 0.
  814. Identifiers in \aexpression\a may be previously defined names
  815. from other \biffe\b tests; undefined names evaluate to 0.
  816. If \aname\a was defined in a previous successful test then
  817. the current and subsequent \bexp\b test on \aname\a are
  818. skipped. If \aname\a is \b-\b then the \aexpression\a is
  819. simply evaluated.]
  820. [+hdr \aname\a?Defines \b_hdr_\b\aname\a if the header
  821. \b<\b\aname\a\b.h>\b exists. The \b--config\b macro name is
  822. \bHAVE_\b\aNAME\a\b_H\b.]
  823. [+if \astatement\a ... | \belif\b \astatement\a ... | \belse\b | \bendif\b?
  824. Nested if-else test control.]
  825. [+iff \aname\a?The generated header \b#ifndef-#endif\b macro guard is
  826. \b_\b\aname\a\b_H\b.]
  827. [+inc \afile\a [ re ]]?Read #define macro names from \afile\a
  828. and arrange for those names to evaluate to 1 in \bexp\b
  829. expressions. If \are\a is specified then macros not matching
  830. \are\a are ignored.]
  831. [+key \aname\a?Defines \b_key_\b\aname\a if \aname\a is a reserved
  832. word (keyword).]
  833. [+lcl \aname\a?Generates a \b#include\b statement for the native version
  834. of the header \b<\b\aname\a\b.h>\b if it exists. Defines
  835. \b_lcl_\b\aname\a on success. The \b--config\b macro name is
  836. \bHAVE_\b\aNAME\a\b_H\b. The default \are\a is \b^HAVE_\b
  837. for \b--config\b and \b^_\b otherwise.]
  838. [+lib \aname\a?Defines \b_lib_\b\aname\a if \aname\a is an external
  839. symbol in the default libraries.]
  840. [+mac \aname\a?Defines \b_mac_\b\aname\a if \aname\a is a macro.]
  841. [+mem \astruct.member\a?Defines \b_mem_\b\amember\a\b_\b\astruct\a
  842. if \amember\a is a member of the structure \astruct\a.]
  843. [+mth \aname\a?Defines \b_mth_\b\aname\a if \aname\a is an external
  844. symbol in the math library.]
  845. [+nop \aname\a?If this is the first test then \aname\a may be used
  846. to name the output file and/or the output header guard macro.
  847. Otherwise this test is ignored.]
  848. [+npt \aname\a?Defines \b_npt_\b\aname\a if the \aname\a symbol
  849. requires a prototype. The \b--config\b macro name is
  850. \bHAVE_\aNAME\a\b_DECL\b with the opposite sense.]
  851. [+num \aname\a?Defines \b_num_\b\aname\a if \aname\a is a numeric
  852. constant \aenum\a or \amacro\a.]
  853. [+nxt \aname\a?Defines a string macro \b_nxt_\b\aname\a suitable for
  854. a \b#include\b statement to include the next (on the include
  855. path) or native version of the header \b<\b\aname\a\b.h>\b
  856. if it exists. Also defines the \"...\" form
  857. \b_nxt_\b\aname\a\b_str\b. The \b--config\b macro name is
  858. \bHAVE_\b\aNAME\a\b_NEXT\b.]
  859. [+one \aheader\a ...?Generates a \b#include\b statement for the first
  860. header found in the \aheader\a list.]
  861. [+opt \aname\a?Defines \b_opt_\b\aname\a if \aname\a is a space-separated
  862. token in the global environment variable \bPACKAGE_OPTIONS\b.]
  863. [+pth \afile\a [ \adir\a ... | { \ag1\a - ... - \agn\a } | < \apkg\a [\aver\a ...]] > ]]?Defines
  864. \b_pth_\b\afile\a, with embedded \b/\b chars translated to
  865. \b_\b, to the path of the first instance of \afile\a in the
  866. \adir\a directories. \b{\b ... \b}\b forms a directory list
  867. from the cross-product of \b-\b separated directory groups
  868. \ag1\a ... \agn\a. < ... > forms a directory list for the
  869. package \apkg\a with optional versions. If no operands are
  870. specified then the default PATH directories are used. The
  871. \b--config\b macro name is \aNAME\a\b_PATH\b.]
  872. [+run \afile\a?Runs the tests in \afile\a based on the \afile\a
  873. suffix:]{
  874. [+.c?\afile\a is compiled and executed and the output is copied
  875. to the \biffe\b output file. Macros and headers supplied
  876. to \bbegin{\b ... \b}end\b are also supplied to
  877. \afile\a.]
  878. [+.sh?\afile\a is executed as a shell script and the output is
  879. copied to the \biffe\b output file.]
  880. [+.iffe \bor no suffix?\afile\a contains \biffe\b
  881. statements.]
  882. }
  883. [+set \aoption value\a?Sets option values. The options are described
  884. above.]
  885. [+siz \aname\a?Defines \b_siz_\b\aname\a to be \bsizeof\b(\aname\a) if
  886. \aname\a is a type in any of \b<sys/types.h>, <times.h>,
  887. <stddef.h>, <stdlib.h>\b. Any \b.\b characters in \aname\a are
  888. translated to space before testing and are translated to \b_\b
  889. in the output macro name.]
  890. [+sym \aname\a?Defines \b_ary_\b\aname\a if \aname\a is an array,
  891. \b_fun_\b\aname\a if \aname\a is a function pointer,
  892. \b_ptr_\b\aname\a if \aname\a is a pointer, or
  893. \b_reg_\b\aname\a if \aname\a is a scalar. In most cases
  894. \aname\a is part of a macro expansion.]
  895. [+sys \aname\a?Defines \b_sys_\b\aname\a if the header
  896. \b<sys/\b\aname\a\b.h>\b exists. The \b--config\b macro name is
  897. \bHAVE_SYS_\b\aNAME\a\b_H\b.]
  898. [+tst \aname\a?A user defined test on name. A source block must be
  899. supplied. Defines \b_\b\aname\a on success. \btst - ...\b is
  900. treated as \btst - - ...\b.]
  901. [+typ \aname\a?Defines \b_typ_\b\aname\a if \aname\a is a type in any
  902. of \b<sys/types.h>, <times.h>, <stddef.h>, <stdlib.h>\b. Any
  903. \b.\b characters in \aname\a are translated to space before
  904. testing and are translated to \b_\b in the output macro name.]
  905. [+val \aname\a?The output of \becho\b \aname\a is written to the
  906. output file.]
  907. [+var \aname\a?A user defined test on name. A source block must be
  908. supplied. Sets the \bexp\b variable \b_\b\aname\a on success
  909. but does not define a macro.]
  910. [+(\aexpression\a)?Equivalent to \bexp -\b \aexpression\a.]
  911. }
  912. [+?Code block names may be prefixed by \bno\b to invert the test sense. The
  913. block names are:]{
  914. [+cat?The block is copied to the output file.]
  915. [+compile?The block is compiled (\bcc -c\b).]
  916. [+cross?The block is executed as a shell script using \bcrossexec\b(1)
  917. if \b--cross\b is on, or on the local host otherwise, and the
  918. output is copied to the output file. Test macros are not
  919. exported to the script.]
  920. [+execute?The block is compiled, linked, and executed. \b0\b exit
  921. status means success.]
  922. [+fail?If the test fails then the block text is evaluated by
  923. \bsh\b(1) in \biffe\b'\'$'s current shell environment.
  924. Changes in the shell state, such as variables, will survive the block.
  925. Standard input is redirected to \b/dev/null\b.
  926. Standard output is copied to the output file.
  927. Standard error may be used to log informative or error messages.
  928. The block may use \bexit\b to abort the \biffe\b run.]
  929. [+link?The block is compiled and linked (\bcc -o\b).]
  930. [+macro?The block is preprocessed (\bcc -E\b) and lines containing
  931. text bracketed by \b<<"\b ... \b">>\b (\aless-than\a \aless-than\a
  932. \adouble-quote\a ... \adouble-quote\a \agreater-than\a \agreater-than\a)
  933. are copied to the output file with the brackets omitted.]
  934. [+no?If the test fails then the block text is copied to the
  935. output file. Deprecated: use { \bif\b \belif\b \belse\b
  936. \bendif\b } with unnamed \b{\b ... \b}\b blocks.]
  937. [+note?If the test succeeds then the block is copied to the output
  938. as a \b/*\b ... \b*/\b comment.]
  939. [+output?The block is compiled, linked, and executed, and the output
  940. is copied to the output file.]
  941. [+pass?If the test succeeds then the block text is evaluated by
  942. \bsh\b(1) in the same manner as \bfail\b above.]
  943. [+preprocess?The block is preprocessed (\bcc -E\b).]
  944. [+run?The block is executed as a shell script and the output is
  945. copied to the output file. Successful test macros are also
  946. defined as shell variables with value \b1\b and are available
  947. within the block. Likewise, failed test macros are defined
  948. as shell variables with value \b0\b.]
  949. [+status?The block is compiled, linked, and executed, and the exit
  950. status is the test outcome, 0 for \afailure\a, the value
  951. otherwise.]
  952. [+yes?If the test succeeds then the block text is copied to the output
  953. file. \byes{\b ... \b}end\b is equivalent to the unnamed block
  954. \b{\b ... \b}\b. Deprecated: use { \bif\b \belif\b \belse\b
  955. \bendif\b } with unnamed \b{\b ... \b}\b blocks.]
  956. }
  957. [+SEE ALSO?\bautoconf\b(1), \bconfig\b(1), \bgetconf\b(1), \bcrossexec\b(1),
  958. \bnmake\b(1), \bpackage\b(1), \bsh\b(1)]
  959. '
  960. while getopts -a "$command" "$USAGE" OPT
  961. do case $OPT in
  962. a) set="$set set all :" ;;
  963. c) set="$set set cc $OPTARG :" ;;
  964. C) set="$set set config :" ;;
  965. d) set="$set set debug $OPTARG :" ;;
  966. D) set="$set set define :" ;;
  967. E) set="$set set explicit :" ;;
  968. F) set="$set set features $OPTARG :" ;;
  969. i) set="$set set input $OPTARG :" ;;
  970. I) set="$set set include $OPTARG :" ;;
  971. L) set="$set set library $OPTARG :" ;;
  972. n) set="$set set namval $OPTARG :" ;;
  973. N) set="$set set nooptimize $OPTARG :" ;;
  974. o) set="$set set output $OPTARG :" ;;
  975. e) ;; # obsolete
  976. p) ;; # obsolete
  977. P) set="$set set pragma $OPTARG :" ;;
  978. r) set="$set set regress :" ;;
  979. s) set="$set set shell $OPTARG :" ;;
  980. S) set="$set set static $OPTARG :" ;;
  981. O) set="$set set stdio $OPTARG :" ;;
  982. u) set="$set set undef :" ;;
  983. v) set="$set set verbose :" ;;
  984. x) set="$set set cross $OPTARG :" ;;
  985. X) set="$set set exclude $OPTARG :" ;;
  986. esac
  987. done
  988. shift $((OPTIND - 1))
  989. ;;
  990. *) while :
  991. do case $# in
  992. 0) break ;;
  993. esac
  994. case $1 in
  995. -) break
  996. ;;
  997. --) shift
  998. break
  999. ;;
  1000. --a|--al|--all)
  1001. REM=a
  1002. ;;
  1003. --cc=*) REM=c$(echo X$1 | sed 's,[^=]*=,,')
  1004. ;;
  1005. --co|--con|--conf|--confi|--config)
  1006. REM=C
  1007. ;;
  1008. --cr=*|--cro=*|--cros=*|--cross=*)
  1009. REM=x$(echo X$1 | sed -e 's,[^=]*=,,')
  1010. ;;
  1011. --d=*|--de=*|--deb=*|--debu=*|--debug=*)
  1012. REM=d$(echo X$1 | sed 's,[^=]*=,,')
  1013. ;;
  1014. --def|--defi|--defin|--define)
  1015. REM=D
  1016. ;;
  1017. --e=*|--ex=*|--exc=*|--excl=*|--exclu=*|--exclud=*|--exclude=*)
  1018. REM=X$(echo X$1 | sed 's,[^=]*=,,')
  1019. ;;
  1020. --e|--ex|--exp|--expl|--expli|--explic|--explici|--explicit)
  1021. REM=E
  1022. ;;
  1023. --f=*|--fe=*|--fea=*|--feat=*|--featu=*|--featur=*|--feature=*|--features=*)
  1024. REM=F$(echo X$1 | sed 's,[^=]*=,,')
  1025. ;;
  1026. --inp=*|--inpu=*|--input=*)
  1027. REM=i$(echo X$1 | sed 's,[^=]*=,,')
  1028. ;;
  1029. --inc=*|--incl=*|--inclu=*|--includ=*|--include=*)
  1030. REM=I$(echo X$1 | sed 's,[^=]*=,,')
  1031. ;;
  1032. --l=*|--li=*|--lib=*|--libr=*|--libra=*|--librar=*|--library=*)
  1033. REM=L$(echo X$1 | sed 's,[^=]*=,,')
  1034. ;;
  1035. --n|--na|--nam|--name|--name-v|--name-va|--name-val|--name-valu|--name-value)
  1036. REM=n
  1037. ;;
  1038. --o=*|--ou=*|--out=*|--outp=*|--outpu=*|--output=*)
  1039. REM=o$(echo X$1 | sed 's,[^=]*=,,')
  1040. ;;
  1041. --pa=*|--pac=*|--pack=*|--packa=*|--packag=*|--package=*)
  1042. # obsolete
  1043. ;;
  1044. --pro|--prot|--proto|--protot|--prototy|--prototyp|--prototype|--prototyped)
  1045. # obsolete
  1046. ;;
  1047. --pra=*|--prag=*|--pragma=*)
  1048. REM=P$(echo X$1 | sed 's,[^=]*=,,')
  1049. ;;
  1050. --r|--re|--reg|--regre|--regres|--regress)
  1051. REM=r
  1052. ;;
  1053. --sh=*|--she=*|--shel=*|--shell=*)
  1054. REM=s$(echo X$1 | sed 's,[^=]*=,,')
  1055. ;;
  1056. --sta=*|--stat=*|--stati=*|--static=*)
  1057. REM=S$(echo X$1 | sed 's,[^=]*=,,')
  1058. ;;
  1059. --std=*|--stdi=*|--stdio=*)
  1060. REM=O$(echo X$1 | sed 's,[^=]*=,,')
  1061. ;;
  1062. --u|--un|--und|--unde|--undef)
  1063. REM=u
  1064. ;;
  1065. --v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
  1066. REM=v
  1067. ;;
  1068. --*) echo $command: $1: unknown option >&2
  1069. exit 2
  1070. ;;
  1071. -*) REM=$(echo X$1 | sed 's,X-,,')
  1072. ;;
  1073. *) break
  1074. ;;
  1075. esac
  1076. shift
  1077. while :
  1078. do case $REM in
  1079. '') break ;;
  1080. esac
  1081. eval $(echo $REM | sed "s,\(.\)\(.*\),OPT='\1' REM='\2',")
  1082. case $OPT in
  1083. [cdFiILoOePsSxX])
  1084. case $REM in
  1085. '') case $# in
  1086. 0) echo $command: -$OPT: option argument expected >&2
  1087. exit 1
  1088. ;;
  1089. esac
  1090. OPTARG=$1
  1091. shift
  1092. ;;
  1093. *) OPTARG=$REM
  1094. REM=''
  1095. ;;
  1096. esac
  1097. esac
  1098. case $OPT in
  1099. a) set="$set set all :" ;;
  1100. c) set="$set set cc $OPTARG :" ;;
  1101. C) set="$set set config :" ;;
  1102. d) set="$set set debug $OPTARG :" ;;
  1103. D) set="$set set define :" ;;
  1104. E) set="$set set explicit :" ;;
  1105. F) set="$set set features $OPTARG :" ;;
  1106. i) set="$set set input $OPTARG :" ;;
  1107. I) set="$set set include $OPTARG :" ;;
  1108. L) set="$set set library $OPTARG :" ;;
  1109. n) set="$set set namval $OPTARG :" ;;
  1110. N) set="$set set nooptimize $OPTARG :" ;;
  1111. o) set="$set set output $OPTARG :" ;;
  1112. e) ;; # obsolete
  1113. p) ;; # obsolete
  1114. P) set="$set set pragma $OPTARG :" ;;
  1115. r) set="$set set regress :" ;;
  1116. s) set="$set set shell $OPTARG :" ;;
  1117. S) set="$set set static $OPTARG :" ;;
  1118. O) set="$set set stdio $OPTARG :" ;;
  1119. u) set="$set set undef :" ;;
  1120. v) set="$set set verbose :" ;;
  1121. x) set="$set set cross $OPTARG :" ;;
  1122. X) set="$set set exclude $OPTARG :" ;;
  1123. *) echo "Usage: $command [-aCDEnpruv] [-c C-compiler-name [C-compiler-flags ...]] [-d level]
  1124. [-F features-header] [-i file] [-o file] [-O stdio-header] [-e name] [-P text]
  1125. [-s shell-path] [-S[flags]] [-x cross-exec-prefix] [-I dir] [-L dir] [-X dir] [ - ]
  1126. [ file.iffe | statement [ : statement ... ] ]" >&2
  1127. exit 2
  1128. ;;
  1129. esac
  1130. done
  1131. done
  1132. ;;
  1133. esac
  1134. case $1 in
  1135. -) out=-; shift ;;
  1136. esac
  1137. case $# in
  1138. 0) in=- ;;
  1139. esac
  1140. set -- $set "$@"
  1141. case " $* " in
  1142. *' set config '*|*' run config.'*|*' run '*' config.'*|*' run '*'/config.'*)
  1143. config=1
  1144. ;;
  1145. esac
  1146. # standard error to /dev/null unless debugging
  1147. # standard output to the current output file
  1148. #
  1149. # stdout original standard output
  1150. # stderr original standard error
  1151. # nullin /dev/null input
  1152. # nullout /dev/null output
  1153. stdout=5 stderr=6 nullin=7 nullout=8
  1154. eval "exec $nullin</dev/null $nullout>/dev/null $stdout>&1 $stderr>&2"
  1155. case " $* " in
  1156. *" set debug "[3456789]*)
  1157. ;;
  1158. *) eval "exec 2>&$nullout"
  1159. ;;
  1160. esac
  1161. # tmp files cleaned up on exit
  1162. # status: 0:success 1:failure 2:interrupt
  1163. status=1
  1164. case $debug in
  1165. 2) core=
  1166. ;;
  1167. *) if (ulimit -c 0) >/dev/null 2>&1
  1168. then ulimit -c 0
  1169. core=
  1170. else core="core core.??*"
  1171. fi
  1172. ;;
  1173. esac
  1174. trap "(set +o noglob; exec rm -f $core $tmp*)" 0
  1175. if (:>$tmp.c) 2>/dev/null
  1176. then rm -f $tmp.c
  1177. else echo "$command: cannot create tmp files in current dir" >&2
  1178. exit 1
  1179. fi
  1180. status=2
  1181. # standard header for c source
  1182. std='/* AST backwards compatibility macros */
  1183. #define _NIL_(x) ((x)0)
  1184. #define _STD_ 1
  1185. #define _ARG_(x) x
  1186. #define _VOID_ void
  1187. #define _BEGIN_EXTERNS_
  1188. #define _END_EXTERNS_'
  1189. # To ensure the environment tested is the same as that used, add standards
  1190. # compliance macros as probed by libast as soon as they are available.
  1191. if test -f "${INSTALLROOT}/src/lib/libast/FEATURE/standards"
  1192. then std=${std}${nl}$(cat "${INSTALLROOT}/src/lib/libast/FEATURE/standards")
  1193. fi
  1194. tst=
  1195. ext="#include <stdio.h>"
  1196. # loop on op [ arg [ ... ] ] [ : op [ arg [ ... ] ] ]
  1197. argx=0
  1198. cur=.
  1199. can=
  1200. cansep=
  1201. cctest=
  1202. file=
  1203. hdrtest=
  1204. ifelse=NONE
  1205. ifstack=
  1206. ini=
  1207. init=1
  1208. line=0
  1209. nan=
  1210. while :
  1211. do case $in in
  1212. "") case $argx:$* in
  1213. 1:$argv);;
  1214. 1:*) argx=0
  1215. set x $argv
  1216. shift
  1217. ;;
  1218. esac
  1219. ;;
  1220. *) case $ini in
  1221. '') if read lin
  1222. then line=$((line+1))
  1223. set x $lin
  1224. case $# in
  1225. 1) continue ;;
  1226. esac
  1227. else set x
  1228. fi
  1229. ;;
  1230. *) set x $ini
  1231. ini=
  1232. ;;
  1233. esac
  1234. shift
  1235. case $init in
  1236. 1) case $1 in
  1237. iff) init=0
  1238. ;;
  1239. print|ref|set)
  1240. ;;
  1241. *) init=0
  1242. ini=$*
  1243. set ini
  1244. ;;
  1245. esac
  1246. esac
  1247. ;;
  1248. esac
  1249. case $# in
  1250. 0) case $ifstack in
  1251. ?*) echo "$command: $file$line: missing endif" >&$stderr
  1252. exit 1
  1253. ;;
  1254. esac
  1255. set set out +
  1256. ;;
  1257. esac
  1258. # if nesting
  1259. while :
  1260. do case $1 in
  1261. "if") ifstack="$ifelse:$ifstack"
  1262. case $ifelse in
  1263. KEEP|NONE)
  1264. ifelse=TEST
  1265. ;;
  1266. TEST) ;;
  1267. *) ifelse=DONE
  1268. ;;
  1269. esac
  1270. shift
  1271. case $explicit in
  1272. 1) set '' - "$@"; shift ;;
  1273. esac
  1274. ;;
  1275. "elif") case $ifelse in
  1276. SKIP) ifelse=TEST
  1277. ;;
  1278. TEST) ;;
  1279. *) ifelse=DONE
  1280. ;;
  1281. NONE) echo "$command: $file$line: $1: no matching if" >&$stderr
  1282. exit 1
  1283. ;;
  1284. esac
  1285. shift
  1286. case $explicit in
  1287. 1) set '' - "$@"; shift ;;
  1288. esac
  1289. ;;
  1290. "else") case $ifelse in
  1291. KEEP) ifelse=DONE
  1292. ;;
  1293. SKIP|TEST)
  1294. ifelse=KEEP
  1295. ;;
  1296. NONE) echo "$command: $file$line: $1: no matching if" >&$stderr
  1297. exit 1
  1298. ;;
  1299. esac
  1300. shift
  1301. ;;
  1302. "endif")case $ifelse in
  1303. NONE) echo "$command: $file$line: $1: no matching if" >&$stderr
  1304. exit 1
  1305. ;;
  1306. esac
  1307. ifelse=${ifstack%%:*}
  1308. ifstack=${ifstack#*:}
  1309. shift
  1310. ;;
  1311. *) break
  1312. ;;
  1313. esac
  1314. done
  1315. # check if "run xxx" is equivalent to "set in xxx"
  1316. case $1 in
  1317. "("*) set exp - "$@" ;;
  1318. *.iffe|*.iff) set run "$@" ;;
  1319. esac
  1320. case $1 in
  1321. :) shift
  1322. continue
  1323. ;;
  1324. run) case ${2##*[\\/]} in
  1325. *.iffe|*.iff)
  1326. set set in $2 ;;
  1327. *.*) ;;
  1328. *) set set in $2 ;;
  1329. esac
  1330. ;;
  1331. esac
  1332. # { inc set } drop out early
  1333. case $1 in
  1334. ""|"#"*)continue
  1335. ;;
  1336. inc) case $ifelse in
  1337. DONE|SKIP) set ''; shift; continue ;;
  1338. esac
  1339. shift
  1340. case $# in
  1341. 0) echo "$command: $file$line: path expected" >&$stderr
  1342. exit 1
  1343. ;;
  1344. esac
  1345. p=$1
  1346. shift
  1347. if test ! -f $p
  1348. then echo "$command: $file$line: $p: file not found" >&$stderr
  1349. exit 1
  1350. fi
  1351. case $# in
  1352. 0) case $config in
  1353. 1) e="^HAVE_" ;;
  1354. *) e="^_" ;;
  1355. esac
  1356. ;;
  1357. 1) e=$1
  1358. ;;
  1359. *) shift
  1360. echo "$command: $file$line: warning: $*: operands ignored" >&$stderr
  1361. ;;
  1362. esac
  1363. eval $(sed -e '/^#define[ ]/!d' -e 's/#define[ ]//' -e 's/[ (].*//' ${e:+"-e/$e/!d"} -e 's/.*/&=1/' $p | LC_ALL=C sort -u)
  1364. continue
  1365. ;;
  1366. set) case $ifelse in
  1367. DONE|SKIP) set ''; shift; continue ;;
  1368. esac
  1369. shift
  1370. case $1 in
  1371. ""|"#"*)op=
  1372. ;;
  1373. *) arg=
  1374. op=$1
  1375. case $op in
  1376. --*) op=${op#--}
  1377. ;;
  1378. -*) case $op in
  1379. -??*) arg=${op#-?}
  1380. op=${op%$arg}
  1381. ;;
  1382. esac
  1383. case $op in
  1384. a) op=all ;;
  1385. c) op=cc ;;
  1386. C) op=config ;;
  1387. d) op=debug ;;
  1388. D) op=define ;;
  1389. E) op=explicit ;;
  1390. F) op=features ;;
  1391. i) op=input ;;
  1392. I) op=include ;;
  1393. L) op=library ;;
  1394. n) op=namval ;;
  1395. N) op=nooptimize ;;
  1396. o) op=output ;;
  1397. e) ;; # obsolete
  1398. p) ;; # obsolete
  1399. P) op=pragma ;;
  1400. r) op=regress ;;
  1401. s) op=shell ;;
  1402. S) op=static ;;
  1403. O) op=stdio ;;
  1404. u) op=undef ;;
  1405. v) op=verbose ;;
  1406. x) op=cross ;;
  1407. X) op=exclude ;;
  1408. esac
  1409. ;;
  1410. esac
  1411. shift
  1412. while :
  1413. do case $# in
  1414. 0) break ;;
  1415. esac
  1416. case $1 in
  1417. *" "*) shift
  1418. continue
  1419. ;;
  1420. ""|"#"*)break
  1421. ;;
  1422. :) shift
  1423. break
  1424. ;;
  1425. esac
  1426. case $arg in
  1427. "") arg=$1 ;;
  1428. *) arg="$arg $1" ;;
  1429. esac
  1430. shift
  1431. done
  1432. ;;
  1433. esac
  1434. case $op in
  1435. all) all=1
  1436. continue
  1437. ;;
  1438. cc) occ=
  1439. for x in $arg
  1440. do case $occ in
  1441. "") case $x in
  1442. *=*) export "$x"
  1443. ;;
  1444. -O*) case $optimize in
  1445. 1) occ=$x ;;
  1446. esac
  1447. ;;
  1448. *) occ=$x
  1449. ;;
  1450. esac
  1451. ;;
  1452. *) occ="$occ $x"
  1453. ;;
  1454. esac
  1455. done
  1456. exclude occ
  1457. continue
  1458. ;;
  1459. config) config=1
  1460. continue
  1461. ;;
  1462. cross) case $arg in
  1463. ""|-) cross= ;;
  1464. *) cross="$arg" libpaths= ;;
  1465. esac
  1466. continue
  1467. ;;
  1468. debug) debug=$arg
  1469. case $arg in
  1470. 0) exec 2>&$nullout
  1471. set +v +x
  1472. ;;
  1473. ""|1) exec 2>&$stderr
  1474. set +v +x
  1475. ;;
  1476. 2|3) exec 2>&$stderr
  1477. # Useful shell-dependent PS4 trace prompts from modernish.
  1478. # The ${foo#{foo%/*/*}/} substitutions below are to trace just the last two
  1479. # elements of path names, instead of the full paths which can be very long.
  1480. case ${ZSH_VERSION:+Zsh}${NETBSD_SHELL:+Netsh}${KSH_VERSION:+Ksh}${BASH_VERSION:+Bash} in
  1481. Zsh) typeset -F SECONDS
  1482. PS4='+ [${SECONDS:+${SECONDS%????}s|}${ZSH_SUBSHELL:+S$ZSH_SUBSHELL,}${funcfiletrace:+${funcfiletrace#${funcfiletrace%/*/*}/},}${funcstack:+${funcstack#${funcstack%/*/*}/},}${LINENO:+L$LINENO,}e$?] ' ;;
  1483. Netsh) PS4='+ [${ToD:+$ToD|}${LINENO:+L$LINENO,}e$?] ' ;;
  1484. Ksh) case $KSH_VERSION in
  1485. 'Version '*)
  1486. typeset -F SECONDS
  1487. PS4='+ [${SECONDS:+${SECONDS%????}s|}${.sh.pid:+P${.sh.pid},}${.sh.subshell:+S${.sh.subshell},}${.sh.file:+${.sh.file#${.sh.file%/*/*}/},}${.sh.fun:+${.sh.fun},}${LINENO:+L$LINENO,}e$?] ' ;;
  1488. @\(*) PS4='+ [${EPOCHREALTIME:+${EPOCHREALTIME#???????}s|}${BASHPID:+P$BASHPID,}${LINENO:+L$LINENO,}e$?] ' ;;
  1489. esac ;;
  1490. Bash) case ${EPOCHREALTIME:+s} in
  1491. s) PS4='+ [${EPOCHREALTIME:+${EPOCHREALTIME#???????}s|}' ;;
  1492. '') PS4='+ [${SECONDS:+${SECONDS}s|}' ;;
  1493. esac
  1494. PS4=$PS4'${BASHPID:+P$BASHPID,}${BASH_SOURCE:+${BASH_SOURCE#${BASH_SOURCE%/*/*}/},}${FUNCNAME:+$FUNCNAME,}${LINENO:+L$LINENO,}e$?] ' ;;
  1495. '') case ${SECONDS:+s} in
  1496. s) PS4='+ [${SECONDS:+${SECONDS}s|}${LINENO:+L$LINENO,}e$?] ' ;;
  1497. '') PS4='+ [${LINENO:+L$LINENO,}e$?] ' ;;
  1498. esac ;;
  1499. esac
  1500. set -x
  1501. ;;
  1502. *) echo "$command: $arg: debug levels are 0, 1, 2, 3" >&$stderr
  1503. ;;
  1504. esac
  1505. continue
  1506. ;;
  1507. define) define=1
  1508. continue
  1509. ;;
  1510. exclude)case $arg in
  1511. ""|-) excludes= ;;
  1512. *) excludes="$excludes $arg" ;;
  1513. esac
  1514. exclude includes occ
  1515. continue
  1516. ;;
  1517. explicit)
  1518. explicit=1
  1519. continue
  1520. ;;
  1521. features)case $arg in
  1522. '') tst= ;;
  1523. *) tst="#include \"$arg\"" ;;
  1524. esac
  1525. continue
  1526. ;;
  1527. "in"|input)
  1528. case $arg in
  1529. "") in=-
  1530. ;;
  1531. *) in=$arg
  1532. if test ! -r $in
  1533. then echo "$command: $in: not found" >&$stderr
  1534. exit 1
  1535. fi
  1536. exec < $in
  1537. file=$in:
  1538. case $out in
  1539. "") case $in in
  1540. *[.\\/]*)
  1541. out=${in##*[\\/]}
  1542. out=${out%.*}
  1543. ;;
  1544. *) out=$in
  1545. ;;
  1546. esac
  1547. ;;
  1548. esac
  1549. ;;
  1550. esac
  1551. continue
  1552. ;;
  1553. include)case $arg in
  1554. ""|-) includes= ;;
  1555. *) includes="$includes -I$arg" ;;
  1556. esac
  1557. exclude includes
  1558. continue
  1559. ;;
  1560. library)for y in $libpaths
  1561. do eval $y=\"\$$y:\$arg\$${y}_default\"
  1562. eval export $y
  1563. done
  1564. continue
  1565. ;;
  1566. namval) define=n
  1567. continue
  1568. ;;
  1569. nodebug)exec 2>&$nullout
  1570. set +v +x
  1571. continue
  1572. ;;
  1573. nodefine)
  1574. define=0
  1575. continue
  1576. ;;
  1577. nooptimize)
  1578. optimize=0
  1579. case $occ in
  1580. *" -O"*)occ=$(echo $occ | sed 's/ -O[^ ]*//g')
  1581. cc=$occ
  1582. ;;
  1583. esac
  1584. ;;
  1585. optimize)
  1586. optimize=1
  1587. ;;
  1588. out|output)
  1589. out=$arg
  1590. defhdr=
  1591. usr=
  1592. deflib=
  1593. one=
  1594. puthdr=
  1595. putlib=
  1596. case $op in
  1597. output) continue ;;
  1598. esac
  1599. def=
  1600. test=
  1601. ;;
  1602. package)# obsolete
  1603. continue
  1604. ;;
  1605. prototyped|noprototyped)
  1606. # obsolete
  1607. continue
  1608. ;;
  1609. pragma) pragma="$pragma $arg"
  1610. continue
  1611. ;;
  1612. regress)regress=1
  1613. version=1995-03-19
  1614. continue
  1615. ;;
  1616. shell) shell=$arg
  1617. continue
  1618. ;;
  1619. static) static=$arg
  1620. continue
  1621. ;;
  1622. stdio) case $arg in
  1623. '') ext=
  1624. ;;
  1625. *) ext=
  1626. sep=
  1627. for i in $arg
  1628. do case $i in
  1629. -) case $ext in
  1630. '') continue ;;
  1631. *) break ;;
  1632. esac
  1633. ;;
  1634. esac
  1635. echo "#include \"$i\"" > t.c
  1636. if $cc -E t.c > /dev/null 2>&1
  1637. then ext="$ext$sep#include \"$arg\""
  1638. sep=$nl
  1639. fi
  1640. done
  1641. ;;
  1642. esac
  1643. continue
  1644. ;;
  1645. undef) undef=1
  1646. continue
  1647. ;;
  1648. verbose)verbose=1
  1649. continue
  1650. ;;
  1651. *) echo "$command: $op: unknown option" >&$stderr
  1652. exit 1
  1653. ;;
  1654. esac
  1655. ;;
  1656. api|define|extern|header|include|print|reference|ver)
  1657. op=$1
  1658. shift
  1659. arg=
  1660. ;;
  1661. *) case $2 in
  1662. '=') def=$1
  1663. shift
  1664. shift
  1665. ;;
  1666. *) case $1 in
  1667. '-'|'?')def=-
  1668. shift
  1669. ;;
  1670. *) def=
  1671. ;;
  1672. esac
  1673. ;;
  1674. esac
  1675. case $1 in
  1676. '!') not=1
  1677. shift
  1678. ;;
  1679. *) not=
  1680. ;;
  1681. esac
  1682. case $1 in
  1683. *'{') op=-
  1684. ;;
  1685. '('*|'"'*'"'|'<'*'>')
  1686. op=exp
  1687. case $def in
  1688. '') def=- ;;
  1689. esac
  1690. ;;
  1691. *) op=$1
  1692. shift
  1693. ;;
  1694. esac
  1695. arg=
  1696. cc="$occ $includes"
  1697. group=
  1698. groups=
  1699. fail=
  1700. hdr=
  1701. lib=
  1702. mac=
  1703. no=
  1704. note=
  1705. opt=
  1706. pass=
  1707. pth=
  1708. run=
  1709. set=
  1710. src=
  1711. test=
  1712. yes=
  1713. case $# in
  1714. 0) ;;
  1715. *) case $1 in
  1716. "#"*) set x
  1717. shift
  1718. ;;
  1719. *) case $op in
  1720. ref) ;;
  1721. *) case $1 in
  1722. '-') case $op:$2 in
  1723. tst:*) arg=$1
  1724. case $2 in
  1725. -) shift ;;
  1726. esac
  1727. ;;
  1728. *:-*) arg=$1
  1729. shift
  1730. ;;
  1731. *) def=-
  1732. shift
  1733. case $1 in
  1734. '('*|*'{'|'"'*'"'|'<'*'>')
  1735. arg=-
  1736. ;;
  1737. *) arg=$1
  1738. case $# in
  1739. 0) ;;
  1740. *) shift ;;
  1741. esac
  1742. ;;
  1743. esac
  1744. ;;
  1745. esac
  1746. ;;
  1747. -*|+*|'('*|*'{'|'"'*'"'|'<'*'>')
  1748. arg=-
  1749. ;;
  1750. *) arg=$1
  1751. shift
  1752. ;;
  1753. esac
  1754. ;;
  1755. esac
  1756. ;;
  1757. esac
  1758. case $1 in
  1759. '('*|'"'*'"'|'<'*'>')
  1760. while :
  1761. do case $# in
  1762. 0) break ;;
  1763. esac
  1764. case $1 in
  1765. *[.{}]*)break ;;
  1766. esac
  1767. case $test in
  1768. '') test=$1 ;;
  1769. *) test="$test $1" ;;
  1770. esac
  1771. shift
  1772. done
  1773. case $arg in
  1774. '') arg=- ;;
  1775. esac
  1776. case $op in
  1777. exp) case $def in
  1778. ''|'-') ;;
  1779. *) arg=$def ;;
  1780. esac
  1781. ;;
  1782. esac
  1783. ;;
  1784. esac
  1785. sline=$line
  1786. while :
  1787. do case $# in
  1788. 0) break ;;
  1789. esac
  1790. case $1 in
  1791. "") ;;
  1792. "#"*) set x
  1793. ;;
  1794. "=") shift
  1795. set=$*
  1796. case $set in
  1797. "") set=" " ;;
  1798. esac
  1799. while :
  1800. do case $# in
  1801. 0) break ;;
  1802. esac
  1803. shift
  1804. done
  1805. break
  1806. ;;
  1807. [abcdefghijklmnopqrstuvwxyz]*'{'|'{')
  1808. v=$1
  1809. shift
  1810. x=
  1811. case $v in
  1812. "note{")
  1813. sep=" " ;;
  1814. *) sep=$nl ;;
  1815. esac
  1816. case $v in
  1817. '{') e='}' ;;
  1818. *) e='}end' ;;
  1819. esac
  1820. n=1
  1821. SEP=
  1822. while :
  1823. do case $# in
  1824. 0) case $in in
  1825. "") echo "$command: $file$line: missing }end" >&$stderr
  1826. exit 1
  1827. ;;
  1828. esac
  1829. while :
  1830. do IFS= read -r lin
  1831. eof=$?
  1832. while :
  1833. do lin="${lin#[' ']}"
  1834. case $lin in
  1835. [' ']*'#'*);;
  1836. *) break ;;
  1837. esac
  1838. done
  1839. case $eof in
  1840. 0) line=$((line+1))
  1841. set x $lin
  1842. case $2 in
  1843. $v) n=$((n+1))
  1844. ;;
  1845. $e|$e';')
  1846. case $n in
  1847. 1) shift
  1848. break 2
  1849. ;;
  1850. esac
  1851. n=$((n-1))
  1852. ;;
  1853. esac
  1854. x="$x$SEP$lin"
  1855. SEP=$sep
  1856. ;;
  1857. *) echo "$command: $file$line: missing $e" >&$stderr
  1858. exit 1
  1859. ;;
  1860. esac
  1861. done
  1862. ;;
  1863. esac
  1864. case $1 in
  1865. $v) n=$((n+1))
  1866. ;;
  1867. $e|$e';')
  1868. case $n in
  1869. 1) break ;;
  1870. esac
  1871. n=$((n-1))
  1872. ;;
  1873. esac
  1874. x="$x$SEP$1"
  1875. SEP=$sep
  1876. shift
  1877. done
  1878. case $v in
  1879. 'note{');;
  1880. *) x="$x$nl" # \r\n bash needs this barf # ;;
  1881. esac
  1882. case $v in
  1883. 'fail{') fail=$x ;;
  1884. 'nofail{') pass=$x v='pass{' ;;
  1885. 'nopass{') fail=$x v='fail{' ;;
  1886. 'no{') no=$x ;;
  1887. 'note{') note=$x ;;
  1888. 'pass{') pass=$x ;;
  1889. 'test{') test=$x ;;
  1890. 'yes{'|'{') yes=$x ;;
  1891. *) src=$x run=$v ;;
  1892. esac
  1893. ;;
  1894. :) shift
  1895. break
  1896. ;;
  1897. *[\"\'\(\)\{\}\ \ ]*)
  1898. case $op in
  1899. pth) pth="$pth $1"
  1900. ;;
  1901. *) case $test in
  1902. '') test=$1 ;;
  1903. *) test="$test $1" ;;
  1904. esac
  1905. ;;
  1906. esac
  1907. ;;
  1908. -) group=$group$1
  1909. case $group in
  1910. -) com_hdr=$hdr
  1911. com_lib=$lib
  1912. com_mac=$mac
  1913. com_opt=$opt
  1914. com_pth=$pth
  1915. com_test=$test
  1916. ;;
  1917. *) groups="$groups $1"
  1918. ;;
  1919. esac
  1920. ;;
  1921. -l*) case $group in
  1922. --*) groups="$groups $1" ;;
  1923. *) lib="$lib $1" ;;
  1924. esac
  1925. ;;
  1926. +l*) x=-${1#+}
  1927. case $group in
  1928. --*) groups="$groups $x" ;;
  1929. *) lib="$lib $x" ;;
  1930. esac
  1931. ;;
  1932. -*|+*) case $op in
  1933. ref) cc="$cc $1"
  1934. occ="$occ $1"
  1935. case $1 in
  1936. -L*) x=${1#-L}
  1937. for y in $libpaths
  1938. do eval $y=\"\$$y:\$x\$${y}_default\"
  1939. eval export $y
  1940. done
  1941. ;;
  1942. esac
  1943. ;;
  1944. *) case $group in
  1945. --*) groups="$groups $1"
  1946. ;;
  1947. *) case $op in
  1948. run) opt="$opt $1"
  1949. ;;
  1950. *) case $1 in
  1951. -D*) mac="$mac $1" ;;
  1952. *) cc="$cc $1" ;;
  1953. esac
  1954. ;;
  1955. esac
  1956. ;;
  1957. esac
  1958. ;;
  1959. esac
  1960. ;;
  1961. *.[aAxX]|*.[dD][lL][lL]|*.[lL][iI][bB])
  1962. case $group in
  1963. --*) groups="$groups $1" ;;
  1964. *) lib="$lib $1" ;;
  1965. esac
  1966. ;;
  1967. *[.\\/]*)
  1968. case $group in
  1969. --*) groups="$groups $1"
  1970. ;;
  1971. *) case $op in
  1972. pth) pth="$pth $1" ;;
  1973. *) hdr="$hdr $1" ;;
  1974. esac
  1975. ;;
  1976. esac
  1977. ;;
  1978. *) case $group in
  1979. --*) groups="$groups $1"
  1980. ;;
  1981. *) case $op in
  1982. pth) pth="$pth $1"
  1983. ;;
  1984. *) case $test in
  1985. '') test=$1 ;;
  1986. *) test="$test $1" ;;
  1987. esac
  1988. ;;
  1989. esac
  1990. ;;
  1991. esac
  1992. ;;
  1993. esac
  1994. shift
  1995. done
  1996. case $group in
  1997. -) group= ;;
  1998. esac
  1999. ;;
  2000. esac
  2001. ;;
  2002. esac
  2003. case $ifelse in
  2004. DONE|SKIP) continue ;;
  2005. esac
  2006. # make sure $cc compiles C
  2007. case $cc in
  2008. "") cc="$occ $includes" ;;
  2009. esac
  2010. case $cctest in
  2011. "") checkcc ;;
  2012. esac
  2013. # some ops allow no args
  2014. case $arg in
  2015. '') case $op in
  2016. api) arg=-
  2017. case $1:$2 in
  2018. [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])
  2019. a=$1
  2020. shift
  2021. case " $apis " in
  2022. *" $a "*)
  2023. ;;
  2024. *) apis="$apis $a"
  2025. eval api_sym_${a}= api_ver_${a}=
  2026. ;;
  2027. esac
  2028. rel=
  2029. while :
  2030. do case $# in
  2031. 0) break ;;
  2032. esac
  2033. case $1 in
  2034. [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])
  2035. rel="$rel $1"
  2036. ;;
  2037. *) break
  2038. ;;
  2039. esac
  2040. shift
  2041. done
  2042. while :
  2043. do case $# in
  2044. 0) break ;;
  2045. esac
  2046. case $1 in
  2047. :) break ;;
  2048. esac
  2049. eval syms='$'api_sym_${a}
  2050. case $syms in
  2051. '') sep='' ;;
  2052. *) sep=$nl ;;
  2053. esac
  2054. for r in $rel
  2055. do syms=$syms$sep${1}:${r}
  2056. sep=$nl
  2057. done
  2058. eval api_sym_${a}='$'syms
  2059. shift
  2060. done
  2061. ;;
  2062. *) echo "$command: $op: expected: name YYYYMMDD symbol ..." >&$stderr
  2063. ;;
  2064. esac
  2065. while :
  2066. do case $# in
  2067. 0) break ;;
  2068. esac
  2069. case $1 in
  2070. :) break ;;
  2071. esac
  2072. shift
  2073. done
  2074. ;;
  2075. iff|ini)arg=-
  2076. ;;
  2077. comment)copy - "/* $* */"
  2078. continue
  2079. ;;
  2080. define) x=$1
  2081. shift
  2082. case $1 in
  2083. '('*')')
  2084. arg=$1
  2085. shift
  2086. ;;
  2087. esac
  2088. case $in in
  2089. "") v=
  2090. while :
  2091. do case $# in
  2092. 0) break ;;
  2093. esac
  2094. t=$1
  2095. shift
  2096. case $t in
  2097. ":") break ;;
  2098. esac
  2099. v="$v $t"
  2100. done
  2101. ;;
  2102. *) v=$*
  2103. ;;
  2104. esac
  2105. is mac $x
  2106. copy $tmp.c "$std
  2107. $usr
  2108. #ifndef $x
  2109. (
  2110. #endif
  2111. int x;
  2112. "
  2113. if compile $cc -c $tmp.c <&$nullin >&$nullout
  2114. then success -
  2115. else failure -
  2116. copy - "#define $x$arg $v"
  2117. usr="$usr${nl}#define $x$arg $v"
  2118. fi
  2119. continue
  2120. ;;
  2121. extern) x=$1
  2122. shift
  2123. t=$1
  2124. shift
  2125. is npt $x
  2126. copy $tmp.c "
  2127. $std
  2128. #include <sys/types.h>
  2129. $usr
  2130. struct _iffe_struct { int _iffe_member; };
  2131. extern struct _iffe_struct* $x (struct _iffe_struct*);
  2132. "
  2133. # some compilers with -O only warn for invalid intrinsic prototypes
  2134. case " $cc " in
  2135. *" -O "*) xx=$(echo $cc | sed 's/ -O / /g') ;;
  2136. *) xx=$cc ;;
  2137. esac
  2138. if compile $xx -c $tmp.c <&$nullin >&$nullout
  2139. then success -
  2140. while :
  2141. do case $1 in
  2142. ''|'('*|'['*)
  2143. break
  2144. ;;
  2145. esac
  2146. t="$t $1"
  2147. shift
  2148. done
  2149. case $in in
  2150. "") v=
  2151. while :
  2152. do case $# in
  2153. 0) break ;;
  2154. esac
  2155. t=$1
  2156. shift
  2157. case $t in
  2158. ":") break ;;
  2159. esac
  2160. v="$v $t"
  2161. done
  2162. ;;
  2163. *) v=$*
  2164. ;;
  2165. esac
  2166. copy - "extern $t $x$v;"
  2167. usr="$usr${nl}extern $t $x$v;"
  2168. else failure -
  2169. case $in in
  2170. "") while :
  2171. do case $# in
  2172. 0) break ;;
  2173. esac
  2174. case $1 in
  2175. ":") break ;;
  2176. esac
  2177. done
  2178. ;;
  2179. esac
  2180. fi
  2181. continue
  2182. ;;
  2183. header|include|reference)
  2184. while :
  2185. do case $# in
  2186. 0) break ;;
  2187. esac
  2188. x=$1
  2189. shift
  2190. case $x in
  2191. ":") break ;;
  2192. esac
  2193. case " $gothdr " in
  2194. *" - $x "*)
  2195. ;;
  2196. *" + $x "*)
  2197. case $usr in
  2198. *"# include <"$x">"*)
  2199. ;;
  2200. *) case $op in
  2201. reference)
  2202. ;;
  2203. *) copy - "#include <$x>"
  2204. ;;
  2205. esac
  2206. usr="$usr${nl}#include <$x>"
  2207. ;;
  2208. esac
  2209. ;;
  2210. *) copy $tmp.c "$std
  2211. $usr
  2212. #include <$x>
  2213. int x;
  2214. "
  2215. if is_hdr - $x
  2216. then gothdr="$gothdr + $x"
  2217. case $op in
  2218. reference)
  2219. ;;
  2220. *) copy - "#include <$x>"
  2221. ;;
  2222. esac
  2223. usr="$usr${nl}#include <$x>"
  2224. else gothdr="$gothdr - $x"
  2225. fi
  2226. ;;
  2227. esac
  2228. done
  2229. continue
  2230. ;;
  2231. print) case $in in
  2232. "") v=
  2233. while :
  2234. do case $# in
  2235. 0) break ;;
  2236. esac
  2237. t=$1
  2238. shift
  2239. case $t in
  2240. ":") break ;;
  2241. esac
  2242. v="$v $t"
  2243. done
  2244. ;;
  2245. *) v=$*
  2246. ;;
  2247. esac
  2248. copy - "$*"
  2249. usr="$usr${nl}$v"
  2250. continue
  2251. ;;
  2252. ver) arg=-
  2253. case $1:$2 in
  2254. [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])
  2255. vers="$vers$nl$1"
  2256. eval ver_$1=$2
  2257. ;;
  2258. *) echo "$command: $op: expected: name YYYYMMDD" >&$stderr
  2259. ;;
  2260. esac
  2261. while :
  2262. do case $# in
  2263. 0) break ;;
  2264. esac
  2265. case $1 in
  2266. :) break ;;
  2267. esac
  2268. shift
  2269. done
  2270. ;;
  2271. esac
  2272. ;;
  2273. esac
  2274. # NOTE() support
  2275. case $ext in
  2276. *"<stdio.h>"*)
  2277. case $ext in
  2278. *"#define NOTE("*)
  2279. ;;
  2280. *) ext="$ext
  2281. #define NOTE(s) do{write(9,\" \",1);write(9,s,strlen(s));write(9,\" ...\",4);}while(0)"
  2282. ;;
  2283. esac
  2284. ;;
  2285. esac
  2286. # save $* for ancient shells
  2287. argx=1
  2288. argv=$*
  2289. # loop on all candidate groups
  2290. while :
  2291. do
  2292. # check the candidate macros
  2293. cc="$cc $mac"
  2294. # check for global default headers (some cc -E insist on compiling)
  2295. case $hdrtest in
  2296. '') hdrtest=1
  2297. allinc=
  2298. for x in types
  2299. do case $config in
  2300. 0) c=_sys_${x}
  2301. ;;
  2302. 1) case $shell in
  2303. ksh) typeset -u u=$x ;;
  2304. *) u=$(echo $x | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ) ;;
  2305. esac
  2306. c=HAVE_SYS_${u}_H
  2307. ;;
  2308. esac
  2309. x=sys/$x.h
  2310. echo "${allinc}#include <$x>" > $tmp.c
  2311. if is_hdr $x
  2312. then gothdr="$gothdr + $x"
  2313. case $explicit in
  2314. 0) can="$can$cansep#define $c 1 /* #include <$x> ok */"
  2315. nan="$nan$cansep$c=1"
  2316. cansep=$nl
  2317. ;;
  2318. esac
  2319. eval $c=1
  2320. allinc="${allinc}#include <$x>$nl"
  2321. else gothdr="$gothdr - $x"
  2322. case $explicit$all$config$undef in
  2323. 0?1?|0??1)
  2324. can="$can$cansep#undef $c /* #include <$x> not ok */"
  2325. nan="$nan$cansep$c="
  2326. cansep=$nl
  2327. ;;
  2328. 01??) can="$can$cansep#define $c 0 /* #include <$x> not ok */"
  2329. nan="$nan$cansep$c=0"
  2330. cansep=$nl
  2331. ;;
  2332. esac
  2333. fi
  2334. done
  2335. ;;
  2336. esac
  2337. # add implicit headers/libraries before the checks
  2338. case $op in
  2339. npt) hdr="sys/types.h stdlib.h unistd.h $hdr"
  2340. ;;
  2341. siz|typ)hdr="sys/types.h time.h sys/time.h sys/times.h stddef.h stdlib.h $hdr"
  2342. ;;
  2343. esac
  2344. # check the candidate headers
  2345. case $hdr in
  2346. ?*) z=$hdr
  2347. hdr=
  2348. dis=0
  2349. for x in $z
  2350. do case $x in
  2351. *.h) case " $gothdr " in
  2352. *" - $x "*)
  2353. continue
  2354. ;;
  2355. *" + $x "*)
  2356. ;;
  2357. *) c=${x##*[\\/]}
  2358. c=${c%%.*}
  2359. case $x in
  2360. */*) c=${x%%[\\/]*}_${c} ;;
  2361. esac
  2362. case $explicit in
  2363. 0) dis=0
  2364. ;;
  2365. *) case $x in
  2366. */*) dis=$c ;;
  2367. *) dis=hdr ;;
  2368. esac
  2369. case ${dis}_ in
  2370. ${op}_*)dis=0 ;;
  2371. *) dis=1 ;;
  2372. esac
  2373. ;;
  2374. esac
  2375. case $config in
  2376. 0) case $x in
  2377. */*) c=_${c} ;;
  2378. *) c=_hdr_${c} ;;
  2379. esac
  2380. ;;
  2381. 1) case $shell in
  2382. ksh) typeset -u u=$c ;;
  2383. *) u=$(echo $c | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ) ;;
  2384. esac
  2385. c=HAVE_${u}_H
  2386. ;;
  2387. esac
  2388. echo "${allinc}#include <$x>" > $tmp.c
  2389. if is_hdr $x
  2390. then gothdr="$gothdr + $x"
  2391. case $dis in
  2392. 0) can="$can$cansep#define $c 1 /* #include <$x> ok */"
  2393. nan="$nan$cansep$c=1"
  2394. cansep=$nl
  2395. ;;
  2396. esac
  2397. eval $c=1
  2398. else gothdr="$gothdr - $x"
  2399. case $dis$all$config$undef in
  2400. 0?1?|0??1)
  2401. can="$can$cansep#undef $c /* #include <$x> not ok */"
  2402. nan="$nan$cansep$c="
  2403. cansep=$nl
  2404. ;;
  2405. 01??) can="$can$cansep#define $c 0 /* #include <$x> not ok */"
  2406. nan="$nan$cansep$c=0"
  2407. cansep=$nl
  2408. ;;
  2409. esac
  2410. continue
  2411. fi
  2412. ;;
  2413. esac
  2414. ;;
  2415. *) test -r $x || continue
  2416. ;;
  2417. esac
  2418. hdr="$hdr $x"
  2419. done
  2420. ;;
  2421. esac
  2422. # check the candidate libraries
  2423. case $lib in
  2424. ?*) z=
  2425. for p in $lib
  2426. do z="$p $z"
  2427. done
  2428. lib=
  2429. p=
  2430. hit=0
  2431. echo "int main(){return(0);}" > $tmp.c
  2432. for x in $z
  2433. do p=$x
  2434. case " $gotlib " in
  2435. *"- $p "*)
  2436. failure +
  2437. p=
  2438. ;;
  2439. *"+ $p "*)
  2440. success +
  2441. lib="$p $lib"
  2442. ;;
  2443. *) rm -f $tmp.exe
  2444. is LIB $p
  2445. if compile $cc -o $tmp.exe $tmp.c $p $lib <&$nullin >&$nullout
  2446. then success
  2447. gotlib="$gotlib + $p"
  2448. lib="$p $lib"
  2449. e=0
  2450. else a=
  2451. e=1
  2452. for l in $z
  2453. do case $l in
  2454. -) a=
  2455. continue
  2456. ;;
  2457. $p) a=$p
  2458. continue
  2459. ;;
  2460. *) case $gotlib in
  2461. *" $l "*) continue ;;
  2462. esac
  2463. ;;
  2464. esac
  2465. case $a in
  2466. $p) a="$a $l"
  2467. if compile $cc -o $tmp.exe $tmp.c $a <&$nullin >&$nullout
  2468. then success
  2469. gotlib="$gotlib + $p"
  2470. lib="$p $lib"
  2471. e=0
  2472. break
  2473. fi
  2474. ;;
  2475. esac
  2476. done
  2477. case $e in
  2478. 1) failure
  2479. gotlib="$gotlib - $p"
  2480. ;;
  2481. esac
  2482. fi
  2483. y=
  2484. for x in $p
  2485. do c=${x#-l}
  2486. case $c in
  2487. *[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
  2488. c=$(echo '' $c | sed -e 's,.*[\\/],,' -e 's,\.[^.]*$,,' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g' -e '/^lib./s,^lib,,')
  2489. ;;
  2490. esac
  2491. case $config in
  2492. 0) case $e$p in
  2493. 0*' '*) case " $gotlib " in
  2494. *[-+]" $x "*)
  2495. ;;
  2496. *) can="$can$cansep#define _LIB_$c 1 /* $x is a library */"
  2497. nan="$nan${cansep}_LIB_$c=1"
  2498. cansep=$nl
  2499. eval _LIB_$c=1
  2500. ;;
  2501. esac
  2502. ;;
  2503. esac
  2504. ;;
  2505. 1) case $shell in
  2506. ksh) typeset -u u=$c ;;
  2507. *) u=$(echo $c | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ) ;;
  2508. esac
  2509. c=$u
  2510. case $e in
  2511. 0*' '*) case " $gotlib " in
  2512. *[-+]" $x "*)
  2513. ;;
  2514. *) can="$can$cansep#define HAVE_${c}_LIB 1 /* $x is a library */"
  2515. nan="$nan${cansep}HAVE_${c}_LIB=1"
  2516. cansep=$nl
  2517. eval HAVE_${c}_LIB=1
  2518. ;;
  2519. esac
  2520. ;;
  2521. esac
  2522. ;;
  2523. esac
  2524. y=${y}_$c
  2525. done
  2526. case $config in
  2527. 0) c=_LIB${y} ;;
  2528. 1) c=HAVE${y}_LIB ;;
  2529. esac
  2530. case $p in
  2531. *' '*) q="a library group" ;;
  2532. *) q="a library" ;;
  2533. esac
  2534. case $e in
  2535. 0) can="$can$cansep#define $c 1 /* $p is $q */"
  2536. nan="$nan$cansep$c=1"
  2537. cansep=$nl
  2538. eval $c=1
  2539. case $hit in
  2540. 1) break ;;
  2541. esac
  2542. ;;
  2543. 1) case $all$config$undef in
  2544. ?1?|??1)can="$can$cansep#undef $c /* $p is not $q */"
  2545. nan="$nan$cansep$c="
  2546. cansep=$nl
  2547. ;;
  2548. 1??) can="$can$cansep#define $c 0 /* $p is not $q */"
  2549. nan="$nan$cansep$c=0"
  2550. cansep=$nl
  2551. ;;
  2552. esac
  2553. eval $c=0
  2554. ;;
  2555. esac
  2556. p=
  2557. ;;
  2558. esac
  2559. done
  2560. ;;
  2561. esac
  2562. # last op precheck
  2563. case $op in
  2564. ref) deflib="$deflib $lib"
  2565. defhdr="$defhdr $hdr"
  2566. break
  2567. ;;
  2568. esac
  2569. IFS=" ,"
  2570. eval op=\"$op\"
  2571. eval arg=\"$arg\"
  2572. IFS=$ifs
  2573. # check for op aliases
  2574. x=
  2575. for o in $op
  2576. do case $o in
  2577. def|default) x="$x cmd dat hdr key lib mth sys typ" ;;
  2578. *) x="$x $o" ;;
  2579. esac
  2580. done
  2581. # loop on the ops o and args a
  2582. result=UNKNOWN
  2583. for o in $x
  2584. do for a in $arg
  2585. do c=
  2586. case $a in
  2587. *[.\\/]*)
  2588. case $o in
  2589. hdr|lcl|nxt|pth|sys)
  2590. x=$a
  2591. case $x in
  2592. *.lcl|*.nxt)
  2593. case $o in
  2594. sys) x=sys/$x ;;
  2595. esac
  2596. o=${x##*.}
  2597. x=${x%.${o}}
  2598. v=$x
  2599. ;;
  2600. esac
  2601. case $x in
  2602. *[\\/]*)
  2603. p=${x%/*}
  2604. v=${x##*/}
  2605. ;;
  2606. *.*) p=${x%.*}
  2607. v=${x##*.}
  2608. ;;
  2609. *) p=
  2610. ;;
  2611. esac
  2612. case $o in
  2613. lcl|nxt) c=$v.$o ;;
  2614. *) c=$v ;;
  2615. esac
  2616. ;;
  2617. *) p=${a%.*}
  2618. p=${p##*[\\/]}
  2619. v=${a##*.}
  2620. v=${v##*[\\/]}
  2621. ;;
  2622. esac
  2623. case $p in
  2624. '') f=${v} ;;
  2625. *) f=${p}/${v} ;;
  2626. esac
  2627. case $o in
  2628. run) v=$p
  2629. p=
  2630. m=_${v}
  2631. ;;
  2632. mem) case $p in
  2633. *.*) m=${p#*.}
  2634. p=${p%%.*}
  2635. v=${m}.${v}
  2636. esac
  2637. case $config in
  2638. 0) m=_${v}_${p} ;;
  2639. 1) m=_${v}_in_${p} ;;
  2640. esac
  2641. ;;
  2642. *) case $p in
  2643. '') m=_${v} ;;
  2644. *) m=_${p}_${v} ;;
  2645. esac
  2646. ;;
  2647. esac
  2648. ;;
  2649. *) p=
  2650. v=$a
  2651. f=$a
  2652. m=_${v}
  2653. ;;
  2654. esac
  2655. case $c in
  2656. '') c=$v ;;
  2657. esac
  2658. M=$m
  2659. case $o in
  2660. out) case $a in
  2661. -) a=-
  2662. ;;
  2663. ?*) test="$a $test"
  2664. a=
  2665. ;;
  2666. esac
  2667. ;;
  2668. *) case " $idyes " in
  2669. *" $m "*)
  2670. i=1
  2671. ;;
  2672. *) case " $idno " in
  2673. *" $m "*)
  2674. i=0
  2675. ;;
  2676. *) case $m in
  2677. *'*') m=$(echo "$m" | sed 's,\*,_ptr,g') ;;
  2678. esac
  2679. case $m in
  2680. *[-+/\\]*)
  2681. i=0
  2682. ;;
  2683. *[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
  2684. is id $m
  2685. copy $tmp.c "int $m = 0;"
  2686. if compile $cc -c $tmp.c
  2687. then success -
  2688. idyes="$idyes $m"
  2689. i=1
  2690. else failure -
  2691. idno="$idno $m"
  2692. i=0
  2693. fi
  2694. ;;
  2695. *) i=1
  2696. ;;
  2697. esac
  2698. ;;
  2699. esac
  2700. case $i in
  2701. 0) case $o in
  2702. dat|dfn|key|lib|mac|mth|nos|npt|siz|sym|typ|val)
  2703. continue
  2704. ;;
  2705. esac
  2706. ;;
  2707. esac
  2708. ;;
  2709. esac
  2710. ;;
  2711. esac
  2712. case $m in
  2713. *[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
  2714. m=$(echo "X$m" | sed -e 's,^.,,' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g')
  2715. ;;
  2716. esac
  2717. # check output redirection
  2718. case $out in
  2719. $cur) ;;
  2720. *) case $cur in
  2721. $a|$c) ;;
  2722. *) case $cur in
  2723. .) ;;
  2724. *) case $vers in
  2725. ?*) echo
  2726. for api in $vers
  2727. do API=$(echo $api | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ)
  2728. eval ver='${'ver_${api}'}'
  2729. echo "#define ${API}_VERSION ${ver}"
  2730. done
  2731. esac
  2732. case $apis in
  2733. ?*) for api in $apis
  2734. do API=$(echo $api | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ)
  2735. echo "#define ${API}API(rel) ( _BLD_${api} || !_API_${api} || _API_${api} >= rel )"
  2736. map=
  2737. sep=
  2738. eval syms='"${'api_sym_${api}'}"'
  2739. # old Solaris requires -k<space><junk> #
  2740. set x x $(echo "$syms" | sort -t: -u -k 1,1 -k 2,2nr 2>/dev/null | sed 's/:/ /')
  2741. case $# in
  2742. 2) # ancient sort doesn't have -k #
  2743. set x x $(echo "$syms" | sort -t: -u +0 -1 +1 -2nr 2>/dev/null | sed 's/:/ /')
  2744. ;;
  2745. esac
  2746. sym=
  2747. while :
  2748. do shift 2
  2749. case $# in
  2750. [01]) break ;;
  2751. esac
  2752. prv=$sym
  2753. sym=$1
  2754. rel=$2
  2755. case $prv in
  2756. $sym) echo "#elif _API_${api} >= $rel"
  2757. ;;
  2758. *) case $prv in
  2759. '') echo
  2760. echo "#if !defined(_API_${api}) && defined(_API_DEFAULT)"
  2761. echo "#define _API_${api} _API_DEFAULT"
  2762. echo "#endif"
  2763. ;;
  2764. *) echo "#endif"
  2765. ;;
  2766. esac
  2767. echo
  2768. echo "#if ${API}API($rel)"
  2769. ;;
  2770. esac
  2771. echo "#undef ${sym}"
  2772. echo "#define ${sym} ${sym}_${rel}"
  2773. map=$map$sep${sym}_${rel}
  2774. sep=' '
  2775. done
  2776. echo "#endif"
  2777. echo
  2778. echo "#define _API_${api}_MAP \"$map\""
  2779. done
  2780. echo
  2781. ;;
  2782. esac
  2783. case $iff in
  2784. ?*) echo "#endif" ;;
  2785. esac
  2786. case $cur in
  2787. -) ;;
  2788. *) exec >/dev/null
  2789. case $cur in
  2790. *[\\/]*|*.h) x=$cur ;;
  2791. *) x=$dir/$cur ;;
  2792. esac
  2793. case $define in
  2794. n) sed '/^#/d' $tmp.h > $tmp.c
  2795. sed '/^#/d' $x > $tmp.t
  2796. ;;
  2797. *) sed 's,/\*[^/]*\*/, ,g' $tmp.h > $tmp.c
  2798. sed 's,/\*[^/]*\*/, ,g' $x > $tmp.t
  2799. ;;
  2800. esac
  2801. if cmp -s $tmp.c $tmp.t
  2802. then rm -f $tmp.h
  2803. case $verbose in
  2804. 1) echo "$command: $x: unchanged" >&$stderr ;;
  2805. esac
  2806. touch "$x" # avoid rerunning test on subsequent runs
  2807. else case $x in
  2808. ${dir}[\\/]$cur) test -d $dir || mkdir $dir || exit 1 ;;
  2809. esac
  2810. mv $tmp.h $x
  2811. fi
  2812. ;;
  2813. esac
  2814. ;;
  2815. esac
  2816. case $out in
  2817. +) case $status in
  2818. 1) ;;
  2819. *) status=0 ;;
  2820. esac
  2821. exit $status
  2822. ;;
  2823. -) eval "exec >&$stdout"
  2824. ;;
  2825. *) exec >$tmp.h
  2826. ;;
  2827. esac
  2828. case $out in
  2829. "") case $a in
  2830. *[\\/]*|???????????????*) cur=$c ;;
  2831. *) cur=$a ;;
  2832. esac
  2833. ;;
  2834. *) cur=$out
  2835. ;;
  2836. esac
  2837. case $in in
  2838. ""|-|+) case $o in
  2839. run) x=" from $a" ;;
  2840. *) x= ;;
  2841. esac
  2842. ;;
  2843. *) x=" from $in"
  2844. ;;
  2845. esac
  2846. # output header comments
  2847. case $define in
  2848. n) ;;
  2849. ?) echo "/* : : generated$x by $command version $version : : */"
  2850. for x in $pragma
  2851. do echo "#pragma $x"
  2852. done
  2853. case $out in
  2854. ""|-|+) x=$m
  2855. ;;
  2856. *.*) i=$out
  2857. x=_
  2858. while :
  2859. do case $i in
  2860. *.*) x=$x${i%%.*}_
  2861. i=${i#*.}
  2862. ;;
  2863. *) x=$x$i
  2864. break
  2865. ;;
  2866. esac
  2867. done
  2868. ;;
  2869. *) x=_$out
  2870. ;;
  2871. esac
  2872. case $o in
  2873. iff) case $M in
  2874. ""|*-*) ;;
  2875. *) iff=${m}_H ;;
  2876. esac
  2877. ;;
  2878. *) case $regress in
  2879. '') case $x in
  2880. *-*) ;;
  2881. *) x=$(pwd | sed -e 's,.*[\\/],,' -e 's,\..*,,' -e 's,^lib,,' -e 's,^,'${x}_',' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g')
  2882. # ksh n+ bug workaround
  2883. case $x in
  2884. *[!_]*) ;;
  2885. *) x=_$$ ;;
  2886. esac
  2887. iff=_def${x}
  2888. ;;
  2889. esac
  2890. ;;
  2891. *) case $x in
  2892. *-*) ;;
  2893. *) iff=_REGRESS
  2894. ;;
  2895. esac
  2896. ;;
  2897. esac
  2898. ;;
  2899. esac
  2900. case $iff in
  2901. ?*) echo "#ifndef $iff"
  2902. echo "#define $iff 1"
  2903. ;;
  2904. esac
  2905. ;;
  2906. esac
  2907. ;;
  2908. esac
  2909. ;;
  2910. esac
  2911. case $can in
  2912. ?*) case $define in
  2913. 1) echo "$can" ;;
  2914. n) echo "$nan" ;;
  2915. esac
  2916. can=
  2917. nan=
  2918. cansep=
  2919. ;;
  2920. esac
  2921. # set up the candidate include list
  2922. pre=
  2923. inc=
  2924. for x in $defhdr - $hdr
  2925. do case $x in
  2926. -) case $pre in
  2927. ?*) continue ;;
  2928. esac
  2929. case $v in
  2930. *.*) for x in $(echo $v | sed 's,\., ,g')
  2931. do pre="$pre$nl#undef $x"
  2932. done
  2933. ;;
  2934. *) case $o in
  2935. siz|typ)case $v in
  2936. char|short|int|long)
  2937. ;;
  2938. *) pre="#undef $v"
  2939. ;;
  2940. esac
  2941. ;;
  2942. *) pre="#undef $v"
  2943. ;;
  2944. esac
  2945. ;;
  2946. esac
  2947. ;;
  2948. *.h) c=${x##*[\\/]}
  2949. c=${c%%.*}
  2950. case $x in
  2951. */*) c=${x%%[\\/]*}_${c} ;;
  2952. esac
  2953. case $config in
  2954. 0) case $x in
  2955. */*) c=_${c} ;;
  2956. *) c=_hdr_${c} ;;
  2957. esac
  2958. ;;
  2959. 1) case $shell in
  2960. ksh) typeset -u u=$c ;;
  2961. *) u=$(echo "$c" | LC_ALL=C tr a-z A-Z) ;;
  2962. esac
  2963. c=HAVE_${u}_H
  2964. ;;
  2965. esac
  2966. case " $puthdr " in
  2967. *" $c "*)
  2968. ;;
  2969. *) puthdr="$puthdr $c"
  2970. usr="$usr$nl#define $c 1"
  2971. ;;
  2972. esac
  2973. inc="$inc$nl#include <$x>"
  2974. ;;
  2975. esac
  2976. done
  2977. # set up the candidate lib list
  2978. for x in $lib $deflib
  2979. do c=${x#-l}
  2980. case $c in
  2981. *[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
  2982. c=$(echo '' $c | sed -e 's,.*[\\/],,' -e 's,\.[^.]*$,,' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g' -e '/^lib./s,^lib,,')
  2983. ;;
  2984. esac
  2985. case $config in
  2986. 0) c=_LIB_${c}
  2987. ;;
  2988. 1) case $shell in
  2989. ksh) typeset -u u=$c ;;
  2990. *) u=$(echo $c | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ) ;;
  2991. esac
  2992. c=HAVE_${u}_LIB
  2993. ;;
  2994. esac
  2995. case " $putlib " in
  2996. *" $c "*)
  2997. ;;
  2998. *) putlib="$putlib $c"
  2999. usr="$usr$nl#define $c 1"
  3000. ;;
  3001. esac
  3002. done
  3003. # src overrides builtin test
  3004. case $config:$def in
  3005. 0:) case $o in
  3006. tst|var);;
  3007. *) m=_${o}${m} ;;
  3008. esac
  3009. ;;
  3010. 1:) case $o in
  3011. tst|var)m=${v} ;;
  3012. esac
  3013. case $shell in
  3014. ksh) typeset -u u=$m ;;
  3015. *) u=$(echo $m | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ) ;;
  3016. esac
  3017. case $o in
  3018. tst|var)case $m in
  3019. $u) ;;
  3020. *) case $m in
  3021. hdr_*|lib_*|sys_*)
  3022. u=${u#????}
  3023. ;;
  3024. esac
  3025. m=HAVE_${u}
  3026. ;;
  3027. esac
  3028. ;;
  3029. dat) m=HAVE${u}_DATA ;;
  3030. hdr|lcl)m=HAVE${u}_H ;;
  3031. key) m=HAVE${u}_RESERVED ;;
  3032. mth) m=HAVE${u}_MATH ;;
  3033. npt) m=HAVE${u}_DECL ;;
  3034. pth) m=${u}_PATH
  3035. m=${m#_}
  3036. ;;
  3037. nxt) m=HAVE${u}_NEXT ;;
  3038. siz) m=SIZEOF${u} ;;
  3039. sys) m=HAVE_SYS${u}_H ;;
  3040. *) m=HAVE${u} ;;
  3041. esac
  3042. ;;
  3043. *) m=$def
  3044. M=$m
  3045. ;;
  3046. esac
  3047. case $src in
  3048. ?*) case $src in
  3049. *[\<\"][Ss][Tt][Dd][Ii][Oo].[Hh][\"\>]* | *\<ast.h\>* | *\<sfio.h\>* | */[*]\<NOSTDIO\>[*]/*)
  3050. EXT=
  3051. ;;
  3052. *) EXT="$tst
  3053. $ext"
  3054. ;;
  3055. esac
  3056. copy $tmp.c "$std
  3057. $EXT
  3058. $usr
  3059. $inc
  3060. $src
  3061. "
  3062. V=1
  3063. e=0
  3064. is tst "${note:-$run}"
  3065. case $run in
  3066. cat*|nocat*)
  3067. copy - "$src"
  3068. ;;
  3069. cross*|nocross*)
  3070. copy $tmp.sh "$src"
  3071. chmod +x $tmp.sh
  3072. execute $tmp.sh <&$nullin || e=1
  3073. ;;
  3074. run*|norun*)
  3075. (eval "$src") <&$nullin || e=1
  3076. ;;
  3077. mac*|nomac*)
  3078. if compile $cc -E -P $tmp.c <&$nullin >$tmp.i
  3079. then sed -e '/<<[ ]*".*"[ ]*>>/!d' -e 's/<<[ ]*"//g' -e 's/"[ ]*>>//g' $tmp.i
  3080. else e=1
  3081. fi
  3082. ;;
  3083. p*|nop*)compile $cc -DTEST=$p -DID=$v -E $tmp.c <&$nullin >&$nullout || e=1
  3084. ;;
  3085. c*|noc*)compile $cc -DTEST=$p -DID=$v -c $tmp.c <&$nullin >&$nullout || e=1
  3086. ;;
  3087. *) case $run in
  3088. status*)ccflags=
  3089. ;;
  3090. s*|nos*)case $reallystatictest in
  3091. '') #UNDENT...
  3092. reallystatictest=.
  3093. echo "$tst$nl$ext${nl}int main(){printf("hello");return(0);}" > ${tmp}s.c
  3094. rm -f ${tmp}s.exe
  3095. if compile $cc -c ${tmp}s.c <&$nullin >&$nullout &&
  3096. compile $cc -o ${tmp}s.exe ${tmp}s.o <&$nullin >&$nullout 2>${tmp}s.e &&
  3097. $executable ${tmp}s.exe
  3098. then e=$(wc -l ${tmp}s.e)
  3099. eval set x x $binding
  3100. while :
  3101. do shift
  3102. shift
  3103. case $# in
  3104. 0) break ;;
  3105. esac
  3106. rm -f ${tmp}s.exe
  3107. compile $cc -o ${tmp}s.exe $1 ${tmp}s.o <&$nullin >&$nullout 2>${tmp}s.e && $executable ${tmp}s.exe || continue
  3108. case $(wc -l ${tmp}s.e) in
  3109. $e) ;;
  3110. *) continue ;;
  3111. esac
  3112. d=$(ls -s ${tmp}s.exe)
  3113. rm -f ${tmp}s.exe
  3114. compile $cc -o ${tmp}s.exe $2 ${tmp}s.o <&$nullin >&$nullout 2>${tmp}s.e && $executable ${tmp}s.exe || continue
  3115. case $(wc -l ${tmp}s.e) in
  3116. $e) ;;
  3117. *) continue ;;
  3118. esac
  3119. case $(ls -s ${tmp}s.exe) in
  3120. $d) ;;
  3121. *) reallystatic=$2
  3122. set x
  3123. shift
  3124. break
  3125. ;;
  3126. esac
  3127. done
  3128. fi
  3129. (set +o noglob; exec rm -f ${tmp}s.*)
  3130. #...INDENT
  3131. ;;
  3132. esac
  3133. ccflags=$reallystatic
  3134. ;;
  3135. *) ccflags=
  3136. ;;
  3137. esac
  3138. set x $mac
  3139. e=1
  3140. while :
  3141. do o=
  3142. shift
  3143. while :
  3144. do case $# in
  3145. 0) break ;;
  3146. esac
  3147. case $1 in
  3148. -) break ;;
  3149. esac
  3150. o="$o $1"
  3151. shift
  3152. done
  3153. rm -f $tmp.exe
  3154. if compile $cc $ccflags $o -DTEST=$p -DID=$v -o $tmp.exe $tmp.c $lib $deflib <&$nullin >&$nullout && $executable $tmp.exe
  3155. then case $run in
  3156. status*)execute $tmp.exe <&$nullin >&$nullout
  3157. V=$?
  3158. case $V in
  3159. 0) e=1 ;;
  3160. *) e=0 ;;
  3161. esac
  3162. break
  3163. ;;
  3164. no[ls]*);;
  3165. [ls]*) e=0 && break ;;
  3166. noo*) execute $tmp.exe <&$nullin >$tmp.out || break ;;
  3167. o*) execute $tmp.exe <&$nullin >$tmp.out && e=0 && break ;;
  3168. no*) execute $tmp.exe <&$nullin >&$nullout || break ;;
  3169. *) execute $tmp.exe <&$nullin >&$nullout && e=0 && break ;;
  3170. esac
  3171. else case $run in
  3172. no[els]*)e=1 && break ;;
  3173. esac
  3174. fi
  3175. case $# in
  3176. 0) case $run in
  3177. no*) e=0 ;;
  3178. esac
  3179. break
  3180. ;;
  3181. esac
  3182. done
  3183. ;;
  3184. esac
  3185. o=1
  3186. case $run in
  3187. no*) case $e in
  3188. 0) e=1 ;;
  3189. *) e=0 ;;
  3190. esac
  3191. ;;
  3192. esac
  3193. case $run in
  3194. o*|noo*)case $e in
  3195. 0) cat $tmp.out ;;
  3196. esac
  3197. rm -f $tmp.out
  3198. ;;
  3199. esac
  3200. report $e $V "${note:-$run\ passed}" "${note:-$run} failed"
  3201. continue
  3202. ;;
  3203. esac
  3204. # initialize common builtin state
  3205. case $o in
  3206. dat|lib|mth|run)
  3207. case $statictest in
  3208. "") statictest=FoobaR
  3209. copy $tmp.c "
  3210. $tst
  3211. $ext
  3212. $std
  3213. $usr
  3214. extern int $statictest;
  3215. int main(){char* i = (char*)&$statictest; return ((unsigned int)i)^0xaaaa;}
  3216. "
  3217. rm -f $tmp.exe
  3218. if compile $cc -o $tmp.exe $tmp.c <&$nullin >&$nullout && $executable $tmp.exe
  3219. then case $static in
  3220. .) static=
  3221. copy $tmp.c "
  3222. $tst
  3223. $ext
  3224. int main(){printf("hello");return(0);}
  3225. "
  3226. rm -f $tmp.exe
  3227. if compile $cc -c $tmp.c <&$nullin >&$nullout &&
  3228. compile $cc -o $tmp.exe $tmp.o <&$nullin >&$nullout &&
  3229. $executable $tmp.exe
  3230. then e=$(wc -l $tmp.e)
  3231. eval set x x $binding
  3232. while :
  3233. do shift
  3234. shift
  3235. case $# in
  3236. 0) break ;;
  3237. esac
  3238. rm -f $tmp.exe
  3239. compile $cc -o $tmp.exe $1 $tmp.o <&$nullin >&$nullout && $executable $tmp.exe || continue
  3240. case $(wc -l $tmp.e) in
  3241. $e) ;;
  3242. *) continue ;;
  3243. esac
  3244. d=$(ls -s $tmp.exe)
  3245. rm -f $tmp.exe
  3246. compile $cc -o $tmp.exe $2 $tmp.o <&$nullin >&$nullout && $executable $tmp.exe || continue
  3247. case $(wc -l $tmp.e) in
  3248. $e) ;;
  3249. *) continue ;;
  3250. esac
  3251. case $(ls -s $tmp.exe) in
  3252. $d) ;;
  3253. *) static=$2
  3254. set x
  3255. shift
  3256. break
  3257. ;;
  3258. esac
  3259. done
  3260. fi
  3261. ;;
  3262. esac
  3263. else static=
  3264. fi
  3265. ;;
  3266. esac
  3267. ;;
  3268. esac
  3269. # builtin tests
  3270. case $o in
  3271. api) ;;
  3272. cmd) case $p in
  3273. ?*) continue ;;
  3274. esac
  3275. is $o $a
  3276. k=1
  3277. pkg $pth # set system default path
  3278. for d in $pth
  3279. do if test -f "$d/$a"
  3280. then s=$(echo "$d" | LC_ALL=C sed 's,[^0-9A-Za-z],_,g')
  3281. case $k in
  3282. 1) k=0
  3283. case $M in
  3284. *-*) ;;
  3285. *) usr="$usr$nl#define $m 1"
  3286. case $define in
  3287. 1) echo "#define $m 1 /* $a in $pth */" ;;
  3288. n) echo "$m=1" ;;
  3289. esac
  3290. ;;
  3291. esac
  3292. ;;
  3293. esac
  3294. c=${s}_${v}
  3295. usr="$usr$nl#define $c 1"
  3296. case $define in
  3297. 1) echo "#define $c 1 /* $d/$a found */" ;;
  3298. n) echo "$c=1" ;;
  3299. esac
  3300. fi
  3301. done
  3302. case $k in
  3303. 0) success ;;
  3304. 1) failure ;;
  3305. esac
  3306. ;;
  3307. dat) case $p in
  3308. ?*) continue ;;
  3309. esac
  3310. {
  3311. copy - "
  3312. $tst
  3313. $ext
  3314. $std
  3315. $usr
  3316. $pre
  3317. "
  3318. case $inc in
  3319. ?*) echo "$inc"
  3320. ;;
  3321. *) echo "extern int $v;"
  3322. ;;
  3323. esac
  3324. echo "
  3325. #ifdef _DLL
  3326. #define _REF_
  3327. #else
  3328. #define _REF_ &
  3329. #endif
  3330. int main(){char* i = (char*) _REF_ $v; return ((unsigned int)i)^0xaaaa;}"
  3331. } > $tmp.c
  3332. is $o $v
  3333. rm -f $tmp.exe
  3334. compile $cc -c $tmp.c <&$nullin >&$nullout &&
  3335. compile $cc $static -o $tmp.exe $tmp.o $lib $deflib <&$nullin >&$nullout &&
  3336. $executable $tmp.exe
  3337. report $? 1 "$v in default lib(s)" "$v not in default lib(s)"
  3338. ;;
  3339. dfn) case $p in
  3340. ?*) continue ;;
  3341. esac
  3342. is dfn $v
  3343. echo "$pre
  3344. $tst
  3345. $ext
  3346. $inc
  3347. #ifdef $v
  3348. <<\"#ifndef $v\">>
  3349. <<\"#define $v\">> $v <<\"/* native $v */\">>
  3350. <<\"#endif\">>
  3351. #endif" > $tmp.c
  3352. if compile $cc -E -P $tmp.c <&$nullin >$tmp.i
  3353. then sed -e '/<<[ ]*".*"[ ]*>>/!d' -e 's/<<[ ]*"//g' -e 's/"[ ]*>>//g' $tmp.i > $tmp.t
  3354. if test -s $tmp.t
  3355. then success
  3356. cat $tmp.t
  3357. else failure
  3358. fi
  3359. else failure
  3360. fi
  3361. ;;
  3362. exp) case $test in
  3363. '') echo "$command: $file$sline: test expression expected for $o" >&$stderr
  3364. exit 1
  3365. ;;
  3366. esac
  3367. case $a in
  3368. -|'') ;;
  3369. *) eval x='$'$a
  3370. case $x in
  3371. 1) result=FAILURE
  3372. continue
  3373. ;;
  3374. esac
  3375. ;;
  3376. esac
  3377. case $test in
  3378. [01]|'"'*'"'|'<'*'>')
  3379. case $a in
  3380. -|'') ;;
  3381. *) case $define$note in
  3382. 1) echo "#define $a $test" ;;
  3383. 1*) echo "#define $a $test /* $note */" ;;
  3384. n) echo "$a=$test" ;;
  3385. esac
  3386. eval $a='$test'
  3387. ;;
  3388. esac
  3389. ;;
  3390. *) case $note in
  3391. '') note=$test ;;
  3392. esac
  3393. case $test in
  3394. '') c=1
  3395. ;;
  3396. *) is exp "$note"
  3397. x=
  3398. for i in $(echo '' $test | sed 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_], & ,g')
  3399. do case $i in
  3400. [\ \ ])
  3401. ;;
  3402. [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]*)
  3403. eval i='${'$i'}'
  3404. case $i in
  3405. '') i=0
  3406. ;;
  3407. '"'*'"');;
  3408. *[!-+0123456789]*)
  3409. case $i in
  3410. *'"'*) i=1 ;;
  3411. *) i='"'$i'"' ;;
  3412. esac
  3413. ;;
  3414. esac
  3415. x="$x $i"
  3416. ;;
  3417. '!') x="$x 0 ="
  3418. ;;
  3419. '&'|'|')case $x in
  3420. *"$i") ;;
  3421. *) x="$x \\$i" ;;
  3422. esac
  3423. ;;
  3424. *) x="$x \\$i"
  3425. ;;
  3426. esac
  3427. done
  3428. c=$(eval expr $x 2>&$stderr)
  3429. ;;
  3430. esac
  3431. case $c in
  3432. 0) c=1 ;;
  3433. *) c=0 ;;
  3434. esac
  3435. M=$a
  3436. m=$a
  3437. report $c 1 "$note is true" "$note is false"
  3438. ;;
  3439. esac
  3440. ;;
  3441. hdr|lcl|nxt|sys)
  3442. case $o in
  3443. lcl|nxt)case $M in
  3444. *-*) continue ;;
  3445. esac
  3446. eval x='$'_$m
  3447. case $x in
  3448. ?*) continue ;;
  3449. esac
  3450. eval _$m=1
  3451. is $o $f
  3452. echo "$pre
  3453. $tst
  3454. $ext
  3455. $inc
  3456. #include <$f.h>" > $tmp.c
  3457. case $f in
  3458. sys/*) e= ;;
  3459. *) e='-e /[\\\\\/]sys[\\\\\/]'$f'\\.h"/d' ;;
  3460. esac
  3461. if compile $cc -E $tmp.c <&$nullin >$tmp.i
  3462. then i=$(sed -e '/^#[line ]*[0123456789][0123456789]*[ ][ ]*"[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:]*[\\\/].*[\\\/]'$f'\.h"/!d' $e -e 's/.*"\(.*\)".*/\1/' -e 's,\\,/,g' -e 's,///*,/,g' $tmp.i | sed 1q)
  3463. case $i in
  3464. [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]:[\\/]*)
  3465. ;;
  3466. */*/*) k=$(echo "$i" | sed 's,.*/\([^/]*/[^/]*\)$,../\1,')
  3467. echo "$pre
  3468. $tst
  3469. $ext
  3470. $inc
  3471. #include <$k>" > $tmp.c
  3472. if compile $cc -E $tmp.c <&$nullin >$tmp.i
  3473. then j=$(sed -e '/^#[line ]*[0123456789][0123456789]*[ ][ ]*"[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:]*[\\\/].*[\\\/]'$f'\.h"/!d' $e -e 's/.*"\(.*\)".*/\1/' -e 's,\\,/,g' -e 's,///*,/,g' $tmp.i | sed 1q)
  3474. wi=$(wc < "$i")
  3475. wj=$(wc < "$j")
  3476. case $wi in
  3477. $wj) i=$k ;;
  3478. esac
  3479. fi
  3480. ;;
  3481. *) echo "$pre
  3482. $tst
  3483. $ext
  3484. $inc
  3485. #include <../include/$f.h>" > $tmp.c
  3486. if compile $cc -E $tmp.c <&$nullin >&$nullout
  3487. then i=../include/$f.h
  3488. fi
  3489. ;;
  3490. esac
  3491. else i=
  3492. fi
  3493. case $i in
  3494. [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]:[\\/]*|[\\/]*)
  3495. success
  3496. case $o in
  3497. lcl) echo "#include <$i> /* the native <$f.h> */"
  3498. echo "#undef $m"
  3499. usr="$usr$nl#define $m 1"
  3500. echo "#define $m 1"
  3501. ;;
  3502. nxt) echo "#define $m <$i> /* include path for the native <$f.h> */"
  3503. echo "#define ${m}_str \"$i\" /* include string for the native <$f.h> */"
  3504. usr="$usr$nl#define $m <$i>$nl#define ${m}_str \"$i\""
  3505. eval $m=\\\<$i\\\>
  3506. ;;
  3507. esac
  3508. break
  3509. ;;
  3510. ../*/*) success
  3511. case $o in
  3512. lcl) echo "#include <$i> /* the native <$f.h> */"
  3513. echo "#undef $m"
  3514. usr="$usr$nl#define $m 1"
  3515. echo "#define $m 1"
  3516. eval $m=1
  3517. ;;
  3518. nxt) echo "#define $m <$i> /* include path for the native <$f.h> */"
  3519. echo "#define ${m}_str \"$i\" /* include string for the native <$f.h> */"
  3520. usr="$usr$nl#define $m <$i>$nl#define ${m}_str \"$i\""
  3521. eval $m=\\\<$i\\\>
  3522. ;;
  3523. esac
  3524. break
  3525. ;;
  3526. *) failure
  3527. case $o in
  3528. lcl) case $all$config$undef in
  3529. ?1?|??1)echo "#undef $m /* no native <$f.h> */" ;;
  3530. 1??) echo "#define $m 0 /* no native <$f.h> */" ;;
  3531. esac
  3532. eval $m=0
  3533. ;;
  3534. nxt) case $all$config$undef in
  3535. ?1?|??1)echo "#undef $m /* no include path for the native <$f.h> */" ;;
  3536. esac
  3537. ;;
  3538. esac
  3539. ;;
  3540. esac
  3541. ;;
  3542. *) case $o in
  3543. hdr) x=$f.h ;;
  3544. sys) x=sys/$f.h ;;
  3545. esac
  3546. case " $gothdr " in
  3547. *" - $x "*)
  3548. failure +
  3549. ;;
  3550. *" + $x "*)
  3551. success +
  3552. ;;
  3553. *) echo "
  3554. $tst
  3555. $ext
  3556. $allinc
  3557. $inc
  3558. #include <$x>" > $tmp.c
  3559. if is_hdr $x
  3560. then gothdr="$gothdr + $x"
  3561. case $M in
  3562. *-*) ;;
  3563. *) case " $puthdr " in
  3564. *" $m "*)
  3565. ;;
  3566. *) puthdr="$puthdr $m"
  3567. usr="$usr$nl#define $m 1"
  3568. ;;
  3569. esac
  3570. case $define in
  3571. 1) echo "#define $m 1 /* #include <$x> ok */" ;;
  3572. n) echo "$m=1" ;;
  3573. esac
  3574. eval $m=1
  3575. ;;
  3576. esac
  3577. else gothdr="$gothdr - $x"
  3578. case $M in
  3579. *-*) ;;
  3580. *) case $define$all$config$undef in
  3581. 1?1?|1??1)echo "#undef $m /* #include <$x> not ok */" ;;
  3582. 11??) echo "#define $m 0 /* #include <$x> not ok */" ;;
  3583. n1?1) echo "$m=" ;;
  3584. n1??) echo "$m=0" ;;
  3585. esac
  3586. eval $m=0
  3587. ;;
  3588. esac
  3589. fi
  3590. ;;
  3591. esac
  3592. continue
  3593. ;;
  3594. esac
  3595. ;;
  3596. iff) ;;
  3597. ini) ;;
  3598. key) case $p in
  3599. ?*) continue ;;
  3600. esac
  3601. w=$v
  3602. while :
  3603. do is $o $w
  3604. echo "$pre
  3605. $tst
  3606. $ext
  3607. int f(){int $w = 1;return($w);}" > $tmp.c
  3608. if compile $cc -c $tmp.c <&$nullin >&$nullout
  3609. then failure
  3610. case $set in
  3611. *" ="|*" = "*)
  3612. set x $set
  3613. shift
  3614. w=
  3615. while :
  3616. do case $# in
  3617. 0) break ;;
  3618. esac
  3619. case $1 in
  3620. =) break ;;
  3621. esac
  3622. case $w in
  3623. '') w=$1 ;;
  3624. *) w="$w $1" ;;
  3625. esac
  3626. shift
  3627. done
  3628. case $1 in
  3629. =) shift
  3630. case $# in
  3631. 0) set=" " ;;
  3632. *) set=$* ;;
  3633. esac
  3634. ;;
  3635. *) set=
  3636. ;;
  3637. esac
  3638. case $shell in
  3639. ksh) typeset -u u=$w ;;
  3640. *) u=$(echo $w | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ) ;;
  3641. esac
  3642. u=_$u
  3643. M=$w
  3644. case $M in
  3645. *[!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*)
  3646. M=$(echo "X$m" | sed -e 's,^.,,' -e 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_],_,g')
  3647. ;;
  3648. esac
  3649. case $config in
  3650. 1) m=HAVE${u}_RESERVED ;;
  3651. *) m=_key_${w} ;;
  3652. esac
  3653. continue
  3654. ;;
  3655. esac
  3656. report - 1 - - "$w is not a reserved keyword" "default for reserved keyword $v"
  3657. else report 0 1 "$w is a reserved keyword" -
  3658. case $M in
  3659. *-*) ;;
  3660. *) case $define$w in
  3661. 1$v) ;;
  3662. 1*) echo "#define $v $w /* alternate for reserved keyword $v */" ;;
  3663. n*) echo "$v=$w" ;;
  3664. esac
  3665. ;;
  3666. esac
  3667. fi
  3668. break
  3669. done
  3670. ;;
  3671. lib|mth)case $p in
  3672. ?*) continue ;;
  3673. esac
  3674. case $v in
  3675. -) continue ;;
  3676. esac
  3677. is $o $v
  3678. copy $tmp.c "
  3679. $tst
  3680. $ext
  3681. $std
  3682. $usr
  3683. $pre
  3684. $inc
  3685. #ifdef _IFFE_type
  3686. $v i;
  3687. #else
  3688. typedef int (*_IFFE_fun)();
  3689. #ifdef _IFFE_extern
  3690. extern int $v();
  3691. #endif
  3692. static _IFFE_fun i=(_IFFE_fun)$v;int main(){return ((unsigned int)i)^0xaaaa;}
  3693. #endif
  3694. "
  3695. d=-D_IFFE_extern
  3696. if compile $cc -c $tmp.c <&$nullin >&$nullout
  3697. then d=
  3698. elif compile $cc $d -c $tmp.c <&$nullin >&$nullout
  3699. then :
  3700. else d=error
  3701. fi
  3702. if test error != "$d"
  3703. then rm -f $tmp.exe
  3704. if compile $cc $d $static -o $tmp.exe $tmp.o $lib $deflib <&$nullin >&$nullout &&
  3705. $executable $tmp.exe
  3706. then case $o in
  3707. lib) c=0 ;;
  3708. *) c=1 ;;
  3709. esac
  3710. report $c 1 "$v() in default lib(s)" "$v() not in default lib(s)" "default for function $v()"
  3711. else case $o in
  3712. mth) rm -f $tmp.exe
  3713. compile $cc $d $static -o $tmp.exe $tmp.o -lm <&$nullin >&$nullout &&
  3714. $executable $tmp.exe
  3715. report $? 1 "$v() in math lib" "$v() not in math lib" "default for function $v()"
  3716. ;;
  3717. *) report 1 1 - "$v() not in default lib(s)" "default for function $v()"
  3718. ;;
  3719. esac
  3720. fi
  3721. else if compile $cc -D_IFFE_type -c $tmp.c <&$nullin >&$nullout
  3722. then c=1
  3723. else case $intrinsic in
  3724. '') copy $tmp.c "
  3725. $tst
  3726. $ext
  3727. $std
  3728. $usr
  3729. $pre
  3730. $inc
  3731. extern int foo();
  3732. static int ((*i)())=foo;int main(){return(i==0);}
  3733. "
  3734. compile $cc -c $tmp.c <&$nullin >&$nullout
  3735. intrinsic=$?
  3736. ;;
  3737. esac
  3738. c=$intrinsic
  3739. fi
  3740. case $o in
  3741. mth) report $c 1 "$v() in math lib" "$v() not in math lib" "default for function $v()" ;;
  3742. *) report $c 1 "$v() in default lib(s)" "$v() not in default lib(s)" "default for function $v()" ;;
  3743. esac
  3744. fi
  3745. ;;
  3746. mac) case $p in
  3747. ?*) continue ;;
  3748. esac
  3749. is mac $v
  3750. echo "
  3751. $tst
  3752. $ext
  3753. $pre
  3754. $inc
  3755. #ifdef $v
  3756. '$m:$v'
  3757. #endif" > $tmp.c
  3758. compile $cc -E $tmp.c <&$nullin | grep -c "'$m:$v'" >&$nullout
  3759. report $? 1 "$v is a macro" "$v is not a macro" "default for macro $v"
  3760. ;;
  3761. mem) case $p in
  3762. ?*) eval i='$'_iffe_typedef_$p
  3763. case $i in
  3764. 0|1) ;;
  3765. *) echo "$pre
  3766. $tst
  3767. $ext
  3768. $inc
  3769. static $p i;
  3770. int n = sizeof(i);" > $tmp.c
  3771. is typ $p
  3772. if compile $cc -c $tmp.c <&$nullin >&$nullout
  3773. then success -
  3774. eval _iffe_typedef_$p=1
  3775. i=1
  3776. else failure -
  3777. eval _iffe_typedef_$p=0
  3778. i=0
  3779. fi
  3780. ;;
  3781. esac
  3782. case $i in
  3783. 0) i="$v is not a member of $p" p="struct $p" ;;
  3784. *) i=- ;;
  3785. esac
  3786. is mem $v "$p"
  3787. echo "$pre
  3788. $tst
  3789. $ext
  3790. $inc
  3791. static $p i;
  3792. int n = sizeof(i.$v);" > $tmp.c
  3793. compile $cc -c $tmp.c <&$nullin >&$nullout
  3794. report $? 1 "$v is a member of $p" "$i"
  3795. ;;
  3796. *) p=$v
  3797. eval i='$'_iffe_typedef_$p
  3798. case $i in
  3799. 0|1) ;;
  3800. *) echo "$pre
  3801. $tst
  3802. $ext
  3803. $inc
  3804. static $p i;
  3805. int n = sizeof(i);" > $tmp.c
  3806. is typ $p
  3807. if compile $cc -c $tmp.c <&$nullin >&$nullout
  3808. then success -
  3809. eval _iffe_typedef_$p=1
  3810. i=1
  3811. else failure -
  3812. eval _iffe_typedef_$p=0
  3813. i=0
  3814. fi
  3815. ;;
  3816. esac
  3817. case $i in
  3818. 0) i="$p is not a non-opaque struct" p="struct $p" ;;
  3819. *) i=- ;;
  3820. esac
  3821. is nos "$p"
  3822. echo "$pre
  3823. $tst
  3824. $ext
  3825. $inc
  3826. static $p i;
  3827. int n = sizeof(i);" > $tmp.c
  3828. if compile $cc -c $tmp.c <&$nullin >&$nullout
  3829. then echo "$pre
  3830. $tst
  3831. $ext
  3832. $inc
  3833. static $p i;
  3834. unsigned long f() { return (unsigned long)i; }" > $tmp.c
  3835. if compile $cc -c $tmp.c <&$nullin >&$nullout
  3836. then c=1
  3837. else c=0
  3838. fi
  3839. else c=1
  3840. fi
  3841. report $c 1 "$p is a non-opaque struct" "$i"
  3842. esac
  3843. ;;
  3844. nop) ;;
  3845. npt) is npt $v
  3846. copy $tmp.c "
  3847. $tst
  3848. $ext
  3849. $std
  3850. $usr
  3851. $pre
  3852. $inc
  3853. struct _iffe_struct { int _iffe_member; };
  3854. extern struct _iffe_struct* $v(struct _iffe_struct*);
  3855. "
  3856. # some compilers with -O only warn for invalid intrinsic prototypes
  3857. case " $cc " in
  3858. *" -O "*) xx=$(echo $cc | sed 's/ -O / /g') ;;
  3859. *) xx=$cc ;;
  3860. esac
  3861. compile $xx -c $tmp.c <&$nullin >&$nullout
  3862. report -$config $? 1 "$v() needs a prototype" "$v() does not need a prototype"
  3863. ;;
  3864. num) is num $v
  3865. copy $tmp.c "
  3866. $tst
  3867. $ext
  3868. $std
  3869. $usr
  3870. $pre
  3871. $inc
  3872. int _iffe_int = $v / 2;
  3873. "
  3874. compile $cc -c $tmp.c <&$nullin >&$nullout
  3875. report $? 1 "$v is a numeric constant" "$v is not a numeric constant"
  3876. ;;
  3877. one) for i in $a $hdr
  3878. do x="#include <$i>"
  3879. case " $gothdr " in
  3880. *" - $i "*)
  3881. continue
  3882. ;;
  3883. *" + $i "*)
  3884. ;;
  3885. *) echo "$x" > $tmp.c
  3886. if is_hdr $x
  3887. then gothdr="$gothdr + $x"
  3888. else gothdr="$gothdr - $x"
  3889. continue
  3890. fi
  3891. ;;
  3892. esac
  3893. case $one in
  3894. "") one=$x
  3895. ;;
  3896. *"$x"*) break
  3897. ;;
  3898. *) echo "$one" > $tmp.c
  3899. if compile $cc -E $tmp.c <&$nullin >$tmp.i
  3900. then c=$i
  3901. case $c in
  3902. *[\\/]*) c=$(echo $c | sed 's,[\\/],[\\/],g') ;;
  3903. esac
  3904. case $(sed -e '/^#[line ]*1[ ][ ]*"[\\\/].*[\\\/]'$c'"/!d' $tmp.i) in
  3905. ?*) break ;;
  3906. esac
  3907. fi
  3908. one="$one$nl$x"
  3909. ;;
  3910. esac
  3911. echo "$x"
  3912. break
  3913. done
  3914. ;;
  3915. opt) M=$m
  3916. is opt $a
  3917. case " $PACKAGE_OPTIONS " in
  3918. *" $a "*) c=0 ;;
  3919. *) c=1 ;;
  3920. esac
  3921. report $c 1 "$a is set in \$PACKAGE_OPTIONS" "$a is not set in \$PACKAGE_OPTIONS"
  3922. ;;
  3923. out|output)
  3924. ;;
  3925. pth) is pth $a
  3926. pkg $pth
  3927. tab=" "
  3928. e=
  3929. f=
  3930. for i in $pth
  3931. do case $i in
  3932. '{') e="${nl}}"
  3933. l=
  3934. x=i
  3935. v="\$${x}"
  3936. t=${nl}${tab}
  3937. b="fnd()${nl}{${t}for ${x} in"
  3938. ;;
  3939. '}') b="${b}${t}do${tab}if $exists ${v}/\${1}${t}${tab}${tab}then${tab}f=${v}/\${1}${t}${tab}${tab}${tab}return${t}${tab}${tab}fi"
  3940. e="${t}done${e}"
  3941. eval "${b}${e}"
  3942. fnd $a
  3943. case $f in
  3944. ?*) break ;;
  3945. esac
  3946. ;;
  3947. -) b="${b}${t}do${tab}test \"${v}\" = '' -o -d \"${v}\" &&${t}${tab}${tab}"
  3948. x=${x}i
  3949. v="${v}\$${x}"
  3950. b="${b}for ${x} in"
  3951. e="${t}done${e}"
  3952. t="${t}${tab}${tab}"
  3953. ;;
  3954. *) case $e in
  3955. '') if $exists ${i}/${a}
  3956. then f=${i}/${a}
  3957. break
  3958. fi
  3959. ;;
  3960. *) case $i in
  3961. /|.) b="${b} ''" ;;
  3962. *) b="${b} /${i}" ;;
  3963. esac
  3964. ;;
  3965. esac
  3966. ;;
  3967. esac
  3968. done
  3969. case $f in
  3970. '') case $set in
  3971. ' ') f=$a ;;
  3972. ?*) f=$set ;;
  3973. esac
  3974. ;;
  3975. esac
  3976. case $f in
  3977. '') c=1
  3978. ;;
  3979. *) c=0
  3980. f="\"$f\""
  3981. ;;
  3982. esac
  3983. report $c "$f" "${note:-$a path}" "$a path not found"
  3984. ;;
  3985. run) is run $a
  3986. if test ! -r $a
  3987. then failure not found
  3988. case $verbose in
  3989. 0) echo "$command: $file$line: $a: not found" >&$stderr ;;
  3990. esac
  3991. exit 1
  3992. fi
  3993. noisy
  3994. case $a in
  3995. *.c) rm -f $tmp.exe
  3996. {
  3997. echo "$tst
  3998. $ext
  3999. $std
  4000. $usr
  4001. $inc"
  4002. cat $a
  4003. } > $tmp.c
  4004. compile $cc -o $tmp.exe $tmp.c $lib $deflib <&$nullin >&$stderr 2>&$stderr &&
  4005. $executable $tmp.exe &&
  4006. execute $tmp.exe $opt <&$nullin
  4007. ;;
  4008. *.sh) {
  4009. copy - ":
  4010. set \"cc='$cc' executable='$executable' id='$m' static='$static' tmp='$tmp'\" $opt $hdr $test"
  4011. cat $a
  4012. } > $tmp.sh
  4013. chmod +x $tmp.sh
  4014. ( . $tmp.sh ) <&$nullin
  4015. ;;
  4016. *) false
  4017. ;;
  4018. esac
  4019. case $? in
  4020. 0) success
  4021. ;;
  4022. *) failure cannot run
  4023. case $verbose in
  4024. 0) echo "$command: $file$line: $a: cannot run" >&$stderr ;;
  4025. esac
  4026. exit 1
  4027. ;;
  4028. esac
  4029. ;;
  4030. siz) case $p in
  4031. "") x= ;;
  4032. *) x="$p " ;;
  4033. esac
  4034. is siz "$x$v"
  4035. {
  4036. case $p:$v in
  4037. long:*|*:*[_0123456789]int[_0123456789]*)
  4038. echo "$pre
  4039. $tst
  4040. $ext
  4041. $inc
  4042. static $x$v i;
  4043. $x$v f() {
  4044. $x$v v; i = 1; v = i;"
  4045. echo "i = v * i; i = i / v; v = v + i; i = i - v;"
  4046. case $v in
  4047. float|double) ;;
  4048. *) echo "v <<= 4; i = v >> 2; i = 10; i = v % i; i |= v; v ^= i; i = 123; v &= i;" ;;
  4049. esac
  4050. echo "return v; }"
  4051. ;;
  4052. *) echo "$pre
  4053. $inc
  4054. struct xxx { $x$v mem; };
  4055. static struct xxx v;
  4056. struct xxx* f() { return &v; }"
  4057. ;;
  4058. esac
  4059. case $x in
  4060. ""|"struct "|"union ")
  4061. echo "int g() { return 0; }"
  4062. ;;
  4063. *) echo "int g() { return sizeof($x$v)<=sizeof($v); }" ;;
  4064. esac
  4065. copy - "
  4066. int main() {
  4067. f();
  4068. g();
  4069. printf(\"%u\\n\", sizeof($x$v));
  4070. return 0;
  4071. }"
  4072. } > $tmp.c
  4073. rm -f $tmp.exe $tmp.dat
  4074. if compile $cc -o $tmp.exe $tmp.c $lib $deflib <&$nullin >&$nullout &&
  4075. $executable $tmp.exe &&
  4076. execute $tmp.exe > $tmp.dat
  4077. then z=$(cat $tmp.dat)
  4078. c=0
  4079. else z=0
  4080. c=1
  4081. fi
  4082. report $c "$z" "sizeof($x$v)" "$x$v not a type with known size"
  4083. ;;
  4084. sym) case $test in
  4085. "") x=$v ;;
  4086. *) x=$test ;;
  4087. esac
  4088. echo "$pre
  4089. $tst
  4090. $ext
  4091. $inc
  4092. '=' $x '='" > $tmp.c
  4093. compile $cc -E $tmp.c <&$nullin \
  4094. | sed \
  4095. -e "/'='/!d" \
  4096. -e "s/'='//g" \
  4097. -e 's/[ ]//g' \
  4098. -e 's/((([^()]*)))->/->/g' \
  4099. -e 's/(([^()]*))->/->/g' \
  4100. -e 's/([^()]*)->/->/g' \
  4101. -e 's/\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*\)\[/\
  4102. ary \1[/g' \
  4103. -e 's/\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*\)(/\
  4104. fun \1[/g' \
  4105. -e 's/\*->\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]\)/->\
  4106. ptr \1/g' \
  4107. -e 's/->\([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]\)/->\
  4108. reg \1/g' \
  4109. -e "/^$v\$/d" \
  4110. -e 's/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*$/\
  4111. nam &/g' \
  4112. | sed \
  4113. -e '/^... /!d' \
  4114. | LC_ALL=C sort \
  4115. -u \
  4116. | sed \
  4117. -e 's/\(...\) \([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*\).*/#ifndef _\1_'$v'\
  4118. #define _\1_'$v' \2\
  4119. #define _\1_'$v'_str "\2"\
  4120. #endif/'
  4121. ;;
  4122. typ) case $p in
  4123. "") x= ;;
  4124. *) x="$p " ;;
  4125. esac
  4126. is typ "$x$v"
  4127. {
  4128. case $p:$v in
  4129. long:*|*:*[_0123456789]int[_0123456789]*)
  4130. echo "$pre
  4131. $tst
  4132. $ext
  4133. $inc
  4134. static $x$v i;
  4135. $x$v f() {
  4136. $x$v v; i = 1; v = i;"
  4137. echo "i = v * i; i = i / v; v = v + i; i = i - v;"
  4138. case $v in
  4139. float|double) ;;
  4140. *) echo "v <<= 4; i = v >> 2; i = 10; i = v % i; i |= v; v ^= i; i = 123; v &= i;" ;;
  4141. esac
  4142. echo "return v; }"
  4143. ;;
  4144. *) echo "$pre
  4145. $tst
  4146. $ext
  4147. $inc
  4148. struct xxx { $x$v mem; };
  4149. static struct xxx v;
  4150. struct xxx* f() { return &v; }"
  4151. ;;
  4152. esac
  4153. case $x in
  4154. ""|"struct "|"union ")
  4155. echo "int main() { f(); return 0; }" ;;
  4156. *) echo "int main() { f(); return sizeof($x$v)<=sizeof($v); }" ;;
  4157. esac
  4158. } > $tmp.c
  4159. rm -f $tmp.exe
  4160. compile $cc -o $tmp.exe $tmp.c $lib $deflib <&$nullin >&$nullout &&
  4161. $executable $tmp.exe &&
  4162. execute $tmp.exe
  4163. report $? 1 "$x$v is a type" "$x$v is not a type" "default for type $x$v"
  4164. ;;
  4165. val) case $arg in
  4166. '"'*'"')echo $arg=\'$val\' ;;
  4167. *) echo $arg=\"$val\" ;;
  4168. esac
  4169. ;;
  4170. ver) ;;
  4171. 0) result=FAILURE
  4172. ;;
  4173. 1) result=SUCCESS
  4174. ;;
  4175. :) ;;
  4176. -) ;;
  4177. *) echo "$command: $file$line: $o: unknown feature test" >&$stderr
  4178. status=1
  4179. ;;
  4180. esac
  4181. done
  4182. done
  4183. case $not in
  4184. 1) case $result in
  4185. FAILURE) result=SUCCESS ;;
  4186. *) result=FAILURE ;;
  4187. esac
  4188. ;;
  4189. esac
  4190. case $result in
  4191. FAILURE) user_pf=$fail user_yn=$no ;;
  4192. *) user_pf=$pass user_yn=$yes ;;
  4193. esac
  4194. case $user_pf in
  4195. ?*) # Run a pass{ or fail{ block in iffe's current environment
  4196. eval "$user_pf" <&$nullin 2>&$stderr ;;
  4197. esac
  4198. case $user_yn in
  4199. ?*) case $def in
  4200. -) ;;
  4201. *) case $note in
  4202. ?*) case $user_yn in
  4203. *$nl*) user_yn="/* $note */$nl$user_yn" ;;
  4204. *) user_yn="$user_yn /* $note */" ;;
  4205. esac
  4206. ;;
  4207. esac
  4208. ;;
  4209. esac
  4210. copy - "$user_yn"
  4211. ;;
  4212. esac
  4213. case $ifelse:$result in
  4214. TEST:SUCCESS) ifelse=KEEP ;;
  4215. TEST:*) ifelse=SKIP ;;
  4216. esac
  4217. case $group:$result in
  4218. :*|*:SUCCESS) break ;;
  4219. esac
  4220. set '' $groups '' "$@"
  4221. shift
  4222. case $1 in
  4223. '') shift; break ;;
  4224. esac
  4225. shift
  4226. # set up and try the next group
  4227. hdr=$com_hdr
  4228. lib=$com_lib
  4229. mac=$com_mac
  4230. opt=$com_opt
  4231. pth=$com_pth
  4232. test=$com_test
  4233. cc="$occ $includes"
  4234. group=
  4235. groups=
  4236. while :
  4237. do case $1 in
  4238. '') shift; break ;;
  4239. esac
  4240. case $1 in
  4241. *[\"\'\(\)\{\}\ \ ]*)
  4242. case $op in
  4243. pth) pth="$pth $1"
  4244. ;;
  4245. *) case $test in
  4246. '') test=$1 ;;
  4247. *) test="$test $1" ;;
  4248. esac
  4249. ;;
  4250. esac
  4251. ;;
  4252. -) group=$group$1
  4253. groups="$groups $1"
  4254. ;;
  4255. -l*) case $group in
  4256. -*) groups="$groups $1" ;;
  4257. *) lib="$lib $1" ;;
  4258. esac
  4259. ;;
  4260. +l*) x=-${1#+}
  4261. case $group in
  4262. -*) groups="$groups $x" ;;
  4263. *) lib="$lib $x" ;;
  4264. esac
  4265. ;;
  4266. -*|+*) case $group in
  4267. -*) groups="$groups $1"
  4268. ;;
  4269. *) case $op in
  4270. run) opt="$opt $1"
  4271. ;;
  4272. *) case $1 in
  4273. -D*) mac="$mac $1" ;;
  4274. *) cc="$cc $1" ;;
  4275. esac
  4276. ;;
  4277. esac
  4278. ;;
  4279. esac
  4280. ;;
  4281. *.[aAxX]|*.[dD][lL][lL]|*.[lL][iI][bB])
  4282. case $group in
  4283. -*) groups="$groups $1" ;;
  4284. *) lib="$lib $1" ;;
  4285. esac
  4286. ;;
  4287. *[.\\/]*)
  4288. case $group in
  4289. -*) groups="$groups $1"
  4290. ;;
  4291. *) case $op in
  4292. pth) pth="$pth $1" ;;
  4293. *) hdr="$hdr $1" ;;
  4294. esac
  4295. ;;
  4296. esac
  4297. ;;
  4298. *) case $group in
  4299. -*) groups="$groups $1"
  4300. ;;
  4301. *) case $op in
  4302. pth) pth="$pth $1"
  4303. ;;
  4304. *) case $test in
  4305. '') test=$1 ;;
  4306. *) test="$test $1" ;;
  4307. esac
  4308. ;;
  4309. esac
  4310. ;;
  4311. esac
  4312. ;;
  4313. esac
  4314. shift
  4315. done
  4316. done
  4317. done