configure.ac 223 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314
  1. # This file is part of libmicrohttpd.
  2. # (C) 2006-2021 Christian Grothoff (and other contributing authors)
  3. # (C) 2014-2024 Evgeny Grin (Karlson2k)
  4. #
  5. # libmicrohttpd is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published
  7. # by the Free Software Foundation; either version 3, or (at your
  8. # option) any later version.
  9. #
  10. # libmicrohttpd is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with libmicrohttpd; see the file COPYING. If not, write to the
  17. # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. # Boston, MA 02110-1301, USA.
  19. #
  20. #
  21. # Process this file with autoconf to produce a configure script.
  22. #
  23. #
  24. AC_PREREQ([2.64])
  25. LT_PREREQ([2.4.0])
  26. AC_INIT([GNU libmicrohttpd],[1.99.0],[[email protected]])
  27. AC_CONFIG_AUX_DIR([build-aux])
  28. MHD_AUX_DIR='build-aux' # Must be set to the same value as in the previous line
  29. AC_CONFIG_HEADERS([src/incl_priv/mhd_config.h])
  30. AC_CONFIG_MACRO_DIR([m4])
  31. m4_pattern_forbid([^_?MHD_[A-Z_]+_CC_])dnl
  32. LIB_VERSION_CURRENT=74
  33. LIB_VERSION_REVISION=1
  34. LIB_VERSION_AGE=62
  35. AC_SUBST([LIB_VERSION_CURRENT])
  36. AC_SUBST([LIB_VERSION_REVISION])
  37. AC_SUBST([LIB_VERSION_AGE])
  38. PACKAGE_VERSION_MAJOR='m4_car(m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  39. PACKAGE_VERSION_MINOR='m4_argn(2, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  40. PACKAGE_VERSION_SUBMINOR='m4_argn(3, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
  41. AS_VAR_ARITH([MHD_W32_DLL_SUFF],[[$LIB_VERSION_CURRENT - $LIB_VERSION_AGE]])
  42. AC_SUBST([PACKAGE_VERSION_MAJOR])
  43. AC_SUBST([PACKAGE_VERSION_MINOR])
  44. AC_SUBST([PACKAGE_VERSION_SUBMINOR])
  45. AC_SUBST([MHD_W32_DLL_SUFF])
  46. AC_CONFIG_FILES([src/mhd2/w32_lib_res.rc])
  47. MHD_LIB_CPPFLAGS=""
  48. MHD_LIB_CFLAGS=""
  49. MHD_LIB_LDFLAGS=""
  50. MHD_LIBDEPS=""
  51. # for pkg-config
  52. MHD_REQ_PRIVATE=''
  53. MHD_LIBDEPS_PKGCFG=''
  54. AS_IF([test -z "$CC" && test -z "$CPP"], [
  55. AC_MSG_CHECKING([[whether z/OS special settings are required]])
  56. AS_IF([test `uname -s` = "OS/390"],
  57. [
  58. # configure binaries for z/OS
  59. AS_IF([test -z "$CC"],
  60. [CC=`pwd`"/contrib/xcc"
  61. chmod +x $CC || true])
  62. AS_IF([test -z "$CPP"],
  63. CPP="c89 -E")
  64. AC_MSG_RESULT([[yes]])
  65. ],
  66. [AC_MSG_RESULT([[no]])]
  67. )
  68. ])
  69. AC_MSG_CHECKING([for build type])
  70. AC_ARG_ENABLE([build-type],
  71. [AS_HELP_STRING([[--enable-build-type=TYPE]],
  72. [enable build TYPE, a set of configuration parameters; individual settings ]
  73. [(asserts, sanitizers, compiler and linker flags) can be overridden by ]
  74. [additional configure parameters (debug, debugger, neutral, release, release-compact, ]
  75. [release-hardened) [neutral]])],
  76. [], [enable_build_type=neutral])
  77. AS_IF([test "x${enable_build_type}" = "x"], [enable_build_type="neutral"])
  78. AS_VAR_IF([enable_build_type], ["no"], [enable_build_type="neutral"])
  79. AS_VAR_IF([enable_build_type], ["yes"], [AC_MSG_ERROR([[Missing TYPE for --enable-build-type=]])])
  80. AS_CASE([${enable_build_type}],
  81. [debug], [AC_MSG_RESULT([debug. Defaults: enable asserts, sanitizers (if any supported), debug information, compiler optimisation for debugging])],
  82. [debugger], [AC_MSG_RESULT([debugger. Defaults: enable asserts, disable sanitizers, debug information, no compiler optimisation, static lib])],
  83. [neutral], [AC_MSG_RESULT([neutral. Defaults: use only user-specified compiler and linker flags])],
  84. [release], [AC_MSG_RESULT([release. Defaults: disable asserts, enable compiler optimisations])],
  85. [release-compact], [AC_MSG_RESULT([release-compact. Defaults: disable asserts, enable compiler optimisations for size, enable compact code])],
  86. [release-hardened], [AC_MSG_RESULT([release-hardened. Defaults: disable asserts, enable compiler optimisations, enable linker and compiler hardening])],
  87. [AC_MSG_ERROR([[Unknown build type: ${enable_build_type}]])]
  88. )
  89. AS_VAR_IF([enable_build_type], ["neutral"], [:],
  90. [
  91. # For all non-neutral build types do not use automatic "-g -O2" for CFLAGS
  92. AS_IF([test -z "${CFLAGS}"], [CFLAGS=""])
  93. ]
  94. )
  95. AS_VAR_IF([enable_build_type], ["debugger"],
  96. [ # Build only static version unless something else is specified by the user
  97. AS_IF([test -z "${enable_static}" || test "x${enable_static}" = "xyes"],
  98. [
  99. AS_IF([test -z "${enable_shared}"],
  100. [
  101. enable_shared="no"
  102. enable_static="yes"
  103. ]
  104. )
  105. ],
  106. [
  107. AS_CASE([${enable_static}],[*libmicrohttpd*],
  108. [AS_IF([test -z "${enable_shared}"], [enable_shared="no"])],
  109. )
  110. ]
  111. )
  112. ]
  113. )
  114. AS_CASE([${enable_build_type}],[debug|debugger],
  115. [ AS_IF([test -z "${enable_silent_rules}"], [ enable_silent_rules="yes" ])]
  116. )
  117. AM_INIT_AUTOMAKE([gnu] [check-news] [filename-length-max=99] [tar-v7] [silent-rules] [subdir-objects])
  118. # Checks for programs.
  119. AC_PROG_AWK
  120. AC_PROG_GREP
  121. AC_PROG_FGREP
  122. AC_PROG_INSTALL
  123. AC_PROG_LN_S
  124. AC_PROG_MAKE_SET
  125. AC_CANONICAL_HOST
  126. m4_version_prereq([2.70],
  127. [
  128. # Find C compiler and compiler options to support
  129. # the latest C standard (C11). Fallback to C99 and C89
  130. # if later C versions are not supported.
  131. AC_PROG_CC
  132. ],
  133. [
  134. # Find C compiler and compiler options to support
  135. # the latest C standard (C99). Fallback to C89
  136. # if later C versions are not supported.
  137. AC_PROG_CC_STDC
  138. ]
  139. )
  140. # Workaround for libgcrypt
  141. AS_IF([[test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x"]], [[SYSROOT="$lt_sysroot"]])
  142. user_CFLAGS="$CFLAGS"
  143. user_LDFLAGS="$LDFLAGS"
  144. user_CPPFLAGS="$CPPFLAGS"
  145. CFLAGS_ac=""
  146. LDFLAGS_ac=""
  147. CPPFLAGS_ac=""
  148. MHD_SYS_EXT([CPPFLAGS_ac])
  149. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  150. LT_INIT([win32-dll])
  151. LT_LANG([Windows Resource])
  152. AC_ARG_ENABLE([compact-code],
  153. [AS_HELP_STRING([[--enable-compact-code]],
  154. [enable use of a reduced size version of the code, resulting in smaller ]
  155. [binaries with a slight performance hit [auto]])],
  156. [], [enable_compact_code=auto])
  157. AS_IF([test "x${enable_compact_code}" = "x"], [enable_compact_code="auto"])
  158. AH_TEMPLATE([[MHD_FAVOR_SMALL_CODE]], [Define to '1' to use compact code version])
  159. AH_TEMPLATE([[MHD_FAVOR_FAST_CODE]], [Define to '1' to use fast (and larger) code version])
  160. AS_UNSET([compact_code_MSG])
  161. AS_CASE([${enable_compact_code}], [auto],
  162. [
  163. # Parameter not set.
  164. # Check preprocessor macros
  165. AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],
  166. [
  167. enable_compact_code="yes"
  168. compact_code_MSG="enabled by preprocessor macro"
  169. ],
  170. [],[/* no includes */]
  171. )
  172. AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],
  173. [
  174. AS_VAR_IF([enable_compact_code],["yes"],
  175. [AC_MSG_ERROR([Both MHD_FAVOR_SMALL_CODE and MHD_FAVOR_FAST_CODE macros are defined])]
  176. )
  177. enable_compact_code="no"
  178. compact_code_MSG="set by preprocessor macro"
  179. ],[],[/* no includes */]
  180. )
  181. AS_VAR_IF([enable_compact_code], ["auto"],
  182. [
  183. # No preference by preprocessor macros
  184. AC_CACHE_CHECK([whether compiler is configured to optimize for size],
  185. [mhd_cv_cc_optim_size],
  186. [
  187. AC_COMPILE_IFELSE(
  188. [
  189. AC_LANG_PROGRAM([[
  190. #ifndef __OPTIMIZE_SIZE__
  191. #error Looks like compiler does not optimize for size
  192. choke me now
  193. #endif
  194. ]],[])
  195. ],
  196. [mhd_cv_cc_optim_size="yes"],[mhd_cv_cc_optim_size="no"]
  197. )
  198. ]
  199. )
  200. AS_VAR_IF([mhd_cv_cc_optim_size], ["yes"],
  201. [
  202. enable_compact_code="yes"
  203. compact_code_MSG="enabled automatically as compiler optimizes for size"
  204. AC_DEFINE([MHD_FAVOR_SMALL_CODE],[1])
  205. ]
  206. )
  207. ]
  208. )
  209. AS_VAR_IF([enable_compact_code], ["auto"],
  210. [
  211. # No preference by preprocessor macros and compiler flags
  212. AS_CASE([${enable_build_type}],[*-compact],
  213. [
  214. enable_compact_code="yes"
  215. compact_code_MSG="enabled by --enable-build-type=${enable_build_type}"
  216. AC_DEFINE([MHD_FAVOR_SMALL_CODE],[1])
  217. ]
  218. )
  219. ]
  220. )
  221. AS_VAR_IF([enable_compact_code], ["auto"],
  222. [
  223. # No preference
  224. enable_compact_code="no"
  225. compact_code_MSG="by default"
  226. AC_DEFINE([MHD_FAVOR_FAST_CODE],[1])
  227. ]
  228. )
  229. ],
  230. [yes],
  231. [
  232. compact_code_MSG="enabled by configure parameter"
  233. AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],
  234. [],
  235. [AC_DEFINE([MHD_FAVOR_SMALL_CODE],[1])],[/* no includes */]
  236. )
  237. AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],
  238. [AC_MSG_ERROR([MHD_FAVOR_FAST_CODE macro is defined, --enable-compact-code could not be used])
  239. ],
  240. [],[/* no includes */]
  241. )
  242. ],
  243. [no],
  244. [
  245. compact_code_MSG="disabled by configure parameter"
  246. AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],
  247. [],
  248. [AC_DEFINE([MHD_FAVOR_FAST_CODE],[1])],[/* no includes */]
  249. )
  250. AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],
  251. [AC_MSG_ERROR([MHD_FAVOR_SMALL_CODE macro is defined, --disable-compact-code could not be used])
  252. ],
  253. [],[/* no includes */]
  254. )
  255. ],
  256. [AC_MSG_ERROR([[Unknown parameter value: --enable-compact-code=${enable_compact_code}]])]
  257. )
  258. AC_MSG_CHECKING([whether to use a reduced size version of the code])
  259. AC_MSG_RESULT([${enable_compact_code} (${compact_code_MSG})])
  260. CFLAGS="${user_CFLAGS}"
  261. # Compiler options to always enable (if supported)
  262. MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-fno-strict-aliasing], [-qnoansialias])
  263. # '-qlonglong' is XLC option for C89, not used with C99 or later
  264. MHD_CHECK_ADD_CC_CFLAG([-qlonglong], [CFLAGS_ac])
  265. # Set basic optimisation flags
  266. AS_VAR_IF([enable_build_type],["neutral"],[],
  267. [ # Any non-neutral build types
  268. AC_CACHE_CHECK([whether workarounds for clang or clang-based compiler are required],
  269. [mhd_cv_cc_clang_based],
  270. [
  271. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  272. #if ! defined(__clang__) && ! defined(__llvm__)
  273. #error Compiler is not clang-based
  274. choke me now
  275. #endif
  276. ]]
  277. )
  278. ],
  279. [mhd_cv_cc_clang_based="yes"],[mhd_cv_cc_clang_based="no"]
  280. )
  281. ]
  282. )
  283. ]
  284. )
  285. AS_CASE([${enable_build_type}],[debug|debugger],
  286. [ # Debug build or build for walking with debugger
  287. CFLAGS="${user_CFLAGS}"
  288. AS_VAR_IF([enable_build_type],["debug"],
  289. [
  290. # Clang has ASAN (pointer compare) broken when '-Og' optimisations are used
  291. AS_IF([test "x${enable_sanitizers}" != "xno" && test "x${mhd_cv_cc_clang_based}" = "xyes"],
  292. [MHD_CHECK_ADD_CC_CFLAG([-O0], [CFLAGS_ac])],
  293. [MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Og], [-O0])]
  294. )
  295. ],
  296. [MHD_CHECK_ADD_CC_CFLAG([-O0], [CFLAGS_ac])]
  297. )
  298. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  299. ]
  300. )
  301. AS_CASE([${enable_build_type}],[release|release-*],
  302. [ # All release types
  303. AS_VAR_IF([enable_build_type],["release-compact"],
  304. [
  305. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  306. AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[],
  307. [AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[],
  308. [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_SMALL_CODE=1])],
  309. [/* no includes */])],[/* no includes */])
  310. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  311. CFLAGS="${user_CFLAGS}"
  312. MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Oz], [-Os], [-O])
  313. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  314. ],
  315. [ # All non-compact release types
  316. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  317. AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[],
  318. [AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[],
  319. [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_FAST_CODE=1])],
  320. [/* no includes */])],[/* no includes */])
  321. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  322. CFLAGS="${user_CFLAGS}"
  323. MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-O2], [-O])
  324. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  325. ]
  326. )
  327. ]
  328. )
  329. AS_VAR_IF([enable_build_type],["neutral"],[],
  330. [ # Any non-neutral build types
  331. MHD_CHECK_ADD_CC_CFLAGS([-Wall -Wnull-dereference], [CFLAGS_ac])
  332. MHD_CHECK_ADD_CC_CFLAGS([-Wdeclaration-after-statement -Wimplicit -Wnested-externs], [CFLAGS_ac])
  333. MHD_CHECK_ADD_CC_CFLAGS([-Wredundant-decls -Wtrampolines -Wunsafe-loop-optimizations], [CFLAGS_ac])
  334. MHD_CHECK_ADD_CC_CFLAGS([-Wpoison-system-directories], [CFLAGS_ac])
  335. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  336. LDFLAGS="${user_LDFLAGS}"
  337. MHD_CHECK_ADD_CC_LDFLAG([-Wl,--warn-common], [LDFLAGS_ac])
  338. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  339. ]
  340. )
  341. AS_CASE([${enable_build_type}],[debug|debugger],
  342. [ # Debug build or build for walking with debugger
  343. CFLAGS="${user_CFLAGS}"
  344. MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-ggdb3], [-g3], [-ggdb], [-g])
  345. MHD_CHECK_ADD_CC_CFLAGS([-Wextra -Wdouble-promotion], [CFLAGS_ac])
  346. MHD_FIND_ADD_CC_CFLAG_IFELSE(
  347. [
  348. # clang produce warning when string pointer is used as a format specifier for v*printf() function
  349. AS_VAR_IF([mhd_cv_cc_clang_based],["yes"],[MHD_CHECK_ADD_CC_CFLAG([-Wno-format-nonliteral], [CFLAGS_ac])])
  350. ],[],
  351. [CFLAGS_ac], [-Wformat=2], [-Wformat]
  352. )
  353. MHD_CHECK_ADD_CC_CFLAGS([-Wformat-overflow -Wformat-truncation -Wformat-security -Wformat-signedness], [CFLAGS_ac])
  354. MHD_CHECK_ADD_CC_CFLAGS([-Wmissing-include-dirs -Wshift-overflow=2 -Wstringop-overflow=4 -Walloc-zero], [CFLAGS_ac])
  355. MHD_CHECK_ADD_CC_CFLAGS([-Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wshadow -Wpointer-arith], [CFLAGS_ac])
  356. MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wshadow-all], [-Wshadow])
  357. MHD_CHECK_ADD_CC_CFLAGS([-Wbad-function-cast -Wcast-qual -Wwrite-strings -Wconversion], [CFLAGS_ac])
  358. MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wcast-align=strict], [-Wcast-align])
  359. MHD_CHECK_ADD_CC_CFLAGS([-Wjump-misses-init -Wlogical-op -Waggregate-return -Wstrict-prototypes], [CFLAGS_ac])
  360. MHD_CHECK_ADD_CC_CFLAGS([-Wold-style-definition -Wmissing-declarations -Wmissing-prototypes], [CFLAGS_ac])
  361. MHD_CHECK_ADD_CC_CFLAGS([-Wuninitialized -Winit-self -Wshift-negative-value -Wswitch-enum], [CFLAGS_ac])
  362. MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wstrict-overflow=4], [-Wstrict-overflow])
  363. MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wnormalized=nfkc], [-Wnormalized])
  364. MHD_CHECK_ADD_CC_CFLAGS([-Walloca -Wbidi-chars=any -Warray-bounds -Wpacked -Wvariadic-macros], [CFLAGS_ac])
  365. MHD_CHECK_ADD_CC_CFLAGS([-Wundef], [CFLAGS_ac])
  366. MHD_CHECK_ADD_CC_CFLAGS([-Wanon-enum-enum-conversion -Warray-bounds-pointer-arithmetic -Wassign-enum], [CFLAGS_ac])
  367. MHD_CHECK_ADD_CC_CFLAGS([-Wbit-int-extension -Wbitfield-enum-conversion -Wparentheses -Wbool-operation], [CFLAGS_ac])
  368. MHD_CHECK_ADD_CC_CFLAGS([-Wcast-function-type -Wcomma -Wcomment -Wcompound-token-split], [CFLAGS_ac])
  369. MHD_CHECK_ADD_CC_CFLAGS([-Wconditional-uninitialized -Wdeprecated], [CFLAGS_ac])
  370. MHD_CHECK_ADD_CC_CFLAGS([-Wdocumentation-pedantic -Wempty-init-stmt -Wenum-conversion -Wexpansion-to-defined], [CFLAGS_ac])
  371. MHD_CHECK_ADD_CC_CFLAGS([-Wflexible-array-extensions -Wloop-analysis -Wformat-pedantic], [CFLAGS_ac])
  372. MHD_CHECK_ADD_CC_CFLAGS([-Wformat-type-confusion -Wfour-char-constants], [CFLAGS_ac])
  373. MHD_CHECK_ADD_CC_CFLAGS([-Wgcc-compat -Wgnu-anonymous-struct -Wgnu-compound-literal-initializer], [CFLAGS_ac])
  374. MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-conditional-omitted-operand -Wgnu-designator -Wgnu-empty-initializer], [CFLAGS_ac])
  375. MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-empty-struct -Wgnu-flexible-array-initializer -Wgnu-folding-constant], [CFLAGS_ac])
  376. MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-null-pointer-arithmetic -Wgnu-pointer-arith -Wgnu-redeclared-enum], [CFLAGS_ac])
  377. MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-union-cast -Wgnu-variable-sized-type-not-at-end -Widiomatic-parentheses], [CFLAGS_ac])
  378. MHD_CHECK_ADD_CC_CFLAGS([-Wmissing-noreturn -Wmissing-variable-declarations -Wnested-anon-types], [CFLAGS_ac])
  379. MHD_CHECK_ADD_CC_CFLAGS([-Wnewline-eof -Wover-aligned -Wredundant-parens], [CFLAGS_ac])
  380. MHD_CHECK_ADD_CC_CFLAGS([-Wshift-sign-overflow -Wtautological-compare -Wunaligned-access], [CFLAGS_ac])
  381. MHD_CHECK_ADD_CC_CFLAGS([-Wunused -Wzero-as-null-pointer-constant -Wzero-length-array], [CFLAGS_ac])
  382. MHD_CHECK_CC_CFLAG([-Wused-but-marked-unused],[CFLAGS_ac],
  383. [
  384. AC_CACHE_CHECK([whether $[]CC -Wused-but-marked-unused works with system headers],
  385. [mhd_cv_wused_but_marked_unused_sys_header],
  386. [
  387. SAVE_ac_c_werror_flag="$ac_c_werror_flag"
  388. ac_c_werror_flag="yes"
  389. CFLAGS="${CFLAGS_ac} -Wused-but-marked-unused ${user_CFLAGS}"
  390. AC_COMPILE_IFELSE(
  391. [
  392. AC_LANG_SOURCE([[
  393. #include <stdio.h>
  394. int main(void)
  395. {
  396. char buf[16];
  397. return (int) snprintf(buf, 16, "test");
  398. }
  399. ]]
  400. )
  401. ],
  402. [mhd_cv_wused_but_marked_unused_sys_header="yes"],
  403. [mhd_cv_wused_but_marked_unused_sys_header="no"]
  404. )
  405. ac_c_werror_flag="$SAVE_ac_c_werror_flag"
  406. ]
  407. )
  408. AS_VAR_IF([mhd_cv_wused_but_marked_unused_sys_header],["yes"],
  409. [MHD_APPEND_FLAG_TO_VAR([CFLAGS_ac],[-Wused-but-marked-unused])]
  410. )
  411. ]
  412. )
  413. #
  414. # Removed flags:
  415. #
  416. # -Wdisabled-macro-expansion - warns about macros from system headers
  417. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  418. LDFLAGS="${user_LDFLAGS}"
  419. MHD_CHECK_ADD_CC_LDFLAG([-Wl,--enable-long-section-names], [LDFLAGS_ac])
  420. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  421. ]
  422. )
  423. AS_CASE([${enable_build_type}],[release|release-*],
  424. [ # All release types
  425. CFLAGS="${user_CFLAGS}"
  426. AS_VAR_IF([enable_build_type],["release-compact"],
  427. [],
  428. [ # All non-compact release types
  429. MHD_CHECK_ADD_CC_CFLAGS([-fsched-pressure -fira-loop-pressure -fmerge-all-constants], [CFLAGS_ac]) # These flags may improve size, recheck with LTO and linker garbage collection
  430. MHD_CHECK_ADD_CC_CFLAGS([-ftree-partial-pre -fgcse-after-reload -fipa-pta], [CFLAGS_ac])
  431. MHD_CHECK_ADD_CC_CFLAGS([-fisolate-erroneous-paths-attribute -ffinite-loops -floop-nest-optimize], [CFLAGS_ac])
  432. MHD_CHECK_ADD_CC_CFLAGS([-fpredictive-commoning -frename-registers], [CFLAGS_ac])
  433. MHD_CHECK_ADD_CC_CFLAGS([-ftree-loop-distribute-patterns -fpeel-loops -fsplit-loops -ftree-vectorize], [CFLAGS_ac])
  434. ]
  435. )
  436. AS_VAR_IF([enable_build_type],["release-hardened"],
  437. [
  438. MHD_CHECK_ADD_CC_CFLAGS([-Wformat-security -Wstack-protector], [CFLAGS_ac])
  439. MHD_CHECK_ADD_CC_CFLAGS([-Wuninitialized -Winit-self -Walloc-zero -Wbidi-chars=any], [CFLAGS_ac])
  440. ]
  441. )
  442. AS_VAR_IF([enable_build_type],["release"],
  443. [ # Flags are not suitable for 'compact' and for 'hardened'
  444. MHD_CHECK_ADD_CC_CFLAGS([-ffast-math -fno-trapping-math], [CFLAGS_ac])
  445. ]
  446. )
  447. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  448. # W32-specific
  449. LDFLAGS="${user_LDFLAGS}"
  450. MHD_CHECK_ADD_CC_LDFLAG([-Wl,--disable-long-section-names], [LDFLAGS_ac])
  451. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  452. ]
  453. )
  454. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  455. # Additional flags are checked and added at the end of 'configure'
  456. # Check for headers that are ALWAYS required
  457. AC_CHECK_HEADERS_ONCE([stdio.h string.h stdint.h stdarg.h errno.h limits.h fcntl.h], [],
  458. [AC_MSG_ERROR([Compiling libmicrohttpd requires standard C and POSIX headers files])], [AC_INCLUDES_DEFAULT])
  459. # Check for basic optional headers
  460. AC_CHECK_HEADERS([stddef.h stdlib.h inttypes.h sys/types.h sys/stat.h unistd.h \
  461. sys/uio.h crtdefs.h malloc.h io.h], [], [], [AC_INCLUDES_DEFAULT])
  462. # Check for clock-specific optional headers
  463. AC_CHECK_HEADERS([sys/time.h time.h], [], [], [AC_INCLUDES_DEFAULT])
  464. # Check for system information and parameters optional headers
  465. AC_CHECK_HEADERS([endian.h machine/endian.h sys/endian.h sys/byteorder.h \
  466. sys/machine.h machine/param.h sys/param.h sys/isa_defs.h \
  467. sys/ioctl.h], [], [], [AC_INCLUDES_DEFAULT])
  468. # Check for network and sockets optional headers
  469. AC_CHECK_HEADERS([sys/socket.h sys/select.h netinet/in_systm.h netinet/in.h \
  470. sys/un.h arpa/inet.h netinet/ip.h netinet/tcp.h net/if.h \
  471. netdb.h sockLib.h inetLib.h selectLib.h afunix.h], [], [],
  472. [AC_INCLUDES_DEFAULT
  473. [
  474. #ifdef HAVE_SYS_TYPES_H
  475. #include <sys/types.h>
  476. #endif /* HAVE_SYS_TYPES_H */
  477. #ifdef HAVE_INTTYPES_H
  478. #include <inttypes.h>
  479. #endif /* HAVE_INTTYPES_H */
  480. #ifdef HAVE_SYS_SOCKET_H
  481. #include <sys/socket.h>
  482. #elif defined(HAVE_UNISTD_H)
  483. #include <unistd.h>
  484. #endif
  485. #ifdef HAVE_NETINET_IN_SYSTM_H
  486. #include <netinet/in_systm.h>
  487. #endif /* HAVE_NETINET_IN_SYSTM_H */
  488. #ifdef HAVE_NETINET_IN_H
  489. #include <netinet/in.h>
  490. #endif /* HAVE_NETINET_IN_H */
  491. #ifdef HAVE_NETINET_IP_H
  492. #include <netinet/ip.h>
  493. #endif /* HAVE_NETINET_IP_H */
  494. #ifdef HAVE_NETINET_TCP_H
  495. #include <netinet/tcp.h>
  496. #endif /* HAVE_NETINET_TCP_H */
  497. ]]
  498. )
  499. # Check for other optional headers
  500. AC_CHECK_HEADERS([sys/msg.h sys/mman.h signal.h], [], [], [AC_INCLUDES_DEFAULT])
  501. AC_CHECK_TYPES([size_t,ssize_t,ptrdiff_t,intptr_t,uintptr_t,uint8_t],[],[],
  502. [[
  503. /* Keep in sync with src/mhd2/sys_base_types.h */
  504. #include <stdint.h> /* uint_fast_XXt, int_fast_XXt */
  505. #if defined(HAVE_STDDEF_H)
  506. # include <stddef.h> /* size_t, NULL */
  507. #elif defined(HAVE_STDLIB_H)
  508. # include <stdlib.h> /* should provide size_t, NULL */
  509. #else
  510. # include <stdio.h> /* should provide size_t, NULL */
  511. #endif
  512. #if defined(HAVE_SYS_TYPES_H)
  513. # include <sys/types.h> /* ssize_t */
  514. #elif defined(HAVE_UNISTD_H)
  515. # include <unistd.h> /* should provide ssize_t */
  516. #endif
  517. #ifdef HAVE_CRTDEFS_H
  518. # include <crtdefs.h> /* W32-specific header */
  519. #endif
  520. ]]
  521. )
  522. AS_IF([test "x$ac_cv_type_size_t" != "xyes"],
  523. [AC_MSG_FAILURE(['size_t' type is not provided by system headers])]
  524. )
  525. AS_IF([test "x$ac_cv_type_uint8_t" != "xyes"],
  526. [AC_MSG_FAILURE(['uint8_t' type is not provided by system headers])]
  527. )
  528. AC_CHECK_SIZEOF([char])
  529. AS_IF([test "x$ac_cv_sizeof_char" != "x1"],
  530. [AC_MSG_FAILURE(['char' type with size different from '1' is not supported])]
  531. )
  532. AC_CHECK_TYPE([socklen_t],
  533. [],
  534. [AC_DEFINE([socklen_t],[int],[Define to suitable 'socklen_t' replacement if 'socklen_t' is not defined by system headers])],
  535. [[
  536. #ifdef HAVE_SYS_TYPES_H
  537. #include <sys/types.h>
  538. #endif /* HAVE_SYS_TYPES_H */
  539. #include <stdint.h>
  540. #ifdef HAVE_INTTYPES_H
  541. #include <inttypes.h>
  542. #endif /* HAVE_INTTYPES_H */
  543. #ifdef HAVE_SYS_SOCKET_H
  544. #include <sys/socket.h>
  545. #endif /* HAVE_SYS_SOCKET_H */
  546. #ifdef HAVE_NETINET_IN_SYSTM_H
  547. #include <netinet/in_systm.h>
  548. #endif /* HAVE_NETINET_IN_SYSTM_H */
  549. #ifdef HAVE_NETINET_IN_H
  550. #include <netinet/in.h>
  551. #endif /* HAVE_NETINET_IN_H */
  552. #ifdef HAVE_UNISTD_H
  553. #include <unistd.h>
  554. #endif /* HAVE_UNISTD_H */
  555. #ifdef HAVE_SOCKLIB_H
  556. #include <sockLib.h>
  557. #endif /* HAVE_SOCKLIB_H */
  558. #if defined(_WIN32) && !defined(__CYGWIN__)
  559. #include <winsock2.h>
  560. #include <ws2tcpip.h>
  561. #endif /* _WIN32 && ! __CYGWIN__ */
  562. ]]
  563. )
  564. AC_CHECK_HEADER([[search.h]],
  565. [
  566. MHD_CHECK_LINK_RUN([[for proper tsearch(), tfind() and tdelete()]],[[mhd_cv_sys_tsearch_usable]],
  567. [
  568. AS_CASE([$host_os],
  569. [openbsd*],
  570. [[ # Some OpenBSD versions have wrong return value for tdelete()
  571. mhd_cv_sys_tsearch_usable='assuming no'
  572. ]],
  573. [netbsd*],
  574. [[ # NetBSD had leaked root node for years
  575. mhd_cv_sys_tsearch_usable='assuming no'
  576. ]],
  577. [[mhd_cv_sys_tsearch_usable='assuming yes']]
  578. )
  579. ],
  580. [
  581. AC_LANG_SOURCE(
  582. [[
  583. #ifdef HAVE_STDDEF_H
  584. #include <stddef.h>
  585. #endif /* HAVE_STDDEF_H */
  586. #ifdef HAVE_STDLIB_H
  587. #include <stdlib.h>
  588. #endif /* HAVE_STDLIB_H */
  589. #include <stdio.h>
  590. #include <search.h>
  591. static int cmp_func(const void *p1, const void *p2)
  592. {
  593. return (*((const int *)p1)) - (*((const int *)p2));
  594. }
  595. int main(void)
  596. {
  597. int ret = 0;
  598. void *root_ptr = NULL;
  599. int element1 = 1;
  600. int **element_ptr_ptr1;
  601. int **element_ptr_ptr2;
  602. element_ptr_ptr1 =
  603. (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func);
  604. if (NULL == element_ptr_ptr1)
  605. {
  606. fprintf (stderr, "NULL pointer has been returned when tsearch() called for the first time.\n");
  607. return ++ret;
  608. }
  609. if (*element_ptr_ptr1 != &element1)
  610. {
  611. fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the first time.\n");
  612. return ++ret;
  613. }
  614. if (NULL == root_ptr)
  615. {
  616. fprintf (stderr, "Root pointer has not been set by tsearch().\n");
  617. return ++ret;
  618. }
  619. element_ptr_ptr2 =
  620. (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func);
  621. if (NULL == element_ptr_ptr2)
  622. {
  623. fprintf (stderr, "NULL pointer has been returned when tsearch() called for the second time.\n");
  624. return ++ret;
  625. }
  626. if (*element_ptr_ptr2 != &element1)
  627. {
  628. fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the second time.\n");
  629. ++ret;
  630. }
  631. if (element_ptr_ptr2 != element_ptr_ptr1)
  632. {
  633. fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n");
  634. ++ret;
  635. }
  636. element_ptr_ptr2 =
  637. (int **) tfind ((void*) &element1, &root_ptr, &cmp_func);
  638. if (NULL == element_ptr_ptr2)
  639. {
  640. fprintf (stderr, "NULL pointer has been returned by tfind().\n");
  641. ++ret;
  642. }
  643. if (*element_ptr_ptr2 != &element1)
  644. {
  645. fprintf (stderr, "Wrong pointer has been returned when by tfind().\n");
  646. ++ret;
  647. }
  648. if (element_ptr_ptr2 != element_ptr_ptr1)
  649. {
  650. fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n");
  651. ++ret;
  652. }
  653. element_ptr_ptr1 =
  654. (int **) tdelete ((void*) &element1, &root_ptr, &cmp_func);
  655. if (NULL == element_ptr_ptr1)
  656. {
  657. fprintf (stderr, "NULL pointer has been returned by tdelete().\n");
  658. ++ret;
  659. }
  660. if (NULL != root_ptr)
  661. {
  662. fprintf (stderr, "Root pointer has not been set to NULL by tdelete().\n");
  663. ++ret;
  664. }
  665. return ret;
  666. }
  667. ]]
  668. )
  669. ],
  670. [AC_DEFINE([[MHD_USE_SYS_TSEARCH]], [[1]], [Define to 1 if you have properly working tsearch(), tfind() and tdelete() functions.])]
  671. )
  672. ],
  673. [], [AC_INCLUDES_DEFAULT]
  674. )
  675. AM_CONDITIONAL([MHD_USE_SYS_TSEARCH], [[test "x$mhd_cv_sys_tsearch_usable" = "xyes" || test "x$mhd_cv_sys_tsearch_usable" = "xassuming yes"]])
  676. # Optional headers used for tests
  677. AC_CHECK_HEADERS([sys/sysctl.h netinet/ip_icmp.h netinet/icmp_var.h], [], [],
  678. [[
  679. #ifdef HAVE_SYS_TYPES_H
  680. #include <sys/types.h>
  681. #endif /* HAVE_SYS_TYPES_H */
  682. #ifdef HAVE_SYS_SYSCTL_H
  683. #include <sys/sysctl.h>
  684. #endif /* HAVE_SYS_SYSCTL_H */
  685. #ifdef HAVE_SYS_SOCKET_H
  686. #include <sys/socket.h>
  687. #elif defined(HAVE_UNISTD_H)
  688. #include <unistd.h>
  689. #endif
  690. #ifdef HAVE_NETINET_IN_SYSTM_H
  691. #include <netinet/in_systm.h>
  692. #endif /* HAVE_NETINET_IN_SYSTM_H */
  693. #ifdef HAVE_NETINET_IN_H
  694. #include <netinet/in.h>
  695. #endif /* HAVE_NETINET_IN_H */
  696. #ifdef HAVE_NETINET_IP_H
  697. #include <netinet/ip.h>
  698. #endif /* HAVE_NETINET_IP_H */
  699. #ifdef HAVE_NETINET_IP_ICMP_H
  700. #include <netinet/ip_icmp.h>
  701. #endif /* HAVE_NETINET_IP_ICMP_H */
  702. ]]
  703. )
  704. AC_ARG_ENABLE([compiler-hardening],
  705. [AS_HELP_STRING([--enable-compiler-hardening], [enable compiler security checks])],
  706. [],
  707. [AS_CASE([${enable_build_type}],[*-hardened],
  708. [enable_compiler_hardening='yes'],[enable_compiler_hardening='no'])]
  709. )
  710. AS_VAR_IF([enable_compiler_hardening],["yes"],
  711. [
  712. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  713. AC_CHECK_DECL([_FORTIFY_SOURCE],
  714. [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-U_FORTIFY_SOURCE])],
  715. [],[/* no includes */])
  716. MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-D_FORTIFY_SOURCE=2])
  717. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  718. CFLAGS="${user_CFLAGS}"
  719. MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac],[-fstack-protector-strong],[-fstack-protector-all],[-fstack-protector])
  720. MHD_CHECK_ADD_CC_CFLAGS([-fstack-clash-protection],[CFLAGS_ac])
  721. MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac],[-ftrivial-auto-var-init=pattern],[-ftrivial-auto-var-init=zero])
  722. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  723. AS_IF([test "x${enable_static}" = "xyes" && test "x${pic_mode}" != "xyes"],
  724. [
  725. # PIE static lib can be used within non-PIE application, but
  726. # PIE static lib cannot be used in non-PIE shared lib. Let's assume
  727. # that static lib will not be used in shared lib
  728. # All "pie" flags will be used automatically by libtool only
  729. # for static library objects.
  730. CFLAGS="${user_CFLAGS}"
  731. # Perform tests here with "-pie" enabled
  732. LDFLAGS="${LDFLAGS_ac} -pie ${user_LDFLAGS}"
  733. MHD_CHECK_ADD_CC_CFLAG([-fPIE],[CFLAGS_ac],
  734. [
  735. MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie])
  736. ],
  737. [
  738. MHD_CHECK_ADD_CC_CFLAG([-fpie],[CFLAGS_ac],
  739. [
  740. MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie])
  741. ]
  742. )
  743. ]
  744. )
  745. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  746. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  747. ]
  748. )
  749. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  750. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  751. ]
  752. )
  753. # Linker hardening options
  754. # Currently these options are ELF specific, they don't work on Darwin and W32
  755. AC_ARG_ENABLE([linker-hardening],
  756. [AS_HELP_STRING([--enable-linker-hardening], [enable linker security fixups])],
  757. [],
  758. [AS_CASE([${enable_build_type}],[*-hardened],
  759. [enable_linker_hardening='yes'],[enable_linker_hardening='no'])]
  760. )
  761. AS_VAR_IF([enable_linker_hardening],["yes"],
  762. [
  763. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  764. LDFLAGS="${user_LDFLAGS}"
  765. MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,relro],[LDFLAGS_ac],
  766. [MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,now],[LDFLAGS_ac])])
  767. # Actually should be "noexec" by default, but let's try to enforce it.
  768. MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,noexecstack],[LDFLAGS_ac])
  769. # W32-specific. Some are enabled by default, but they will be enfored to be sure.
  770. MHD_CHECK_ADD_CC_LDFLAGS([-Wl,--large-address-aware -Wl,--enable-auto-image-base],[LDFLAGS_ac])
  771. MHD_CHECK_ADD_CC_LDFLAGS([-Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va],[LDFLAGS_ac])
  772. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  773. ]
  774. )
  775. AH_TEMPLATE([[HAVE_STDBOOL_H]], [Define to 1 if you have the <stdbool.h> header file and <stdbool.h> defines 'bool' type.])
  776. AH_TEMPLATE([[HAVE_BUILTIN_TYPE_BOOL]], [Define to 1 if you have the real boolean type.])
  777. AH_TEMPLATE([[bool]], [Define to type name which will be used as boolean type.])
  778. AC_CHECK_HEADER([stdbool.h],
  779. [
  780. AC_CHECK_TYPE([bool],
  781. [
  782. AC_DEFINE([[HAVE_STDBOOL_H]], [[1]])
  783. AC_DEFINE([[HAVE_BUILTIN_TYPE_BOOL]], [[1]])
  784. ],
  785. [
  786. AC_MSG_WARN([[Header <stdbool.h> is present, but "bool" type cannot be detected. Check compiler flags.]])
  787. AC_DEFINE([[bool]], [[int]])
  788. ], [
  789. #include <stdbool.h>
  790. ]
  791. )
  792. ],
  793. [
  794. AC_CHECK_TYPE([bool],
  795. [AC_DEFINE([[HAVE_BUILTIN_TYPE_BOOL]], [[1]])],
  796. [
  797. AC_CHECK_TYPE([_Bool],
  798. [
  799. AC_DEFINE([[HAVE_BUILTIN_TYPE_BOOL]], [[1]])
  800. AC_DEFINE([[bool]], [[_Bool]])
  801. ],
  802. [
  803. AC_DEFINE([[bool]], [[int]])
  804. ], []
  805. )
  806. ], []
  807. )
  808. ],
  809. [AC_INCLUDES_DEFAULT]
  810. )
  811. AC_CACHE_CHECK([[whether "true" is defined or builtin]], [[mhd_cv_macro_true_defined]],
  812. [AC_COMPILE_IFELSE(
  813. [AC_LANG_PROGRAM(
  814. [[
  815. #ifdef HAVE_STDBOOL_H
  816. #include <stdbool.h>
  817. #endif
  818. ]], [[
  819. #if defined(true)
  820. /* dummy */
  821. #else
  822. (void)true;
  823. #endif
  824. ]])
  825. ], [[mhd_cv_macro_true_defined='yes']], [[mhd_cv_macro_true_defined='no']])
  826. ])
  827. AS_VAR_IF([[mhd_cv_macro_true_defined]], [["yes"]], [[:]],
  828. [AC_DEFINE([[true]],[[(!0)]], [Define to value interpreted by compiler as boolean "true", if "true" is not defined by system headers.])])
  829. AC_CACHE_CHECK([[whether "false" is defined or builtin]], [[mhd_cv_macro_false_defined]],
  830. [AC_COMPILE_IFELSE(
  831. [AC_LANG_PROGRAM(
  832. [[
  833. #ifdef HAVE_STDBOOL_H
  834. #include <stdbool.h>
  835. #endif
  836. ]], [[
  837. #if !defined(false)
  838. (void)false;
  839. #else
  840. /* dummy */
  841. #endif
  842. ]])
  843. ], [[mhd_cv_macro_false_defined='yes']], [[mhd_cv_macro_false_defined='no']])
  844. ])
  845. AS_VAR_IF([[mhd_cv_macro_false_defined]], [["yes"]], [[:]],
  846. [AC_DEFINE([[false]],[[0]], [Define to value interpreted by compiler as boolean "false", if "false" is not defined by system headers.])])
  847. AC_CACHE_CHECK([[whether "true" and "false" could be used]], [[mhd_cv_macro_true_false_valid]],
  848. [AC_COMPILE_IFELSE(
  849. [AC_LANG_PROGRAM(
  850. [[
  851. #ifdef HAVE_STDBOOL_H
  852. #include <stdbool.h>
  853. #endif
  854. ]], [[
  855. int var1[true ? 1 : -1] = { 1 };
  856. int var2[false ? -1 : 1] = { 2 };
  857. int var3[!true ? -1 : 1] = { 3 };
  858. int var4[!false ? 1 : -1] = { 4 };
  859. if (var1[0] == var2[0] || var3[0] == var4[0])
  860. return 1;
  861. ]])
  862. ], [[mhd_cv_macro_true_false_valid='yes']], [[mhd_cv_macro_true_false_valid='no']])
  863. ])
  864. AS_VAR_IF([[mhd_cv_macro_true_false_valid]], [["yes"]], [[:]],
  865. [AC_MSG_ERROR([[Value of "true" or value of "false" is not valid. Check config.log for details.]])])
  866. AC_CACHE_CHECK([whether the NULL pointer has all zero bits],
  867. [mhd_cv_ptr_null_all_zeros],
  868. [
  869. AC_RUN_IFELSE(
  870. [
  871. AC_LANG_SOURCE([[
  872. #include <string.h>
  873. #if defined(HAVE_STDDEF_H)
  874. #include <stddef.h>
  875. #elif define(HAVE_STDLIB_H)
  876. #include <stdlib.h>
  877. #else
  878. #include <stdio.h>
  879. #endif
  880. int main(void)
  881. {
  882. void *ptr1;
  883. void *ptr2;
  884. ptr1 = &ptr2;
  885. ptr2 = NULL;
  886. memset(&ptr1, 0, sizeof(ptr1));
  887. if (ptr2 != ptr1)
  888. return 2;
  889. ptr2 = &ptr1;
  890. ptr1 = NULL;
  891. memset(&ptr2, 0, sizeof(ptr2));
  892. if (0 != memcmp (&ptr1, &ptr2, sizeof(ptr1)))
  893. return 3;
  894. ptr1 = &ptr1;
  895. ptr2 = &ptr2;
  896. memset(&ptr1, 0, sizeof(ptr1));
  897. memset(&ptr2, 0, sizeof(ptr2));
  898. if (NULL != ptr1)
  899. return 4;
  900. if (NULL != ptr2)
  901. return 5;
  902. return 0;
  903. }
  904. ]]
  905. )
  906. ],
  907. [mhd_cv_ptr_null_all_zeros="yes"],
  908. [mhd_cv_ptr_null_all_zeros="no"],
  909. [
  910. AS_CASE([$host_cpu],dnl
  911. [[i[234567]86|x86_64|amd64|arm|armeb|armv[0123456789]|armv[0123456789]eb|aarch64|aarch64_be|arm64|mips|mipsel|mips64|mips64el|powerpc|powerpcle|powerpc64|powerpc64le|riscv32|riscv32be|riscv64|riscv64be]],
  912. [
  913. AS_CASE([$host_os],dnl
  914. [[linux*|freebsd|cygwin|mingw*|msys|gnu|netbsd*|openbsd*|darwin*|solaris2*|haiku]],
  915. [mhd_cv_ptr_null_all_zeros="assuming yes"],
  916. [mhd_cv_ptr_null_all_zeros="assuming no"]
  917. )
  918. ],
  919. [mhd_cv_ptr_null_all_zeros="assuming no"]
  920. )
  921. ]
  922. )
  923. ]
  924. )
  925. AS_IF([test "x${mhd_cv_ptr_null_all_zeros}" = "xyes" || test "x${mhd_cv_ptr_null_all_zeros}" = "xassuming yes"],
  926. [AC_DEFINE([HAVE_NULL_PTR_ALL_ZEROS],[1],[Define to '1' if NULL pointers binary representation is all zero bits])]
  927. )
  928. AC_CACHE_CHECK([whether $CC supports variadic macros],[mhd_cv_cc_macro_variadic],
  929. [
  930. AS_CASE([$ac_prog_cc_stdc],
  931. [c89],[:],
  932. [c??],[mhd_cv_cc_macro_variadic="yes"]
  933. )
  934. AS_VAR_SET_IF([mhd_cv_cc_macro_variadic],[:],
  935. [
  936. MHD_SAVED_ac_c_werror_flag="$ac_c_werror_flag"
  937. ac_c_werror_flag=yes
  938. AC_COMPILE_IFELSE(
  939. [
  940. AC_LANG_SOURCE([[
  941. #define GET_THIRD(arg1,arg2,arg3,arg4) (arg3)
  942. #define GET_THIRD_VARIADIC(...) GET_THIRD(__VA_ARGS__)
  943. int main(void)
  944. {
  945. int arr[GET_THIRD_VARIADIC(-1,-2,5,-3) - 4] = {0};
  946. if (0 != arr[GET_THIRD_VARIADIC(100,1000,0,10000)])
  947. return 2;
  948. return 0;
  949. }
  950. ]]
  951. )
  952. ],
  953. [mhd_cv_cc_macro_variadic="yes"],
  954. [mhd_cv_cc_macro_variadic="no"]
  955. )
  956. ac_c_werror_flag="$MHD_SAVED_ac_c_werror_flag"
  957. AS_UNSET([MHD_SAVED_ac_c_werror_flag])
  958. ]
  959. )
  960. ]
  961. )
  962. AS_VAR_IF([mhd_cv_cc_macro_variadic],["yes"],
  963. [AC_DEFINE([HAVE_MACRO_VARIADIC],[1],[Define to '1' if your compiler supports variadic macros])]
  964. )
  965. AC_CACHE_CHECK([whether $CC supports compound literals],[mhd_cv_cc_compound_literals],
  966. [
  967. MHD_SAVED_ac_c_werror_flag="$ac_c_werror_flag"
  968. ac_c_werror_flag=yes
  969. AC_COMPILE_IFELSE(
  970. [
  971. AC_LANG_SOURCE([[
  972. struct test_strct
  973. {
  974. char c;
  975. int i;
  976. };
  977. int main(void)
  978. {
  979. struct test_strct strct_var;
  980. int i;
  981. strct_var = (struct test_strct) { 'a', 0 };
  982. i = (int){0};
  983. if (strct_var.i != i) /* Process all variables to avoid warnings */
  984. return 2;
  985. return 0;
  986. }
  987. ]]
  988. )
  989. ],
  990. [mhd_cv_cc_compound_literals="yes"],
  991. [mhd_cv_cc_compound_literals="no"]
  992. )
  993. ac_c_werror_flag="$MHD_SAVED_ac_c_werror_flag"
  994. AS_UNSET([MHD_SAVED_ac_c_werror_flag])
  995. ]
  996. )
  997. AS_VAR_IF([mhd_cv_cc_compound_literals],["yes"],
  998. [
  999. AC_DEFINE([HAVE_COMPOUND_LITERALS],[1],[Define to '1' if your compiler supports compound literals])
  1000. AC_CACHE_CHECK([whether $CC supports compound literals as arrays of the scope],[mhd_cv_cc_compound_literals_arr_scope],
  1001. [
  1002. MHD_SAVED_ac_c_werror_flag="$ac_c_werror_flag"
  1003. ac_c_werror_flag=yes
  1004. AC_COMPILE_IFELSE(
  1005. [
  1006. AC_LANG_SOURCE([[
  1007. #ifdef __cplusplus
  1008. choke me now; /* Clang++ actually may handle this check properly, but it is too tricky to test it corretly */
  1009. #error This is a C++ compiler
  1010. #endif
  1011. struct test_strct
  1012. {
  1013. char c;
  1014. int i;
  1015. };
  1016. static int test_strct_func(struct test_strct *strc)
  1017. {
  1018. return 3 == strc->i;
  1019. }
  1020. int main(void)
  1021. {
  1022. struct test_strct *strct_ptr1;
  1023. struct test_strct *strct_ptr2;
  1024. int *int_ptr;
  1025. void *ptr;
  1026. ptr = (struct test_strct[]) { { 'p', 11 }, { 'q', 22 }, { 'r', 33 } };
  1027. strct_ptr1 = (struct test_strct[]) { { 'a', 1 }, { 'b', 2 }, { 'c', 3 } };
  1028. int_ptr = (int[]){0xFF,0xFE,0xFD,0xFC,0xFB,0xFA};
  1029. if (2 != (strct_ptr1 + 1)->i)
  1030. return 3;
  1031. strct_ptr2 = (struct test_strct[]) { { 'a', 8 }, { 'b', 9 }, { 'c', 7 } };
  1032. if (0xFE != int_ptr[1])
  1033. return 4;
  1034. if (*(int_ptr + 4) != 0xFB)
  1035. return 5;
  1036. if (!test_strct_func(strct_ptr1 + 2))
  1037. return 6;
  1038. if (int_ptr[2] != 0xFD)
  1039. return 7;
  1040. if (((struct test_strct *)ptr)[0].c == 'p')
  1041. ptr = (struct test_strct[]) { { 'x', 55 }, { 'y', 66 }, { 'z', 77 } };
  1042. if (*((char *)ptr) != 'x')
  1043. return 8;
  1044. if (*(int_ptr + 5) != 0xFA)
  1045. return 9;
  1046. if (strct_ptr2[1].c != 'b')
  1047. return 10;
  1048. return strct_ptr1[1].i == 2 ? 0 : 11;
  1049. }
  1050. ]]
  1051. )
  1052. ],
  1053. [mhd_cv_cc_compound_literals_arr_scope="yes"],
  1054. [mhd_cv_cc_compound_literals_arr_scope="no"]
  1055. )
  1056. ac_c_werror_flag="$MHD_SAVED_ac_c_werror_flag"
  1057. AS_UNSET([MHD_SAVED_ac_c_werror_flag])
  1058. ]
  1059. )
  1060. AS_VAR_IF([mhd_cv_cc_compound_literals_arr_scope],["yes"],
  1061. [AC_DEFINE([HAVE_COMPOUND_LITERALS_ARRAYS_SCOPE],[1],[Define to '1' if your compiler supports compound literals as arrays of the scope])]
  1062. )
  1063. AC_CACHE_CHECK([whether $CC supports compound literals as local arrays],[mhd_cv_cc_compound_literals_arr_local],
  1064. [
  1065. MHD_SAVED_ac_c_werror_flag="$ac_c_werror_flag"
  1066. ac_c_werror_flag=yes
  1067. AC_COMPILE_IFELSE(
  1068. [
  1069. AC_LANG_SOURCE([[
  1070. struct test_strct
  1071. {
  1072. char c;
  1073. int i;
  1074. };
  1075. static int test_strct_func(struct test_strct *strc)
  1076. {
  1077. return 0 == strc->i;
  1078. }
  1079. int main(void)
  1080. {
  1081. if (test_strct_func((struct test_strct[]) { { 'a', 0 }, { 'b', 1 }, { 'c', 2 } }))
  1082. return 4;
  1083. return ((struct test_strct[]) { { 'a', 0 }, { 'b', 1 }, { 'c', 2 } })->i;
  1084. }
  1085. ]]
  1086. )
  1087. ],
  1088. [mhd_cv_cc_compound_literals_arr_local="yes"],
  1089. [mhd_cv_cc_compound_literals_arr_local="no"]
  1090. )
  1091. ac_c_werror_flag="$MHD_SAVED_ac_c_werror_flag"
  1092. AS_UNSET([MHD_SAVED_ac_c_werror_flag])
  1093. ]
  1094. )
  1095. AS_VAR_IF([mhd_cv_cc_compound_literals_arr_local],["yes"],
  1096. [AC_DEFINE([HAVE_COMPOUND_LITERALS_ARRAYS_LOCAL],[1],[Define to '1' if your compiler supports compound literals as local arrays])]
  1097. )
  1098. AC_CACHE_CHECK([whether $CC supports compound literals as lvalue],[mhd_cv_cc_compound_literals_lvalues],
  1099. [
  1100. MHD_SAVED_ac_c_werror_flag="$ac_c_werror_flag"
  1101. ac_c_werror_flag=yes
  1102. AC_COMPILE_IFELSE(
  1103. [
  1104. AC_LANG_SOURCE([[
  1105. struct test_strct
  1106. {
  1107. char c;
  1108. int i;
  1109. };
  1110. static int test_strct_func(struct test_strct *strc)
  1111. {
  1112. return 0 != strc->i;
  1113. }
  1114. int main(void)
  1115. {
  1116. struct test_strct *strct_ptr;
  1117. int int_var;
  1118. int *int_ptr;
  1119. int_var = ++(int) {0};
  1120. int_ptr = &((int) {1});
  1121. if (int_var != *int_ptr) /* Process all variables to avoid warnings */
  1122. return 2;
  1123. if (test_strct_func(&( (struct test_strct) { 'a', 0 } )))
  1124. return 4;
  1125. return 0;
  1126. }
  1127. ]]
  1128. )
  1129. ],
  1130. [mhd_cv_cc_compound_literals_lvalues="yes"],
  1131. [mhd_cv_cc_compound_literals_lvalues="no"]
  1132. )
  1133. ac_c_werror_flag="$MHD_SAVED_ac_c_werror_flag"
  1134. AS_UNSET([MHD_SAVED_ac_c_werror_flag])
  1135. ]
  1136. )
  1137. AS_VAR_IF([mhd_cv_cc_compound_literals_lvalues],["yes"],
  1138. [AC_DEFINE([HAVE_COMPOUND_LITERALS_LVALUES],[1],[Define to '1' if your compiler supports compound literals as lvalues])]
  1139. )
  1140. ],
  1141. [
  1142. AS_UNSET([mhd_cv_cc_compound_literals_arr_local])
  1143. AS_UNSET([mhd_cv_cc_compound_literals_lvalue])
  1144. AS_UNSET([mhd_cv_cc_compound_literals_arr_scope])
  1145. ]
  1146. )
  1147. AS_VAR_SET_IF([ac_cv_c_restrict],[],
  1148. [
  1149. # "cache" result in advance if it is known from the compiler test
  1150. AS_CASE([$ac_prog_cc_stdc],
  1151. [c89],[:],
  1152. [c??],[ac_cv_c_restrict="restrict"]
  1153. )
  1154. ]
  1155. )
  1156. AC_C_RESTRICT
  1157. AS_VAR_IF([ac_cv_c_restrict],["no"],[],
  1158. [AC_DEFINE([HAVE_RESTRICT],[1],[Define to '1' if your compiler supports 'restrict' keyword])]
  1159. )
  1160. AC_C_INLINE
  1161. AS_UNSET([errattr_CFLAGS])
  1162. CFLAGS="${user_CFLAGS}"
  1163. MHD_CHECK_CC_CFLAG([-Werror=attributes],[CFLAGS_ac],
  1164. [
  1165. AC_CACHE_CHECK([whether -Werror=attributes actually works],[mhd_cv_cflag_werror_attr_works],
  1166. [
  1167. CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -Werror=attributes"
  1168. AC_COMPILE_IFELSE([
  1169. AC_LANG_PROGRAM(
  1170. [[__attribute__((non_existing_attrb_dummy)) static int SimpleFunc(void) {return 3;}]],
  1171. [[int r = SimpleFunc(); if (r) return r;]]
  1172. )
  1173. ],
  1174. [mhd_cv_cflag_werror_attr_works="no"],
  1175. [mhd_cv_cflag_werror_attr_works="yes"]
  1176. )
  1177. ]
  1178. )
  1179. AS_VAR_IF([mhd_cv_cflag_werror_attr_works],["yes"],
  1180. [errattr_CFLAGS="-Werror=attributes"]
  1181. )
  1182. ]
  1183. )
  1184. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  1185. AS_IF([test "x$ac_cv_c_inline" != "xno"],
  1186. [
  1187. AC_DEFINE([HAVE_INLINE_FUNCS],[1],[Define to 1 if your C compiler supports inline functions.])
  1188. AC_CACHE_CHECK([for function force inline keywords supported by $CC],[mhd_cv_cc_kwd_forceinline],
  1189. [
  1190. MHD_SAVED_ac_c_werror_flag="$ac_c_werror_flag"
  1191. ac_c_werror_flag=yes
  1192. mhd_cv_cc_kwd_forceinline="none"
  1193. CFLAGS="${CFLAGS_ac} ${user_CFLAGS} $errattr_CFLAGS"
  1194. for keyword_chk in "inline __attribute__((always_inline))" __forceinline
  1195. do
  1196. AS_CASE([${keyword_chk}],
  1197. [*attribute*],
  1198. [AS_IF([test "x$errattr_CFLAGS" = "x"],[continue])]
  1199. )
  1200. AC_LINK_IFELSE([
  1201. AC_LANG_SOURCE([[
  1202. #ifdef HAVE_STDBOOL_H
  1203. #include <stdbool.h>
  1204. #endif
  1205. static ${keyword_chk} bool cmpfn(int x, int y)
  1206. { return x > y; }
  1207. static ${keyword_chk} int sumfn(int x, int y)
  1208. { return x + y; }
  1209. int main(void)
  1210. {
  1211. int a = 1, b = 100, c;
  1212. if (cmpfn(a, b))
  1213. c = sumfn(a, b);
  1214. else
  1215. c = 0 - sumfn(a, b);
  1216. return (cmpfn(0, c) ? 0 : 5);
  1217. }
  1218. ]]
  1219. )
  1220. ],
  1221. [mhd_cv_cc_kwd_forceinline="${keyword_chk}"]
  1222. )
  1223. test "x${mhd_cv_cc_kwd_forceinline}" != "xnone" && break
  1224. done
  1225. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  1226. ac_c_werror_flag="$MHD_SAVED_ac_c_werror_flag"
  1227. AS_UNSET([MHD_SAVED_ac_c_werror_flag])
  1228. ]
  1229. )
  1230. ]
  1231. )
  1232. AS_IF([test "x$ac_cv_c_inline" != "xno" && test "x${mhd_cv_cc_kwd_forceinline}" != "xnone"],
  1233. [AC_DEFINE_UNQUOTED([MHD_static_inline_],[static $mhd_cv_cc_kwd_forceinline],[Define to prefix which will be used with MHD static inline functions.])]
  1234. ,
  1235. [AC_DEFINE([MHD_static_inline_],[static inline],[Define to prefix which will be used with MHD static inline functions.])]
  1236. )
  1237. AC_CACHE_CHECK([for 'unreachable' keywords supported by $CC],[mhd_cv_cc_kwd_unreachable],
  1238. [
  1239. mhd_cv_cc_kwd_unreachable="none"
  1240. for keyword_chk in '__builtin_unreachable()' '__assume(0)' 'unreachable()'
  1241. do
  1242. AC_LINK_IFELSE([
  1243. AC_LANG_SOURCE([[
  1244. #ifdef HAVE_STDDEF_H
  1245. #include <stddef.h>
  1246. #endif
  1247. int zero_if_positive(int val)
  1248. {
  1249. if (val > 0)
  1250. return 0;
  1251. ${keyword_chk};
  1252. return 1;
  1253. }
  1254. int main(void)
  1255. {
  1256. return zero_if_positive(1);
  1257. }
  1258. ]]
  1259. )
  1260. ],
  1261. [mhd_cv_cc_kwd_unreachable="$keyword_chk"]
  1262. )
  1263. test "x${mhd_cv_cc_kwd_unreachable}" != "xnone" && break
  1264. done
  1265. ]
  1266. )
  1267. AS_IF([test "x${mhd_cv_cc_kwd_unreachable}" != "xnone"],
  1268. [
  1269. AC_DEFINE_UNQUOTED([MHD_UNREACHABLE_],[$mhd_cv_cc_kwd_unreachable],[Define to keyword used to indicate unreachable code paths])
  1270. AS_IF([test "x${mhd_cv_cc_kwd_unreachable}" = 'xunreachable()'],
  1271. AC_DEFINE([MHD_UNREACHABLE_NEEDS_STDDEF_H],[$mhd_cv_cc_kwd_unreachable],[Define to '1' if MHD_UNREACHABLE_() requires include of <stddef.h> header])
  1272. )
  1273. ]
  1274. )
  1275. AC_CHECK_HEADERS([stdalign.h], [], [], [AC_INCLUDES_DEFAULT])
  1276. AC_CACHE_CHECK([[for C11 'alignof()' support]], [[mhd_cv_c_alignof]],
  1277. [AC_COMPILE_IFELSE(
  1278. [AC_LANG_PROGRAM(
  1279. [[
  1280. #ifdef HAVE_STDALIGN_H
  1281. #include <stdalign.h>
  1282. #endif
  1283. ]], [[
  1284. int var1[(alignof(int) >= 2) ? 1 : -1];
  1285. int var2[alignof(unsigned int) - 1];
  1286. int var3[(alignof(char) > 0) ? 1 : -1];
  1287. int var4[(alignof(long) >= 4) ? 1 : -1];
  1288. /* Mute compiler warnings */
  1289. var1[0] = var2[0] = var3[0] = 0;
  1290. var4[0] = 1;
  1291. if (var1[0] + var2[0] + var3[0] == var4[0])
  1292. return 1;
  1293. ]])
  1294. ], [
  1295. AC_COMPILE_IFELSE(
  1296. [AC_LANG_PROGRAM(
  1297. [[
  1298. #ifdef HAVE_STDALIGN_H
  1299. #include <stdalign.h>
  1300. #endif
  1301. ]], [[
  1302. /* Should fail if 'alignof()' works */
  1303. int var1[alignof(nonexisting_type) - 1];
  1304. /* Mute compiler warnings */
  1305. var1[0] = 1;
  1306. if (var1[0] + 1 == 1)
  1307. return 1;
  1308. ]])
  1309. ], [[mhd_cv_c_alignof='no']], [[mhd_cv_c_alignof='yes']])
  1310. ], [[mhd_cv_c_alignof='no']])
  1311. ])
  1312. AS_VAR_IF([mhd_cv_c_alignof], ["yes"],
  1313. [AC_DEFINE([[HAVE_C_ALIGNOF]], [1], [Define to 1 if your compiler supports 'alignof()'])])
  1314. # Check system type
  1315. AC_MSG_CHECKING([[for target host OS]])
  1316. os_is_windows="no"
  1317. os_is_native_w32="no"
  1318. AS_CASE(["$host_os"],
  1319. [*darwin* | *rhapsody* | *macosx*],
  1320. [AC_DEFINE([OSX],[1],[This is an OS X system])
  1321. mhd_host_os='Darwin'
  1322. AC_MSG_RESULT([[$mhd_host_os]])],
  1323. [kfreebsd*-gnu],
  1324. [AC_DEFINE([SOMEBSD],[1],[This is a BSD system])
  1325. AC_DEFINE([FREEBSD],[1],[This is a FreeBSD system])
  1326. mhd_host_os='FreeBSD kernel with GNU userland'
  1327. AC_MSG_RESULT([[$mhd_host_os]])],
  1328. [freebsd*],
  1329. [AC_DEFINE([SOMEBSD],[1],[This is a BSD system])
  1330. AC_DEFINE([FREEBSD],[1],[This is a FreeBSD system])
  1331. mhd_host_os='FreeBSD'
  1332. AC_MSG_RESULT([[$mhd_host_os]])],
  1333. [openbsd*],
  1334. [AC_DEFINE([SOMEBSD],[1],[This is a BSD system])
  1335. AC_DEFINE([OPENBSD],[1],[This is an OpenBSD system])
  1336. mhd_host_os='OpenBSD'
  1337. AC_MSG_RESULT([[$mhd_host_os]])],
  1338. [netbsd*],
  1339. [AC_DEFINE([SOMEBSD],[1],[This is a BSD system])
  1340. AC_DEFINE([NETBSD],[1],[This is a NetBSD system])
  1341. mhd_host_os='NetBSD'
  1342. AC_MSG_RESULT([[$mhd_host_os]])],
  1343. [*solaris*],
  1344. [AC_DEFINE([SOLARIS],[1],[This is a Solaris system])
  1345. AC_DEFINE([_REENTRANT],[1],[Need with solaris or errno does not work])
  1346. mhd_host_os='Solaris'
  1347. AC_MSG_RESULT([[$mhd_host_os]])],
  1348. [*linux*],
  1349. [AC_DEFINE([LINUX],[1],[This is a Linux kernel])
  1350. mhd_host_os='Linux'
  1351. AC_MSG_RESULT([[$mhd_host_os]])],
  1352. [*cygwin*],
  1353. [AC_DEFINE([CYGWIN],[1],[This is a Cygwin system])
  1354. mhd_host_os='Windows/Cygwin'
  1355. AC_MSG_RESULT([[$mhd_host_os]])
  1356. os_is_windows="yes"],
  1357. [*mingw*],
  1358. [
  1359. AC_DEFINE([MINGW],[1],[This is a MinGW system])
  1360. AC_DEFINE([WINDOWS],[1],[This is a Windows system])
  1361. mhd_host_os='Windows/MinGW'
  1362. AC_MSG_RESULT([[$mhd_host_os]])
  1363. AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([[Winsock2 headers are required for W32]])], [AC_INCLUDES_DEFAULT])
  1364. AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool],
  1365. [mslibcheck=`lib 2>&1`
  1366. AS_IF([echo "$mslibcheck" | $GREP -e '^Microsoft (R) Library Manager' - >/dev/null],
  1367. [ac_cv_use_ms_lib_tool=yes],
  1368. [ac_cv_use_ms_lib_tool=no])
  1369. ])
  1370. AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes"],
  1371. [AC_SUBST([MS_LIB_TOOL], [[lib]])])
  1372. AC_SUBST([lt_cv_objdir])
  1373. os_is_windows="yes"
  1374. os_is_native_w32="yes"
  1375. ],
  1376. [*openedition*],
  1377. [AC_DEFINE([OS390],[1],[This is a OS/390 system])
  1378. mhd_host_os='OS/390'
  1379. AC_MSG_RESULT([[$mhd_host_os]])],
  1380. [gnu*],
  1381. [AC_DEFINE([[GNU_HURD]], [[1]], [Define to `1' if host machine runs on GNU Hurd.])
  1382. mhd_host_os='GNU Hurd'
  1383. AC_MSG_RESULT([[$mhd_host_os]])
  1384. ],
  1385. [
  1386. AC_MSG_RESULT([unrecognised OS])
  1387. mhd_host_os="${host_os}"
  1388. AC_MSG_WARN([Unrecognised OS $host_os])
  1389. AC_DEFINE([OTHEROS],1,[Some strange OS])
  1390. ])
  1391. AM_CONDITIONAL([CYGWIN_TARGET], [[test "x$os_is_windows" = "xyes" && \
  1392. test "x${os_is_native_w32}" != "xyes"]])
  1393. AS_VAR_IF([os_is_windows], ["yes"],
  1394. [
  1395. AC_MSG_CHECKING([[whether target W32 version is specified by precompiler defines]])
  1396. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1397. /* Note: check logic is reversed for easy log reading */
  1398. #ifdef WINVER
  1399. #error WINVER is defined
  1400. choke me now;
  1401. #endif
  1402. #ifdef _WIN32_WINNT
  1403. #error _WIN32_WINNT is defined
  1404. choke me now;
  1405. #endif
  1406. #ifdef NTDDI
  1407. #error NTDDI is defined
  1408. choke me now;
  1409. #endif
  1410. ]],[[(void)0]])
  1411. ], [[mhd_w32_ver_preselect=no]], [[mhd_w32_ver_preselect=yes]]
  1412. )
  1413. AC_MSG_RESULT([[${mhd_w32_ver_preselect}]])
  1414. AC_CHECK_HEADERS([windows.h sdkddkver.h], [], [], [AC_INCLUDES_DEFAULT])
  1415. AS_VAR_IF([mhd_w32_ver_preselect],["yes"],
  1416. [
  1417. AC_MSG_CHECKING([[for specified target W32 version]])
  1418. AS_UNSET([[mhd_w32_ver]])
  1419. AS_UNSET([[mhd_w32_ver_msg]])
  1420. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1421. #if _WIN32_WINNT+0 < 0x0501
  1422. /* Check before headers inclusion */
  1423. #error _WIN32_WINNT is less than 0x0501
  1424. choke me now;
  1425. #endif
  1426. #ifdef HAVE_SDKDDKVER_H
  1427. #include <sdkddkver.h>
  1428. #endif
  1429. #ifdef HAVE_WINDOWS_H
  1430. #include <windows.h>
  1431. #endif
  1432. #if _WIN32_WINNT+0 < 0x0501
  1433. #error _WIN32_WINNT is less than 0x0501
  1434. choke me now;
  1435. #endif
  1436. ]],[[(void)0]])
  1437. ], [], [
  1438. AC_MSG_RESULT([[pre-WinXP]])
  1439. AC_MSG_ERROR([[libmicrohttpd cannot be compiled for Windows version before Windows XP]])
  1440. ]
  1441. )
  1442. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1443. #ifdef HAVE_SDKDDKVER_H
  1444. #include <sdkddkver.h>
  1445. #endif
  1446. #ifdef HAVE_WINDOWS_H
  1447. #include <windows.h>
  1448. #endif
  1449. #if _WIN32_WINNT+0 == 0x0501
  1450. #error _WIN32_WINNT is 0x0501
  1451. choke me now;
  1452. #endif
  1453. #if _WIN32_WINNT+0 == 0x0502
  1454. #error _WIN32_WINNT is 0x0502
  1455. choke me now;
  1456. #endif
  1457. ]],[[(void)0]])
  1458. ], [], [
  1459. mhd_w32_ver="WinXP"
  1460. mhd_w32_ver_msg="WinXP (selected by precompiler flags)"
  1461. ]
  1462. )
  1463. AS_VAR_SET_IF([mhd_w32_ver], [],
  1464. [
  1465. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1466. #ifdef HAVE_SDKDDKVER_H
  1467. #include <sdkddkver.h>
  1468. #endif
  1469. #ifdef HAVE_WINDOWS_H
  1470. #include <windows.h>
  1471. #endif
  1472. #if _WIN32_WINNT+0 < 0x0600
  1473. #error _WIN32_WINNT is less than 0x0600 but greater than 0x0502
  1474. choke me now;
  1475. #endif
  1476. ]],[[(void)0]])
  1477. ], [], [
  1478. AC_MSG_ERROR([[_WIN32_WINNT value is wrong (less than 0x0600 but greater than 0x0502)]])
  1479. ]
  1480. )
  1481. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1482. #ifdef HAVE_SDKDDKVER_H
  1483. #include <sdkddkver.h>
  1484. #endif
  1485. #ifdef HAVE_WINDOWS_H
  1486. #include <windows.h>
  1487. #endif
  1488. #if _WIN32_WINNT+0 == 0x0600
  1489. #error _WIN32_WINNT is 0x0600
  1490. choke me now;
  1491. #endif
  1492. ]],[[(void)0]])
  1493. ], [], [
  1494. mhd_w32_ver="Vista"
  1495. mhd_w32_ver_msg="Vista (selected by precompiler flags)"
  1496. ]
  1497. )
  1498. ]
  1499. )
  1500. AS_VAR_SET_IF([mhd_w32_ver], [],
  1501. [
  1502. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1503. #ifdef HAVE_SDKDDKVER_H
  1504. #include <sdkddkver.h>
  1505. #endif
  1506. #ifdef HAVE_WINDOWS_H
  1507. #include <windows.h>
  1508. #endif
  1509. #if _WIN32_WINNT+0 > 0x0600
  1510. #error _WIN32_WINNT is greater than 0x0600
  1511. choke me now;
  1512. #endif
  1513. ]],[[(void)0]])
  1514. ], [
  1515. mhd_w32_ver="unknown"
  1516. mhd_w32_ver_msg="unknown (cannot be detected)"
  1517. ], [
  1518. mhd_w32_ver="newer than Vista"
  1519. mhd_w32_ver_msg="newer than Vista (selected by precompiler flags)"
  1520. ]
  1521. )
  1522. ]
  1523. )
  1524. AC_MSG_RESULT([[${mhd_w32_ver}]])
  1525. ], [
  1526. mhd_w32_ver="Vista"
  1527. mhd_w32_ver_msg="Vista (default, override by CPPFLAGS=-D_WIN32_WINNT=0xNNNN)"
  1528. CPPFLAGS_ac="${CPPFLAGS_ac} -D_WIN32_WINNT=0x0600"
  1529. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  1530. AC_MSG_CHECKING([[whether headers accept _WIN32_WINNT=0x0600]])
  1531. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1532. #ifdef HAVE_SDKDDKVER_H
  1533. #include <sdkddkver.h>
  1534. #endif
  1535. #ifdef HAVE_WINDOWS_H
  1536. #include <windows.h>
  1537. #endif
  1538. #include <stdio.h>
  1539. ]],[[(void)0]])
  1540. ], [
  1541. AC_MSG_RESULT([[yes]])
  1542. ], [
  1543. AC_MSG_RESULT([[no]])
  1544. AC_MSG_ERROR([Headers do not accept _WIN32_WINNT=0x0600. Consider override target W32 version by CPPFLAGS=-D_WIN32_WINNT=0xNNNN])
  1545. ]
  1546. )
  1547. ]
  1548. )
  1549. ]
  1550. )
  1551. AS_IF([test "x${os_is_windows}" = "xyes" && test "x${os_is_native_w32}" = "xyes"],
  1552. [
  1553. AC_CACHE_CHECK([W32 run-time library type], [mhd_cv_wctr_type],
  1554. [
  1555. AC_EGREP_CPP([MHDMARKER: UCRT run-time library in use!], [
  1556. #include <stdio.h>
  1557. #if defined(_UCRT)
  1558. #define CRT_STR "MHDMARKER: UCRT run-time library in use!"
  1559. #endif
  1560. #if defined(__MSVCRT_VERSION__)
  1561. #if (__MSVCRT_VERSION__ >= 0xE00) && (__MSVCRT_VERSION__ < 0x1000)
  1562. #define CRT_STR "MHDMARKER: UCRT run-time library in use!"
  1563. #endif
  1564. #if (__MSVCRT_VERSION__ > 0x1400)
  1565. #define CRT_STR "MHDMARKER: UCRT run-time library in use!"
  1566. #endif
  1567. #endif
  1568. #ifndef CRT_STR
  1569. #define CRT_STR "MHDMARKER: MSVCRT run-time library in use!"
  1570. #endif
  1571. int main(void)
  1572. {
  1573. printf ("%\n", CRT_STR);
  1574. return 0;
  1575. }
  1576. ],
  1577. [mhd_cv_wctr_type="ucrt"], [mhd_cv_wctr_type="msvcrt"])
  1578. ]
  1579. )
  1580. mhd_host_os="${mhd_host_os}-${mhd_cv_wctr_type}"
  1581. AS_VAR_IF([mhd_cv_wctr_type], ["msvcrt"],
  1582. [
  1583. # Use CFLAGS here to override user-supplied wrong CPPFLAGS. Durty trick, but choice is limited.
  1584. AX_APPEND_COMPILE_FLAGS([-U__USE_MINGW_ANSI_STDIO -D__USE_MINGW_ANSI_STDIO=0], [CFLAGS_ac])
  1585. AC_SUBST([W32CRT], [MSVCRT])
  1586. ], [AC_SUBST([W32CRT], [UCRT])]
  1587. )
  1588. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  1589. LDFLAGS="${user_LDFLAGS}"
  1590. AS_CASE([$mhd_w32_ver],
  1591. [WinXP],
  1592. [MHD_CHECK_ADD_CC_LDFLAG([-Wl,--major-subsystem-version,5,--minor-subsystem-version,1],[LDFLAGS_ac])],
  1593. [Vista],
  1594. [MHD_CHECK_ADD_CC_LDFLAG([-Wl,--major-subsystem-version,6,--minor-subsystem-version,0],[LDFLAGS_ac])]
  1595. )
  1596. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  1597. ]
  1598. )
  1599. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  1600. AC_ARG_WITH([threads],
  1601. [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto, none) [auto]])],
  1602. [], [with_threads='auto'])
  1603. AS_CASE([[$with_threads]],
  1604. [[win32]], [[with_threads='w32']],
  1605. [[pthreads]], [[with_threads='posix']],
  1606. [[posix]], [[:]],
  1607. [[w32]], [[:]],
  1608. [[none]], [[with_threads='none']],
  1609. [[no]], [[with_threads='none']],
  1610. [[auto]], [[:]],
  1611. [AC_MSG_ERROR([[incorrect parameter "$with_threads" specified for --with-threads]])]
  1612. )
  1613. # Check for posix threads support, regardless of configure parameters as
  1614. # testsuite uses only posix threads.
  1615. AX_PTHREAD(
  1616. [
  1617. mhd_have_posix_threads='yes'
  1618. AC_DEFINE([[HAVE_PTHREAD_H]],[[1]],[Define to 1 if you have the <pthread.h> header file.])
  1619. AC_CACHE_CHECK([[whether pthread_sigmask(3) is available]],
  1620. [[mhd_cv_func_pthread_sigmask]], [dnl
  1621. save_LIBS="$LIBS"
  1622. LIBS="$PTHREAD_LIBS $LIBS"
  1623. CFLAGS="${CFLAGS_ac} ${PTHREAD_CFLAGS} ${user_CFLAGS}"
  1624. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]],
  1625. [[
  1626. sigset_t nset, oset;
  1627. sigemptyset (&nset);
  1628. sigaddset (&nset, SIGPIPE);
  1629. if (0 != pthread_sigmask(SIG_BLOCK, &nset, &oset)) return 1;
  1630. ]])],
  1631. [[mhd_cv_func_pthread_sigmask="yes"]],[[mhd_cv_func_pthread_sigmask="no"]])
  1632. LIBS="${save_LIBS}"
  1633. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  1634. ])
  1635. AS_VAR_IF([mhd_cv_func_pthread_sigmask],["yes"],
  1636. [AC_DEFINE([[HAVE_PTHREAD_SIGMASK]],[[1]],[Define to 1 if you have the pthread_sigmask(3) function.])])
  1637. ],[[mhd_have_posix_threads='no']])
  1638. AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$mhd_have_posix_threads" = "xyes"])
  1639. mhd_have_w32_threads='no'
  1640. AS_IF([[test "x$with_threads" = "xauto"]],
  1641. [
  1642. AS_IF([[test "x$os_is_windows" = "xyes"]],
  1643. [
  1644. AC_MSG_CHECKING([[for W32 threads]])
  1645. AC_LINK_IFELSE(
  1646. [AC_LANG_PROGRAM([[
  1647. #include <windows.h>
  1648. ]], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])]
  1649. , [[mhd_have_w32_threads='yes']], [[mhd_have_w32_threads='no']]
  1650. )
  1651. AC_MSG_RESULT([[$mhd_have_w32_threads]])
  1652. ])
  1653. ]
  1654. )
  1655. AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd ($with_threads)]])
  1656. AS_IF([test "x$with_threads" = "xposix"],
  1657. [ # forced posix threads
  1658. AS_IF([test "x$mhd_have_posix_threads" = "xyes"], [USE_THREADS='posix'],
  1659. [ AS_IF([[test "x$os_is_windows" = "xyes"]] ,
  1660. [ AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]])],
  1661. [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]])] )
  1662. ])
  1663. ])
  1664. AS_IF([test "x$with_threads" = "xw32"],
  1665. [ # forced w32 threads
  1666. AS_IF([[test "x$mhd_have_w32_threads" = "xyes"]],
  1667. [[ USE_THREADS='w32' ]],
  1668. [ AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]])])
  1669. ])
  1670. AS_IF([test "x$with_threads" = "xauto"],
  1671. [# automatic threads lib selection
  1672. AS_IF([[test "x$os_is_native_w32" = "xyes" && test "x$mhd_have_w32_threads" = "xyes"]] ,
  1673. [[ USE_THREADS='w32' ]] ,
  1674. [[ test "x$mhd_have_posix_threads" = "xyes" ]], [[ USE_THREADS='posix' ]],
  1675. [[ test "x$mhd_have_w32_threads" = "xyes" ]], [[ USE_THREADS='w32' ]],
  1676. [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]]) ]
  1677. )])
  1678. AS_IF([test "x$with_threads" = "xnone"],
  1679. [USE_THREADS='none'])
  1680. AS_IF([test "x$USE_THREADS" = "xposix"],
  1681. [CC="$PTHREAD_CC"
  1682. AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads])
  1683. MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS"
  1684. MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS"
  1685. MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG"],
  1686. [AS_IF([test "x$USE_THREADS" = "xw32"],
  1687. [AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads])])])
  1688. AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"])
  1689. AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"])
  1690. AM_CONDITIONAL([MHD_USE_THREADS], [test "x$USE_THREADS" != "xnone"])
  1691. AM_CONDITIONAL([DISABLE_THREADS], [test "x$USE_THREADS" = "xnone"])
  1692. AC_MSG_RESULT([$USE_THREADS])
  1693. AC_ARG_ENABLE([[thread-names]],
  1694. [AS_HELP_STRING([--disable-thread-names],[do not set names on MHD generated threads [auto]])],
  1695. [], [enable_thread_names='auto'])
  1696. AS_IF([test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix"],[
  1697. # Check for thread name function
  1698. HAVE_THREAD_NAME_FUNC="no"
  1699. SAVE_LIBS="$LIBS"
  1700. LIBS="$PTHREAD_LIBS $LIBS"
  1701. CFLAGS="${CFLAGS_ac} $PTHREAD_CFLAGS ${user_CFLAGS}"
  1702. AC_CHECK_HEADERS([pthread_np.h],[],[],
  1703. [
  1704. AC_INCLUDES_DEFAULT
  1705. [
  1706. #include <pthread.h>
  1707. ]
  1708. ])
  1709. # Try to find how to set thread name by thread attributes.
  1710. # If pthread_attr_setname_np(3) is not declared, it's not possible to detect
  1711. # form of pthread_attr_setname_np(3) due to C "feature" "implicit declaration".
  1712. AC_CHECK_DECL([[pthread_attr_setname_np]],[],[],[[
  1713. #include <pthread.h>
  1714. #ifdef HAVE_PTHREAD_NP_H
  1715. #include <pthread_np.h>
  1716. #endif
  1717. ]])
  1718. AS_IF([[test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]],
  1719. [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in NetBSD or OSF1 form]])
  1720. AC_LINK_IFELSE(
  1721. [AC_LANG_PROGRAM([[
  1722. #include <pthread.h>
  1723. #ifdef HAVE_PTHREAD_NP_H
  1724. #include <pthread_np.h>
  1725. #endif
  1726. ]], [[
  1727. pthread_attr_t thr_attr;
  1728. pthread_attr_init(&thr_attr);
  1729. pthread_attr_setname_np(&thr_attr, "name", 0);
  1730. pthread_attr_destroy(&thr_attr);
  1731. ]])],
  1732. [AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_attr_setname_np(3) function.])
  1733. HAVE_THREAD_NAME_FUNC="yes"
  1734. AC_MSG_RESULT([[yes]])],
  1735. [AC_MSG_RESULT([[no]])]
  1736. )
  1737. ])
  1738. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]],
  1739. [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in IBM i or Solaris form]])
  1740. AC_LINK_IFELSE(
  1741. [AC_LANG_PROGRAM([[
  1742. #include <pthread.h>
  1743. #ifdef HAVE_PTHREAD_NP_H
  1744. #include <pthread_np.h>
  1745. #endif
  1746. ]], [[
  1747. pthread_attr_t thr_attr;
  1748. pthread_attr_init(&thr_attr);
  1749. pthread_attr_setname_np(&thr_attr, "name");
  1750. pthread_attr_destroy(&thr_attr);
  1751. ]])],
  1752. [AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI]], [[1]], [Define if you have IBM i form (or Solaris form) of pthread_attr_setname_np(3) function.])
  1753. HAVE_THREAD_NAME_FUNC="yes"
  1754. AC_MSG_RESULT([[yes]])],
  1755. [AC_MSG_RESULT([[no]])]
  1756. )
  1757. ])
  1758. # Try to find how to set thread name for started thread - less convenient
  1759. # than setting name by attributes.
  1760. # If pthread_setname_np(3) is not declared, it's not possible to detect
  1761. # form of pthread_setname_np(3) due to C "feature" "implicit declaration".
  1762. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]],
  1763. [AC_CHECK_DECL([[pthread_setname_np]],[],[],[[
  1764. #include <pthread.h>
  1765. #ifdef HAVE_PTHREAD_NP_H
  1766. #include <pthread_np.h>
  1767. #endif
  1768. ]])
  1769. ])
  1770. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  1771. [AC_MSG_CHECKING([[for pthread_setname_np(3) in NetBSD or OSF1 form]])
  1772. AC_LINK_IFELSE(
  1773. [AC_LANG_PROGRAM([[
  1774. #include <pthread.h>
  1775. #ifdef HAVE_PTHREAD_NP_H
  1776. #include <pthread_np.h>
  1777. #endif
  1778. ]], [[int res = pthread_setname_np(pthread_self(), "name", 0); if (res) return res;]])],
  1779. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_setname_np(3) function.])
  1780. HAVE_THREAD_NAME_FUNC="yes"
  1781. AC_MSG_RESULT([[yes]])],
  1782. [AC_MSG_RESULT([[no]])]
  1783. )
  1784. ])
  1785. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  1786. [AC_MSG_CHECKING([[for pthread_setname_np(3) in GNU/Linux form]])
  1787. AC_LINK_IFELSE(
  1788. [AC_LANG_PROGRAM([[
  1789. #include <pthread.h>
  1790. #ifdef HAVE_PTHREAD_NP_H
  1791. #include <pthread_np.h>
  1792. #endif
  1793. ]], [[int res = pthread_setname_np(pthread_self(), "name"); if (res) return res;]])],
  1794. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_GNU]], [[1]], [Define if you have GNU/Linux form of pthread_setname_np(3) function.])
  1795. HAVE_THREAD_NAME_FUNC="yes"
  1796. AC_MSG_RESULT([[yes]])],
  1797. [AC_MSG_RESULT([[no]])]
  1798. )
  1799. ])
  1800. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
  1801. [AC_MSG_CHECKING([[for pthread_setname_np(3) in Darwin form]])
  1802. AC_LINK_IFELSE(
  1803. [AC_LANG_PROGRAM([[
  1804. #include <pthread.h>
  1805. #ifdef HAVE_PTHREAD_NP_H
  1806. #include <pthread_np.h>
  1807. #endif
  1808. ]], [[int res = pthread_setname_np("name"); if (res) return res;]])],
  1809. [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_DARWIN]], [[1]], [Define if you have Darwin form of pthread_setname_np(3) function.])
  1810. HAVE_THREAD_NAME_FUNC="yes"
  1811. AC_MSG_RESULT([[yes]])],
  1812. [AC_MSG_RESULT([[no]])]
  1813. )
  1814. ])
  1815. AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]],
  1816. [
  1817. AC_CHECK_DECL([[pthread_set_name_np]],
  1818. [
  1819. AC_MSG_CHECKING([[for pthread_set_name_np(3) in FreeBSD form]])
  1820. AC_LINK_IFELSE(
  1821. [AC_LANG_PROGRAM([[
  1822. #include <pthread.h>
  1823. #ifdef HAVE_PTHREAD_NP_H
  1824. #include <pthread_np.h>
  1825. #endif
  1826. ]], [[pthread_set_name_np(pthread_self(), "name");]])],
  1827. [AC_DEFINE([[HAVE_PTHREAD_SET_NAME_NP_FREEBSD]], [[1]], [Define if you have FreeBSD form of pthread_set_name_np(3) function.])
  1828. HAVE_THREAD_NAME_FUNC="yes"
  1829. AC_MSG_RESULT([[yes]])],
  1830. [AC_MSG_RESULT([[no]])]
  1831. )
  1832. ],[],[[
  1833. #include <pthread.h>
  1834. #ifdef HAVE_PTHREAD_NP_H
  1835. #include <pthread_np.h>
  1836. #endif
  1837. ]]
  1838. )
  1839. ])
  1840. LIBS="$SAVE_LIBS"
  1841. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  1842. ])
  1843. AS_IF([[test "x$enable_thread_names" != "xno"]],
  1844. [
  1845. AC_MSG_CHECKING([[whether to enable thread names]])
  1846. AC_COMPILE_IFELSE(
  1847. [AC_LANG_PROGRAM([], [[
  1848. #ifdef MHD_NO_THREAD_NAMES
  1849. #error Thread names are disabled.
  1850. choke me
  1851. #endif
  1852. /* Keep in sync with mhd_threads.h */
  1853. #if defined(MHD_USE_POSIX_THREADS) && (defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) || \
  1854. defined(HAVE_PTHREAD_SETNAME_NP_GNU) || defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || \
  1855. defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) )
  1856. (void) 0; /* no-op */
  1857. #elif defined(MHD_USE_W32_THREADS) && defined(_MSC_FULL_VER)
  1858. (void) 0; /* no-op */
  1859. #else
  1860. #error No thread name function is available.
  1861. choke me
  1862. #endif
  1863. ]])
  1864. ], [
  1865. enable_thread_names='yes'
  1866. ], [
  1867. AS_IF([[test "x$enable_thread_names" = "xyes"]],
  1868. [
  1869. AC_MSG_RESULT([[no]])
  1870. AC_MSG_ERROR([[thread names was explicitly requested, but thread name function is not available]])
  1871. ])
  1872. enable_thread_names='no'
  1873. ])
  1874. AC_MSG_RESULT([[$enable_thread_names]])
  1875. ])
  1876. AS_IF([[test "x$enable_thread_names" = "xno"]],
  1877. [AC_DEFINE([[MHD_NO_THREAD_NAMES]], [[1]], [Define to 1 to disable setting name on generated threads])])
  1878. AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"])
  1879. w32_shared_lib_exp=no
  1880. AS_IF([test "x$enable_shared" = "xyes" && test "x$os_is_native_w32" = "xyes"],
  1881. [
  1882. AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes" || test -n "$DLLTOOL"],
  1883. [
  1884. w32_shared_lib_exp=yes
  1885. use_expfile="no"
  1886. AS_VAR_IF([ac_cv_use_ms_lib_tool], ["yes"], [use_expfile="yes"],
  1887. [
  1888. AC_CACHE_CHECK([whether $DLLTOOL supports export file generation], [mhd_cv_dlltool_expfile],
  1889. [
  1890. AS_IF([AC_RUN_LOG([$DLLTOOL -e conftest.exp >&2 ])],
  1891. [
  1892. AS_IF([test -f conftest.exp], [mhd_cv_dlltool_expfile="yes"], [mhd_cv_dlltool_expfile="no"])
  1893. ], [mhd_cv_dlltool_expfile="no"]
  1894. )
  1895. rm -f conftest.exp
  1896. ]
  1897. )
  1898. use_expfile="${mhd_cv_dlltool_expfile}"
  1899. ]
  1900. )
  1901. ],
  1902. [
  1903. AC_MSG_WARN([[GNU dlltool or MS lib.exe is required for creating shared library export on W32]])
  1904. AC_MSG_WARN([[Export library libmicrohttpd.lib will not be created]])
  1905. ]
  1906. )
  1907. ]
  1908. )
  1909. AM_CONDITIONAL([W32_SHARED_LIB_EXP], [test "x$w32_shared_lib_exp" = "xyes"])
  1910. AM_CONDITIONAL([USE_MS_LIB_TOOL], [test "x$ac_cv_use_ms_lib_tool" = "xyes"])
  1911. AM_CONDITIONAL([USE_EXPORT_FILE], [test "x$use_expfile" = "xyes"])
  1912. dnl gethostbyname() is not really needed
  1913. dnl AC_SEARCH_LIBS([gethostbyname], [nsl])
  1914. MHD_FIND_LIB([socket],
  1915. [[
  1916. #ifdef HAVE_SYS_TYPES_H
  1917. #include <sys/types.h>
  1918. #endif
  1919. #ifdef HAVE_SYS_SOCKET_H
  1920. #include <sys/socket.h>
  1921. #elif defined(HAVE_UNISTD_H)
  1922. #include <unistd.h>
  1923. #endif
  1924. #ifdef HAVE_SOCKLIB_H
  1925. #include <sockLib.h>
  1926. #endif
  1927. #if defined(_WIN32) && ! defined(__CYGWIN__)
  1928. #include <winsock2.h>
  1929. #endif
  1930. ]],
  1931. [(void)socket(0, 0, 0);],
  1932. [socket ws2_32 xnet],
  1933. [
  1934. AS_VAR_IF([[mhd_cv_find_lib_socket]],[["none required"]], [],
  1935. [
  1936. MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_socket} $MHD_LIBDEPS_PKGCFG"
  1937. ]
  1938. )
  1939. ],
  1940. [AC_MSG_ERROR([[cannot find header or library required for function socket()]])]
  1941. )
  1942. MHD_CHECK_SOCKET_SHUTDOWN_TRIGGER([AC_DEFINE([HAVE_LISTEN_SHUTDOWN],[1],[can use shutdown on listen sockets])])
  1943. AM_CONDITIONAL([HAVE_LISTEN_SHUTDOWN], [test "x$mhd_cv_host_shtdwn_trgr_select" = "xyes"])
  1944. AC_CACHE_CHECK([fo][r system default FD_SETSIZE value],[mhd_cv_sys_fd_setsize_value],
  1945. [
  1946. CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -UFD_SETSIZE"
  1947. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS} -UFD_SETSIZE"
  1948. AC_COMPUTE_INT([mhd_cv_sys_fd_setsize_value],[FD_SETSIZE],dnl
  1949. [[
  1950. #ifdef HAVE_SYS_TIME_H
  1951. #include <sys/time.h>
  1952. #endif
  1953. #ifdef HAVE_SYS_TYPES_H
  1954. #include <sys/types.h>
  1955. #endif
  1956. #ifdef HAVE_UNISTD_H
  1957. #include <unistd.h>
  1958. #endif
  1959. #ifdef HAVE_SYS_SOCKET_H
  1960. #include <sys/socket.h>
  1961. #endif
  1962. #ifdef HAVE_SOCKLIB_H
  1963. #include <sockLib.h>
  1964. #endif
  1965. #if defined(_WIN32) && ! defined(__CYGWIN__)
  1966. #include <winsock2.h>
  1967. #endif
  1968. #ifdef HAVE_SYS_SELECT_H
  1969. #include <sys/select.h>
  1970. #endif
  1971. ]], [mhd_cv_sys_fd_setsize_value="unknown"]
  1972. )
  1973. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  1974. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  1975. AS_IF([test "x${mhd_cv_sys_fd_setsize_value}" != "xunknown" && \
  1976. test "${mhd_cv_sys_fd_setsize_value}" -eq "0" \
  1977. ], [mhd_cv_sys_fd_setsize_value="unknown"]
  1978. )
  1979. ]
  1980. )
  1981. AS_VAR_IF([mhd_cv_sys_fd_setsize_value],["unknown"],[:],
  1982. [
  1983. AC_DEFINE_UNQUOTED([MHD_SYS_FD_SETSIZE_],[${mhd_cv_sys_fd_setsize_value}],
  1984. [Define to system default value of FD_SETSIZE macro]
  1985. )
  1986. ]
  1987. )
  1988. AM_CONDITIONAL([NEED_SYS_FD_SET_SIZE_VALUE],[test "x${mhd_cv_sys_fd_setsize_value}" = "xunknown"])
  1989. AC_CACHE_CHECK([fo][r current FD_SETSIZE value],[mhd_cv_fd_setsize_value],
  1990. [
  1991. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  1992. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  1993. AS_IF([test "x${cross_compiling}" != "xno" && test "x${mhd_cv_sys_fd_setsize_value}" != "xunknown"],
  1994. [
  1995. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  1996. [[
  1997. #ifdef HAVE_SYS_TIME_H
  1998. #include <sys/time.h>
  1999. #endif
  2000. #ifdef HAVE_SYS_TYPES_H
  2001. #include <sys/types.h>
  2002. #endif
  2003. #ifdef HAVE_UNISTD_H
  2004. #include <unistd.h>
  2005. #endif
  2006. #ifdef HAVE_SYS_SOCKET_H
  2007. #include <sys/socket.h>
  2008. #endif
  2009. #ifdef HAVE_SOCKLIB_H
  2010. #include <sockLib.h>
  2011. #endif
  2012. #if defined(_WIN32) && ! defined(__CYGWIN__)
  2013. #include <winsock2.h>
  2014. #endif
  2015. #ifdef HAVE_SYS_SELECT_H
  2016. #include <sys/select.h>
  2017. #endif
  2018. #define DETECTED_FD_SETZIE_VALUE ${mhd_cv_sys_fd_setsize_value}
  2019. #if (FD_SETSIZE) != (DETECTED_FD_SETZIE_VALUE)
  2020. #error The current default FD_SETSIZE value is different from ${mhd_cv_sys_fd_setsize_value}
  2021. choke me here now
  2022. #endif /* (FD_SETSIZE) != (DETECTED_FD_SETZIE_VALUE) */
  2023. #if (FD_SETSIZE) != (${mhd_cv_sys_fd_setsize_value})
  2024. #error The current default FD_SETSIZE value is different from ${mhd_cv_sys_fd_setsize_value}
  2025. choke me here now
  2026. #endif /* (FD_SETSIZE) != (${mhd_cv_sys_fd_setsize_value}) */
  2027. ]],[]
  2028. )
  2029. ],
  2030. [mhd_cv_fd_setsize_value="${mhd_cv_sys_fd_setsize_value}"]
  2031. )
  2032. ]
  2033. )
  2034. AS_VAR_SET_IF([mhd_cv_fd_setsize_value],[:],
  2035. [
  2036. AC_COMPUTE_INT([mhd_cv_fd_setsize_value],[FD_SETSIZE],dnl
  2037. [[
  2038. #ifdef HAVE_SYS_TIME_H
  2039. #include <sys/time.h>
  2040. #endif
  2041. #ifdef HAVE_SYS_TYPES_H
  2042. #include <sys/types.h>
  2043. #endif
  2044. #ifdef HAVE_UNISTD_H
  2045. #include <unistd.h>
  2046. #endif
  2047. #ifdef HAVE_SYS_SOCKET_H
  2048. #include <sys/socket.h>
  2049. #endif
  2050. #ifdef HAVE_SOCKLIB_H
  2051. #include <sockLib.h>
  2052. #endif
  2053. #if defined(_WIN32) && ! defined(__CYGWIN__)
  2054. #include <winsock2.h>
  2055. #endif
  2056. #ifdef HAVE_SYS_SELECT_H
  2057. #include <sys/select.h>
  2058. #endif
  2059. ]], [mhd_cv_fd_setsize_value="unknown"]
  2060. )
  2061. ]
  2062. )
  2063. AS_IF([test "x${mhd_cv_fd_setsize_value}" != "xunknown" && \
  2064. test "${mhd_cv_fd_setsize_value}" -eq "0"],
  2065. [mhd_cv_fd_setsize_value="unknown"]
  2066. )
  2067. ]
  2068. )
  2069. AC_CACHE_CHECK([whether FD_SETSIZE is overridable],[mhd_cv_fd_setsize_overridable],
  2070. [
  2071. AS_VAR_IF([mhd_cv_fd_setsize_value],["unknown"],
  2072. [
  2073. AS_VAR_IF([mhd_cv_sys_fd_setsize_value],["unknown"],
  2074. [
  2075. # Assume the most popular FD_SETSIZE value
  2076. base_fd_setsize=1024
  2077. ],
  2078. [base_fd_setsize="${mhd_cv_sys_fd_setsize_value}"]
  2079. )
  2080. base_min_fd_setsize="${base_fd_setsize}"
  2081. ],
  2082. [
  2083. AS_VAR_IF([mhd_cv_sys_fd_setsize_value],["unknown"],
  2084. [
  2085. base_fd_setsize="${mhd_cv_fd_setsize_value}"
  2086. base_min_fd_setsize="${base_fd_setsize}"
  2087. ],
  2088. [
  2089. AS_IF([test "${mhd_cv_fd_setsize_value}" -ge "${mhd_cv_sys_fd_setsize_value}"],
  2090. [
  2091. base_fd_setsize="${mhd_cv_fd_setsize_value}"
  2092. base_min_fd_setsize="${mhd_cv_sys_fd_setsize_value}"
  2093. ],
  2094. [
  2095. base_fd_setsize="${mhd_cv_sys_fd_setsize_value}"
  2096. base_min_fd_setsize="${mhd_cv_fd_setsize_value}"
  2097. ]
  2098. )
  2099. ]
  2100. )
  2101. ]
  2102. )
  2103. # Use two times larger FD_SETSIZE value for test
  2104. AS_VAR_ARITH([test_fd_setsize],[${base_fd_setsize} '+' ${base_fd_setsize}])
  2105. AS_IF([test "${test_fd_setsize}" -lt "128"],[test_fd_setsize=128])
  2106. test_type_fd_setsize="larger"
  2107. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  2108. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  2109. _AS_ECHO_LOG([testing whether FD_SETSIZE test value (${test_fd_setsize}) is suitable for 'int' type])
  2110. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
  2111. [[
  2112. static int test_arr1[(((long long)${test_fd_setsize}) != ((int)${test_fd_setsize})) ? -1 : 1];
  2113. static int test_arr2[(0 > ((int)${test_fd_setsize})) ? -1 : 1];
  2114. test_arr1[0] = 0;
  2115. test_arr2[0] = 0;
  2116. i][f (test_arr1[0] != test_arr2[0]) return 1;
  2117. ]]
  2118. )
  2119. ],[],
  2120. [
  2121. _AS_ECHO_LOG([The selected test FD_SETSIZE value (${test_fd_setsize}) is too large for 'int' type])
  2122. AS_VAR_ARITH([test_fd_setsize],[${base_min_fd_setsize} '/' '2'])
  2123. test_type_fd_setsize="smaller"
  2124. ]
  2125. )
  2126. _AS_ECHO_LOG([will try ${test_fd_setsize} as FD_SETSIZE value])
  2127. AS_IF([test "x${cross_compiling}" = "xno" && test "x${test_type_fd_setsize}" = "xlarger"],
  2128. [
  2129. _AS_ECHO_LOG([will try ${test_fd_setsize} as FD_SETSIZE value with run test])
  2130. AC_RUN_IFELSE(
  2131. [
  2132. AC_LANG_SOURCE(
  2133. [[
  2134. #ifdef FD_SETSIZE
  2135. #undef FD_SETSIZE
  2136. #endif /* FD_SETSIZE */
  2137. #define FD_SETSIZE ${test_fd_setsize}
  2138. #define MY_TEST_FD_SETSIZE ${test_fd_setsize}
  2139. #ifdef HAVE_SYS_TIME_H
  2140. #include <sys/time.h>
  2141. #endif
  2142. #ifdef HAVE_SYS_TYPES_H
  2143. #include <sys/types.h>
  2144. #endif
  2145. #ifdef HAVE_UNISTD_H
  2146. #include <unistd.h>
  2147. #endif
  2148. #ifdef HAVE_SYS_SOCKET_H
  2149. #include <sys/socket.h>
  2150. #endif
  2151. #ifdef HAVE_SOCKLIB_H
  2152. #include <sockLib.h>
  2153. #endif
  2154. #if defined(_WIN32) && ! defined(__CYGWIN__)
  2155. #include <winsock2.h>
  2156. #define MHD_TEST_SOCKET_TYPE SOCKET
  2157. #else
  2158. #define MHD_TEST_SOCKET_TYPE int
  2159. #endif
  2160. #ifdef HAVE_SYS_SELECT_H
  2161. #include <sys/select.h>
  2162. #endif
  2163. #include <string.h>
  2164. #include <stdio.h>
  2165. /* Test fo][r mismatch by macro check */
  2166. #if (FD_SETSIZE) != (MY_TEST_FD_SETSIZE)
  2167. #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize}
  2168. choke me here now;
  2169. #endif /* (FD_SETSIZE) != (MY_TEST_FD_SETSIZE) */
  2170. /* Additional test fo][r mismatch by macro check */
  2171. #if (FD_SETSIZE) != (${test_fd_setsize})
  2172. #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize}
  2173. choke me here now;
  2174. #endif /* (FD_SETSIZE) != (${test_fd_setsize}) */
  2175. static unsigned long var_fd_setsize_value = FD_SETSIZE;
  2176. static unsigned long var_my_test_fd_setsize_value = MY_TEST_FD_SETSIZE;
  2177. int main(void)
  2178. {
  2179. fd_set fds_num_one_copy;
  2180. fd_set fds_num_three_copy;
  2181. fd_set test_fdsets[6];
  2182. int i;
  2183. int ret = 0;
  2184. #if defined(_WIN32) && ! defined(__CYGWIN__)
  2185. WSADATA wsa_data;
  2186. if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data))
  2187. return 21;
  2188. if (MAKEWORD(2, 2) != wsa_data.wVersion)
  2189. {
  2190. WSACleanup();
  2191. return 22;
  2192. }
  2193. #endif /* _WIN32 && ! __CYGWIN__ */
  2194. /* Init with zeros to make sure that slack areas are equal */
  2195. memset(test_fdsets, 0, sizeof(test_fdsets));
  2196. /* Correctly init fd_sets */
  2197. for (i = 0; i < 6; ++i)
  2198. FD_ZERO(test_fdsets + i);
  2199. /* Make copies of zero-inited fd_sets */
  2200. memcpy(&fds_num_one_copy, test_fdsets + 1, sizeof(fd_set));
  2201. memcpy(&fds_num_three_copy, test_fdsets + 3, sizeof(fd_set));
  2202. if (var_fd_setsize_value != var_my_test_fd_setsize_value)
  2203. {
  2204. fprintf (stderr, "System headers redefined FD_SETSIZE to another value (%lu).\n",
  2205. (unsigned long) FD_SETSIZE);
  2206. ret = 2;
  2207. }
  2208. else
  2209. {
  2210. /* Set (almost) all FDs in test_fdset[2] */
  2211. for (i = 1; i < FD_SETSIZE; ++i)
  2212. FD_SET((MHD_TEST_SOCKET_TYPE)i, test_fdsets + 2);
  2213. if (! FD_ISSET((MHD_TEST_SOCKET_TYPE)1, test_fdsets + 2))
  2214. {
  2215. fprintf (stderr, "FD number one in original fd_set is unset, while should be set.\n");
  2216. ret |= 3;
  2217. }
  2218. if (! FD_ISSET((MHD_TEST_SOCKET_TYPE)(FD_SETSIZE - 1), test_fdsets + 2))
  2219. {
  2220. fprintf (stderr, "FD number %lu in original fd_set is unset, while should be set.\n",
  2221. (unsigned long) FD_SETSIZE);
  2222. ret |= 3;
  2223. }
  2224. if (FD_ISSET((MHD_TEST_SOCKET_TYPE)1, test_fdsets + 1))
  2225. {
  2226. fprintf (stderr, "FD number one in the first fd_set is unset, while should be set.\n");
  2227. ret |= 4;
  2228. }
  2229. if (FD_ISSET((MHD_TEST_SOCKET_TYPE)(FD_SETSIZE - 1), test_fdsets + 1))
  2230. {
  2231. fprintf (stderr, "FD number %lu in the first fd_set is unset, while should be set.\n",
  2232. (unsigned long) FD_SETSIZE);
  2233. ret |= 4;
  2234. }
  2235. if (0 != memcmp (&fds_num_one_copy, test_fdsets + 1, sizeof(fd_set)))
  2236. {
  2237. fprintf (stderr, "The first fd_set has been altered.\n");
  2238. ret |= 4;
  2239. }
  2240. if (FD_ISSET((MHD_TEST_SOCKET_TYPE)1, test_fdsets + 3))
  2241. {
  2242. fprintf (stderr, "FD number one in the third fd_set is unset, while should be set.\n");
  2243. ret |= 8;
  2244. }
  2245. if (FD_ISSET((MHD_TEST_SOCKET_TYPE)(FD_SETSIZE - 1), test_fdsets + 3))
  2246. {
  2247. fprintf (stderr, "FD number %lu in the third fd_set is unset, while should be set.\n",
  2248. (unsigned long) FD_SETSIZE);
  2249. ret |= 8;
  2250. }
  2251. if (0 != memcmp (&fds_num_three_copy, test_fdsets + 3, sizeof(fd_set)))
  2252. {
  2253. fprintf (stderr, "The third fd_set has been altered.\n");
  2254. ret |= 8;
  2255. }
  2256. }
  2257. #if defined(_WIN32) && ! defined(__CYGWIN__)
  2258. WSACleanup();
  2259. #endif /* _WIN32 && ! __CYGWIN__ */
  2260. return ret;
  2261. }
  2262. ]]
  2263. )
  2264. ],
  2265. [mhd_cv_fd_setsize_overridable="yes"],
  2266. [mhd_cv_fd_setsize_overridable="no"],
  2267. [[# Not used when cross-compiling ]]
  2268. )
  2269. ],
  2270. [
  2271. _AS_ECHO_LOG([will try ${test_fd_setsize} as FD_SETSIZE with simple compile test])
  2272. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  2273. [[
  2274. #ifdef FD_SETSIZE
  2275. #undef FD_SETSIZE
  2276. #endif /* FD_SETSIZE */
  2277. #define FD_SETSIZE ${test_fd_setsize}
  2278. #define MY_TEST_FD_SETSIZE ${test_fd_setsize}
  2279. #ifdef HAVE_SYS_TIME_H
  2280. #include <sys/time.h>
  2281. #endif
  2282. #ifdef HAVE_SYS_TYPES_H
  2283. #include <sys/types.h>
  2284. #endif
  2285. #ifdef HAVE_UNISTD_H
  2286. #include <unistd.h>
  2287. #endif
  2288. #ifdef HAVE_SYS_SOCKET_H
  2289. #include <sys/socket.h>
  2290. #endif
  2291. #ifdef HAVE_SOCKLIB_H
  2292. #include <sockLib.h>
  2293. #endif
  2294. #if defined(_WIN32) && ! defined(__CYGWIN__)
  2295. #include <winsock2.h>
  2296. #endif
  2297. #ifdef HAVE_SYS_SELECT_H
  2298. #include <sys/select.h>
  2299. #endif
  2300. /* Test fo][r mismatch by macro check */
  2301. #if (FD_SETSIZE) != (MY_TEST_FD_SETSIZE)
  2302. #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize}
  2303. choke me here now
  2304. #endif /* (FD_SETSIZE) != (MY_TEST_FD_SETSIZE) */
  2305. /* Additional test fo][r mismatch by macro check */
  2306. #if (FD_SETSIZE) != (${test_fd_setsize})
  2307. #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize}
  2308. choke me here now
  2309. #endif /* (FD_SETSIZE) != (${test_fd_setsize}) */
  2310. ]],[]
  2311. )
  2312. ],
  2313. [
  2314. _AS_ECHO_LOG([comple test succeed, will check whether another FD_SETSIZE value changes the size of 'fd_set'])
  2315. # Check current size of fd_set
  2316. _AS_ECHO_LOG([find the sizeof(fd_setsize) with current default (${mhd_cv_fd_setsize_value}) FD_SETSIZE value])
  2317. AC_COMPUTE_INT([sizeof_cur_fd_set],[sizeof(fd_set)],dnl
  2318. [[
  2319. #ifdef HAVE_SYS_TIME_H
  2320. #include <sys/time.h>
  2321. #endif
  2322. #ifdef HAVE_SYS_TYPES_H
  2323. #include <sys/types.h>
  2324. #endif
  2325. #ifdef HAVE_UNISTD_H
  2326. #include <unistd.h>
  2327. #endif
  2328. #ifdef HAVE_SYS_SOCKET_H
  2329. #include <sys/socket.h>
  2330. #endif
  2331. #ifdef HAVE_SOCKLIB_H
  2332. #include <sockLib.h>
  2333. #endif
  2334. #if defined(_WIN32) && ! defined(__CYGWIN__)
  2335. #include <winsock2.h>
  2336. #endif
  2337. #ifdef HAVE_SYS_SELECT_H
  2338. #include <sys/select.h>
  2339. #endif
  2340. ]], [sizeof_cur_fd_set="unknown"]
  2341. )
  2342. _AS_ECHO_LOG([the sizeof(fd_setsize) with current default (${mhd_cv_fd_setsize_value}) FD_SETSIZE value is ${sizeof_cur_fd_set}])
  2343. # Check the size of fd_set with redefined FD_SETSIZE
  2344. _AS_ECHO_LOG([find the sizeof(fd_setsize) with redefined (${test_fd_setsize}) FD_SETSIZE value])
  2345. AC_COMPUTE_INT([sizeof_mod_fd_set],[sizeof(fd_set)],dnl
  2346. [[
  2347. #ifdef FD_SETSIZE
  2348. #undef FD_SETSIZE
  2349. #endif /* FD_SETSIZE */
  2350. #define FD_SETSIZE ${test_fd_setsize}
  2351. #ifdef HAVE_SYS_TIME_H
  2352. #include <sys/time.h>
  2353. #endif
  2354. #ifdef HAVE_SYS_TYPES_H
  2355. #include <sys/types.h>
  2356. #endif
  2357. #ifdef HAVE_UNISTD_H
  2358. #include <unistd.h>
  2359. #endif
  2360. #ifdef HAVE_SYS_SOCKET_H
  2361. #include <sys/socket.h>
  2362. #endif
  2363. #ifdef HAVE_SOCKLIB_H
  2364. #include <sockLib.h>
  2365. #endif
  2366. #if defined(_WIN32) && ! defined(__CYGWIN__)
  2367. #include <winsock2.h>
  2368. #endif
  2369. #ifdef HAVE_SYS_SELECT_H
  2370. #include <sys/select.h>
  2371. #endif
  2372. ]], [sizeof_mod_fd_set="unknown"]
  2373. )
  2374. _AS_ECHO_LOG([the sizeof(fd_setsize) with redefined (${test_fd_setsize}) FD_SETSIZE value is ${sizeof_mod_fd_set}])
  2375. _AS_ECHO_LOG([detected sizes of 'fd_set': '${sizeof_cur_fd_set}' (by default), '${sizeof_mod_fd_set}' with modified FD_SETSIZE])
  2376. AS_IF([test "x${sizeof_cur_fd_set}" != "x${sizeof_mod_fd_set}"],
  2377. [mhd_cv_fd_setsize_overridable="yes"],
  2378. [mhd_cv_fd_setsize_overridable="no"]
  2379. )
  2380. AS_UNSET([sizeof_mod_fd_set])
  2381. AS_UNSET([sizeof_cur_fd_set])
  2382. ],
  2383. [mhd_cv_fd_setsize_overridable="no"]
  2384. )
  2385. ]
  2386. )
  2387. AS_UNSET([test_type_fd_setsize])
  2388. AS_UNSET([test_fd_setsize])
  2389. AS_UNSET([base_min_fd_setsize])
  2390. AS_UNSET([base_fd_setsize])
  2391. ]
  2392. )
  2393. AS_VAR_IF([mhd_cv_fd_setsize_overridable],["no"],
  2394. [
  2395. AS_VAR_IF([os_is_native_w32],["yes"],
  2396. [AC_MSG_ERROR([Non-overridable FD_SETSIZE detected for native W32 build. FD_SETSIZE is overridable on W32.])]
  2397. )
  2398. AS_IF([test "x${mhd_cv_fd_setsize_value}" != "xunknown" && test "x${mhd_cv_sys_fd_setsize_value}" != "xunknown" && test "${mhd_cv_fd_setsize_value}" -ne "${mhd_cv_sys_fd_setsize_value}"],
  2399. [AC_MSG_WARN([Detected non-overridable FD_SETSIZE, but the toolchain uses FD_SETSIZE (${mhd_cv_fd_setsize_value}) different from system default (${mhd_cv_sys_fd_setsize_value})])]
  2400. )
  2401. ],
  2402. [AC_DEFINE([HAS_FD_SETSIZE_OVERRIDABLE],[1],[Define to 1 i][f your system allow overriding the value of FD_SETSIZE macro])]
  2403. )
  2404. AC_CACHE_CHECK([whether socket value is a signed type],[mhd_cv_socket_signed],
  2405. [
  2406. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  2407. #ifdef HAVE_SYS_TIME_H
  2408. #include <sys/time.h>
  2409. #endif
  2410. #ifdef HAVE_SYS_TYPES_H
  2411. #include <sys/types.h>
  2412. #endif
  2413. #ifdef HAVE_UNISTD_H
  2414. #include <unistd.h>
  2415. #endif
  2416. #ifdef HAVE_SYS_SOCKET_H
  2417. #include <sys/socket.h>
  2418. #endif
  2419. #ifdef HAVE_SOCKLIB_H
  2420. #include <sockLib.h>
  2421. #endif
  2422. #if defined(_WIN32) && ! defined(__CYGWIN__)
  2423. #include <winsock2.h>
  2424. #endif
  2425. #ifdef HAVE_SYS_SELECT_H
  2426. #include <sys/select.h>
  2427. #endif
  2428. /* Keep in sync with microhttpd.h */
  2429. #if ! defined(_WIN32) || defined(_SYS_TYPES_FD_SET)
  2430. typedef int MHD_Socket;
  2431. #else /* defined(_WIN32) && ! defined(_SYS_TYPES_FD_SET) */
  2432. typedef SOCKET MHD_Socket;
  2433. #endif /* defined(_WIN32) && ! defined(_SYS_TYPES_FD_SET) */
  2434. int main(void)
  2435. {
  2436. int test_arr[2 - 5*(!!(0 < ((MHD_Socket)-1)))];
  2437. test_arr[1] = 0;
  2438. return test_arr[1];
  2439. }
  2440. ]]
  2441. )
  2442. ],
  2443. [mhd_cv_socket_signed="yes"],
  2444. [mhd_cv_socket_signed="no"]
  2445. )
  2446. ]
  2447. )
  2448. AS_VAR_IF([mhd_cv_socket_signed],["yes"],
  2449. [AC_DEFINE([HAS_SIGNED_SOCKET],[1],[Define to 1 i][f your socket type is signed])]
  2450. )
  2451. MHD_CHECK_FUNC([writev],
  2452. [[#include <sys/uio.h>]],
  2453. [[
  2454. struct iovec iov[2];
  2455. char some_str[4] = "OK\n";
  2456. iov[0].iov_base = (void *) some_str;
  2457. iov[0].iov_len = 3;
  2458. i][f (0 > writev(1, iov, 1))
  2459. return 2;
  2460. ]]
  2461. )
  2462. MHD_FIND_LIB([sendmsg],
  2463. [[
  2464. #ifdef HAVE_SYS_TYPES_H
  2465. #include <sys/types.h>
  2466. #endif
  2467. #ifdef HAVE_SYS_SOCKET_H
  2468. #include <sys/socket.h>
  2469. #elif defined(HAVE_UNISTD_H)
  2470. #include <unistd.h>
  2471. #endif
  2472. #ifdef HAVE_SOCKLIB_H
  2473. #include <sockLib.h>
  2474. #endif
  2475. #ifdef HAVE_SYS_UIO_H
  2476. #include <sys/uio.h>
  2477. #endif
  2478. ]],
  2479. [[
  2480. struct msghdr msg;
  2481. struct iovec iov;
  2482. unsigned int i;
  2483. char some_str[5] = "test";
  2484. iov.iov_base = (void*)some_str;
  2485. iov.iov_len = 4;
  2486. for (i = 0; i < (unsigned int) sizeof(msg); i++)
  2487. {
  2488. *(((unsigned char *)&msg) + i) = 0;
  2489. }
  2490. msg.msg_iov = &iov;
  2491. msg.msg_iovlen = 1;
  2492. i][f (0 > sendmsg(1, &msg, 0))
  2493. return -1;
  2494. ]],
  2495. [socket],
  2496. [
  2497. AC_DEFINE([HAVE_SENDMSG],[1],[Define to '1' if your have sendmsg() function])
  2498. AS_VAR_IF([[mhd_cv_find_lib_sendmsg]],[["none required"]], [],
  2499. [
  2500. MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_sendmsg} $MHD_LIBDEPS_PKGCFG"
  2501. ]
  2502. )
  2503. ],[],
  2504. [MHD_LIBDEPS]
  2505. )
  2506. AC_C_BIGENDIAN
  2507. AC_C_VARARRAYS
  2508. AC_CACHE_CHECK([[whether __func__ magic-macro is available]],
  2509. [[mhd_cv_macro___func___avail]], [dnl
  2510. AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[const char *funcname = __func__ ; if (!funcname) return 1;]])],
  2511. [[mhd_cv_macro___func___avail="yes"]],[[mhd_cv_macro___func___avail="no"]])
  2512. ])
  2513. AS_VAR_IF([mhd_cv_macro___func___avail], ["yes"],
  2514. [AC_DEFINE([HAVE___FUNC__], [1], [Define to 1 if your compiler supports __func__ magic-macro.])],
  2515. [
  2516. AC_CACHE_CHECK([[whether __FUNCTION__ magic-macro is available]],
  2517. [[mhd_cv_macro___function___avail]], [dnl
  2518. AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[const char *funcname = __FUNCTION__ ; if (!funcname) return 1;]])],
  2519. [[mhd_cv_macro___function___avail="yes"]],[[mhd_cv_macro___function___avail="no"]])
  2520. ])
  2521. AS_VAR_IF([mhd_cv_macro___function___avail], ["yes"],
  2522. [AC_DEFINE([HAVE___FUNCTION__], [1], [Define to 1 if your compiler supports __FUNCTION__ magic-macro.])],
  2523. [
  2524. AC_CACHE_CHECK([[whether __PRETTY_FUNCTION__ magic-macro is available]],
  2525. [[mhd_cv_macro___pretty_function___avail]], [dnl
  2526. AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[const char *funcname = __PRETTY_FUNCTION__ ; if (!funcname) return 1;]])],
  2527. [[mhd_cv_macro___pretty_function___avail="yes"]],[[mhd_cv_macro___pretty_function___avail="no"]])
  2528. ])
  2529. AS_VAR_IF([mhd_cv_macro___pretty_function___avail], ["yes"],
  2530. [AC_DEFINE([HAVE___PRETTY_FUNCTION__], [1], [Define to 1 if your compiler supports __PRETTY_FUNCTION__ magic-macro.])],
  2531. )
  2532. ]
  2533. )
  2534. ]
  2535. )
  2536. AC_CACHE_CHECK([[whether __builtin_bswap32() is available]],
  2537. [[mhd_cv_func___builtin_bswap32_avail]], [dnl
  2538. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint_fast32_t a = 1; uint_fast32_t b = __builtin_bswap32(a); a = b; (void) a;]])],
  2539. [[mhd_cv_func___builtin_bswap32_avail="yes"]],[[mhd_cv_func___builtin_bswap32_avail="no"]])
  2540. ])
  2541. AS_IF([[test "x$mhd_cv_func___builtin_bswap32_avail" = "xyes"]],
  2542. [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP32]], [[1]], [Define to 1 if you have __builtin_bswap32() builtin function])])
  2543. AC_CACHE_CHECK([[whether __builtin_bswap64() is available]],
  2544. [[mhd_cv_func___builtin_bswap64_avail]], [dnl
  2545. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint_fast64_t a = 1; uint_fast64_t b = __builtin_bswap64(a); a = b; (void) a;]])],
  2546. [[mhd_cv_func___builtin_bswap64_avail="yes"]], [[mhd_cv_func___builtin_bswap64_avail="no"]])
  2547. ])
  2548. AS_IF([[test "x$mhd_cv_func___builtin_bswap64_avail" = "xyes"]],
  2549. [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP64]], [[1]], [Define to 1 if you have __builtin_bswap64() builtin function])])
  2550. AC_CHECK_PROG([HAVE_CURL_BINARY],[curl],[yes],[no])
  2551. AM_CONDITIONAL([HAVE_CURL_BINARY],[test "x$HAVE_CURL_BINARY" = "xyes"])
  2552. AC_CHECK_PROG([HAVE_MAKEINFO_BINARY],[makeinfo],[yes],[no])
  2553. AM_CONDITIONAL([HAVE_MAKEINFO_BINARY],[test "x$HAVE_MAKEINFO_BINARY" = "xyes"])
  2554. AM_CONDITIONAL(W32_STATIC_LIB, [test "x$os_is_native_w32" = "xyes" && test "x$enable_static" = "xyes"])
  2555. AC_ARG_ENABLE([[doc]],
  2556. [AS_HELP_STRING([[--disable-doc]], [do not build any documentation])], ,
  2557. [enable_doc=yes])
  2558. test "x$enable_doc" = "xno" || enable_doc=yes
  2559. AM_CONDITIONAL([BUILD_DOC], [test "x$enable_doc" = "xyes"])
  2560. AC_ARG_ENABLE([[examples]],
  2561. [AS_HELP_STRING([[--disable-examples]], [do not build any examples])], ,
  2562. [enable_examples=yes])
  2563. test "x$enable_examples" = "xno" || enable_examples=yes
  2564. AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" = "xyes"])
  2565. AC_ARG_ENABLE([[tools]],
  2566. [AS_HELP_STRING([[--disable-tools]], [do not build testing and demo tools])], ,
  2567. [enable_tools=yes])
  2568. test "x$enable_tools" = "xyes" || enable_tools=no
  2569. AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"])
  2570. AC_ARG_ENABLE([[heavy-tests]],
  2571. [AS_HELP_STRING([[--enable-heavy-tests[=SCOPE]]], [use SCOPE of heavy tests in test-suite. WARNING:]
  2572. [a dedicated host with minimal number of background processes and no network]
  2573. [activity is recommended to enable. (basic, full)])], [],
  2574. [enable_heavy_tests=no])
  2575. use_heavy_tests="no"
  2576. use_vheavy_tests="no"
  2577. use_heavy_tests_MSG="no"
  2578. AS_CASE([${enable_heavy_tests}],
  2579. [yes|basic],
  2580. [
  2581. enable_heavy_tests="basic"
  2582. use_heavy_tests="yes"
  2583. use_vheavy_tests="no"
  2584. use_heavy_tests_MSG="yes, basic heavy tests (a dedicated host is recommended)"
  2585. ],
  2586. [all|full],
  2587. [
  2588. enable_heavy_tests="full"
  2589. use_heavy_tests="yes"
  2590. use_vheavy_tests="yes"
  2591. use_heavy_tests_MSG="yes, full set of heavy tests (a dedicated host is recommended)"
  2592. ],
  2593. [no],
  2594. [
  2595. use_heavy_tests="no"
  2596. use_vheavy_tests="no"
  2597. use_heavy_tests_MSG="no"
  2598. ],
  2599. [AC_MSG_ERROR([[Unknown parameter value: --enable-heavy-tests=${enable_heavy_tests}]])]
  2600. )
  2601. AS_VAR_IF([use_heavy_tests], ["yes"],
  2602. [
  2603. HEAVY_TESTS_NOTPARALLEL='.NOTPARALLEL:'
  2604. AC_DEFINE([_MHD_HEAVY_TESTS], [1], [Define to 1 to enable "heavy" test paths.])
  2605. AS_VAR_IF([use_vheavy_tests], ["yes"],
  2606. [AC_DEFINE([_MHD_VHEAVY_TESTS], [1], [Define to 1 to enable "very heavy" test paths.])]
  2607. )
  2608. ],
  2609. [
  2610. HEAVY_TESTS_NOTPARALLEL=" "
  2611. ]
  2612. )
  2613. AM_CONDITIONAL([HEAVY_TESTS],[test "x$use_heavy_tests" = "xyes"])
  2614. AM_CONDITIONAL([VHEAVY_TESTS],[test "x$use_vheavy_tests" = "xyes"])
  2615. AM_CONDITIONAL([TESTS_STRESS_OS],[false])
  2616. AC_ARG_ENABLE([[select]],
  2617. [
  2618. AS_HELP_STRING([[--enable-select[=ARG]]], [enable 'select()' support (yes, no, auto) [auto]])
  2619. ],[],[enable_select='auto']
  2620. )
  2621. AC_CACHE_CHECK([for select() function],[mhd_cv_func_select],
  2622. [
  2623. AS_IF([test "x$os_is_native_w32" = "xyes"],
  2624. [mhd_cv_func_select="yes"],
  2625. [
  2626. AC_LINK_IFELSE(
  2627. [
  2628. AC_LANG_SOURCE([[
  2629. #ifdef HAVE_SYS_TYPES_H
  2630. #include <sys/types.h>
  2631. #endif
  2632. #ifdef HAVE_SYS_TIME_H
  2633. #include <sys/time.h>
  2634. #endif
  2635. #ifdef HAVE_UNISTD_H
  2636. #include <unistd.h>
  2637. #endif
  2638. #ifdef HAVE_SYS_SELECT_H
  2639. #include <sys/select.h>
  2640. #endif
  2641. #ifdef HAVE_SELECTLIB_H
  2642. #include <selectLib.h>
  2643. #endif
  2644. int main(void)
  2645. {
  2646. int res;
  2647. fd_set rfds;
  2648. fd_set wfds;
  2649. fd_set efds;
  2650. struct timeval tv_to;
  2651. tv_to.tv_sec = 1;
  2652. tv_to.tv_usec = 0;
  2653. FD_ZERO(&rfds);
  2654. FD_ZERO(&wfds);
  2655. FD_ZERO(&efds);
  2656. FD_SET(1, &wfds);
  2657. res = select(2, &rfds, &wfds, &efds, &tv_to);
  2658. if (res < 0)
  2659. return 3;
  2660. FD_CLR(1, &efds);
  2661. if (FD_ISSET(1, &efds))
  2662. return 4;
  2663. return 0;
  2664. }
  2665. ]]
  2666. )
  2667. ],
  2668. [mhd_cv_func_select="yes"],
  2669. [mhd_cv_func_select="no"]
  2670. )
  2671. ]
  2672. )
  2673. ]
  2674. )
  2675. AS_VAR_IF([mhd_cv_func_select],["yes"],
  2676. [
  2677. AC_DEFINE([[HAVE_SELECT]],[[1]],[Define to '1' if select() is supported on your platform])
  2678. AS_IF([test "x$enable_select" != "xno"],
  2679. [
  2680. enable_select="yes"
  2681. AC_DEFINE([[MHD_USE_SELECT]],[[1]],[Define to '1' to enable use of select() system call])
  2682. ]
  2683. )
  2684. ],
  2685. [
  2686. AS_VAR_IF([enable_select],["yes"],
  2687. [AC_MSG_ERROR([Support for select() was explicitly requested but cannot be enabled on this platform.])]
  2688. )
  2689. ]
  2690. )
  2691. AM_CONDITIONAL([MHD_USE_SELECT],[test "x${enable_select}" = "xyes"])
  2692. AC_ARG_ENABLE([[poll]],
  2693. [
  2694. AS_HELP_STRING([[--enable-poll[=ARG]]], [enable 'poll()' support (yes, no, auto) [auto]])
  2695. ],[],[enable_poll='auto']
  2696. )
  2697. AS_IF([test "$os_is_native_w32" != "yes"],
  2698. [
  2699. AC_CHECK_HEADERS([poll.h],[AC_INCLUDES_DEFAULT])
  2700. MHD_CHECK_FUNC([poll],
  2701. [[
  2702. #include <poll.h>
  2703. ]],
  2704. [[
  2705. struct pollfd fds[2];
  2706. fds[0].fd = 0;
  2707. fds[0].events = POLLIN;
  2708. if (0 > poll(fds, 1, 0))
  2709. return 2;
  2710. ]],
  2711. [have_poll='yes'],[have_poll='no']
  2712. )
  2713. ],
  2714. [
  2715. MHD_CHECK_FUNC([WSAPoll],
  2716. [[
  2717. #include <winsock2.h>
  2718. ]],
  2719. [[
  2720. WSAPOLLFD fda[2];
  2721. WSAPoll(fda, 2, 0);
  2722. ]],
  2723. [have_poll='yes'],[have_poll='no']
  2724. )
  2725. ]
  2726. )
  2727. AS_VAR_IF([have_poll],["yes"],
  2728. [
  2729. AC_DEFINE([[HAVE_POLL]],[[1]],[Define to '1' if poll() is supported on your platform])
  2730. AC_CHECK_DECLS([POLLRDNORM,POLLIN,POLLRDBAND,POLLWRNORM,POLLOUT,POLLWRBAND,POLLPRI],[],[],[[
  2731. #ifdef HAVE_POLL_H
  2732. #include <poll.h>
  2733. #endif
  2734. #ifdef HAVE_WINSOCK2_H
  2735. #include <winsock2.h>
  2736. #endif
  2737. ]]
  2738. )
  2739. AS_IF([test "x$enable_poll" != "xno"],
  2740. [
  2741. enable_poll="yes"
  2742. AC_DEFINE([[MHD_USE_POLL]],[[1]],[Define to '1' to enable use of select() system call])
  2743. ]
  2744. )
  2745. ],
  2746. [
  2747. AS_VAR_IF([enable_poll],["yes"],
  2748. [AC_MSG_ERROR([Support for poll() was explicitly requested but cannot be enabled on this platform.])]
  2749. )
  2750. ]
  2751. )
  2752. AM_CONDITIONAL([MHD_USE_POLL],[test "x${enable_poll}" = "xyes"])
  2753. AC_ARG_ENABLE([[epoll]],
  2754. [
  2755. AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])
  2756. ],[],[enable_epoll='auto']
  2757. )
  2758. AS_IF([test "$enable_epoll" != "no"],
  2759. [
  2760. AX_HAVE_EPOLL
  2761. AS_IF([test "${ax_cv_have_epoll}" = "yes"],
  2762. [
  2763. AC_DEFINE([[HAVE_EPOLL]],[[1]],[Define to '1' if epoll is supported on your platform])
  2764. AC_DEFINE([[MHD_USE_EPOLL]],[[1]],[Define to '1' to enable 'epoll' functionality])
  2765. enable_epoll='yes'
  2766. ],
  2767. [
  2768. AS_IF([test "$enable_epoll" = "yes"],
  2769. [AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]])]
  2770. )
  2771. enable_epoll='no'
  2772. ]
  2773. )
  2774. ]
  2775. )
  2776. AM_CONDITIONAL([MHD_USE_EPOLL], [[test "x${enable_epoll}" = "xyes"]])
  2777. AS_IF([test "x$enable_epoll" = "xyes"],
  2778. [
  2779. MHD_CHECK_FUNC([epoll_create1],
  2780. [[
  2781. #include <sys/epoll.h>
  2782. ]],
  2783. [[
  2784. i][f (0 > epoll_create1(EPOLL_CLOEXEC))
  2785. return 3;
  2786. ]]
  2787. )
  2788. ]
  2789. )
  2790. AC_CACHE_CHECK([for supported 'noreturn' keyword], [mhd_cv_decl_noreturn],
  2791. [
  2792. mhd_cv_decl_noreturn="none"
  2793. CFLAGS="${CFLAGS_ac} ${user_CFLAGS} ${errattr_CFLAGS}"
  2794. MHD_SAVED_ac_c_werror_flag="$ac_c_werror_flag"
  2795. ac_c_werror_flag=yes
  2796. for decl_noret in ['[[noreturn]]'] '_Noreturn' '__attribute__((__noreturn__))' '__declspec(noreturn)'
  2797. do
  2798. AC_LINK_IFELSE([AC_LANG_SOURCE(
  2799. [[
  2800. #ifdef HAVE_STDLIB_H
  2801. #include <stdlib.h>
  2802. #endif
  2803. ${decl_noret} static void myexitfunc(int code)
  2804. {
  2805. #ifdef HAVE_STDLIB_H
  2806. exit (code);
  2807. #else
  2808. (void)code;
  2809. #endif
  2810. }
  2811. int main (int argc, char *const *argv)
  2812. {
  2813. (void) argv;
  2814. if (argc > 2)
  2815. myexitfunc (2);
  2816. return 0;
  2817. }
  2818. ]]
  2819. )], [mhd_cv_decl_noreturn="${decl_noret}"]
  2820. )
  2821. AS_IF([test "x${mhd_cv_decl_noreturn}" != "xnone"], [break])
  2822. done
  2823. ac_c_werror_flag="$MHD_SAVED_ac_c_werror_flag"
  2824. AS_UNSET([MHD_SAVED_ac_c_werror_flag])
  2825. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  2826. ]
  2827. )
  2828. AS_VAR_IF([mhd_cv_decl_noreturn], ["none"],
  2829. [AC_DEFINE([MHD_NORETURN_], [[/* empty */]], [Define to the supported 'noreturn' function declaration])],
  2830. [AC_DEFINE_UNQUOTED([MHD_NORETURN_], [${mhd_cv_decl_noreturn}], [Define to the supported 'noreturn' function declaration])]
  2831. )
  2832. # Check for types sizes
  2833. # Types sizes are used as an indirect indication of maximum allowed values for types
  2834. # which is used to exclude by preprocessor some compiler checks for values clips
  2835. # Assuming no staffing or uniform staffing for integer types
  2836. AC_CACHE_CHECK([size of tv_sec member of struct timeval], [mhd_cv_size_timeval_tv_sec],
  2837. [
  2838. AC_COMPUTE_INT([mhd_cv_size_timeval_tv_sec], [((long int)sizeof(test_var.tv_sec))],
  2839. [[
  2840. #ifdef HAVE_SYS_TIME_H
  2841. #include <sys/time.h>
  2842. #endif /* HAVE_SYS_TIME_H */
  2843. #ifdef HAVE_TIME_H
  2844. #include <time.h>
  2845. #endif /* HAVE_TIME_H */
  2846. #if HAVE_SYS_TYPES_H
  2847. #include <sys/types.h>
  2848. #endif /* HAVE_SYS_TYPES_H */
  2849. static struct timeval test_var;
  2850. ]],
  2851. [
  2852. # The size is used only to exclude additional checks/comparison in code
  2853. # to avoid compiler warnings. With larger size MHD code will use
  2854. # additional checks which ensure that value will fit but it may produce
  2855. # a harmless compiler warning.
  2856. AC_MSG_WARN([The size cannot be determined, assuming 8.])
  2857. mhd_cv_size_timeval_tv_sec=8
  2858. ]
  2859. )
  2860. ]
  2861. )
  2862. AC_DEFINE_UNQUOTED([SIZEOF_STRUCT_TIMEVAL_TV_SEC], [$mhd_cv_size_timeval_tv_sec],
  2863. [The size of `tv_sec' member of `struct timeval', as computed by sizeof])
  2864. AC_CHECK_SIZEOF([int_fast64_t], [], [[#include <stdint.h>]])
  2865. AC_CHECK_SIZEOF([uint_fast64_t], [], [[#include <stdint.h>]])
  2866. AC_CHECK_SIZEOF([int], [], [[#include <stdint.h>]])
  2867. AC_CHECK_SIZEOF([unsigned int], [], [[#include <stdint.h>]])
  2868. AC_CHECK_SIZEOF([unsigned long long], [], [[#include <stdint.h>]])
  2869. AC_CHECK_SIZEOF([size_t], [],
  2870. [[
  2871. #ifdef HAVE_STDLIB_H
  2872. #include <stdlib.h>
  2873. #endif /* HAVE_STDLIB_H */
  2874. #ifdef HAVE_STDDEF_H
  2875. #include <stddef.h>
  2876. #endif /* HAVE_STDDEF_H */
  2877. #include <stdio.h>
  2878. ]]
  2879. )
  2880. AC_CHECK_HEADERS([dlfcn.h],[have_tlsplugin=yes],[have_tlsplugin=no], [AC_INCLUDES_DEFAULT])
  2881. AM_CONDITIONAL([MHD_HAVE_TLS_PLUGIN], [[test "x$have_tlsplugin" = xyes]])
  2882. AC_CHECK_HEADERS([zlib.h],[have_zlib=yes],[have_zlib=no], [AC_INCLUDES_DEFAULT])
  2883. AM_CONDITIONAL([HAVE_ZLIB], [[test "x$have_zlib" = xyes]])
  2884. # Check for generic functions
  2885. MHD_CHECK_FUNC([random],
  2886. [
  2887. AC_INCLUDES_DEFAULT
  2888. [#include <stdlib.h>
  2889. ]],
  2890. [[long int r = random(); (void)r;]],
  2891. [],
  2892. [
  2893. MHD_CHECK_FUNC([rand],
  2894. [
  2895. AC_INCLUDES_DEFAULT
  2896. [#include <stdlib.h>
  2897. ]],
  2898. [[int r = rand(); (void)r;]],
  2899. )
  2900. ]
  2901. )
  2902. AC_CHECK_MEMBERS([struct sockaddr.sa_len, struct sockaddr_storage.ss_len,
  2903. struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len],
  2904. [], [],
  2905. [
  2906. #ifdef HAVE_SYS_TYPES_H
  2907. #include <sys/types.h>
  2908. #endif
  2909. #ifdef HAVE_SYS_SOCKET_H
  2910. #include <sys/socket.h>
  2911. #elif defined(HAVE_UNISTD_H)
  2912. #include <unistd.h>
  2913. #endif
  2914. #ifdef HAVE_NETINET_IN_H
  2915. #include <netinet/in.h>
  2916. #endif
  2917. #ifdef HAVE_WINSOCK2_H
  2918. #include <winsock2.h>
  2919. #endif
  2920. #ifdef HAVE_WS2TCPIP_H
  2921. #include <ws2tcpip.h>
  2922. #endif
  2923. ])
  2924. MHD_CHECK_LINK_RUN([[f][or working getsockname()]],[[mhd_cv_getsockname_usable]],
  2925. [[mhd_cv_getsockname_usable='assuming yes']],
  2926. [
  2927. AC_LANG_SOURCE(
  2928. [[
  2929. #ifdef HAVE_SYS_TYPES_H
  2930. #include <sys/types.h>
  2931. #endif
  2932. #ifdef HAVE_SYS_SOCKET_H
  2933. #include <sys/socket.h>
  2934. #endif
  2935. #ifdef HAVE_UNISTD_H
  2936. #include <unistd.h>
  2937. #endif
  2938. #ifdef HAVE_WINSOCK2_H
  2939. #include <winsock2.h>
  2940. #endif
  2941. #ifdef HAVE_WS2TCPIP_H
  2942. #include <ws2tcpip.h>
  2943. #endif
  2944. #ifdef HAVE_NETINET_IN_H
  2945. #include <netinet/in.h>
  2946. #endif
  2947. #ifdef HAVE_NETINET_IP_H
  2948. #include <netinet/ip.h>
  2949. #endif
  2950. #ifdef HAVE_ARPA_INET_H
  2951. #include <arpa/inet.h>
  2952. #endif
  2953. static void zr_mem(void *ptr, socklen_t size)
  2954. { char *mem = ptr; while(size--) {mem[0] = 0; mem++;} }
  2955. int main(void)
  2956. {
  2957. const socklen_t c_addr_size = (socklen_t)sizeof(struct sockaddr_in);
  2958. struct sockaddr_in sa;
  2959. socklen_t addr_size;
  2960. int ret = 1;
  2961. #if !defined(_WIN32) || defined(__CYGWIN__)
  2962. int sckt;
  2963. const int invld_sckt = -1;
  2964. #else
  2965. SOCKET sckt;
  2966. const SOCKET invld_sckt = INVALID_SOCKET;
  2967. WSADATA wsa_data;
  2968. if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data) || MAKEWORD(2, 2) != wsa_data.wVersion)
  2969. return 20;
  2970. #endif
  2971. sckt = socket (PF_INET, SOCK_STREAM, 0);
  2972. if (invld_sckt != sckt)
  2973. {
  2974. zr_mem(&sa, c_addr_size);
  2975. sa.sin_family = AF_INET;
  2976. #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
  2977. sa.sin_len = c_addr_size;
  2978. #endif
  2979. if (0 == bind (sckt, (struct sockaddr *)&sa, c_addr_size))
  2980. {
  2981. if (0 == listen (sckt, 1))
  2982. {
  2983. addr_size = c_addr_size;
  2984. if (0 == getsockname (sckt, (struct sockaddr *)&sa, &addr_size))
  2985. {
  2986. if (c_addr_size >= addr_size)
  2987. {
  2988. if (0 != ntohs(sa.sin_port))
  2989. { ret = 0;
  2990. } else ret = 7;
  2991. } else ret = 6;
  2992. } else ret = 5;
  2993. } else ret = 4;
  2994. } else ret = 3;
  2995. } else ret = 2;
  2996. #if !defined(_WIN32) || defined(__CYGWIN__)
  2997. close (sckt);
  2998. #else
  2999. closesocket (sckt);
  3000. WSACleanup();
  3001. #endif
  3002. return ret;
  3003. }
  3004. ]]
  3005. )
  3006. ],
  3007. [AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable `getsockname' function.])]
  3008. )
  3009. AS_VAR_IF([[os_is_native_w32]], [["yes"]],[],
  3010. [
  3011. MHD_CHECK_FUNC([socketpair],
  3012. [[
  3013. #ifdef HAVE_SYS_TYPES_H
  3014. #include <sys/types.h>
  3015. #endif
  3016. #ifdef HAVE_SYS_SOCKET_H
  3017. #include <sys/socket.h>
  3018. #endif
  3019. #if defined(HAVE_UNISTD_H)
  3020. #include <unistd.h>
  3021. #endif
  3022. #ifdef HAVE_SYS_UN_H
  3023. #include <sys/un.h>
  3024. #endif
  3025. ]],
  3026. [[
  3027. int arr[2];
  3028. i][f (0 != socketpair(0, SOCK_STREAM, 0, arr)) return 2;
  3029. close (arr[1]);
  3030. close (arr[0]);
  3031. ]],
  3032. [],
  3033. [AS_UNSET([mhd_cv_socketpair_usable])]
  3034. )
  3035. ]
  3036. )
  3037. AC_CHECK_DECLS([AF_UNIX,AF_LOCAL,SOMAXCONN,IPV6_V6ONLY,SO_REUSEADDR,SO_REUSEPORT,\
  3038. TCP_NODELAY,TCP_FASTOPEN],[],[],
  3039. [[
  3040. #ifdef HAVE_SYS_TYPES_H
  3041. #include <sys/types.h>
  3042. #endif
  3043. #ifdef HAVE_SYS_SOCKET_H
  3044. #include <sys/socket.h>
  3045. #endif
  3046. #if defined(HAVE_UNISTD_H)
  3047. #include <unistd.h>
  3048. #endif
  3049. #ifdef HAVE_SOCKLIB_H
  3050. #include <sockLib.h>
  3051. #endif
  3052. #ifdef HAVE_SYS_UN_H
  3053. #include <sys/un.h>
  3054. #endif
  3055. #ifdef HAVE_WINSOCK2_H
  3056. #include <winsock2.h>
  3057. #endif
  3058. #ifdef HAVE_INETLIB_H
  3059. #include <inetLib.h>
  3060. #endif
  3061. #ifdef HAVE_NETINET_IN_H
  3062. #include <netinet/in.h>
  3063. #endif
  3064. #ifdef HAVE_ARPA_INET_H
  3065. #include <arpa/inet.h>
  3066. #endif
  3067. #if !defined(HAVE_NETINET_IN_H) && !defined(HAVE_ARPA_INET_H) && defined(HAVE_NETDB_H)
  3068. #include <netdb.h>
  3069. #endif
  3070. #ifdef HAVE_NETINET_TCP_H
  3071. #include <netinet/tcp.h>
  3072. #endif
  3073. #ifdef HAVE_AFUNIX_H
  3074. #include <afunix.h>
  3075. #endif
  3076. #ifdef HAVE_WS2TCPIP_H
  3077. #include <ws2tcpip.h>
  3078. #endif
  3079. ]]
  3080. )
  3081. AC_CACHE_CHECK([for usable PAGESIZE macro], [mhd_cv_macro_pagesize_usable],
  3082. [
  3083. AC_LINK_IFELSE(
  3084. [
  3085. AC_LANG_PROGRAM(
  3086. [[
  3087. #ifdef HAVE_UNISTD_H
  3088. #include <unistd.h>
  3089. #endif
  3090. #ifdef HAVE_LIMITS_H
  3091. #include <limits.h>
  3092. #endif
  3093. #ifdef HAVE_SYS_PARAM_H
  3094. #include <sys/param.h>
  3095. #endif
  3096. #ifndef PAGESIZE
  3097. #error No PAGESIZE macro defined
  3098. choke me now
  3099. #endif
  3100. ]],
  3101. [[
  3102. long pgsz = PAGESIZE + 0;
  3103. if (1 > pgsz) return 1;
  3104. ]]
  3105. )
  3106. ],
  3107. [[mhd_cv_macro_pagesize_usable="yes"]], [[mhd_cv_macro_pagesize_usable="no"]]
  3108. )
  3109. ]
  3110. )
  3111. AS_VAR_IF([[mhd_cv_macro_pagesize_usable]], [["yes"]],
  3112. [
  3113. AC_DEFINE([[MHD_USE_PAGESIZE_MACRO]],[[1]],[Define if you have usable PAGESIZE macro])
  3114. AC_CACHE_CHECK([whether PAGESIZE macro could be used for static init], [mhd_cv_macro_pagesize_usable_static],
  3115. [
  3116. AC_LINK_IFELSE(
  3117. [
  3118. AC_LANG_PROGRAM(
  3119. [[
  3120. #ifdef HAVE_UNISTD_H
  3121. #include <unistd.h>
  3122. #endif
  3123. #ifdef HAVE_LIMITS_H
  3124. #include <limits.h>
  3125. #endif
  3126. #ifdef HAVE_SYS_PARAM_H
  3127. #include <sys/param.h>
  3128. #endif
  3129. #ifndef PAGESIZE
  3130. #error No PAGESIZE macro defined
  3131. choke me now
  3132. #endif
  3133. static long ac_pgsz = PAGESIZE + 0;
  3134. ]],
  3135. [[
  3136. if (1 > ac_pgsz) return 1;
  3137. ]]
  3138. )
  3139. ],
  3140. [[mhd_cv_macro_pagesize_usable_static="yes"]], [[mhd_cv_macro_pagesize_usable_static="no"]]
  3141. )
  3142. ]
  3143. )
  3144. AS_VAR_IF([[mhd_cv_macro_pagesize_usable_static]], [["yes"]],
  3145. [AC_DEFINE([[MHD_USE_PAGESIZE_MACRO_STATIC]],[[1]],[Define if you have PAGESIZE macro usable for static init])]
  3146. )
  3147. ],
  3148. [
  3149. AC_CACHE_CHECK([for usable PAGE_SIZE macro], [mhd_cv_macro_page_size_usable],
  3150. [
  3151. AC_LINK_IFELSE(
  3152. [
  3153. AC_LANG_PROGRAM(
  3154. [[
  3155. #ifdef HAVE_UNISTD_H
  3156. #include <unistd.h>
  3157. #endif
  3158. #ifdef HAVE_LIMITS_H
  3159. #include <limits.h>
  3160. #endif
  3161. #ifdef HAVE_SYS_PARAM_H
  3162. #include <sys/param.h>
  3163. #endif
  3164. #ifndef PAGE_SIZE
  3165. #error No PAGE_SIZE macro defined
  3166. choke me now
  3167. #endif
  3168. ]],
  3169. [[
  3170. long pgsz = PAGE_SIZE + 0;
  3171. if (1 > pgsz) return 1;
  3172. ]]
  3173. )
  3174. ],
  3175. [[mhd_cv_macro_page_size_usable="yes"]], [[mhd_cv_macro_page_size_usable="no"]]
  3176. )
  3177. ]
  3178. )
  3179. AS_VAR_IF([[mhd_cv_macro_page_size_usable]], [["yes"]],
  3180. [
  3181. AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO]],[[1]],[Define if you have usable PAGE_SIZE macro])
  3182. AC_CACHE_CHECK([whether PAGE_SIZE macro could be used for static init], [mhd_cv_macro_page_size_usable_static],
  3183. [
  3184. AC_LINK_IFELSE(
  3185. [
  3186. AC_LANG_PROGRAM(
  3187. [[
  3188. #ifdef HAVE_UNISTD_H
  3189. #include <unistd.h>
  3190. #endif
  3191. #ifdef HAVE_LIMITS_H
  3192. #include <limits.h>
  3193. #endif
  3194. #ifdef HAVE_SYS_PARAM_H
  3195. #include <sys/param.h>
  3196. #endif
  3197. #ifndef PAGE_SIZE
  3198. #error No PAGE_SIZE macro defined
  3199. choke me now
  3200. #endif
  3201. static long ac_pgsz = PAGE_SIZE + 0;
  3202. ]],
  3203. [[
  3204. if (1 > ac_pgsz) return 1;
  3205. ]]
  3206. )
  3207. ],
  3208. [[mhd_cv_macro_page_size_usable_static="yes"]], [[mhd_cv_macro_page_size_usable_static="no"]]
  3209. )
  3210. ]
  3211. )
  3212. AS_VAR_IF([[mhd_cv_macro_page_size_usable_static]], [["yes"]],
  3213. [AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO_STATIC]],[[1]],[Define if you have PAGE_SIZE macro usable for static init])]
  3214. )
  3215. ]
  3216. )
  3217. ]
  3218. )
  3219. # Check for inter-thread signaling type
  3220. AC_ARG_ENABLE([[itc]],
  3221. [AS_HELP_STRING([[--enable-itc=TYPE]], [use TYPE of inter-thread communication (pipe, socketpair, eventfd) [auto]])], [],
  3222. [[enable_itc='auto']]
  3223. )
  3224. AS_CASE([[$enable_itc]],
  3225. [[pipe]], [[:]],
  3226. [[socketpair]], [[:]],
  3227. [[eventfd]], [[:]],
  3228. [[auto]], [AS_VAR_IF([[os_is_windows]], [["yes"]], [[enable_itc='socketpair']])],
  3229. [[eventFD]], [[enable_itc='eventfd']],
  3230. [[socket]], [[enable_itc='socketpair']],
  3231. [[no]], [AC_MSG_ERROR([[inter-thread communication cannot be disabled]])],
  3232. [AC_MSG_ERROR([[unrecognized type "$enable_itc" of inter-thread communication specified by "--enable-itc=$enable_itc"]])]
  3233. )
  3234. AS_UNSET([[use_itc]])
  3235. AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]],
  3236. [
  3237. MHD_CHECK_LINK_RUN([[f][or working eventfd(2)]],[[mhd_cv_eventfd_usable]],[[mhd_cv_eventfd_usable='assuming no']],
  3238. [
  3239. AC_LANG_SOURCE([[
  3240. #include <sys/eventfd.h>
  3241. #include <unistd.h>
  3242. int main(void)
  3243. {
  3244. unsigned char buf[8];
  3245. int ret;
  3246. int efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
  3247. if (0 > efd)
  3248. return 2;
  3249. ret = 0;
  3250. buf[3] = 1;
  3251. if (8 != write(efd, buf, 8))
  3252. ret = 3;
  3253. else
  3254. {
  3255. if (8 != read(efd, buf, 8))
  3256. ret = 4;
  3257. }
  3258. close(efd);
  3259. return ret;
  3260. }
  3261. ]]
  3262. )
  3263. ],
  3264. [
  3265. use_itc='eventfd'
  3266. enable_itc="$use_itc"
  3267. AC_DEFINE([[MHD_ITC_EVENTFD_]], [[1]], [Define to use eventFD for inter-thread communication])
  3268. ],
  3269. [
  3270. AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not usable, consider using other type of inter-thread communication]])])
  3271. ]
  3272. )
  3273. AS_VAR_IF([mhd_cv_eventfd_usable],["assuming no"],
  3274. [AC_MSG_WARN([if you have 'eventfd' support enabled on your target system consider overriding test result by "mhd_cv_eventfd_usable=yes" configure parameter])]
  3275. )
  3276. ]
  3277. )
  3278. AS_IF([[test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto"]], [
  3279. AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
  3280. AC_CACHE_CHECK([[whether pipe(3) is usable]], [[mhd_cv_pipe_usable]], [
  3281. AC_LINK_IFELSE([
  3282. AC_LANG_PROGRAM([
  3283. AC_INCLUDES_DEFAULT
  3284. #ifdef HAVE_UNISTD_H
  3285. #include <unistd.h>
  3286. #endif
  3287. ], [[
  3288. int arr[2];
  3289. int res;
  3290. res = pipe(arr);
  3291. if (res != 0) return 33;
  3292. close (arr[0]);
  3293. close (arr[1]);
  3294. ]])
  3295. ], [[mhd_cv_pipe_usable='yes']], [[mhd_cv_pipe_usable='no']])
  3296. ])
  3297. AS_VAR_IF([[mhd_cv_pipe_usable]], [["yes"]], [
  3298. use_itc='pipe'
  3299. enable_itc="$use_itc"
  3300. AC_DEFINE([[MHD_ITC_PIPE_]], [[1]], [Define to use pipe for inter-thread communication])
  3301. MHD_CHECK_LINK_RUN([[whether pipe2(2) is usable]],[[mhd_cv_pipe2_usable]],
  3302. [
  3303. # Cross-compiling
  3304. AS_CASE([${host_os}], [kfreebsd*-gnu], [[mhd_cv_pipe2_usable='assuming no']],
  3305. [[mhd_cv_pipe2_usable='assuming yes']])
  3306. ],
  3307. [
  3308. AC_LANG_PROGRAM([
  3309. AC_INCLUDES_DEFAULT
  3310. #ifdef HAVE_FCNTL_H
  3311. #include <fcntl.h>
  3312. #endif
  3313. #ifdef HAVE_UNISTD_H
  3314. #include <unistd.h>
  3315. #endif
  3316. ], [[
  3317. int arr[2];
  3318. int res;
  3319. res = pipe2(arr, O_CLOEXEC | O_NONBLOCK);
  3320. if (res != 0) return 33;
  3321. close (arr[0]);
  3322. close (arr[1]);
  3323. ]]
  3324. )
  3325. ],
  3326. [AC_DEFINE([[HAVE_PIPE2_FUNC]], [[1]], [Define if you have usable pipe2(2) function])]
  3327. )
  3328. ], [
  3329. AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not usable, consider using other type of inter-thread communication]])])
  3330. ])
  3331. ])
  3332. ])
  3333. AS_IF([[test "x$enable_itc" = "xsocketpair" || test "x$enable_itc" = "xauto"]],
  3334. [
  3335. AS_IF([test "x${os_is_native_w32}" = "xyes"],
  3336. [mhd_cv_socketpair_usable='yes'],
  3337. [test "x${mhd_cv_func_socketpair}" = "xyes"],
  3338. [
  3339. AC_CACHE_CHECK([[whether socketpair(3) is usable]], [[mhd_cv_socketpair_usable]],
  3340. [
  3341. AC_LINK_IFELSE([
  3342. AC_LANG_PROGRAM(
  3343. [[
  3344. #ifdef HAVE_SYS_TYPES_H
  3345. #include <sys/types.h>
  3346. #endif
  3347. #ifdef HAVE_SYS_SOCKET_H
  3348. #include <sys/socket.h>
  3349. #endif
  3350. #if defined(HAVE_UNISTD_H)
  3351. #include <unistd.h>
  3352. #endif
  3353. #ifdef HAVE_SYS_UN_H
  3354. #include <sys/un.h>
  3355. #endif
  3356. ]], [[
  3357. int arr[2];
  3358. int res;
  3359. #if defined(AF_UNIX)
  3360. res = socketpair(AF_UNIX, SOCK_STREAM, 0, arr);
  3361. #elif defined(AF_LOCAL)
  3362. res = socketpair(AF_LOCAL, SOCK_STREAM, 0, arr);
  3363. #else
  3364. #error AF_LOCAL and AF_UNIX are both undefined
  3365. choke me now;
  3366. #endif
  3367. if (res != 0) return 1;
  3368. close (arr[1]);
  3369. close (arr[0]);
  3370. ]]
  3371. )
  3372. ],
  3373. [[mhd_cv_socketpair_usable='yes']],
  3374. [[mhd_cv_socketpair_usable='no']]
  3375. )
  3376. ]
  3377. )
  3378. ],
  3379. [AS_UNSET([mhd_cv_socketpair_usable])]
  3380. )
  3381. AS_VAR_IF([[mhd_cv_socketpair_usable]], [["yes"]],
  3382. [
  3383. use_itc='socketpair'
  3384. enable_itc="$use_itc"
  3385. AC_DEFINE([[MHD_ITC_SOCKETPAIR_]], [[1]], [Define to use socketpair for inter-thread communication])
  3386. ],
  3387. [
  3388. AS_VAR_IF([[enable_itc]], [["socketpair"]], [
  3389. AC_MSG_ERROR([[socketpair(3) is not usable, consider using other type of inter-thread communication]])]
  3390. )
  3391. ]
  3392. )
  3393. ]
  3394. )
  3395. AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find usable type of inter-thread communication]])])
  3396. MHD_CHECK_FUNC([accept4],
  3397. [[
  3398. #if defined(HAVE_SYS_TYPES_H)
  3399. # include <sys/types.h>
  3400. #endif
  3401. #include <sys/socket.h>
  3402. ]],
  3403. [[
  3404. struct sockaddr sk_addr;
  3405. socklen_t addr_size;
  3406. i][f (0 > accept4(0, &sk_addr, &addr_size, 0))
  3407. return 3;
  3408. ]]
  3409. )
  3410. MHD_CHECK_FUNC([gmtime_r],
  3411. [[
  3412. #if defined(HAVE_SYS_TYPES_H)
  3413. # include <sys/types.h>
  3414. #endif
  3415. #include <time.h>
  3416. ]],
  3417. [[
  3418. time_t timer = (time_t) 0;
  3419. struct tm res;
  3420. i][f (&res != gmtime_r(&timer, &res))
  3421. return 3;
  3422. ]]
  3423. )
  3424. MHD_CHECK_FUNC([memmem],
  3425. [[
  3426. #if defined(HAVE_STDDEF_H)
  3427. # include <stddef.h>
  3428. #elif defined(HAVE_STDLIB_H)
  3429. # include <stdlib.h>
  3430. #endif /* HAVE_STDLIB_H */
  3431. #include <string.h>
  3432. ]],
  3433. [[
  3434. const char *haystack = "abc";
  3435. size_t hslen = 3;
  3436. const char *needle = "b";
  3437. size_t needlelen = 1;
  3438. i][f ((haystack + 1) != memmem(haystack, hslen, needle, needlelen))
  3439. return 3;
  3440. ]]
  3441. )
  3442. MHD_CHECK_FUNC([snprintf],
  3443. [[
  3444. #include <stdio.h>
  3445. ]],
  3446. [[
  3447. char buf[2];
  3448. i][f (1 != snprintf(buf, 2, "a"))
  3449. return 3;
  3450. /* Do not use the next check to avoid compiler warning */
  3451. /* i][f (4 != snprintf(buf, 2, "abcd"))
  3452. return 4; */
  3453. ]]
  3454. )
  3455. AC_CHECK_DECL([gmtime_s],
  3456. [
  3457. AC_MSG_CHECKING([[whether gmtime_s is in C11 form]])
  3458. AC_LINK_IFELSE(
  3459. [ AC_LANG_PROGRAM(
  3460. [[
  3461. #define __STDC_WANT_LIB_EXT1__ 1
  3462. #include <time.h>
  3463. #ifdef __cplusplus
  3464. extern "C"
  3465. #endif
  3466. struct tm* gmtime_s(const time_t* time, struct tm* result);
  3467. ]], [[
  3468. static struct tm res;
  3469. static time_t t = 0;
  3470. gmtime_s (&t, &res);
  3471. ]])
  3472. ],
  3473. [
  3474. AC_DEFINE([HAVE_C11_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in C11 form.])
  3475. AC_MSG_RESULT([[yes]])
  3476. ],
  3477. [
  3478. AC_MSG_RESULT([[no]])
  3479. AC_MSG_CHECKING([[whether gmtime_s is in W32 form]])
  3480. AC_LINK_IFELSE(
  3481. [ AC_LANG_PROGRAM(
  3482. [[
  3483. #include <time.h>
  3484. #ifdef __cplusplus
  3485. extern "C"
  3486. #endif
  3487. errno_t gmtime_s(struct tm* _tm, const time_t* time);
  3488. ]], [[
  3489. static struct tm res;
  3490. static time_t t = 0;
  3491. gmtime_s (&res, &t);
  3492. ]])
  3493. ],
  3494. [
  3495. AC_DEFINE([HAVE_W32_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in W32 form.])
  3496. AC_MSG_RESULT([[yes]])
  3497. ],
  3498. [AC_MSG_RESULT([[no]])
  3499. ])
  3500. ])
  3501. ], [],
  3502. [[#define __STDC_WANT_LIB_EXT1__ 1
  3503. #include <time.h>]])
  3504. AC_CHECK_DECL([SOCK_NONBLOCK], [AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBLOCK is defined in a socket header])], [],
  3505. [[
  3506. #if defined(HAVE_SYS_TYPES_H)
  3507. # include <sys/types.h>
  3508. #endif
  3509. #if defined(HAVE_SYS_SOCKET_H)
  3510. # include <sys/socket.h>
  3511. #elif defined(HAVE_WINSOCK2_H)
  3512. # include <winsock2.h>
  3513. #elif defined(HAVE_UNISTD_H)
  3514. # include <unistd.h>
  3515. #endif
  3516. ]]
  3517. )
  3518. MHD_FIND_LIB([clock_gettime],[[#include <time.h>]],
  3519. [[
  3520. struct timespec tp;
  3521. i][f (0 > clock_gettime(CLOCK_REALTIME, &tp))
  3522. return 3;
  3523. ]],
  3524. [rt],
  3525. [
  3526. AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define to '1' if you have clock_gettime() function])
  3527. AS_VAR_IF([[mhd_cv_find_lib_clock_gettime]],[["none required"]], [],
  3528. [
  3529. MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_clock_gettime} $MHD_LIBDEPS_PKGCFG"
  3530. ]
  3531. )
  3532. ],[],
  3533. [MHD_LIBDEPS]
  3534. )
  3535. MHD_CHECK_FUNC([clock_get_time],
  3536. [[
  3537. #include <mach/clock.h>
  3538. #include <mach/mach.h>
  3539. ]],
  3540. [[
  3541. clock_serv_t cs;
  3542. mach_timespec_t mt;
  3543. host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
  3544. clock_get_time(cs, &mt);
  3545. mach_port_deallocate(mach_task_self(), cs);
  3546. ]]
  3547. )
  3548. MHD_CHECK_FUNC([gethrtime],
  3549. [[
  3550. #ifdef HAVE_SYS_TIME_H
  3551. /* Solaris define gethrtime() in sys/time.h */
  3552. #include <sys/time.h>
  3553. #endif /* HAVE_SYS_TIME_H */
  3554. #ifdef HAVE_TIME_H
  3555. /* HP-UX define gethrtime() in time.h */
  3556. #include <time.h>
  3557. #endif /* HAVE_TIME_H */
  3558. ]],
  3559. [[
  3560. hrtime_t hrt = gethrtime();
  3561. i][f (0 == hrt)
  3562. return 3;
  3563. ]]
  3564. )
  3565. AS_VAR_IF([ac_cv_header_time_h], ["yes"],
  3566. [
  3567. MHD_CHECK_FUNC([timespec_get],
  3568. [[
  3569. #include <time.h>
  3570. #ifndef TIME_UTC
  3571. #error TIME_UTC must be defined to use timespec_get()
  3572. choke me now
  3573. #endif
  3574. ]],
  3575. [[
  3576. struct timespec ts;
  3577. i][f (TIME_UTC != timespec_get (&ts, TIME_UTC))
  3578. return 3;
  3579. ]]
  3580. )
  3581. ]
  3582. )
  3583. MHD_CHECK_FUNC_GETTIMEOFDAY
  3584. # IPv6
  3585. AC_CACHE_CHECK([for IPv6],[mhd_cv_have_inet6],
  3586. [
  3587. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3588. #include <stdio.h>
  3589. #ifdef HAVE_SYS_SOCKET_H
  3590. #include <sys/socket.h>
  3591. #elif defined(HAVE_UNISTD_H)
  3592. #include <unistd.h>
  3593. #endif
  3594. #ifdef HAVE_NETINET_IN_H
  3595. #include <netinet/in.h>
  3596. #endif
  3597. #ifdef HAVE_WINSOCK2_H
  3598. #include <winsock2.h>
  3599. #endif
  3600. #ifdef HAVE_WS2TCPIP_H
  3601. #include <ws2tcpip.h>
  3602. #endif
  3603. ]], [[
  3604. int af=AF_INET6;
  3605. struct sockaddr_in6 sa;
  3606. printf("%d %p\n", (int) af, (void*) &sa);
  3607. ]]
  3608. )
  3609. ],
  3610. [AS_VAR_SET([mhd_cv_have_inet6],["yes"])],
  3611. [AS_VAR_SET([mhd_cv_have_inet6],["no"])]
  3612. )
  3613. ]
  3614. )
  3615. AS_VAR_IF([mhd_cv_have_inet6],["yes"],
  3616. [AC_DEFINE([HAVE_INET6], [1], [Define to '1' if you have IPv6 headers])]
  3617. )
  3618. MHD_CHECK_FUNC([[sysconf]], [[#include <unistd.h>]], [[long a = sysconf(0); if (a) return 1;]])
  3619. MHD_CHECK_FUNC([[sysctl]], [[
  3620. #ifdef HAVE_SYS_TYPES_H
  3621. #include <sys/types.h>
  3622. #endif
  3623. #ifdef HAVE_SYS_SYSCTL_H
  3624. #include <sys/sysctl.h>
  3625. #endif
  3626. #if defined(HAVE_STDDEF_H)
  3627. #include <stddef.h>
  3628. #elif defined(HAVE_STDLIB_H)
  3629. #include <stdlib.h>
  3630. #endif
  3631. ]], [[
  3632. int mib[2] = {0, 0}; /* Avoid any platform-specific values */
  3633. i][f (sysctl(mib, 2, NULL, NULL, NULL, 0)) return 1;
  3634. ]],
  3635. [
  3636. AC_CHECK_DECLS([CTL_NET,PF_INET,IPPROTO_ICMP,ICMPCTL_ICMPLIM],[],[],
  3637. [[
  3638. #ifdef HAVE_SYS_TYPES_H
  3639. #include <sys/types.h>
  3640. #endif /* HAVE_SYS_TYPES_H */
  3641. #ifdef HAVE_SYS_SYSCTL_H
  3642. #include <sys/sysctl.h>
  3643. #endif /* HAVE_SYS_SYSCTL_H */
  3644. #ifdef HAVE_SYS_SYSCTL_H
  3645. #include <sys/sysctl.h>
  3646. #endif /* HAVE_SYS_SYSCTL_H */
  3647. #ifdef HAVE_SYS_SOCKET_H
  3648. #include <sys/socket.h>
  3649. #elif defined(HAVE_UNISTD_H)
  3650. #include <unistd.h>
  3651. #endif
  3652. #ifdef HAVE_NETINET_IN_SYSTM_H
  3653. #include <netinet/in_systm.h>
  3654. #endif /* HAVE_NETINET_IN_SYSTM_H */
  3655. #ifdef HAVE_NETINET_IN_H
  3656. #include <netinet/in.h>
  3657. #endif /* HAVE_NETINET_IN_H */
  3658. #ifdef HAVE_NETINET_IP_H
  3659. #include <netinet/ip.h>
  3660. #endif /* HAVE_NETINET_IP_H */
  3661. #ifdef HAVE_NETINET_IP_ICMP_H
  3662. #include <netinet/ip_icmp.h>
  3663. #endif /* HAVE_NETINET_IP_ICMP_H */
  3664. #ifdef HAVE_NETINET_ICMP_VAR_H
  3665. #include <netinet/icmp_var.h>
  3666. #endif /* HAVE_NETINET_ICMP_VAR_H */
  3667. ]]
  3668. )
  3669. ]
  3670. )
  3671. MHD_CHECK_FUNC([[sysctlbyname]], [[
  3672. #ifdef HAVE_SYS_TYPES_H
  3673. #include <sys/types.h>
  3674. #endif
  3675. #ifdef HAVE_SYS_SYSCTL_H
  3676. #include <sys/sysctl.h>
  3677. #endif
  3678. #if defined(HAVE_STDDEF_H)
  3679. #include <stddef.h>
  3680. #elif defined(HAVE_STDLIB_H)
  3681. #include <stdlib.h>
  3682. #endif
  3683. ]], [[sysctlbyname("test", NULL, NULL, NULL, 0);]]
  3684. )
  3685. MHD_CHECK_FUNC([[usleep]], [[#include <unistd.h>]], [[usleep(100000);]])
  3686. MHD_CHECK_FUNC([[nanosleep]], [[#include <time.h>]], [[struct timespec ts2, ts1 = {0, 0}; nanosleep(&ts1, &ts2);]])
  3687. # NOTE: require setting of errattr_CFLAGS above
  3688. CFLAGS="${CFLAGS_ac} ${user_CFLAGS} ${errattr_CFLAGS}"
  3689. AC_CACHE_CHECK([whether $CC supports __attribute__((used))],[mhd_cv_cc_attr_used],
  3690. [
  3691. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3692. extern __attribute__((used)) int
  3693. test_func(void);
  3694. extern __attribute__((used)) int
  3695. test_func(void) {return 0;}
  3696. int main(void) {return test_func();}
  3697. ]])
  3698. ],
  3699. [mhd_cv_cc_attr_used="yes"],[mhd_cv_cc_attr_used="no"]
  3700. )
  3701. ]
  3702. )
  3703. AS_VAR_IF([mhd_cv_cc_attr_used],["yes"],
  3704. [
  3705. AC_DEFINE([HAVE_ATTR_USED],[1],
  3706. [Define to '1' if your compiler supports __attribute__((used))]
  3707. )
  3708. ]
  3709. )
  3710. AC_CACHE_CHECK([whether $CC supports __attribute__((pure))],[mhd_cv_cc_attr_pure],
  3711. [
  3712. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3713. extern __attribute__((pure)) int
  3714. test_func(const char *ptr);
  3715. extern __attribute__((pure)) int
  3716. test_func(const char *ptr) {return (0 == (*ptr));}
  3717. int main(void) {return test_func("");}
  3718. ]])
  3719. ],
  3720. [mhd_cv_cc_attr_pure="yes"],[mhd_cv_cc_attr_pure="no"]
  3721. )
  3722. ]
  3723. )
  3724. AS_VAR_IF([mhd_cv_cc_attr_pure],["yes"],
  3725. [
  3726. AC_DEFINE([HAVE_ATTR_PURE],[1],
  3727. [Define to '1' if your compiler supports __attribute__((pure))]
  3728. )
  3729. ]
  3730. )
  3731. AC_CACHE_CHECK([whether $CC supports __attribute__((const))],[mhd_cv_cc_attr_const],
  3732. [
  3733. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3734. extern __attribute__((const)) int
  3735. test_func(int a);
  3736. extern __attribute__((const)) int
  3737. test_func(int a) {return a + 1;}
  3738. int main(void) {return test_func(-1);}
  3739. ]])
  3740. ],
  3741. [mhd_cv_cc_attr_const="yes"],[mhd_cv_cc_attr_const="no"]
  3742. )
  3743. ]
  3744. )
  3745. AS_VAR_IF([mhd_cv_cc_attr_const],["yes"],
  3746. [
  3747. AC_DEFINE([HAVE_ATTR_CONST],[1],
  3748. [Define to '1' if your compiler supports __attribute__((const))]
  3749. )
  3750. ]
  3751. )
  3752. AC_CACHE_CHECK([whether $CC supports __attribute__((visibility("default")))],[mhd_cv_cc_attr_visibility_default],
  3753. [
  3754. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3755. extern __attribute__((visibility("default"))) int
  3756. test_extrn_func(void);
  3757. extern __attribute__((visibility("default"))) int
  3758. test_extrn_func(void) {return 0;}
  3759. int main(void) {return test_extrn_func();}
  3760. ]])
  3761. ],
  3762. [mhd_cv_cc_attr_visibility_default="yes"],[mhd_cv_cc_attr_visibility_default="no"]
  3763. )
  3764. ]
  3765. )
  3766. AS_VAR_IF([mhd_cv_cc_attr_visibility_default],["yes"],
  3767. [
  3768. AC_DEFINE([HAVE_ATTR_VISIBILITY_DEFAULT],[1],
  3769. [Define to '1' if your compiler supports __attribute__((visibility("default")))]
  3770. )
  3771. AC_CACHE_CHECK([whether $CC supports __attribute__((visibility("internal")))],[mhd_cv_cc_attr_visibility_internal],
  3772. [
  3773. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3774. __attribute__((visibility("internal"))) int
  3775. test_intern_func(void);
  3776. __attribute__((visibility("internal"))) int
  3777. test_intern_func(void) {return 0;}
  3778. int main(void) {return test_intern_func();}
  3779. ]])
  3780. ],
  3781. [mhd_cv_cc_attr_visibility_internal="yes"],[mhd_cv_cc_attr_visibility_internal="no"]
  3782. )
  3783. ]
  3784. )
  3785. AS_VAR_IF([mhd_cv_cc_attr_visibility_internal],["yes"],
  3786. [
  3787. AC_DEFINE([HAVE_ATTR_VISIBILITY_INTERNAL],[1],
  3788. [Define to '1' if your compiler supports __attribute__((visibility("internal")))]
  3789. )
  3790. ]
  3791. )
  3792. CFLAGS="${user_CFLAGS}"
  3793. MHD_CHECK_CC_CFLAG([-fvisibility=hidden],[CFLAGS_ac],
  3794. [
  3795. MHD_APPEND_FLAG_TO_VAR([MHD_LIB_CFLAGS],[-fvisibility=hidden])
  3796. ],
  3797. [
  3798. AC_MSG_WARN([[$CC supports __attribute__((visibility("default"))), but does not support -fvisibility=hidden. Check compiler and compiler flags.]])
  3799. ]
  3800. )
  3801. ]
  3802. )
  3803. CFLAGS="${CFLAGS_ac} ${user_CFLAGS} ${errattr_CFLAGS}"
  3804. AC_CACHE_CHECK([whether $CC supports __attribute__ ((warn_unused_result))],[mhd_cv_cc_attr_warn_unused_res],
  3805. [
  3806. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3807. static __attribute__ ((warn_unused_result)) int
  3808. test_func(void) {return 0; }
  3809. int main(void) { return test_func(); }
  3810. ]])
  3811. ],
  3812. [mhd_cv_cc_attr_warn_unused_res="yes"],[mhd_cv_cc_attr_warn_unused_res="no"]
  3813. )
  3814. ]
  3815. )
  3816. AS_VAR_IF([mhd_cv_cc_attr_warn_unused_res],["yes"],
  3817. [
  3818. AC_DEFINE([HAVE_ATTR_WARN_UNUSED_RES],[1],
  3819. [Define to '1' if your compiler supports __attribute__ ((warn_unused_result))]
  3820. )
  3821. ]
  3822. )
  3823. AC_CACHE_CHECK([whether $CC supports __attribute__ ((returns_nonnull))],[mhd_cv_cc_attr_ret_nonnull],
  3824. [
  3825. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3826. static __attribute__ ((returns_nonnull)) int *
  3827. test_func(void) {
  3828. static int i = 0;
  3829. return &i;
  3830. }
  3831. int main(void) {
  3832. return *(test_func());
  3833. }
  3834. ]])
  3835. ],
  3836. [mhd_cv_cc_attr_ret_nonnull="yes"],[mhd_cv_cc_attr_ret_nonnull="no"]
  3837. )
  3838. ]
  3839. )
  3840. AS_VAR_IF([mhd_cv_cc_attr_ret_nonnull],["yes"],
  3841. [
  3842. AC_DEFINE([HAVE_ATTR_RET_NONNULL],[1],
  3843. [Define to '1' if your compiler supports __attribute__ ((returns_nonnull))]
  3844. )
  3845. ]
  3846. )
  3847. AC_CACHE_CHECK([whether $CC supports __attribute__ ((nonnull))],[mhd_cv_cc_attr_nonnull],
  3848. [
  3849. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3850. static __attribute__ ((nonnull)) int
  3851. test_func(int *p) {return 0 == *p;}
  3852. int main(void) {
  3853. int i = 0;
  3854. return test_func(&i) ? 0 : 5;
  3855. }
  3856. ]])
  3857. ],
  3858. [mhd_cv_cc_attr_nonnull="yes"],[mhd_cv_cc_attr_nonnull="no"]
  3859. )
  3860. ]
  3861. )
  3862. AS_VAR_IF([mhd_cv_cc_attr_nonnull],["yes"],
  3863. [
  3864. AC_DEFINE([HAVE_ATTR_NONNULL],[1],
  3865. [Define to '1' if your compiler supports __attribute__ ((nonnull))]
  3866. )
  3867. ]
  3868. )
  3869. AC_CACHE_CHECK([whether $CC supports __attribute__ ((nonnull(NUM)))],[mhd_cv_cc_attr_nonnull_num],
  3870. [
  3871. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3872. static __attribute__ ((nonnull(2))) int
  3873. test_func(int *p1, int *p2) {
  3874. return (((int *)(void *)0) == p1) && (0 == *p2);
  3875. }
  3876. int main(void) {
  3877. int i = 0;
  3878. return test_func( (int *)(void *)0, &i) ? 0 : 5;
  3879. }
  3880. ]])
  3881. ],
  3882. [mhd_cv_cc_attr_nonnull_num="yes"],[mhd_cv_cc_attr_nonnull_num="no"]
  3883. )
  3884. ]
  3885. )
  3886. AS_VAR_IF([mhd_cv_cc_attr_nonnull_num],["yes"],
  3887. [
  3888. AC_DEFINE([HAVE_ATTR_NONNULL_NUM],[1],
  3889. [Define to '1' if your compiler supports __attribute__ ((nonnull(NUM)))]
  3890. )
  3891. ]
  3892. )
  3893. AC_CACHE_CHECK([whether $CC supports __attribute__ ((access (read_only,NUM)))],[mhd_cv_cc_attr_access_read],
  3894. [
  3895. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3896. static __attribute__ ((access (read_only,1))) int
  3897. test_func(int *p) {return 0 == *p;}
  3898. int main(void) {
  3899. int i = 0;
  3900. return test_func(&i) ? 0 : 5;
  3901. }
  3902. ]])
  3903. ],
  3904. [mhd_cv_cc_attr_access_read="yes"],[mhd_cv_cc_attr_access_read="no"]
  3905. )
  3906. ]
  3907. )
  3908. AS_VAR_IF([mhd_cv_cc_attr_access_read],["yes"],
  3909. [
  3910. AC_DEFINE([HAVE_ATTR_ACCESS_READ],[1],
  3911. [Define to '1' if your compiler supports __attribute__ ((access (read_only,NUM)))]
  3912. )
  3913. ]
  3914. )
  3915. AC_CACHE_CHECK([whether $CC supports __attribute__ ((access (write_only,NUM)))],[mhd_cv_cc_attr_access_write],
  3916. [
  3917. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3918. static __attribute__ ((access (write_only,1))) void
  3919. test_func(int *p) {*p = 0;}
  3920. int main(void) {
  3921. int i = 1;
  3922. test_func(&i);
  3923. return i;
  3924. }
  3925. ]])
  3926. ],
  3927. [mhd_cv_cc_attr_access_write="yes"],[mhd_cv_cc_attr_access_write="no"]
  3928. )
  3929. ]
  3930. )
  3931. AS_VAR_IF([mhd_cv_cc_attr_access_write],["yes"],
  3932. [
  3933. AC_DEFINE([HAVE_ATTR_ACCESS_WRITE],[1],
  3934. [Define to '1' if your compiler supports __attribute__ ((access (write_only,NUM)))]
  3935. )
  3936. ]
  3937. )
  3938. AC_CACHE_CHECK([whether $CC supports __attribute__ ((access (read_write,NUM)))],[mhd_cv_cc_attr_access_read_write],
  3939. [
  3940. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3941. static __attribute__ ((access (read_write,1))) void
  3942. test_func(int *p) {*p = *p - 1;}
  3943. int main(void) {
  3944. int i = 1;
  3945. test_func(&i);
  3946. return i;
  3947. }
  3948. ]])
  3949. ],
  3950. [mhd_cv_cc_attr_access_read_write="yes"],[mhd_cv_cc_attr_access_read_write="no"]
  3951. )
  3952. ]
  3953. )
  3954. AS_VAR_IF([mhd_cv_cc_attr_access_read_write],["yes"],
  3955. [
  3956. AC_DEFINE([HAVE_ATTR_ACCESS_READ_WRITE],[1],
  3957. [Define to '1' if your compiler supports __attribute__ ((access (read_write,NUM)))]
  3958. )
  3959. ]
  3960. )
  3961. AC_CACHE_CHECK([whether $CC supports __attribute__ ((access (read_only,NUM,NUM_SIZE)))],[mhd_cv_cc_attr_access_read_size],
  3962. [
  3963. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3964. static __attribute__ ((access (read_only,2,1))) int
  3965. test_func(unsigned int num, int *arr) {return 2 == arr[num - 1];}
  3966. int main(void) {
  3967. int arr[4] = {5, 4, 3, 2};
  3968. return test_func(4, arr) ? 0 : 5;
  3969. }
  3970. ]])
  3971. ],
  3972. [mhd_cv_cc_attr_access_read_size="yes"],[mhd_cv_cc_attr_access_read_size="no"]
  3973. )
  3974. ]
  3975. )
  3976. AS_VAR_IF([mhd_cv_cc_attr_access_read_size],["yes"],
  3977. [
  3978. AC_DEFINE([HAVE_ATTR_ACCESS_READ_SIZE],[1],
  3979. [Define to '1' if your compiler supports __attribute__ ((access (read_only,NUM,NUM_SIZE)))]
  3980. )
  3981. ]
  3982. )
  3983. AC_CACHE_CHECK([whether $CC supports __attribute__ ((access (write_only,NUM,NUM_SIZE)))],[mhd_cv_cc_attr_access_write_size],
  3984. [
  3985. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  3986. static __attribute__ ((access (write_only,2,1))) void
  3987. test_func(unsigned int num, int *arr) {arr[num-1] = 0;}
  3988. int main(void) {
  3989. int arr[4] = {5, 4, 3, 2};
  3990. test_func(4, arr);
  3991. return arr[3];
  3992. }
  3993. ]])
  3994. ],
  3995. [mhd_cv_cc_attr_access_write_size="yes"],[mhd_cv_cc_attr_access_write_size="no"]
  3996. )
  3997. ]
  3998. )
  3999. AS_VAR_IF([mhd_cv_cc_attr_access_write_size],["yes"],
  4000. [
  4001. AC_DEFINE([HAVE_ATTR_ACCESS_WRITE_SIZE],[1],
  4002. [Define to '1' if your compiler supports __attribute__ ((access (write_only,NUM,NUM_SIZE)))]
  4003. )
  4004. ]
  4005. )
  4006. AC_CACHE_CHECK([whether $CC supports __attribute__ ((access (read_write,NUM,NUM_SIZE)))],[mhd_cv_cc_attr_access_read_write_size],
  4007. [
  4008. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  4009. static __attribute__ ((access (read_write,2,1))) void
  4010. test_func(unsigned int num, int *arr) {arr[num-1] = arr[1] - 4;}
  4011. int main(void) {
  4012. int arr[4] = {5, 4, 3, 2};
  4013. test_func(4, arr);
  4014. return arr[3];
  4015. }
  4016. ]])
  4017. ],
  4018. [mhd_cv_cc_attr_access_read_write_size="yes"],[mhd_cv_cc_attr_access_read_write_size="no"]
  4019. )
  4020. ]
  4021. )
  4022. AS_VAR_IF([mhd_cv_cc_attr_access_read_write_size],["yes"],
  4023. [
  4024. AC_DEFINE([HAVE_ATTR_ACCESS_READ_WRITE_SIZE],[1],
  4025. [Define to '1' if your compiler supports __attribute__ ((access (read_write,NUM,NUM_SIZE)))]
  4026. )
  4027. ]
  4028. )
  4029. AC_CACHE_CHECK([whether $CC supports __attribute__ ((fd_arg_read (NUM)))],[mhd_cv_cc_attr_fd_arg_read],
  4030. [
  4031. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  4032. #ifndef _CRT_NONSTDC_NO_WARNINGS
  4033. #define _CRT_NONSTDC_NO_WARNINGS 1
  4034. #endif
  4035. #ifdef HAVE_SYS_TYPES_H
  4036. #include <sys/types.h>
  4037. #endif
  4038. #include <stdio.h>
  4039. #ifdef HAVE_IO_H
  4040. #include <io.h>
  4041. #endif
  4042. #ifdef HAVE_STDLIB_H
  4043. #include <stdlib.h>
  4044. #endif
  4045. #include <fcntl.h>
  4046. #ifdef HAVE_UNISTD_H
  4047. #include <unistd.h>
  4048. #endif
  4049. static __attribute__ ((fd_arg_read (1))) int
  4050. test_func(int fd)
  4051. {
  4052. int data_in;
  4053. int read_size;
  4054. read_size = (int) read(fd, &data_in, sizeof(data_in));
  4055. if (read_size < (int) sizeof(data_in)) return 4;
  4056. return data_in;
  4057. }
  4058. int main(void) {
  4059. int fd = open("test.txt", O_RDONLY);
  4060. int res = test_func(fd);
  4061. close (fd);
  4062. return res;
  4063. }
  4064. ]])
  4065. ],
  4066. [mhd_cv_cc_attr_fd_arg_read="yes"],[mhd_cv_cc_attr_fd_arg_read="no"]
  4067. )
  4068. ]
  4069. )
  4070. AS_VAR_IF([mhd_cv_cc_attr_fd_arg_read],["yes"],
  4071. [
  4072. AC_DEFINE([HAVE_ATTR_FD_ARG_READ],[1],
  4073. [Define to '1' if your compiler supports __attribute__ ((fd_arg_read (NUM)))]
  4074. )
  4075. ]
  4076. )
  4077. AC_CACHE_CHECK([whether $CC supports __attribute__ ((null_terminated_string_arg (NUM)))],[mhd_cv_cc_attr_null_term_str],
  4078. [
  4079. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  4080. static __attribute__ ((null_terminated_string_arg (1))) int
  4081. test_func(const char *str) {return (0 == str[0]) ? 5 : 0;}
  4082. int main(void) {
  4083. return test_func("test");
  4084. }
  4085. ]])
  4086. ],
  4087. [mhd_cv_cc_attr_null_term_str="yes"],[mhd_cv_cc_attr_null_term_str="no"]
  4088. )
  4089. ]
  4090. )
  4091. AS_VAR_IF([mhd_cv_cc_attr_null_term_str],["yes"],
  4092. [
  4093. AC_DEFINE([HAVE_ATTR_NULL_TERM_STR],[1],
  4094. [Define to '1' if your compiler supports __attribute__ ((null_terminated_string_arg (NUM)))]
  4095. )
  4096. ]
  4097. )
  4098. AC_CACHE_CHECK([whether $CC supports __attribute__((enum_extensibility (closed)))],[mhd_cv_cc_attr_enum_extns_closed],
  4099. [
  4100. SAVE_ac_c_werror_flag="$ac_c_werror_flag"
  4101. ac_c_werror_flag="yes"
  4102. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  4103. enum __attribute__((enum_extensibility (closed))) Test_Enum
  4104. {Val_A = 0, Val_B = 3};
  4105. int main(void)
  4106. {
  4107. enum Test_Enum var = Val_A;
  4108. return (var != Val_B) ? 0 : 3;
  4109. }
  4110. ]])
  4111. ],
  4112. [mhd_cv_cc_attr_enum_extns_closed="yes"],[mhd_cv_cc_attr_enum_extns_closed="no"]
  4113. )
  4114. ac_c_werror_flag="$SAVE_ac_c_werror_flag"
  4115. AS_UNSET([SAVE_ac_c_werror_flag])
  4116. ]
  4117. )
  4118. AS_VAR_IF([mhd_cv_cc_attr_enum_extns_closed],["yes"],
  4119. [
  4120. AC_DEFINE([HAVE_ATTR_ENUM_EXTNS_CLOSED],[1],
  4121. [Define to '1' if your compiler supports __attribute__((enum_extensibility (closed)))]
  4122. )
  4123. ]
  4124. )
  4125. AC_CACHE_CHECK([whether $CC supports __attribute__((flag_enum))],[mhd_cv_cc_attr_flag_enum],
  4126. [
  4127. SAVE_ac_c_werror_flag="$ac_c_werror_flag"
  4128. ac_c_werror_flag="yes"
  4129. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  4130. #ifdef HAVE_ATTR_ENUM_EXTNS_CLOSED
  4131. #define ATTR_EXTNS_CLOSED_IF_SUPPORTED __attribute__((enum_extensibility (closed)))
  4132. #else
  4133. #define ATTR_EXTNS_CLOSED_IF_SUPPORTED /* empty */
  4134. #endif
  4135. enum ATTR_EXTNS_CLOSED_IF_SUPPORTED __attribute__((flag_enum)) Test_Enum
  4136. {Flag_A = 1 << 0, Flag_B = 1 << 1, Flag_C = 1 << 2, Flag_D = 1 << 3};
  4137. int main(void)
  4138. {
  4139. enum Test_Enum var = Flag_A;
  4140. var |= Flag_C;
  4141. var = var | Flag_D | Flag_A;
  4142. return (var != Flag_B) ? 0 : 3;
  4143. }
  4144. ]])
  4145. ],
  4146. [mhd_cv_cc_attr_flag_enum="yes"],[mhd_cv_cc_attr_flag_enum="no"]
  4147. )
  4148. ac_c_werror_flag="$SAVE_ac_c_werror_flag"
  4149. AS_UNSET([SAVE_ac_c_werror_flag])
  4150. ]
  4151. )
  4152. AS_VAR_IF([mhd_cv_cc_attr_flag_enum],["yes"],
  4153. [
  4154. AC_DEFINE([HAVE_ATTR_FLAG_ENUM],[1],
  4155. [Define to '1' if your compiler supports __attribute__((flag_enum))]
  4156. )
  4157. ]
  4158. )
  4159. AC_CACHE_CHECK([[whether $CC supports array[static N] with fixed N as a function parameter]],[mhd_cv_cc_func_param_arr_static_fixed],
  4160. [
  4161. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  4162. static int
  4163. test_func(int arr[static 4]) { return arr[2] - 4; }
  4164. int main(void) {
  4165. int arr[4] = {5, 4, 3, 2};
  4166. return test_func(arr);
  4167. }
  4168. ]])
  4169. ],
  4170. [mhd_cv_cc_func_param_arr_static_fixed="yes"],[mhd_cv_cc_func_param_arr_static_fixed="no"]
  4171. )
  4172. ]
  4173. )
  4174. AS_VAR_IF([mhd_cv_cc_func_param_arr_static_fixed],["yes"],
  4175. [
  4176. AC_DEFINE([HAVE_FUNC_PARAM_ARR_STATIC_FIXED],[1],
  4177. [[Define to '1' if your compiler supports 'array[static N]' with fixed N as function parameter]]
  4178. )
  4179. ]
  4180. )
  4181. AC_CACHE_CHECK([[whether $CC supports array[static N] with variable N as a function parameter]],[mhd_cv_cc_func_param_arr_static_var],
  4182. [
  4183. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  4184. static int
  4185. test_func(int num, int arr[static num]) { return arr[num-2] - 4; }
  4186. int main(void) {
  4187. int arr[4] = {5, 4, 3, 2};
  4188. return test_func(4, arr);
  4189. }
  4190. ]])
  4191. ],
  4192. [mhd_cv_cc_func_param_arr_static_var="yes"],[mhd_cv_cc_func_param_arr_static_var="no"]
  4193. )
  4194. ]
  4195. )
  4196. AS_VAR_IF([mhd_cv_cc_func_param_arr_static_var],["yes"],
  4197. [
  4198. AC_DEFINE([HAVE_FUNC_PARAM_ARR_STATIC_VAR],[1],
  4199. [[Define to '1' if your compiler supports 'array[static N]' with variable N as a function parameter]]
  4200. )
  4201. ]
  4202. )
  4203. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  4204. # libcurl (required for testing)
  4205. AC_ARG_ENABLE([curl],
  4206. [AS_HELP_STRING([--disable-curl],[disable cURL based testcases])],
  4207. [enable_curl=${enableval}])
  4208. curl=0
  4209. AS_IF([test "$enable_curl" != "no"],
  4210. [LIBCURL_CHECK_CONFIG([yes],[7.16.4],[enable_curl=yes],
  4211. [
  4212. AS_IF([test "x$enable_curl" = "xyes"],
  4213. [AC_MSG_WARN([[cURL-based tests cannot be enabled because libcurl is missing]])])
  4214. enable_curl=no
  4215. ])
  4216. ])
  4217. AM_CONDITIONAL([RUN_LIBCURL_TESTS], [test "x$enable_curl" = "xyes"])
  4218. AS_IF([test "x$enable_curl" = "xyes"],
  4219. [MSG_CURL="yes"],
  4220. [MSG_CURL="no, many unit tests will not run"]
  4221. )
  4222. MHD_CHECK_FUNC([magic_open],
  4223. [[
  4224. #include <magic.h>
  4225. ]],
  4226. [[
  4227. char var_data[256];
  4228. const char *var_mime;
  4229. magic_t var_magic = magic_open (MAGIC_MIME_TYPE);
  4230. (void)magic_load (var_magic, "filename");
  4231. var_data[0] = 0;
  4232. var_mime = magic_buffer (var_magic, var_data, 1);
  4233. i][f (! var_mime)
  4234. return 1;
  4235. magic_close (var_magic);
  4236. ]],
  4237. [AC_DEFINE([MHD_HAVE_LIBMAGIC], [1], [Define to 1 if you have suitable libmagic.])],
  4238. [],
  4239. [-lmagic]
  4240. )
  4241. AM_CONDITIONAL([MHD_HAVE_LIBMAGIC], [[test "x$mhd_cv_func_magic_open" = "xyes"]])
  4242. # large file support (> 4 GB)
  4243. AC_SYS_LARGEFILE
  4244. AC_FUNC_FSEEKO
  4245. MHD_CHECK_FUNC([lseek64],
  4246. [[
  4247. #if defined(HAVE_SYS_TYPES_H)
  4248. # include <sys/types.h>
  4249. #endif
  4250. #include <unistd.h>
  4251. ]],
  4252. [[
  4253. i][f (((off64_t) -1) == lseek64(0, (off64_t) 0, SEEK_SET))
  4254. return 3;
  4255. ]]
  4256. )
  4257. MHD_CHECK_FUNC([pread64],
  4258. [[
  4259. #if defined(HAVE_SYS_TYPES_H)
  4260. # include <sys/types.h>
  4261. #endif
  4262. #include <unistd.h>
  4263. ]],
  4264. [[
  4265. char buf[5];
  4266. i][f (0 > pread64(0, (void *) buf, 1, (off64_t) 0))
  4267. return 3;
  4268. ]]
  4269. )
  4270. MHD_CHECK_FUNC([pread],
  4271. [[
  4272. #if defined(HAVE_SYS_TYPES_H)
  4273. # include <sys/types.h>
  4274. #endif
  4275. #include <unistd.h>
  4276. ]],
  4277. [[
  4278. char buf[5];
  4279. i][f (0 > pread(0, (void *) buf, 1, 0))
  4280. return 3;
  4281. ]]
  4282. )
  4283. # check for various sendfile functions
  4284. AC_ARG_ENABLE([sendfile],
  4285. [AS_HELP_STRING([--disable-sendfile],
  4286. [disable usage of sendfile() for HTTP connections [auto]])],
  4287. [],
  4288. [enable_sendfile="auto"])
  4289. AS_CASE([$enable_sendfile],
  4290. [[auto | yes]],[[found_sendfile="no"]],
  4291. [[no]],[[found_sendfile="disabled"]],
  4292. [AC_MSG_ERROR([[unknown value specified: --enable-sendfile=$enable_sendfile]])]
  4293. )
  4294. AS_VAR_IF([[found_sendfile]], [["no"]],
  4295. [
  4296. AC_MSG_CHECKING([[for Linux-style sendfile(2)]])
  4297. AC_LINK_IFELSE(
  4298. [AC_LANG_PROGRAM(
  4299. [[
  4300. #include <sys/sendfile.h>
  4301. static void empty_func(void)
  4302. {
  4303. /* Check for declaration */
  4304. #ifndef sendfile
  4305. (void)sendfile;
  4306. #endif
  4307. }
  4308. ]],
  4309. [[
  4310. int fd1=0, fd2=2;
  4311. off_t o = 0;
  4312. size_t s = 5;
  4313. ssize_t r;
  4314. r = sendfile (fd1, fd2, &o, s);
  4315. if (r)
  4316. empty_func();
  4317. ]]
  4318. )
  4319. ],
  4320. [
  4321. AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).])
  4322. found_sendfile="yes, Linux-style"
  4323. AC_MSG_RESULT([[yes]])
  4324. MHD_CHECK_FUNC([sendfile64],
  4325. [[
  4326. #include <sys/sendfile.h>
  4327. ]],
  4328. [[
  4329. off64_t f_offset = (off64_t) 0;
  4330. if (0 > sendfile64 (0, 1, &f_offset, 1))
  4331. return 3;
  4332. ]]
  4333. )
  4334. ],
  4335. [AC_MSG_RESULT([[no]])
  4336. ]
  4337. )
  4338. ]
  4339. )
  4340. AS_VAR_IF([[found_sendfile]], [["no"]],
  4341. [
  4342. AC_MSG_CHECKING([[for FreeBSD-style sendfile(2)]])
  4343. AC_LINK_IFELSE(
  4344. [AC_LANG_PROGRAM(
  4345. [[
  4346. #ifdef HAVE_SYS_TYPES_H
  4347. #include <sys/types.h>
  4348. #endif
  4349. #ifdef HAVE_UNISTD_H
  4350. #include <unistd.h>
  4351. #endif
  4352. #ifdef HAVE_SYS_SOCKET_H
  4353. #include <sys/socket.h>
  4354. #endif
  4355. #include <sys/uio.h>
  4356. static void empty_func(void)
  4357. {
  4358. /* Check for declaration */
  4359. #ifndef sendfile
  4360. (void)sendfile;
  4361. #endif
  4362. }
  4363. ]],
  4364. [[
  4365. int fd1=0, fd2=1;
  4366. off_t o = 0;
  4367. size_t s = 5;
  4368. off_t r1;
  4369. int r2;
  4370. r2 = sendfile (fd1, fd2, o, s, (struct sf_hdtr *)0, &r1, 0);
  4371. if (r2)
  4372. empty_func();
  4373. ]]
  4374. )
  4375. ],
  4376. [
  4377. AC_DEFINE([HAVE_FREEBSD_SENDFILE], [1], [Define to 1 if you have FreeBSD-style sendfile(2).])
  4378. found_sendfile="yes, FreeBSD-style"
  4379. AC_MSG_RESULT([[yes]])
  4380. ],
  4381. [AC_MSG_RESULT([[no]])
  4382. ]
  4383. )
  4384. ]
  4385. )
  4386. AS_VAR_IF([[found_sendfile]], [["no"]],
  4387. [
  4388. AC_MSG_CHECKING([[for Darwin-style sendfile(2)]])
  4389. AC_LINK_IFELSE(
  4390. [AC_LANG_PROGRAM(
  4391. [[
  4392. #ifdef HAVE_SYS_TYPES_H
  4393. #include <sys/types.h>
  4394. #endif
  4395. #ifdef HAVE_UNISTD_H
  4396. #include <unistd.h>
  4397. #endif
  4398. #ifdef HAVE_SYS_SOCKET_H
  4399. #include <sys/socket.h>
  4400. #endif
  4401. #include <sys/uio.h>
  4402. static void empty_func(void)
  4403. {
  4404. /* Check for declaration */
  4405. #ifndef sendfile
  4406. (void)sendfile;
  4407. #endif
  4408. }
  4409. ]],
  4410. [[
  4411. int fd=0, s=1;
  4412. off_t o = 0;
  4413. off_t l = 5;
  4414. int r;
  4415. r = sendfile (fd, s, o, &l, (struct sf_hdtr *)0, 0);
  4416. if (r)
  4417. empty_func();
  4418. ]]
  4419. )
  4420. ],
  4421. [
  4422. AC_DEFINE([HAVE_DARWIN_SENDFILE], [1], [Define to 1 if you have Darwin-style sendfile(2).])
  4423. found_sendfile="yes, Darwin-style"
  4424. AC_MSG_RESULT([[yes]])
  4425. ],
  4426. [AC_MSG_RESULT([[no]])
  4427. ]
  4428. )
  4429. ]
  4430. )
  4431. AS_VAR_IF([[found_sendfile]], [["no"]],
  4432. [
  4433. AC_MSG_CHECKING([[for old Solaris-style sendfile(3)]])
  4434. SAVE_LIBS="$LIBS"
  4435. LIBS="-lsendfile $LIBS"
  4436. AC_LINK_IFELSE(
  4437. [AC_LANG_PROGRAM(
  4438. [[
  4439. #ifdef HAVE_SYS_TYPES_H
  4440. #include <sys/types.h>
  4441. #endif
  4442. #ifdef HAVE_UNISTD_H
  4443. #include <unistd.h>
  4444. #endif
  4445. #ifdef HAVE_SYS_SOCKET_H
  4446. #include <sys/socket.h>
  4447. #endif
  4448. #include <sys/sendfile.h>
  4449. static void empty_func(void)
  4450. {
  4451. /* Check for declaration */
  4452. #ifndef sendfile
  4453. (void)sendfile;
  4454. #endif
  4455. }
  4456. ]],
  4457. [[
  4458. int fd1=0, fd2=1;
  4459. off_t o = 0;
  4460. size_t l = 5;
  4461. ssize_t r;
  4462. r = sendfile (fd1, fd2, &o, l);
  4463. if (r)
  4464. empty_func();
  4465. ]]
  4466. )
  4467. ],
  4468. [
  4469. # Solaris uses the same format as GNU/Linux. Old versions need libsendfile.
  4470. AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).])
  4471. found_sendfile="yes, Solaris-style"
  4472. MHD_LIBDEPS="-lsendfile $MHD_LIBDEPS"
  4473. MHD_LIBDEPS_PKGCFG="-lsendfile $MHD_LIBDEPS_PKGCFG"
  4474. AC_MSG_RESULT([[yes]])
  4475. MHD_CHECK_FUNC([sendfile64],
  4476. [[
  4477. #ifdef HAVE_SYS_TYPES_H
  4478. #include <sys/types.h>
  4479. #endif
  4480. #ifdef HAVE_UNISTD_H
  4481. #include <unistd.h>
  4482. #endif
  4483. #ifdef HAVE_SYS_SOCKET_H
  4484. #include <sys/socket.h>
  4485. #endif
  4486. #include <sys/sendfile.h>
  4487. ]],
  4488. [[
  4489. off64_t f_offset = (off64_t) 0;
  4490. #ifndef sendfile64
  4491. (void)sendfile64;
  4492. #endif
  4493. if (0 > sendfile64 (0, 1, &f_offset, 1))
  4494. return 3;
  4495. ]]
  4496. )
  4497. ],
  4498. [AC_MSG_RESULT([[no]])
  4499. ]
  4500. )
  4501. LIBS="$SAVE_LIBS"
  4502. ]
  4503. )
  4504. AS_IF([[test "x$found_sendfile" = "xno" && test "x$enable_sendfile" = "xyes"]],
  4505. [AC_MSG_ERROR([[sendfile() usage was requested by configure parameter, but no usable sendfile() function is detected]])]
  4506. )
  4507. # optional: disable log and HTTP automatic messages
  4508. AC_ARG_ENABLE([messages],
  4509. [
  4510. AS_HELP_STRING([--disable-messages],
  4511. [disable log messages and text bodies for ]
  4512. [automatic HTTP responses (to reduce the binary size)]
  4513. )
  4514. ],
  4515. [],[enable_messages="yes"]
  4516. )
  4517. AC_MSG_CHECKING([[whether to support internal logging functionality and build messages for log]])
  4518. AC_ARG_ENABLE([log-messages],
  4519. [
  4520. AS_HELP_STRING([--disable-log-messages],
  4521. [disable logger functionality and exclude log mesages from binary]
  4522. )
  4523. ],
  4524. [],[enable_log_messages="$enable_messages"]
  4525. )
  4526. AS_VAR_IF([enable_log_messages],["yes"],
  4527. [AC_DEFINE([HAVE_LOG_FUNCTIONALITY],[1],[Define to '1' to enable internal logging and log messages.])],
  4528. [enable_log_messages="no"]
  4529. )
  4530. AC_MSG_RESULT([[$enable_log_messages]])
  4531. AM_CONDITIONAL([HAVE_LOG_FUNCTIONALITY], [test "x$enable_log_messages" != "xno"])
  4532. AC_MSG_CHECKING([[whether to build text bodies for automatic HTTP response messages]])
  4533. AC_ARG_ENABLE([http-messages],
  4534. [
  4535. AS_HELP_STRING([--disable-http-messages],
  4536. [use empty bodies for automatic HTTP responses (less verbose for clients)]
  4537. )
  4538. ],
  4539. [],[enable_http_messages="$enable_messages"]
  4540. )
  4541. AS_VAR_IF([enable_http_messages],["yes"],
  4542. [AC_DEFINE([HAVE_HTTP_AUTO_MESSAGES_BODIES],[1],[Define to '1' to enable verbose text bodies for automatic HTTP replies.])],
  4543. [enable_http_messages="no"]
  4544. )
  4545. AC_MSG_RESULT([[$enable_http_messages]])
  4546. AM_CONDITIONAL([HAVE_HTTP_AUTO_MESSAGES_BODIES], [test "x$enable_http_messages" != "xno"])
  4547. # optional: have postprocessor?
  4548. AC_MSG_CHECKING([[whether to enable postprocessor]])
  4549. AC_ARG_ENABLE([postprocessor],
  4550. [AS_HELP_STRING([--disable-postprocessor],
  4551. [disable MHD PostProcessor functionality])],
  4552. [enable_postprocessor=${enableval}],
  4553. [enable_postprocessor=yes])
  4554. AS_IF([[test "x$enable_postprocessor" != "xno"]],
  4555. [ enable_postprocessor=yes
  4556. AC_DEFINE([HAVE_POSTPROCESSOR],[1],[Define to 1 if libmicrohttpd is compiled with postprocessor support.]) ])
  4557. AM_CONDITIONAL([HAVE_POSTPROCESSOR], [test "x$enable_postprocessor" != "xno"])
  4558. AC_MSG_RESULT([[$enable_postprocessor]])
  4559. have_gnutls=no
  4560. have_gnutls_sni=no
  4561. have_gcrypt=no
  4562. AS_UNSET([GNUTLS_CPPFLAGS])
  4563. AS_UNSET([GNUTLS_LDFLAGS])
  4564. # optional: HTTPS support. Enabled by default
  4565. AC_ARG_ENABLE([https],
  4566. [AS_HELP_STRING([--enable-https],
  4567. [enable HTTPS support (yes, no, auto)[auto]])],
  4568. [enable_https=${enableval}])
  4569. AS_IF([test "x$enable_https" != "xno"],[
  4570. #
  4571. # Next block is large unindented block
  4572. #
  4573. # gnutls
  4574. have_gnutls_pkgcfg=no
  4575. AC_MSG_CHECKING([[how to find GnuTLS library]])
  4576. AC_ARG_WITH([[gnutls]],
  4577. [AS_HELP_STRING([[--with-gnutls[=PFX]]],[use GnuTLS for HTTPS support, optional PFX overrides pkg-config data for GnuTLS headers (PFX/include) and libs (PFX/lib)])],
  4578. [
  4579. AS_CASE([$with_gnutls],
  4580. [no],[
  4581. AC_MSG_RESULT([[GnuTLS disabled]])
  4582. AS_UNSET([GNUTLS_CPPFLAGS])
  4583. AS_UNSET([GNUTLS_CFLAGS])
  4584. AS_UNSET([GNUTLS_LDFLAGS])
  4585. AS_UNSET([GNUTLS_LIBS])
  4586. ],
  4587. [yes],[
  4588. AC_MSG_RESULT([[automatically, forced]])
  4589. ],
  4590. [
  4591. AC_MSG_RESULT([[-I$with_gnutls/include -L$with_gnutls/lib -lgnutls]])
  4592. SAVE_LIBS="$LIBS"
  4593. LDFLAGS="${LDFLAGS_ac} -L$with_gnutls/lib ${user_LDFLAGS}"
  4594. CPPFLAGS="${CPPFLAGS_ac} -I$with_gnutls/include ${user_CPPFLAGS}"
  4595. have_gnutls_pkgcfg=no
  4596. MHD_CHECK_FUNC([gnutls_check_version],[[#include <gnutls/gnutls.h>]],
  4597. [
  4598. if(!gnutls_check_version("2.0.0"))
  4599. return 3;
  4600. ],
  4601. [
  4602. GNUTLS_CPPFLAGS="-I$with_gnutls/include"
  4603. GNUTLS_LDFLAGS="-L$with_gnutls/lib"
  4604. GNUTLS_LIBS="-lgnutls"
  4605. have_gnutls=yes
  4606. ],
  4607. [AC_MSG_ERROR([can't find usable libgnutls at specified prefix $with_gnutls])],
  4608. [-lgnutls]
  4609. )
  4610. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  4611. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  4612. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  4613. LIBS="$SAVE_LIBS"
  4614. ])
  4615. ],
  4616. [AC_MSG_RESULT([[automatically]])
  4617. ])
  4618. AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"],
  4619. [
  4620. PKG_CHECK_MODULES(GNUTLS, [[gnutls]],
  4621. [
  4622. have_gnutls_pkgcfg='yes'
  4623. SAVE_LIBS="$LIBS"
  4624. CFLAGS="${CFLAGS_ac} $GNUTLS_CFLAGS ${user_CFLAGS}"
  4625. LIBS="$GNUTLS_LIBS $LIBS"
  4626. AC_MSG_CHECKING([[whether GnuTLS is usable]])
  4627. AC_LINK_IFELSE([
  4628. AC_LANG_PROGRAM([[
  4629. #include <gnutls/gnutls.h>
  4630. ]], [[
  4631. gnutls_session_t session;
  4632. gnutls_priority_t priorities;
  4633. gnutls_global_init();
  4634. gnutls_priority_init(&priorities, "NORMAL", NULL);
  4635. gnutls_init(&session, GNUTLS_SERVER);
  4636. gnutls_priority_set(session, priorities);
  4637. ]])],
  4638. [
  4639. AC_MSG_RESULT([[yes]])
  4640. have_gnutls=yes
  4641. # GNUTLS_CFLAGS is actually CPPFLAGS
  4642. GNUTLS_CPPFLAGS="$GNUTLS_CFLAGS"
  4643. # GNUTLS_LDFLAGS is a combination of LDFLAGS and LIBS
  4644. GNUTLS_LDFLAGS="$GNUTLS_LIBS"
  4645. ],
  4646. [
  4647. AC_MSG_RESULT([[no]])
  4648. have_gnutls=no
  4649. ])
  4650. AS_IF([test "x$have_gnutls" != "xyes"],
  4651. [
  4652. AC_MSG_WARN([pkg-config reports that GnuTLS is present, but GnuTLS can't be used])
  4653. AS_UNSET([GNUTLS_CPPFLAGS])
  4654. AS_UNSET([GNUTLS_CFLAGS])
  4655. AS_UNSET([GNUTLS_LDFLAGS])
  4656. AS_UNSET([GNUTLS_LIBS])
  4657. ]
  4658. )
  4659. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  4660. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  4661. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  4662. LIBS="$SAVE_LIBS"
  4663. ],
  4664. [
  4665. # check for GnuTLS at default paths
  4666. have_gnutls_pkgcfg='no'
  4667. AC_CHECK_HEADERS([gnutls/gnutls.h],
  4668. [AC_CHECK_LIB([gnutls], [gnutls_priority_set],
  4669. [
  4670. GNUTLS_LIBS="-lgnutls"
  4671. have_gnutls=yes
  4672. ])], [], [AC_INCLUDES_DEFAULT])
  4673. ])
  4674. ])
  4675. have_gcrypt='unknown'
  4676. AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"],
  4677. [
  4678. AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no])
  4679. AS_IF([[test "x$have_gcrypt" = "xyes"]],
  4680. [
  4681. SAVE_LIBS="$LIBS"
  4682. CFLAGS="${CFLAGS_ac} $LIBGCRYPT_CFLAGS ${user_CFLAGS}"
  4683. # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both
  4684. CPPFLAGS="${CPPFLAGS_ac} $LIBGCRYPT_CFLAGS ${user_CPPFLAGS}"
  4685. AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT])
  4686. # Check for GnuTLS with gcrypt flags
  4687. LDFLAGS="${LDFLAGS_ac} ${LIBGCRYPT_LIBS} ${user_LDFLAGS}"
  4688. # A bit of hack: unset cache variable to force recheck
  4689. AS_UNSET([ac_cv_header_gnutls_gnutls_h])
  4690. AC_CHECK_HEADERS([gnutls/gnutls.h],
  4691. [AS_UNSET([ac_cv_lib_gnutls_gnutls_priority_set]) # A bit of hack: unset cache variable to force recheck
  4692. AC_CHECK_LIB([gnutls], [gnutls_priority_set],
  4693. [
  4694. GNUTLS_CPPFLAGS="$LIBGCRYPT_CFLAGS"
  4695. GNUTLS_CFLAGS="$LIBGCRYPT_CFLAGS"
  4696. GNUTLS_LDFLAGS="$LIBGCRYPT_LIBS"
  4697. GNUTLS_LIBS="-lgnutls"
  4698. have_gnutls=yes
  4699. ])], [], [AC_INCLUDES_DEFAULT])
  4700. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  4701. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  4702. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  4703. LIBS="$SAVE_LIBS"
  4704. ]
  4705. )
  4706. ]
  4707. )
  4708. AS_IF([test "x$have_gnutls" != "xyes" && test "x$with_gnutls" = "xyes"],
  4709. [AC_MSG_ERROR([[can't find usable libgnutls]])])
  4710. AS_IF([test "x$have_gnutls" = "xyes"],
  4711. [
  4712. SAVE_LIBS="$LIBS"
  4713. CPPFLAGS="${CPPFLAGS_ac} ${GNUTLS_CPPFLAGS} ${user_CPPFLAGS}"
  4714. CFLAGS="${CFLAGS_ac} ${GNUTLS_CFLAGS} ${user_CFLAGS}"
  4715. LDFLAGS="${LDFLAGS_ac} ${GNUTLS_LDFLAGS} ${user_LDFLAGS}"
  4716. LIBS="$GNUTLS_LIBS $LIBS"
  4717. AC_MSG_CHECKING([[for gnutls_privkey_import_x509_raw()]])
  4718. AC_LINK_IFELSE([
  4719. AC_LANG_PROGRAM([[
  4720. #include <gnutls/gnutls.h>
  4721. #include <gnutls/abstract.h>
  4722. ]], [[
  4723. gnutls_datum_t data;
  4724. gnutls_privkey_t key = 0;
  4725. #ifndef gnutls_load_file
  4726. (void)gnutls_load_file; /* Check for declaration. */
  4727. #endif
  4728. #ifndef gnutls_privkey_import_x509_raw
  4729. (void)gnutls_privkey_import_x509_raw; /* Check for declaration. */
  4730. #endif
  4731. gnutls_load_file("key.pem", &data);
  4732. gnutls_privkey_import_x509_raw(key, &data, GNUTLS_X509_FMT_PEM, NULL, 0);
  4733. gnutls_free(data.data);
  4734. ]])], [[have_gnutls_sni=yes]], [[have_gnutls_sni=no]])
  4735. AC_MSG_RESULT([[$have_gnutls_sni]])
  4736. AC_CACHE_CHECK([[whether GnuTLS require libgcrypt initialisation]], [mhd_cv_gcrypt_required],
  4737. [
  4738. AC_COMPILE_IFELSE(
  4739. [
  4740. AC_LANG_PROGRAM(
  4741. [
  4742. #include <gnutls/gnutls.h>
  4743. ],
  4744. [
  4745. #if !defined(GNUTLS_VERSION_NUMBER) || GNUTLS_VERSION_NUMBER+0 <= 0x020c14
  4746. #error Old versions of GnuTLS require libgcript initialisation
  4747. choke me now
  4748. #endif
  4749. ]
  4750. )
  4751. ],
  4752. [[mhd_cv_gcrypt_required='no']], [[mhd_cv_gcrypt_required='yes']]
  4753. )
  4754. ]
  4755. )
  4756. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  4757. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  4758. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  4759. LIBS="$SAVE_LIBS"
  4760. ],
  4761. [
  4762. AS_UNSET([GNUTLS_CPPFLAGS])
  4763. AS_UNSET([GNUTLS_LDFLAGS])
  4764. ]
  4765. )
  4766. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" = "xunknown"]],
  4767. [
  4768. AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no])
  4769. AS_IF([[test "x$have_gcrypt" = "xyes"]],
  4770. [
  4771. CFLAGS="${CFLAGS_ac} ${LIBGCRYPT_CFLAGS} ${user_CFLAGS}"
  4772. # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both
  4773. CPPFLAGS="${CPPFLAGS_ac} ${LIBGCRYPT_CFLAGS} ${user_CPPFLAGS}"
  4774. AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT])
  4775. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  4776. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  4777. ]
  4778. )
  4779. ]
  4780. )
  4781. AS_UNSET([[crypt_missing]])
  4782. AS_IF([[test "x$have_gnutls" = "xyes"]],
  4783. [
  4784. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" != "xyes"]],
  4785. [
  4786. crypt_missing="required libgcrypt"
  4787. AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])])
  4788. enable_https=no
  4789. MSG_HTTPS="no (lacking $crypt_missing)"
  4790. AS_UNSET([LIBGCRYPT_CFLAGS])
  4791. AS_UNSET([LIBGCRYPT_LIBS])
  4792. AS_UNSET([GNUTLS_CPPFLAGS])
  4793. AS_UNSET([GNUTLS_CFLAGS])
  4794. AS_UNSET([GNUTLS_LDFLAGS])
  4795. AS_UNSET([GNUTLS_LIBS])
  4796. ],
  4797. [
  4798. AC_DEFINE([[HTTPS_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTPS support.])
  4799. enable_https=yes
  4800. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
  4801. [
  4802. MSG_HTTPS="yes (using libgnutls and libgcrypt)"
  4803. MHD_TLS_LIB_CPPFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CPPFLAGS"
  4804. MHD_TLS_LIB_CFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CFLAGS"
  4805. MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS"
  4806. MHD_TLS_LIBDEPS="$GNUTLS_LIBS $LIBGCRYPT_LIBS"
  4807. AC_DEFINE([[MHD_HTTPS_REQUIRE_GCRYPT]], [[1]], [Define to `1' if HTTPS require initialisation of libgcrypt])
  4808. ],
  4809. [
  4810. MSG_HTTPS="yes (using libgnutls)"
  4811. AS_UNSET([LIBGCRYPT_CFLAGS])
  4812. AS_UNSET([LIBGCRYPT_LIBS])
  4813. MHD_TLS_LIB_CPPFLAGS="$GNUTLS_CPPFLAGS"
  4814. MHD_TLS_LIB_CFLAGS="$GNUTLS_CFLAGS"
  4815. MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS"
  4816. MHD_TLS_LIBDEPS="$GNUTLS_LIBS"
  4817. ]
  4818. )
  4819. AS_IF([[ test "x$have_gnutls_pkgcfg" = "xyes" ]],
  4820. [ # remove GnuTLS from private libs in .pc file as it defined in Requires.private
  4821. MHD_REQ_PRIVATE='gnutls'
  4822. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
  4823. [[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]]
  4824. )
  4825. ],
  4826. [
  4827. MHD_REQ_PRIVATE=''
  4828. AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
  4829. [[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]]
  4830. )
  4831. MHD_LIBDEPS_PKGCFG="$GNUTLS_LIBS $MHD_LIBDEPS_PKGCFG"
  4832. ])
  4833. ]
  4834. )
  4835. ],
  4836. [
  4837. crypt_missing="libgnutls"
  4838. AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])])
  4839. enable_https=no
  4840. MSG_HTTPS="no (lacking $crypt_missing)"
  4841. AS_UNSET([LIBGCRYPT_CFLAGS])
  4842. AS_UNSET([LIBGCRYPT_LIBS])
  4843. AS_UNSET([GNUTLS_CPPFLAGS])
  4844. AS_UNSET([GNUTLS_CFLAGS])
  4845. AS_UNSET([GNUTLS_LDFLAGS])
  4846. AS_UNSET([GNUTLS_LIBS])
  4847. ]
  4848. )
  4849. ],[
  4850. MSG_HTTPS="no (disabled)"
  4851. ])
  4852. #
  4853. # End of large unindented block
  4854. #
  4855. AC_MSG_CHECKING(whether to support HTTPS)
  4856. AC_MSG_RESULT([$MSG_HTTPS])
  4857. AM_CONDITIONAL([HAVE_GNUTLS], [[test "x$have_gnutls" = "xyes"]])
  4858. AM_CONDITIONAL([HAVE_GNUTLS_SNI], [[test "x$have_gnutls_sni" = "xyes"]])
  4859. AM_CONDITIONAL([ENABLE_HTTPS], [test "x$enable_https" = "xyes"])
  4860. AM_CONDITIONAL([HTTPS_REQUIRE_GCRYPT], [[test "x$enable_https" = "xyes" && test "x$mhd_cv_gcrypt_required" = "xyes"]])
  4861. AC_SUBST([GNUTLS_CPPFLAGS])
  4862. AC_SUBST([GNUTLS_CFLAGS])
  4863. AC_SUBST([GNUTLS_LDFLAGS])
  4864. AC_SUBST([GNUTLS_LIBS])
  4865. AS_VAR_IF([have_gnutls], ["yes"],
  4866. [
  4867. AC_CACHE_CHECK([for GnuTLS quirks], [mhd_cv_gnutls_mthread_broken],
  4868. [
  4869. mhd_cv_gnutls_mthread_broken="no"
  4870. AS_IF([test -r /etc/redhat-release],
  4871. [
  4872. AS_IF([$FGREP ' release 6.' /etc/redhat-release >/dev/null || $FGREP '(Santiago)' /etc/redhat-release >/dev/null],
  4873. [mhd_cv_gnutls_mthread_broken="found"],
  4874. )
  4875. ]
  4876. )
  4877. AS_VAR_IF([mhd_cv_gnutls_mthread_broken], ["no"],
  4878. [
  4879. AS_IF([command -v rpm >/dev/null],
  4880. [
  4881. AS_IF([test "r`rpm -E '%{rhel}' 2>/dev/null`" = "r6"],
  4882. [mhd_cv_gnutls_mthread_broken="found"],
  4883. )
  4884. ]
  4885. )
  4886. ]
  4887. )
  4888. ]
  4889. )
  4890. AC_CACHE_CHECK([for gnutls-cli binary], [mhd_cv_gnutls_cli],
  4891. [
  4892. mhd_cv_gnutls_cli="no"
  4893. AS_IF([command -v gnutls-cli >/dev/null 2>&1],
  4894. [AS_IF([AC_RUN_LOG([gnutls-cli --version >&2])], [mhd_cv_gnutls_cli="yes"])]
  4895. )
  4896. ]
  4897. )
  4898. ]
  4899. )
  4900. AM_CONDITIONAL([HAVE_GNUTLS_MTHREAD_BROKEN], [[test "x${mhd_cv_gnutls_mthread_broken}" = "xfound"]])
  4901. AM_CONDITIONAL([USE_UPGRADE_TLS_TESTS], [[test "x${mhd_cv_gnutls_mthread_broken}" = "xno" || test "x${mhd_cv_gnutls_cli}" = "xyes"]])
  4902. # optional: HTTP Basic Auth support. Enabled by default
  4903. AC_MSG_CHECKING([[whether to support HTTP Basic authentication]])
  4904. AC_ARG_ENABLE([bauth],
  4905. [AS_HELP_STRING([--disable-bauth],[disable HTTP Basic Authentication support])],
  4906. [enable_bauth=${enableval}],
  4907. [enable_bauth=yes])
  4908. AS_IF([[test "x$enable_bauth" != "xno"]],
  4909. [ enable_bauth=yes
  4910. AC_DEFINE([BAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with Basic Auth support.]) ])
  4911. AM_CONDITIONAL([ENABLE_BAUTH], [test "x$enable_bauth" != "xno"])
  4912. AC_MSG_RESULT([[$enable_bauth]])
  4913. # optional: HTTP Digest Auth support. Enabled by default
  4914. AC_MSG_CHECKING([[whether to support HTTP Digest authentication]])
  4915. AC_ARG_ENABLE([dauth],
  4916. [AS_HELP_STRING([--disable-dauth], [disable HTTP Digest Authentication support])],
  4917. [enable_dauth="${enableval}"],
  4918. [enable_dauth="yes"])
  4919. AS_IF([[test "x$enable_dauth" != "xno"]],
  4920. [ enable_dauth=yes
  4921. AC_DEFINE([DAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with Digest Auth support.]) ])
  4922. AM_CONDITIONAL([ENABLE_DAUTH], [test "x$enable_dauth" != "xno"])
  4923. AC_MSG_RESULT([[$enable_dauth]])
  4924. AS_VAR_IF([enable_dauth], ["yes"],
  4925. [
  4926. AC_MSG_CHECKING([[for Digest Authentication default nonce timeout value]])
  4927. AC_ARG_ENABLE([dauth-def-timeout],
  4928. [AS_HELP_STRING([--enable-dauth-def-timeout=NNN],
  4929. [set default Digest Auth nonce validity time to NNN seconds])],
  4930. [enable_dauth_def_timeout="${enableval}"],
  4931. [enable_dauth_def_timeout=""]
  4932. )
  4933. AS_VAR_IF([enable_dauth_def_timeout], ["no"],
  4934. [
  4935. AC_MSG_WARN([Default Diget Auth nonce validity time cannot be disabled, --disable-dauth-def-timeout parameter is ignored])
  4936. enable_dauth_def_timeout=""
  4937. ]
  4938. )
  4939. AS_IF([test -z "${enable_dauth_def_timeout}"],
  4940. [
  4941. enable_dauth_def_timeout="90"
  4942. enable_dauth_def_timeout_MSG="${enable_dauth_def_timeout} seconds (default)"
  4943. ],
  4944. [
  4945. AS_IF([[test "x${enable_dauth_def_timeout}" = "x`echo ${enable_dauth_def_timeout}|${SED-sed} 's/[^0-9]//g'`" && \
  4946. test "${enable_dauth_def_timeout}" -ge "0" 2>/dev/null ]],[:],
  4947. [AC_MSG_ERROR([Invalid parameter --enable-dauth-def-timeout=${enable_dauth_def_timeout}. Timeout value must be a positive integer.])
  4948. ]
  4949. )
  4950. AC_COMPILE_IFELSE(
  4951. [
  4952. AC_LANG_PROGRAM([],
  4953. [[
  4954. static int arr[((int) 2) - 4 * (int)(${enable_dauth_def_timeout} != ((unsigned int)${enable_dauth_def_timeout}))];
  4955. (void) arr;
  4956. ]]
  4957. )
  4958. ],
  4959. [],
  4960. [AC_MSG_ERROR([The value specified by --enable-dauth-def-timeout=${enable_dauth_def_timeout} is too large.])]
  4961. )
  4962. enable_dauth_def_timeout_MSG="${enable_dauth_def_timeout} seconds (set by parameter)"
  4963. ]
  4964. )
  4965. AC_DEFINE_UNQUOTED([MHD_DAUTH_DEF_TIMEOUT_],[${enable_dauth_def_timeout}],
  4966. [The default HTTP Digest Auth default nonce timeout value (in seconds)])
  4967. AC_MSG_RESULT([[${enable_dauth_def_timeout_MSG}]])
  4968. AC_MSG_CHECKING([[for Digest Authentication default maximum nc value]])
  4969. AC_ARG_ENABLE([dauth-def-max-nc],
  4970. [AS_HELP_STRING([--enable-dauth-def-max-nc=NNN],
  4971. [set default Digest Auth maximum nc (nonce count) value to NNN])],
  4972. [enable_dauth_def_max_nc="${enableval}"],
  4973. [enable_dauth_def_max_nc=""]
  4974. )
  4975. AS_VAR_IF([enable_dauth_def_max_nc], ["no"],
  4976. [
  4977. AC_MSG_WARN([Default Diget Auth maximum nc cannot be disabled, --disable-dauth-def-max-nc parameter is ignored])
  4978. enable_dauth_def_max_nc=""
  4979. ]
  4980. )
  4981. AS_IF([test -z "${enable_dauth_def_max_nc}"],
  4982. [
  4983. enable_dauth_def_max_nc="1000"
  4984. enable_dauth_def_max_nc_MSG="${enable_dauth_def_max_nc} (default)"
  4985. ],
  4986. [
  4987. AS_IF([[test "x${enable_dauth_def_max_nc}" = "x`echo ${enable_dauth_def_max_nc}|${SED-sed} 's/[^0-9]//g'`" && \
  4988. test "${enable_dauth_def_max_nc}" -ge "0" 2>/dev/null ]],[:],
  4989. [AC_MSG_ERROR([Invalid parameter --enable-dauth-def-max-nc=${enable_dauth_def_max_nc}. The value must be a positive integer.])
  4990. ]
  4991. )
  4992. AC_COMPILE_IFELSE(
  4993. [
  4994. AC_LANG_PROGRAM(
  4995. [[
  4996. #include <stdint.h>
  4997. ]],
  4998. [[
  4999. static int arr[((int) 2) - 4 * (int)(${enable_dauth_def_max_nc} != ((uint_fast32_t)${enable_dauth_def_max_nc}))];
  5000. (void) arr;
  5001. ]]
  5002. )
  5003. ],
  5004. [],
  5005. [AC_MSG_ERROR([The value specified by --enable-dauth-def-max-nc=${enable_dauth_def_max_nc} is too large.])]
  5006. )
  5007. enable_dauth_def_max_nc_MSG="${enable_dauth_def_max_nc} (set by parameter)"
  5008. ]
  5009. )
  5010. AC_DEFINE_UNQUOTED([MHD_DAUTH_DEF_MAX_NC_],[${enable_dauth_def_max_nc}],
  5011. [The default HTTP Digest Auth default maximum nc (nonce count) value])
  5012. AC_MSG_RESULT([[${enable_dauth_def_max_nc_MSG}]])
  5013. dauth_defs_MSG="timeout: ${enable_dauth_def_timeout_MSG}, max nc: ${enable_dauth_def_max_nc_MSG}"
  5014. ],
  5015. [
  5016. dauth_defs_MSG="N/A"
  5017. ]
  5018. )
  5019. AM_CONDITIONAL([HAVE_ANYAUTH],[test "x$enable_bauth" != "xno" || test "x$enable_dauth" != "xno"])
  5020. # optional: HTTP "Upgrade" support. Enabled by default
  5021. AC_MSG_CHECKING([[whether to support HTTP "Upgrade"]])
  5022. AC_ARG_ENABLE([[httpupgrade]],
  5023. [AS_HELP_STRING([[--disable-httpupgrade]], [disable HTTP "Upgrade" support])],
  5024. [AS_VAR_IF([[enable_httpupgrade]],[["no"]],[],[[enable_httpupgrade='yes']])],
  5025. [[enable_httpupgrade='yes']])
  5026. AS_VAR_IF([[enable_httpupgrade]],[["yes"]],
  5027. [
  5028. AC_DEFINE([[UPGRADE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTP Upgrade support.]) ])
  5029. AM_CONDITIONAL([ENABLE_UPGRADE], [[test "x$enable_httpupgrade" = "xyes"]])
  5030. AC_MSG_RESULT([[$enable_httpupgrade]])
  5031. # optional: HTTP cookie parsing support. Enabled by default
  5032. AC_MSG_CHECKING([[whether to support HTTP cookie parsing]])
  5033. AC_ARG_ENABLE([[cookie]],
  5034. [AS_HELP_STRING([[--disable-cookie]], [disable HTTP cookie parsing support])],
  5035. [AS_VAR_IF([[enable_cookie]],[["no"]],[],[[enable_cookie='yes']])],
  5036. [[enable_cookie='yes']])
  5037. AS_VAR_IF([[enable_cookie]],[["yes"]],
  5038. [
  5039. AC_DEFINE([[COOKIE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTP cookie parsing support.]) ])
  5040. AM_CONDITIONAL([ENABLE_COOKIE], [[test "x$enable_cookie" = "xyes"]])
  5041. AC_MSG_RESULT([[$enable_cookie]])
  5042. # optional: MD5 support for Digest Auth. Enabled by default.
  5043. AC_ARG_ENABLE([[md5]],
  5044. [AS_HELP_STRING([[--enable-md5=TYPE]],
  5045. [enable TYPE of MD5 hashing code (yes, no, builtin, tlslib) [yes if dauth enabled]])],
  5046. [
  5047. AS_VAR_IF([enable_md5],["internal"],[enable_md5='builtin'])
  5048. AS_VAR_IF([enable_md5],["built-in"],[enable_md5='builtin'])
  5049. AS_VAR_IF([enable_dauth],["yes"],[],
  5050. [
  5051. AS_VAR_IF([enable_md5],["no"],[],
  5052. [
  5053. AC_MSG_WARN([The parameter --enable-md5=${enable_md5} is ignored as Digest Authentication is disabled])
  5054. enable_md5='no'
  5055. ]
  5056. )
  5057. ]
  5058. )
  5059. ], [[enable_md5="${enable_dauth}"]]
  5060. )
  5061. AS_CASE([${enable_md5}],[yes|tlslib],
  5062. [
  5063. AS_IF([test "x${enable_compact_code}" != "xno" || test "x$enable_md5" = "xtlslib"],
  5064. [
  5065. AS_IF([test "x$enable_https" = "xyes"],
  5066. [
  5067. AC_CACHE_CHECK([whether GnuTLS supports MD5 hashing],[mhd_cv_gnutls_md5],
  5068. [
  5069. CFLAGS="${CFLAGS_ac} ${GNUTLS_CFLAGS} ${user_CFLAGS}"
  5070. CPPFLAGS="${CPPFLAGS_ac} ${MHD_TLS_LIB_CPPFLAGS} ${user_CPPFLAGS}"
  5071. CFLAGS="${CFLAGS_ac} ${MHD_TLS_LIB_CFLAGS} ${user_CFLAGS}"
  5072. LDFLAGS="${LDFLAGS_ac} ${MHD_TLS_LIB_LDFLAGS} ${user_LDFLAGS}"
  5073. save_LIBS="$LIBS"
  5074. LIBS="${MHD_TLS_LIBDEPS} ${LIBS}"
  5075. AC_LINK_IFELSE(
  5076. [
  5077. AC_LANG_PROGRAM(
  5078. [[
  5079. #include <gnutls/crypto.h>
  5080. ]],
  5081. [[
  5082. gnutls_hash_hd_t hash_handle;
  5083. unsigned char digest[16];
  5084. int exit_code;
  5085. if (0 == gnutls_hash_init(&hash_handle, GNUTLS_DIG_MD5))
  5086. {
  5087. if (0 == gnutls_hash(hash_handle, "", 1))
  5088. {
  5089. gnutls_hash_output(hash_handle, digest);
  5090. if (0x93 == digest[0])
  5091. exit_code = 0;
  5092. else
  5093. exit_code = 7;
  5094. }
  5095. else
  5096. exit_code = 5;
  5097. gnutls_hash_deinit(hash_handle, (void *)0);
  5098. }
  5099. else
  5100. exit_code = 2;
  5101. if (exit_code)
  5102. return exit_code;
  5103. ]]
  5104. )
  5105. ],
  5106. [mhd_cv_gnutls_md5='yes'],[mhd_cv_gnutls_md5='no']
  5107. )
  5108. LIBS="${save_LIBS}"
  5109. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  5110. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  5111. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  5112. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  5113. ]
  5114. )
  5115. AS_VAR_IF([mhd_cv_gnutls_md5],["no"],
  5116. [
  5117. AS_VAR_IF([enable_md5],["tlslib"],
  5118. [AC_MSG_FAILURE([TLS library MD5 implementation is not available])]
  5119. )
  5120. enable_md5="builtin"
  5121. ],
  5122. [enable_md5="tlslib"]
  5123. )
  5124. ],
  5125. [
  5126. AS_VAR_IF([enable_md5],["tlslib"],
  5127. [AC_MSG_ERROR([HTTPS is not enabled, TLS library MD5 implementation cannot be used])]
  5128. )
  5129. enable_md5="builtin"
  5130. ]
  5131. )
  5132. ],
  5133. [
  5134. enable_md5="builtin"
  5135. ]
  5136. )
  5137. ]
  5138. )
  5139. AC_MSG_CHECKING([[whether to support MD5]])
  5140. AS_UNSET([enable_md5_MSG])
  5141. AS_CASE([${enable_md5}],
  5142. [builtin],[enable_md5_MSG='yes, built-in'],
  5143. [tlslib],[enable_md5_MSG='yes, external (TLS library)'],
  5144. [no],[enable_md5_MSG='no'],
  5145. [yes],[AC_MSG_ERROR([configure internal error: unexpected variable value])],
  5146. [AC_MSG_ERROR([Unrecognized parameter --enable-md5=${enable_md5}])]
  5147. )
  5148. AS_IF([test "x${enable_md5}" = "xbuiltin" || test "x${enable_md5}" = "xtlslib" ],
  5149. [
  5150. AC_DEFINE([[MHD_MD5_SUPPORT]],[[1]],
  5151. [Define to 1 if libmicrohttpd is compiled with MD5 hashing support.])
  5152. ]
  5153. )
  5154. AS_IF([test "x${enable_md5}" = "xtlslib" ],
  5155. [
  5156. AC_DEFINE([[MHD_MD5_TLSLIB]],[[1]],
  5157. [Define to 1 if libmicrohttpd is compiled with MD5 hashing by TLS library.])
  5158. ]
  5159. )
  5160. AM_CONDITIONAL([ENABLE_MD5], [[test "x${enable_md5}" = "xbuiltin" || test "x${enable_md5}" = "xtlslib" ]])
  5161. AM_CONDITIONAL([ENABLE_MD5_EXT], [[test "x${enable_md5}" = "xtlslib" ]])
  5162. AC_MSG_RESULT([[${enable_md5_MSG}]])
  5163. # optional: SHA-256 support for Digest Auth. Enabled by default.
  5164. AC_ARG_ENABLE([[sha256]],
  5165. [AS_HELP_STRING([[--enable-sha256=TYPE]],
  5166. [enable TYPE of SHA-256 hashing code (yes, no, builtin, tlslib) [yes if dauth enabled]])],
  5167. [
  5168. AS_VAR_IF([enable_sha256],["internal"],[enable_sha256='builtin'])
  5169. AS_VAR_IF([enable_sha256],["built-in"],[enable_sha256='builtin'])
  5170. AS_VAR_IF([enable_dauth],["yes"],[],
  5171. [
  5172. AS_VAR_IF([enable_sha256],["no"],[],
  5173. [
  5174. AC_MSG_WARN([The parameter --enable-sha256=${enable_sha256} is ignored as Digest Authentication is disabled])
  5175. enable_sha256='no'
  5176. ]
  5177. )
  5178. ]
  5179. )
  5180. ], [[enable_sha256="${enable_dauth}"]]
  5181. )
  5182. AS_CASE([${enable_sha256}],[yes|tlslib],
  5183. [
  5184. AS_IF([test "x${enable_compact_code}" != "xno" || test "x$enable_sha256" = "xtlslib"],
  5185. [
  5186. AS_IF([test "x$enable_https" = "xyes"],
  5187. [
  5188. AC_CACHE_CHECK([whether GnuTLS supports sha256 hashing],[mhd_cv_gnutls_sha256],
  5189. [
  5190. CFLAGS="${CFLAGS_ac} ${GNUTLS_CFLAGS} ${user_CFLAGS}"
  5191. CPPFLAGS="${CPPFLAGS_ac} ${MHD_TLS_LIB_CPPFLAGS} ${user_CPPFLAGS}"
  5192. CFLAGS="${CFLAGS_ac} ${MHD_TLS_LIB_CFLAGS} ${user_CFLAGS}"
  5193. LDFLAGS="${LDFLAGS_ac} ${MHD_TLS_LIB_LDFLAGS} ${user_LDFLAGS}"
  5194. save_LIBS="$LIBS"
  5195. LIBS="${MHD_TLS_LIBDEPS} ${LIBS}"
  5196. AC_LINK_IFELSE(
  5197. [
  5198. AC_LANG_PROGRAM(
  5199. [[
  5200. #include <gnutls/crypto.h>
  5201. ]],
  5202. [[
  5203. gnutls_hash_hd_t hash_handle;
  5204. unsigned char digest[32];
  5205. int exit_code;
  5206. if (0 == gnutls_hash_init(&hash_handle, GNUTLS_DIG_SHA256))
  5207. {
  5208. if (0 == gnutls_hash(hash_handle, "", 1))
  5209. {
  5210. gnutls_hash_output(hash_handle, digest);
  5211. if (0x6e == digest[0])
  5212. exit_code = 0;
  5213. else
  5214. exit_code = 7;
  5215. }
  5216. else
  5217. exit_code = 5;
  5218. gnutls_hash_deinit(hash_handle, (void *)0);
  5219. }
  5220. else
  5221. exit_code = 2;
  5222. if (exit_code)
  5223. return exit_code;
  5224. ]]
  5225. )
  5226. ],
  5227. [mhd_cv_gnutls_sha256='yes'],[mhd_cv_gnutls_sha256='no']
  5228. )
  5229. LIBS="${save_LIBS}"
  5230. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  5231. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  5232. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  5233. LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
  5234. ]
  5235. )
  5236. AS_VAR_IF([mhd_cv_gnutls_sha256],["no"],
  5237. [
  5238. AS_VAR_IF([enable_sha256],["tlslib"],
  5239. [AC_MSG_FAILURE([TLS library SHA-256 implementation is not available])]
  5240. )
  5241. enable_sha256="builtin"
  5242. ],
  5243. [enable_sha256="tlslib"]
  5244. )
  5245. ],
  5246. [
  5247. AS_VAR_IF([enable_sha256],["tlslib"],
  5248. [AC_MSG_ERROR([HTTPS is not enabled, TLS library SHA-256 implementation cannot be used])]
  5249. )
  5250. enable_sha256="builtin"
  5251. ]
  5252. )
  5253. ],
  5254. [
  5255. enable_sha256="builtin"
  5256. ]
  5257. )
  5258. ]
  5259. )
  5260. AC_MSG_CHECKING([[whether to support SHA-256]])
  5261. AS_UNSET([enable_sha256_MSG])
  5262. AS_CASE([${enable_sha256}],
  5263. [builtin],[enable_sha256_MSG='yes, built-in'],
  5264. [tlslib],[enable_sha256_MSG='yes, external (TLS library)'],
  5265. [no],[enable_sha256_MSG='no'],
  5266. [yes],[AC_MSG_ERROR([configure internal error: unexpected variable value])],
  5267. [AC_MSG_ERROR([Unrecognized parameter --enable-sha256=${enable_sha256}])]
  5268. )
  5269. AS_IF([test "x${enable_sha256}" = "xbuiltin" || test "x${enable_sha256}" = "xtlslib" ],
  5270. [
  5271. AC_DEFINE([[MHD_SHA256_SUPPORT]],[[1]],
  5272. [Define to 1 if libmicrohttpd is compiled with SHA-256 hashing support.])
  5273. ]
  5274. )
  5275. AS_IF([test "x${enable_sha256}" = "xtlslib" ],
  5276. [
  5277. AC_DEFINE([[MHD_SHA256_TLSLIB]],[[1]],
  5278. [Define to 1 if libmicrohttpd is compiled with SHA-256 hashing by TLS library.])
  5279. ]
  5280. )
  5281. AM_CONDITIONAL([ENABLE_SHA256], [[test "x${enable_sha256}" = "xbuiltin" || test "x${enable_sha256}" = "xtlslib" ]])
  5282. AM_CONDITIONAL([ENABLE_SHA256_EXT], [[test "x${enable_sha256}" = "xtlslib" ]])
  5283. AC_MSG_RESULT([[${enable_sha256_MSG}]])
  5284. # optional: SHA-512/256 support for Digest Auth. Enabled by default.
  5285. AC_ARG_ENABLE([[sha512-256]],
  5286. [AS_HELP_STRING([[--disable-sha512-256]],
  5287. [disable SHA-512/256 hashing support for Digest Authentication])],
  5288. [
  5289. AS_VAR_IF([[enable_sha512_256]],[["yes"]],
  5290. [
  5291. AS_VAR_IF([enable_dauth],["yes"],[],
  5292. [
  5293. AC_MSG_WARN([The parameter --enable-sha512-256 is ignored as Digest Authentication is disabled])
  5294. enable_sha512_256='no'
  5295. ]
  5296. )
  5297. ],[[enable_sha512_256='no']]
  5298. )
  5299. ], [[enable_sha512_256="${enable_dauth}"]]
  5300. )
  5301. AC_MSG_CHECKING([[whether to support SHA-512/256]])
  5302. AS_UNSET([enable_sha512_256_MSG])
  5303. AS_CASE([${enable_sha512_256}],
  5304. [yes],[enable_sha512_256_MSG='yes, built-in'],
  5305. [no],[enable_sha512_256_MSG='no'],
  5306. [AC_MSG_ERROR([Unrecognized parameter --enable-sha512-256=${enable_sha512_256}])]
  5307. )
  5308. AS_VAR_IF([[enable_sha512_256]],[["yes"]],
  5309. [
  5310. AC_DEFINE([[MHD_SHA512_256_SUPPORT]],[[1]],
  5311. [Define to 1 if libmicrohttpd is compiled with SHA-512/256 hashing support.])
  5312. ]
  5313. )
  5314. AM_CONDITIONAL([ENABLE_SHA512_256], [[test "x${enable_sha512_256}" = "xyes"]])
  5315. AC_MSG_RESULT([[${enable_sha512_256_MSG}]])
  5316. AS_IF([test "x$enable_dauth" != "xno"],
  5317. [
  5318. AS_IF([test "x${enable_md5}" = "xno" && test "x${enable_sha256}" = "xno" && test "x${enable_sha512_256}" != "xyes"],
  5319. [AC_MSG_ERROR([At least one hashing algorithm must be enabled if Digest Auth is enabled])]
  5320. )
  5321. ]
  5322. )
  5323. AC_CACHE_CHECK([[for calloc()]], [[mhd_cv_have_func_calloc]],
  5324. [
  5325. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  5326. #ifdef HAVE_STDLIB_H
  5327. #include <stdlib.h>
  5328. #elif defined(HAVE_MALLOC_H)
  5329. #include <malloc.h>
  5330. #else
  5331. #include <unistd.h>
  5332. #endif
  5333. ]],[[void * ptr = calloc(1, 2); if (ptr) return 1;]])
  5334. ],
  5335. [[mhd_cv_have_func_calloc='yes']],
  5336. [[mhd_cv_have_func_calloc='no']]
  5337. )
  5338. ]
  5339. )
  5340. AS_VAR_IF([[mhd_cv_have_func_calloc]], [["yes"]],
  5341. [AC_DEFINE([[HAVE_CALLOC]], [[1]], [Define to 1 if you have the usable `calloc' function.])])
  5342. AM_CONDITIONAL([HAVE_SYS_CALLOC], [[test "x${mhd_cv_have_func_calloc}" = "xyes"]])
  5343. # Some systems have IPv6 disabled in kernel at run-time
  5344. AS_IF([[test "x${mhd_cv_have_inet6}" = "xyes" && test "x${cross_compiling}" = "xno"]],
  5345. [
  5346. AC_CACHE_CHECK([whether IPv6 could be used for testing],[mhd_cv_ipv6_for_testing],
  5347. [
  5348. AC_RUN_IFELSE(
  5349. [
  5350. AC_LANG_SOURCE([[
  5351. #ifdef HAVE_UNISTD_H
  5352. #include <unistd.h>
  5353. #endif
  5354. #ifdef HAVE_SYS_TYPES_H
  5355. #include <sys/types.h>
  5356. #endif
  5357. #ifdef HAVE_SYS_SOCKET_H
  5358. #include <sys/socket.h>
  5359. #endif
  5360. #ifdef HAVE_WINSOCK2_H
  5361. #include <winsock2.h>
  5362. #endif
  5363. #ifdef HAVE_WS2TCPIP_H
  5364. #include <ws2tcpip.h>
  5365. #endif
  5366. #ifdef HAVE_NETINET_IN_H
  5367. #include <netinet/in.h>
  5368. #endif
  5369. #ifdef HAVE_NETINET_IP_H
  5370. #include <netinet/ip.h>
  5371. #endif
  5372. #ifdef HAVE_ARPA_INET_H
  5373. #include <arpa/inet.h>
  5374. #endif
  5375. #ifdef HAVE_NETINET_TCP_H
  5376. #include <netinet/tcp.h>
  5377. #endif
  5378. static void zr_mem(void *ptr, socklen_t size)
  5379. { char *mem = ptr; while(size--) {mem[0] = 0; mem++;} }
  5380. int main(void)
  5381. {
  5382. int ret = 30;
  5383. struct sockaddr_in6 sa;
  5384. #if !defined(_WIN32) || defined(__CYGWIN__)
  5385. int sckt;
  5386. const int invld_sckt = -1;
  5387. #else
  5388. SOCKET sckt;
  5389. const SOCKET invld_sckt = INVALID_SOCKET;
  5390. WSADATA wsa_data;
  5391. WSAStartup(MAKEWORD(2, 2), &wsa_data);
  5392. #endif
  5393. zr_mem(&sa, sizeof(sa));
  5394. sa.sin6_family = AF_INET6;
  5395. sa.sin6_port = 0;
  5396. sa.sin6_addr = in6addr_loopback;
  5397. #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
  5398. sa.sin6_len = sizeof(sa);
  5399. #endif
  5400. sckt = socket (PF_INET6, SOCK_STREAM, 0);
  5401. if (invld_sckt != sckt)
  5402. {
  5403. if (0 == bind (sckt, (struct sockaddr *)&sa, sizeof(sa)))
  5404. {
  5405. if (0 == listen (sckt, 1))
  5406. ret = 0;
  5407. else
  5408. ret = 1; /* listen() failed */
  5409. } else ret = 2; /* bind() failed */
  5410. #if !defined(_WIN32) || defined(__CYGWIN__)
  5411. close (sckt);
  5412. #else
  5413. closesocket (sckt);
  5414. #endif
  5415. } else ret = 3; /* socket() failed */
  5416. #if defined(_WIN32) && !defined(__CYGWIN__)
  5417. WSACleanup();
  5418. #endif
  5419. return ret;
  5420. }
  5421. ]])
  5422. ], [[mhd_cv_ipv6_for_testing="yes"]], [[mhd_cv_ipv6_for_testing="no"]], [[mhd_cv_ipv6_for_testing="no"]]
  5423. )
  5424. ]
  5425. )
  5426. ]
  5427. )
  5428. AS_VAR_IF([mhd_cv_ipv6_for_testing],["yes"],
  5429. [AC_DEFINE([[USE_IPV6_TESTING]], [[1]], [Define to 1 if your kernel supports IPv6 and IPv6 is enabled and useful for testing.])]
  5430. )
  5431. AM_CONDITIONAL([USE_IPV6_TESTING], [[test "x$mhd_cv_ipv6_for_testing" = "xyes"]])
  5432. AS_VAR_IF([enable_tools],["yes"],
  5433. [
  5434. AC_CHECK_HEADERS([features.h sys/pstat.h vxCpuLib.h],[],[],[AC_INCLUDES_DEFAULT])
  5435. AC_CHECK_DECLS(
  5436. [_SC_NPROCESSORS_ONLN,_SC_NPROC_ONLN,_SC_CRAY_NCPU,_SC_NPROCESSORS_CONF,CTL_HW,HW_NCPUONLINE,HW_NCPU,HW_AVAILCPU],
  5437. [],[],
  5438. [[
  5439. #ifdef HAVE_SYS_TYPES_H
  5440. #include <sys/types.h>
  5441. #endif /* HAVE_SYS_TYPES_H */
  5442. #ifdef HAVE_SYS_PARAM_H
  5443. #include <sys/param.h>
  5444. #endif /* HAVE_SYS_PARAM_H */
  5445. #ifdef HAVE_SYS_SYSCTL_H
  5446. #include <sys/sysctl.h>
  5447. #endif /* HAVE_SYS_SYSCTL_H */
  5448. #ifdef HAVE_UNISTD_H
  5449. #include <unistd.h>
  5450. #endif /* HAVE_UNISTD_H */
  5451. ]]
  5452. )
  5453. MHD_CHECK_FUNC([pstat_getdynamic],[[
  5454. #include <sys/param.h>
  5455. #include <sys/pstat.h>
  5456. ]],
  5457. [[
  5458. struct pst_dynamic psd_data;
  5459. i][f (1 != pstat_getdynamic(&psd_data, sizeof(psd_data), (size_t)1, 0))
  5460. return 2;
  5461. i][f (0 >= psd_data.psd_proc_cnt)
  5462. return 3;
  5463. ]]
  5464. )
  5465. MHD_CHECK_FUNC([vxCpuEnabledGet],[[#include <vxCpuLib.h>]],
  5466. [[
  5467. cpuset_t enb_set;
  5468. enb_set = vxCpuEnabledGet();
  5469. (void) enb_set;
  5470. ]]
  5471. )
  5472. AC_CHECK_HEADERS([sched.h sys/_cpuset.h sys/cpuset.h],[],[],[AC_INCLUDES_DEFAULT])
  5473. # glibc / Linux kernel
  5474. MHD_CHECK_FUNC([getpid],[[
  5475. #ifdef HAVE_SYS_TYPES_H
  5476. #include <sys/types.h>
  5477. #endif /* HAVE_SYS_TYPES_H */
  5478. #include <unistd.h>
  5479. ]],
  5480. [[
  5481. pid_t cur_pid;
  5482. cur_pid = getpid();
  5483. (void) &cur_pid; /* Mute possible warning */
  5484. ]],
  5485. [
  5486. MHD_CHECK_FUNC([sched_getaffinity],[[
  5487. #ifdef HAVE_SYS_TYPES_H
  5488. #include <sys/types.h>
  5489. #endif /* HAVE_SYS_TYPES_H */
  5490. #include <unistd.h>
  5491. #include <sched.h>
  5492. ]],
  5493. [[
  5494. cpu_set_t cur_set;
  5495. i][f (0 != sched_getaffinity(getpid(), sizeof(cur_set), &cur_set))
  5496. return 2;
  5497. i][f (0 == CPU_SET (0, &cur_set))
  5498. return 3; /* Actually this could be a valid result */
  5499. ]],
  5500. [
  5501. MHD_CHECK_FUNC([CPU_COUNT],[[
  5502. #include <stddef.h>
  5503. #include <sched.h>
  5504. ]],
  5505. [[
  5506. cpu_set_t cur_set;
  5507. CPU_ZERO(&cur_set);
  5508. i][f (0 != CPU_COUNT(&cur_set))
  5509. return 2;
  5510. ]],
  5511. [
  5512. MHD_CHECK_FUNC([CPU_COUNT_S],[[
  5513. #include <stddef.h>
  5514. #include <sched.h>
  5515. ]],
  5516. [[
  5517. static const unsigned int set_size_cpus = 2048u;
  5518. const size_t set_size_bytes = (size_t) CPU_ALLOC_SIZE(set_size_cpus);
  5519. cpu_set_t *p_set;
  5520. p_set = CPU_ALLOC(set_size_cpus);
  5521. i][f (!p_set)
  5522. return 2;
  5523. CPU_ZERO_S(set_size_bytes, p_set);
  5524. i][f (0 != CPU_COUNT_S(set_size_bytes, p_set))
  5525. {
  5526. CPU_FREE(p_set);
  5527. return 3;
  5528. }
  5529. CPU_FREE(p_set);
  5530. ]],
  5531. [AC_CHECK_DECLS([CPU_SETSIZE],[],[],[#include <sched.h>])]
  5532. )
  5533. ]
  5534. )
  5535. ]
  5536. )
  5537. # NetBSD
  5538. # Should work only with -lrt, but actually works without it.
  5539. MHD_CHECK_FUNC([sched_getaffinity_np],[[
  5540. #ifdef HAVE_SYS_TYPES_H
  5541. #include <sys/types.h>
  5542. #endif /* HAVE_SYS_TYPES_H */
  5543. #include <unistd.h>
  5544. #include <sched.h>
  5545. ]],
  5546. [[
  5547. cpuset_t *cpuset_ptr;
  5548. cpuid_t cpu_num = 0;
  5549. cpuset_ptr = cpuset_create();
  5550. i][f (!cpuset_ptr)
  5551. return 2;
  5552. i][f (0 != sched_getaffinity_np(getpid(), cpuset_size(cpuset_ptr), cpuset_ptr))
  5553. {
  5554. cpuset_destroy(cpuset_ptr);
  5555. return 3;
  5556. }
  5557. i][f (0 >= cpuset_isset(cpu_num, cpuset_ptr))
  5558. {
  5559. cpuset_destroy(cpuset_ptr);
  5560. return 4; /* Actually this could be a valid result */
  5561. }
  5562. cpuset_destroy(cpuset_ptr);
  5563. ]]
  5564. )
  5565. ]
  5566. )
  5567. # FreeBSD
  5568. MHD_CHECK_FUNC([cpuset_getaffinity],[[
  5569. #ifdef HAVE_SYS_PARAM_H
  5570. #include <sys/param.h>
  5571. #endif /* HAVE_SYS_PARAM_H */
  5572. #include <sys/cpuset.h>
  5573. ]],
  5574. [[
  5575. cpuset_t cur_mask;
  5576. i][f (0 != cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, (id_t) -1, sizeof(cur_mask), &cur_mask))
  5577. return 2;
  5578. ]],
  5579. [
  5580. MHD_CHECK_FUNC([CPU_COUNT],[[
  5581. #ifdef HAVE_SYS_PARAM_H
  5582. #include <sys/param.h>
  5583. #endif /* HAVE_SYS_PARAM_H */
  5584. #ifdef HAVE_SYS__CPUSET_H
  5585. #include <sys/_cpuset.h>
  5586. #endif /* HAVE_SYS_PARAM_H */
  5587. #include <sys/cpuset.h>
  5588. ]],
  5589. [[
  5590. cpuset_t test_mask;
  5591. CPU_ZERO(&test_mask);
  5592. i][f (0 != CPU_COUNT(&test_mask))
  5593. return 2;
  5594. ]],
  5595. [
  5596. MHD_CHECK_FUNC([CPU_COUNT_S],[[
  5597. #ifdef HAVE_SYS_PARAM_H
  5598. #include <sys/param.h>
  5599. #endif /* HAVE_SYS_PARAM_H */
  5600. #ifdef HAVE_SYS__CPUSET_H
  5601. #include <sys/_cpuset.h>
  5602. #endif /* HAVE_SYS_PARAM_H */
  5603. #include <sys/cpuset.h>
  5604. ]],
  5605. [[
  5606. static const unsigned int max_cpu_num = 2048u;
  5607. cpuset_t *mask_ptr;
  5608. mask_ptr = CPU_ALLOC(max_cpu_num);
  5609. i][f (! mask_ptr)
  5610. return 2;
  5611. i][f (0 != cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, (id_t) -1,
  5612. CPU_ALLOC_SIZE(max_cpu_num), mask_ptr))
  5613. {
  5614. CPU_FREE(mask_ptr);
  5615. return 3;
  5616. }
  5617. i][f (0 == CPU_COUNT_S(CPU_ALLOC_SIZE(max_cpu_num), &test_mask))
  5618. {
  5619. CPU_FREE(mask_ptr);
  5620. return 4;
  5621. }
  5622. CPU_FREE(mask_ptr);
  5623. ]]
  5624. )
  5625. ]
  5626. )
  5627. ]
  5628. )
  5629. AS_VAR_IF([mhd_cv_func_CPU_COUNT_S],["yes"],
  5630. [
  5631. AC_CACHE_CHECK([whether CPU_COUNT_S() expects max CPU number as 'size' parameter],[mhd_cv_func_cpu_count_s_cpus],
  5632. [
  5633. AS_VAR_IF([cross-compiling],["yes"],[mhd_cv_func_cpu_count_s_cpus="assuming no"],
  5634. [
  5635. AC_LINK_IFELSE(
  5636. [
  5637. AC_LANG_PROGRAM([[
  5638. #ifdef HAVE_SYS_TYPES_H
  5639. #include <sys/types.h>
  5640. #endif /* HAVE_SYS_TYPES_H */
  5641. #ifdef HAVE_SYS_PARAM_H
  5642. #include <sys/param.h>
  5643. #endif /* HAVE_SYS_PARAM_H */
  5644. #ifdef HAVE_SYS__CPUSET_H
  5645. #include <sys/_cpuset.h>
  5646. #endif /* HAVE_SYS_PARAM_H */
  5647. #ifdef HAVE_SYS_CPUSET_H
  5648. #include <sys/cpuset.h>
  5649. #endif /* HAVE_SYS_CPUSET_H */
  5650. #ifdef HAVE_STDDEF_H
  5651. #include <stddef.h>
  5652. #endif /* HAVE_STDDEF_H */
  5653. #ifdef HAVE_UNISTD_H
  5654. #include <unistd.h>
  5655. #endif /* HAVE_UNISTD_H */
  5656. #ifdef HAVE_SCHED_H
  5657. #include <sched.h>
  5658. #endif /* HAVE_SCHED_H */
  5659. #include <stdio.h>
  5660. #ifdef HAVE_SCHED_GETAFFINITY
  5661. #define TEST_CPUSET_TYPE cpu_set_t
  5662. #else /* ! HAVE_SCHED_GETAFFINITY */
  5663. #define TEST_CPUSET_TYPE cpuset_t
  5664. #endif /* ! HAVE_SCHED_GETAFFINITY */
  5665. ]],
  5666. [[
  5667. TEST_CPUSET_TYPE *p_testset;
  5668. /* The size of the cpuset that is larger then the test cpuset (in CPUs) */
  5669. static const unsigned int testset_size_oversized_cpus = (8 * sizeof(long)) * 1024;
  5670. const size_t testset_size_oversized_bytes = CPU_ALLOC_SIZE(testset_size_oversized_cpus);
  5671. /* The size of the test cpuset in number of CPUs */
  5672. const unsigned int testset_size_cpus = (unsigned int) testset_size_oversized_bytes;
  5673. /* The size of the test cpuset in bytes */
  5674. const size_t testset_size_bytes = CPU_ALLOC_SIZE(testset_size_cpus);
  5675. /* The last one CPU in the test set */
  5676. const unsigned int test_cpu_num1 = testset_size_cpus - 1;
  5677. /* The penultimate CPU in the test set */
  5678. const unsigned int test_cpu_num2 = testset_size_cpus - 2;
  5679. /* The CPU numbers that should be cleared */
  5680. const unsigned int test_cpu_clear1 = testset_size_cpus - 3;
  5681. const unsigned int test_cpu_clear2 = testset_size_cpus - 4;
  5682. unsigned int count_res;
  5683. int ret = 0;
  5684. /* Allocate oversize area to ensure that memory outside the buffer is not used */
  5685. p_testset = CPU_ALLOC(testset_size_oversized_cpus);
  5686. if (! p_testset)
  5687. {
  5688. fprintf (stderr, "Error allocating memory.\n");
  5689. return 99;
  5690. }
  5691. /* Set the some CPU numbers and then clear them */
  5692. CPU_SET_S(test_cpu_clear1, testset_size_bytes, p_testset);
  5693. CPU_SET_S(test_cpu_clear2, testset_size_bytes, p_testset);
  5694. CPU_ZERO_S(testset_size_bytes, p_testset);
  5695. /* Set two CPUs on */
  5696. CPU_SET_S(test_cpu_num1, testset_size_bytes, p_testset);
  5697. CPU_SET_S(test_cpu_num2, testset_size_bytes, p_testset);
  5698. count_res = (unsigned int) CPU_COUNT_S(testset_size_bytes, p_testset);
  5699. if (0 == count_res)
  5700. {
  5701. fprintf (stderr, "Full cpuset cannot be read by CPU_COUNT_S() when using the number of bytes as the size parameter.\n");
  5702. /* Set the some CPU numbers and then clear them */
  5703. CPU_SET_S(test_cpu_clear1, testset_size_cpus, p_testset);
  5704. CPU_SET_S(test_cpu_clear2, testset_size_cpus, p_testset);
  5705. CPU_ZERO_S(testset_size_cpus, p_testset);
  5706. /* Set two CPUs on */
  5707. CPU_SET_S(test_cpu_num1, testset_size_cpus, p_testset);
  5708. CPU_SET_S(test_cpu_num2, testset_size_cpus, p_testset);
  5709. count_res = (unsigned int) CPU_COUNT_S(testset_size_cpus, p_testset);
  5710. if (2 == count_res)
  5711. {
  5712. fprintf (stderr, "Full cpuset is read by CPU_COUNT_S() only when using the maximum CPU number as the size parameter.\n");
  5713. ret = 3;
  5714. }
  5715. else
  5716. {
  5717. fprintf (stderr, "Wrong result returned by CPU_COUNT_S() when using the maximum CPU number as the size parameter.\n");
  5718. fprintf (stderr, "Number of 'enabled' CPUs: 2\n");
  5719. fprintf (stderr, "Number of counted CPUs: %u\n", count_res);
  5720. fprintf (stderr, "CPU_COUNT_S() could be unreliable.\n");
  5721. ret = 70;
  5722. }
  5723. }
  5724. else if (2 == count_res)
  5725. {
  5726. fprintf (stderr, "Full cpuset is read by CPU_COUNT_S() when using the number of bytes as the size parameter.\n");
  5727. }
  5728. else
  5729. {
  5730. fprintf (stderr, "Wrong result returned by CPU_COUNT_S() when using the number of bytes as the size parameter.\n");
  5731. fprintf (stderr, "Number of 'enabled' CPUs: 2\n");
  5732. fprintf (stderr, "Number of counted CPUs: %u\n", count_res);
  5733. fprintf (stderr, "CPU_COUNT_S() could be unreliable.\n");
  5734. ret = 71;
  5735. }
  5736. CPU_FREE(p_testset);
  5737. if (0 != ret)
  5738. return ret;
  5739. ]]
  5740. )
  5741. ],
  5742. [
  5743. AM_RUN_LOG([./conftest$EXEEXT])
  5744. count_test_res=$?
  5745. AS_IF([test $count_test_res -eq 0],[mhd_cv_func_cpu_count_s_cpus="no"],
  5746. [test $count_test_res -eq 3],[mhd_cv_func_cpu_count_s_cpus="yes"],
  5747. [
  5748. AC_MSG_WARN([Unexpected value returned by CPU_COUNT_S() test program. Please report to ${PACKAGE_BUGREPORT}])
  5749. mhd_cv_func_cpu_count_s_cpus="assuming no"
  5750. ]
  5751. )
  5752. ],
  5753. [
  5754. AC_MSG_WARN([Cannot build CPU_COUNT_S() test program. Please report to ${PACKAGE_BUGREPORT}])
  5755. mhd_cv_func_cpu_count_s_cpus="assuming no"
  5756. ]
  5757. )
  5758. ]
  5759. )
  5760. ]
  5761. )
  5762. AS_VAR_IF([mhd_cv_func_cpu_count_s_cpus],["yes"],
  5763. [AC_DEFINE([MHD_FUNC_CPU_COUNT_S_GETS_CPUS],[1],
  5764. [Define to '1' if CPU_COUNT_S() function expects max CPU number as 'size' parameter])
  5765. ]
  5766. )
  5767. ]
  5768. )
  5769. ]
  5770. )
  5771. # Check for fork() and waitpid(). They are used for tests.
  5772. AC_MSG_CHECKING([[for fork()]])
  5773. mhd_have_fork_waitpid='no'
  5774. AC_LINK_IFELSE(
  5775. [
  5776. AC_LANG_PROGRAM(
  5777. [[
  5778. #ifdef HAVE_SYS_TYPES_H
  5779. #include <sys/types.h>
  5780. #endif
  5781. #ifdef HAVE_UNISTD_H
  5782. #include <unistd.h>
  5783. #endif
  5784. ]], [[
  5785. pid_t p = fork ();
  5786. if (0 == p)
  5787. return 1;
  5788. ]])
  5789. ], [
  5790. AC_DEFINE([[HAVE_FORK]], [[1]], [Define to 1 if you have the usable `fork' function.])
  5791. AC_MSG_RESULT([[yes]])
  5792. AC_MSG_CHECKING([[for waitpid()]])
  5793. AC_LINK_IFELSE(
  5794. [
  5795. AC_LANG_PROGRAM(
  5796. [[
  5797. #ifdef HAVE_SYS_TYPES_H
  5798. #include <sys/types.h>
  5799. #endif
  5800. #ifdef HAVE_UNISTD_H
  5801. #include <unistd.h>
  5802. #endif
  5803. #include <sys/wait.h>
  5804. ]], [[
  5805. pid_t p = fork ();
  5806. if (0 == p)
  5807. return 1;
  5808. waitpid (p, (void*)0, 0)
  5809. ]])
  5810. ], [
  5811. AC_DEFINE([[HAVE_WAITPID]], [[1]], [Define to 1 if you have the usable `waitpid' function.])
  5812. AC_MSG_RESULT([[yes]])
  5813. mhd_have_fork_waitpid='yes'
  5814. ],[
  5815. AC_MSG_RESULT([[no]])
  5816. ])
  5817. ],[
  5818. AC_MSG_RESULT([[no]])
  5819. ])
  5820. AM_CONDITIONAL([HAVE_FORK_WAITPID], [test "x$mhd_have_fork_waitpid" = "xyes"])
  5821. # gcov compilation
  5822. AC_MSG_CHECKING(whether to compile with support for code coverage analysis)
  5823. AC_ARG_ENABLE([coverage],
  5824. AS_HELP_STRING([--enable-coverage],
  5825. [compile the library with code coverage support]),
  5826. [use_gcov=${enableval}],
  5827. [use_gcov=no])
  5828. AC_MSG_RESULT($use_gcov)
  5829. AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
  5830. AX_COUNT_CPUS
  5831. AC_SUBST([MHD_REAL_CPU_COUNT],[${CPU_COUNT}])
  5832. AM_SUBST_NOTMAKE([MHD_REAL_CPU_COUNT])
  5833. AC_MSG_CHECKING([for number of CPU cores to use in tests])
  5834. AS_VAR_IF([use_heavy_tests], ["yes"],
  5835. [
  5836. # Enable usage of many core if heavy tests are enabled
  5837. AS_IF([[test "$CPU_COUNT" -gt "32"]], [[CPU_COUNT="32"]])dnl Limit resource usage
  5838. ],
  5839. [
  5840. # Limit usage to just a few cores if heavy tests are not enabled
  5841. AS_IF([[test "$CPU_COUNT" -gt "6"]], [[CPU_COUNT="6"]])
  5842. AS_IF([[test "$CPU_COUNT" -lt "2"]], [[CPU_COUNT="2"]])
  5843. ]
  5844. )
  5845. AC_MSG_RESULT([$CPU_COUNT])
  5846. AC_ARG_ENABLE([[asserts]],
  5847. [AS_HELP_STRING([[--enable-asserts]],
  5848. [enable test build with debug asserts])],
  5849. [],
  5850. [enable_asserts='auto']
  5851. )
  5852. AS_UNSET([use_asserts_MSG])
  5853. AC_CACHE_CHECK([[whether NDEBUG macro is defined]], [mhd_cv_macro_ndebug_def],
  5854. [
  5855. AC_LINK_IFELSE(
  5856. [
  5857. AC_LANG_SOURCE([[
  5858. #ifndef NDEBUG
  5859. #error NDEBUG is NOT defined
  5860. chome me now
  5861. #endif
  5862. int main(void)
  5863. {
  5864. return 0;
  5865. }
  5866. ]]
  5867. )
  5868. ],
  5869. [[mhd_cv_macro_ndebug_def='yes']],
  5870. [[mhd_cv_macro_ndebug_def='no']]
  5871. )
  5872. ]
  5873. )
  5874. AS_VAR_IF([enable_asserts],["yes"],
  5875. [
  5876. AS_VAR_IF([mhd_cv_macro_ndebug_def],["yes"],
  5877. [
  5878. AC_MSG_FAILURE([Parameter --enable-asserts is specified, but NDEBUG macro is defined as well])
  5879. ]
  5880. )
  5881. use_asserts_MSG="yes, enabled by configure parameter"
  5882. ]
  5883. )
  5884. AC_CACHE_CHECK([[whether _DEBUG macro is defined]], [mhd_cv_macro__debug_def],
  5885. [
  5886. AC_LINK_IFELSE(
  5887. [
  5888. AC_LANG_SOURCE([[
  5889. #ifndef _DEBUG
  5890. #error _DEBUG is NOT defined
  5891. chome me now
  5892. #endif
  5893. int main(void)
  5894. {
  5895. return 0;
  5896. }
  5897. ]]
  5898. )
  5899. ],
  5900. [[mhd_cv_macro__debug_def='yes']],
  5901. [[mhd_cv_macro__debug_def='no']]
  5902. )
  5903. ]
  5904. )
  5905. AS_VAR_IF([enable_asserts],["no"],
  5906. [
  5907. AS_VAR_IF([mhd_cv_macro__debug_def],["yes"],
  5908. [
  5909. AC_MSG_FAILURE([Parameter --disable-asserts is specified, but _DEBUG macro is defined as well])
  5910. ]
  5911. )
  5912. use_asserts_MSG="no, set by configure parameter"
  5913. ]
  5914. )
  5915. AS_IF([test "x${mhd_cv_macro_ndebug_def}" = "xyes" && test "x${mhd_cv_macro__debug_def}" = "xyes"],
  5916. [AC_MSG_FAILURE([Both NDEBUG and _DEBUG macros are defined])]
  5917. )
  5918. AS_VAR_IF([enable_asserts],["auto"],
  5919. [
  5920. AS_VAR_IF([mhd_cv_macro_ndebug_def],["yes"],
  5921. [
  5922. enable_asserts="no"
  5923. use_asserts_MSG="no, set by NDEBUG preprocessor macro"
  5924. ]
  5925. )
  5926. ]
  5927. )
  5928. AS_VAR_IF([enable_asserts],["auto"],
  5929. [
  5930. AS_VAR_IF([mhd_cv_macro__debug_def],["yes"],
  5931. [
  5932. enable_asserts="yes"
  5933. use_asserts_MSG="yes, enabled by _DEBUG preprocessor macro"
  5934. ]
  5935. )
  5936. ]
  5937. )
  5938. AS_VAR_IF([enable_asserts],["auto"],
  5939. [
  5940. AC_CACHE_CHECK([[whether DEBUG macro is defined]], [mhd_cv_macro_debug_def],
  5941. [
  5942. AC_LINK_IFELSE(
  5943. [
  5944. AC_LANG_SOURCE([[
  5945. #ifndef DEBUG
  5946. #error DEBUG is NOT defined
  5947. chome me now
  5948. #endif
  5949. int main(void)
  5950. {
  5951. return 0;
  5952. }
  5953. ]]
  5954. )
  5955. ],
  5956. [[mhd_cv_macro_debug_def='yes']],
  5957. [[mhd_cv_macro_debug_def='no']]
  5958. )
  5959. ]
  5960. )
  5961. AS_VAR_IF([mhd_cv_macro_debug_def],["yes"],
  5962. [
  5963. enable_asserts="yes"
  5964. use_asserts_MSG="yes, enabled by DEBUG preprocessor macro"
  5965. ]
  5966. )
  5967. ]
  5968. )
  5969. AC_MSG_CHECKING([[whether to enable debug asserts]])
  5970. AS_VAR_IF([enable_asserts],["auto"],
  5971. [
  5972. AS_CASE([${enable_build_type}],
  5973. [debug|debugger],
  5974. [
  5975. enable_asserts="yes"
  5976. use_asserts_MSG="yes, enabled by --enable-bulid-type=${enable_build_type}"
  5977. ],
  5978. [
  5979. enable_asserts="no"
  5980. use_asserts_MSG="no"
  5981. ]
  5982. )
  5983. ]
  5984. )
  5985. AS_CASE([[$enable_asserts]], [[yes]], [[:]], [[no]], [[:]], [[enable_asserts='no']])
  5986. AC_MSG_RESULT([[${use_asserts_MSG=no}]])
  5987. AS_VAR_IF([[enable_asserts]], [["yes"]],
  5988. [
  5989. AS_VAR_IF([[mhd_cv_macro__debug_def]], [["yes"]], [:],
  5990. [
  5991. MHD_PREPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-D_DEBUG=1])
  5992. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  5993. ]
  5994. )
  5995. AC_CACHE_CHECK([[whether system assert() is available]], [mhd_cv_sys_assert_avail],
  5996. [
  5997. AC_LINK_IFELSE(
  5998. [
  5999. AC_LANG_SOURCE([[
  6000. #include <assert.h>
  6001. static int pos_val(void) {return 5;}
  6002. static int neg_val(void) {return -5;}
  6003. int main(void)
  6004. {
  6005. int pos_var = pos_val(), neg_var = neg_val();
  6006. assert(neg_var > pos_var); /* Must trigger assert. */
  6007. return pos_var + neg_var;
  6008. }
  6009. ]])
  6010. ],
  6011. [[mhd_cv_sys_assert_avail='yes']],
  6012. [[mhd_cv_sys_assert_avail='no']]
  6013. )
  6014. ]
  6015. )
  6016. AS_VAR_IF([[mhd_cv_sys_assert_avail]], [["no"]], [],
  6017. [AC_DEFINE([[HAVE_ASSERT]], [[1]], [Define if you have usable assert() and assert.h])])
  6018. ],
  6019. [
  6020. AS_VAR_IF([[mhd_cv_macro_ndebug_def]], [["yes"]], [:],
  6021. [
  6022. MHD_PREPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DNDEBUG=1])
  6023. CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
  6024. ]
  6025. )
  6026. ]
  6027. )
  6028. AS_UNSET([enabled_sanitizers])
  6029. TESTS_ENVIRONMENT_ac=""
  6030. AM_ASAN_OPTIONS=""
  6031. AM_UBSAN_OPTIONS=""
  6032. AM_LSAN_OPTIONS=""
  6033. AS_UNSET([ASAN_OPTIONS])
  6034. AS_UNSET([UBSAN_OPTIONS])
  6035. AS_UNSET([LSAN_OPTIONS])
  6036. AC_MSG_CHECKING([whether to enable run-time sanitizers])
  6037. AC_ARG_ENABLE([sanitizers],
  6038. [AS_HELP_STRING([[--enable-sanitizers[=address,undefined,leak,user-poison]]],
  6039. [enable run-time sanitizers, specify the list of types of sanitizers to enable, ]
  6040. [leave the list empty (or set to "auto") to enable all supported and available ]
  6041. [sanitizers, or specify "auto-fallback" to use sanitizers even without ]
  6042. [installed sanitizer run-time library])],
  6043. [], [AS_CASE([${enable_build_type}],[debug],
  6044. [enable_sanitizers='auto-optional'],[enable_sanitizers='no'])]
  6045. )
  6046. AS_IF([test "x${enable_sanitizers}" = "x"], [enable_sanitizers="auto"])
  6047. AS_VAR_IF([enable_sanitizers], ["yes"], [enable_sanitizers="auto"])
  6048. AS_VAR_IF([enable_sanitizers], ["autofallback"], [enable_sanitizers="auto-fallback"])
  6049. AS_VAR_IF([enable_sanitizers], ["autooptional"], [enable_sanitizers="auto-optional"])
  6050. AS_IF([test "x${enable_sanitizers}" = "xno"],
  6051. [
  6052. enable_sanitizers="no"
  6053. enable_san_address="no"
  6054. enable_san_undef="no"
  6055. enable_san_leak="no"
  6056. enable_san_upoison="no"
  6057. ],
  6058. [test "x${enable_sanitizers}" = "xauto" || test "x${enable_sanitizers}" = "xauto-optional"],
  6059. [
  6060. AS_VAR_IF([enable_compiler_hardening],["yes"],
  6061. [
  6062. AS_VAR_IF([enable_sanitizers],["auto"],
  6063. [AC_MSG_ERROR([sanitizers cannot be enabled with compiler hardnening])],
  6064. [AC_MSG_WARN([sanitizers cannot be enabled with compiler hardnening])]
  6065. )
  6066. enable_sanitizers="no"
  6067. enable_san_address="no"
  6068. enable_san_undef="no"
  6069. enable_san_leak="no"
  6070. enable_san_upoison="no"
  6071. ],
  6072. [
  6073. enable_san_address="auto"
  6074. enable_san_undef="auto"
  6075. enable_san_leak="auto"
  6076. enable_san_upoison="auto"
  6077. ]
  6078. )
  6079. ],
  6080. [test "x${enable_sanitizers}" = "xauto-fallback"],
  6081. [
  6082. enable_san_address="auto"
  6083. enable_san_undef="auto-fallback"
  6084. enable_san_leak="auto"
  6085. enable_san_upoison="auto"
  6086. ],
  6087. [
  6088. AS_UNSET([san])
  6089. enable_san_address="no"
  6090. enable_san_undef="no"
  6091. enable_san_leak="no"
  6092. enable_san_upoison="no"
  6093. f][or san in `AS_ECHO([${enable_sanitizers}]) | tr ',' ' '`
  6094. do
  6095. AS_CASE([$san],
  6096. [address], [enable_san_address="yes"],
  6097. [undefined], [enable_san_undef="yes"],
  6098. [leak], [enable_san_leak="yes"],
  6099. [user-poison|user_poison], [enable_san_upoison="yes"],
  6100. [no|yes|auto|auto-fallback|autofallback], [AC_MSG_ERROR(["$san" cannot be used with other options for --enable-sanitizers=])],
  6101. [AC_MSG_ERROR([Unknown parameter "$san" for --enable-sanitizers=])]
  6102. )
  6103. done
  6104. AS_IF([test "x${enable_san_upoison}" = "xyes" && test "x${enable_san_address}" = "xno"],
  6105. [AC_MSG_ERROR([User memory poisoning cannot be used without address sanitizer])]
  6106. )
  6107. enable_sanitizers="selected"
  6108. ]
  6109. )
  6110. AS_CASE([${enable_sanitizers}],
  6111. [selected], [AC_MSG_RESULT([selected])],
  6112. [auto], [AC_MSG_RESULT([yes, detect and use supported sanitizers])],
  6113. [auto-fallback], [AC_MSG_RESULT([yes, detect and use supported sanitizers even without run-time lib])],
  6114. [auto-optional], [AC_MSG_RESULT([yes, detect and use supported sanitizers if any])],
  6115. [AC_MSG_RESULT([no])]
  6116. )
  6117. AS_VAR_IF([enable_sanitizers], ["no"], [:],
  6118. [
  6119. AS_UNSET([san_FLAGS]) # the sanitizer flags to be added to both CFLAGS and LDFLAGS
  6120. AS_UNSET([san_CFLAGS]) # the sanitizer flags to be added to CFLAGS
  6121. AC_CACHE_CHECK([whether '-fsanitize=' works for $CC],
  6122. [mhd_cv_cc_sanitizer_works],
  6123. [
  6124. CFLAGS="${CFLAGS_ac} -fsanitize=wrongFeatureName ${user_CFLAGS}"
  6125. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
  6126. [mhd_cv_cc_sanitizer_works=no], [mhd_cv_cc_sanitizer_works=yes])
  6127. ]
  6128. )
  6129. AS_VAR_IF([mhd_cv_cc_sanitizer_works], ["yes"],
  6130. [
  6131. AS_VAR_IF([enable_san_address], ["no"], [:],
  6132. [
  6133. AC_CACHE_CHECK([for address sanitizer], [mhd_cv_cc_sanitizer_address],
  6134. [
  6135. CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=address ${user_CFLAGS}"
  6136. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
  6137. [mhd_cv_cc_sanitizer_address=yes], [mhd_cv_cc_sanitizer_address=no])
  6138. ]
  6139. )
  6140. AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"],
  6141. [
  6142. AC_DEFINE([MHD_ASAN_ACTIVE], [1], [Define to '1' if you have address sanitizer enabled])
  6143. AX_APPEND_FLAG([-fsanitize=address], [san_FLAGS])
  6144. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }address"
  6145. AS_VAR_IF([enable_san_leak], ["no"], [:],
  6146. [
  6147. AC_CACHE_CHECK([whether leak detect is not rejected by address sanitizer], [mhd_cv_cc_sanitizer_address_leak],
  6148. [
  6149. CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${user_CFLAGS}"
  6150. ASAN_OPTIONS="exitcode=88:detect_leaks=1:halt_on_error=1"
  6151. export ASAN_OPTIONS
  6152. AC_RUN_IFELSE([AC_LANG_PROGRAM([],[])],
  6153. [mhd_cv_cc_sanitizer_address_leak=yes], [mhd_cv_cc_sanitizer_address_leak=no],
  6154. [
  6155. # Cross-compiling with sanitizers?
  6156. mhd_cv_cc_sanitizer_address_leak='assuming no'
  6157. ]
  6158. )
  6159. AS_UNSET([ASAN_OPTIONS])
  6160. ]
  6161. )
  6162. ]
  6163. )
  6164. AC_CACHE_CHECK([for pointer compare sanitizer], [mhd_cv_cc_sanitizer_pointer_compare],
  6165. [
  6166. CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-compare ${user_CFLAGS}"
  6167. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
  6168. [mhd_cv_cc_sanitizer_pointer_compare=yes], [mhd_cv_cc_sanitizer_pointer_compare=no])
  6169. ]
  6170. )
  6171. AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_compare],["yes"],
  6172. [
  6173. AX_APPEND_FLAG([-fsanitize=pointer-compare], [san_FLAGS])
  6174. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer compare"
  6175. ]
  6176. )
  6177. AC_CACHE_CHECK([for pointer subtract sanitizer], [mhd_cv_cc_sanitizer_pointer_subtract],
  6178. [
  6179. CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-subtract ${user_CFLAGS}"
  6180. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
  6181. [mhd_cv_cc_sanitizer_pointer_subtract=yes], [mhd_cv_cc_sanitizer_pointer_subtract=no])
  6182. ]
  6183. )
  6184. AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_subtract],["yes"],
  6185. [
  6186. AX_APPEND_FLAG([-fsanitize=pointer-subtract], [san_FLAGS])
  6187. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer subtract"
  6188. ]
  6189. )
  6190. AS_VAR_IF([enable_san_upoison], ["no"], [:],
  6191. [
  6192. AC_CHECK_HEADERS([sanitizer/asan_interface.h], [], [], [AC_INCLUDES_DEFAULT])
  6193. AS_VAR_IF([ac_cv_header_sanitizer_asan_interface_h],["yes"],
  6194. [
  6195. CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}"
  6196. MHD_CHECK_FUNC([__asan_address_is_poisoned],[[#include <sanitizer/asan_interface.h>]],
  6197. [[int a_var=1; i][f(__asan_address_is_poisoned((void*) &a_var)) return 3;]]
  6198. )
  6199. MHD_CHECK_FUNC([__asan_region_is_poisoned],[[#include <sanitizer/asan_interface.h>]],
  6200. [[int a_var=1; i][f(((void*) 0) != __asan_region_is_poisoned((void*) &a_var, sizeof(a_var))) return 3;]]
  6201. )
  6202. AC_CACHE_CHECK([whether special function attribute is needed for user-poison], [mhd_cv_func_u_p_attribute_needed],
  6203. [
  6204. ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1"
  6205. export ASAN_OPTIONS
  6206. CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}"
  6207. AC_RUN_IFELSE(
  6208. [
  6209. AC_LANG_SOURCE(
  6210. [[
  6211. #include <stdint.h>
  6212. #include <stdlib.h>
  6213. #include <sanitizer/asan_interface.h>
  6214. static const size_t first_pos = 0;
  6215. static const size_t mid_pos = 64;
  6216. static const size_t last_pos = 128;
  6217. static const size_t zone_size = 16;
  6218. static const size_t buf_size = 128 + 16;
  6219. static int ptr_compare(void *ptr1, uint8_t *ptr2)
  6220. {
  6221. if ((((uintptr_t) (uint8_t *)ptr1) >= ((uintptr_t)ptr2)))
  6222. return ((char *) ptr1)[0] < ((char *) ptr2)[0];
  6223. return ((char *) ptr1)[0] > ((char *) ptr2)[0];
  6224. }
  6225. static int ptr_subtract(void *ptr1, uint8_t *ptr2)
  6226. {
  6227. return ((size_t)(((uintptr_t)(uint8_t*)ptr1) - ((uintptr_t)ptr2))) <= last_pos;
  6228. }
  6229. int main(int argc, char *argv[])
  6230. {
  6231. char *buf = (char*) malloc (buf_size);
  6232. char *a;
  6233. char *b;
  6234. int ret;
  6235. (void) argv;
  6236. if (NULL == buf)
  6237. return 10;
  6238. ASAN_POISON_MEMORY_REGION (buf + first_pos + zone_size, mid_pos - first_pos - zone_size);
  6239. ASAN_POISON_MEMORY_REGION (buf + mid_pos + zone_size, last_pos - mid_pos - zone_size);
  6240. if (0 < argc)
  6241. a = buf + last_pos;
  6242. else
  6243. a = buf + first_pos;
  6244. b = buf + mid_pos;
  6245. *a = '0';
  6246. *b = '9';
  6247. if (ptr_compare((void *)a, (uint8_t*) b))
  6248. {
  6249. if (ptr_subtract((void *)a, (uint8_t*) b))
  6250. ret = 0;
  6251. else
  6252. ret = 10;
  6253. }
  6254. else
  6255. ret = 5;
  6256. ASAN_UNPOISON_MEMORY_REGION (buf, buf_size);
  6257. free (buf);
  6258. return ret;
  6259. }
  6260. ]]
  6261. )
  6262. ],
  6263. [mhd_cv_func_u_p_attribute_needed="no"], [mhd_cv_func_u_p_attribute_needed="yes"],
  6264. [
  6265. # Cross-compiling with sanitizers??
  6266. mhd_cv_func_up_attribute_needed='assuming no'
  6267. ]
  6268. )
  6269. AS_UNSET([ASAN_OPTIONS])
  6270. ]
  6271. )
  6272. ]
  6273. )
  6274. AS_VAR_IF([mhd_cv_func_u_p_attribute_needed],["yes"],[:],
  6275. [
  6276. AC_DEFINE([FUNC_PTRCOMPARE_CAST_WORKAROUND_WORKS],[1],[Define to '1' if cast to 'uintptr_t' works for safely processing user-poisoned pointer])
  6277. ]
  6278. )
  6279. AS_IF([test "x${mhd_cv_func_u_p_attribute_needed}" = "xyes" && test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes"],
  6280. [
  6281. AC_CACHE_CHECK([whether '__attribute__((no_sanitize("pointer-compare")))' and '__attribute__((no_sanitize("pointer-subtract")))' work],
  6282. [mhd_cv_func_attribute_nosanitize_ptr],
  6283. [
  6284. ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1"
  6285. export ASAN_OPTIONS
  6286. CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}"
  6287. AC_RUN_IFELSE(
  6288. [
  6289. AC_LANG_SOURCE(
  6290. [[
  6291. #include <stdint.h>
  6292. #include <stdlib.h>
  6293. #include <sanitizer/asan_interface.h>
  6294. static const size_t first_pos = 0;
  6295. static const size_t mid_pos = 64;
  6296. static const size_t last_pos = 128;
  6297. static const size_t zone_size = 16;
  6298. static const size_t buf_size = 128 + 16;
  6299. __attribute__((no_sanitize("pointer-compare")))
  6300. static int ptr_compare(void *ptr1, uint8_t *ptr2)
  6301. {
  6302. if ((((const uint8_t*)ptr1) >= ((const uint8_t*)ptr2)))
  6303. return ((char *) ptr1)[0] < ((char *) ptr2)[0];
  6304. return ((char *) ptr1)[0] > ((char *) ptr2)[0];
  6305. }
  6306. __attribute__((no_sanitize("pointer-subtract")))
  6307. static int ptr_subtract(void *ptr1, uint8_t *ptr2)
  6308. {
  6309. return ((size_t)(((const uint8_t*)ptr1) - \
  6310. ((const uint8_t*)ptr2))) <= last_pos;
  6311. }
  6312. int main(int argc, char *argv[])
  6313. {
  6314. char *buf = (char*) malloc (buf_size);
  6315. char *a;
  6316. char *b;
  6317. int ret;
  6318. (void) argv;
  6319. if (NULL == buf)
  6320. return 10;
  6321. ASAN_POISON_MEMORY_REGION (buf + first_pos + zone_size, mid_pos - first_pos - zone_size);
  6322. ASAN_POISON_MEMORY_REGION (buf + mid_pos + zone_size, last_pos - mid_pos - zone_size);
  6323. if (0 < argc)
  6324. a = buf + last_pos;
  6325. else
  6326. a = buf + first_pos;
  6327. b = buf + mid_pos;
  6328. *a = '0';
  6329. *b = '9';
  6330. if (ptr_compare((void *)a, (uint8_t*) b))
  6331. {
  6332. if (ptr_subtract((void *)a, (uint8_t*) b))
  6333. ret = 0;
  6334. else
  6335. ret = 10;
  6336. }
  6337. else
  6338. ret = 5;
  6339. ASAN_UNPOISON_MEMORY_REGION (buf, buf_size);
  6340. free (buf);
  6341. return ret;
  6342. }
  6343. ]]
  6344. )
  6345. ],
  6346. [mhd_cv_func_attribute_nosanitize_ptr=yes], [mhd_cv_func_attribute_nosanitize_ptr=no],
  6347. [
  6348. # Cross-compiling with sanitizers??
  6349. mhd_cv_func_attribute_nosanitize_ptr='assuming no'
  6350. ]
  6351. )
  6352. AS_UNSET([ASAN_OPTIONS])
  6353. ]
  6354. )
  6355. AS_VAR_IF([mhd_cv_func_attribute_nosanitize_ptr], ["yes"],
  6356. [
  6357. AC_DEFINE([FUNC_ATTR_PTRCOMPARE_WORKS],[1],[Define to '1' if '__attribute__((no_sanitize("pointer-compare")))' works])
  6358. AC_DEFINE([FUNC_ATTR_PTRSUBTRACT_WORKS],[1],[Define to '1' if '__attribute__((no_sanitize("pointer-subtract")))' works])
  6359. ],
  6360. [
  6361. AC_CACHE_CHECK([whether '__attribute__((no_sanitize("address")))' works for pointers compare], [mhd_cv_func_attribute_nosanitize_addr],
  6362. [
  6363. ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1"
  6364. export ASAN_OPTIONS
  6365. CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}"
  6366. AC_RUN_IFELSE(
  6367. [
  6368. AC_LANG_SOURCE(
  6369. [[
  6370. #include <stdint.h>
  6371. #include <stdlib.h>
  6372. #include <sanitizer/asan_interface.h>
  6373. static const size_t first_pos = 0;
  6374. static const size_t mid_pos = 64;
  6375. static const size_t last_pos = 128;
  6376. static const size_t zone_size = 16;
  6377. static const size_t buf_size = 128 + 16;
  6378. __attribute__((no_sanitize("address")))
  6379. static int ptr_compare(void *ptr1, uint8_t *ptr2)
  6380. {
  6381. if ((((const uint8_t*)ptr1) >= ((const uint8_t*)ptr2)))
  6382. return ((char *) ptr1)[0] < ((char *) ptr2)[0];
  6383. return ((char *) ptr1)[0] > ((char *) ptr2)[0];
  6384. }
  6385. __attribute__((no_sanitize("address")))
  6386. static int ptr_subtract(void *ptr1, uint8_t *ptr2)
  6387. {
  6388. return ((size_t)(((const uint8_t*)ptr1) - \
  6389. ((const uint8_t*)ptr2))) <= last_pos;
  6390. }
  6391. int main(int argc, char *argv[])
  6392. {
  6393. char *buf = (char*) malloc (buf_size);
  6394. char *a;
  6395. char *b;
  6396. int ret;
  6397. (void) argv;
  6398. if (NULL == buf)
  6399. return 10;
  6400. ASAN_POISON_MEMORY_REGION (buf + first_pos + zone_size, mid_pos - first_pos - zone_size);
  6401. ASAN_POISON_MEMORY_REGION (buf + mid_pos + zone_size, last_pos - mid_pos - zone_size);
  6402. if (0 < argc)
  6403. a = buf + last_pos;
  6404. else
  6405. a = buf + first_pos;
  6406. b = buf + mid_pos;
  6407. *a = '0';
  6408. *b = '9';
  6409. if (ptr_compare((void *)a, (uint8_t*) b))
  6410. {
  6411. if (ptr_subtract((void *)a, (uint8_t*) b))
  6412. ret = 0;
  6413. else
  6414. ret = 10;
  6415. }
  6416. else
  6417. ret = 5;
  6418. ASAN_UNPOISON_MEMORY_REGION (buf, buf_size);
  6419. free (buf);
  6420. return ret;
  6421. }
  6422. ]]
  6423. )
  6424. ],
  6425. [mhd_cv_func_attribute_nosanitize_addr=yes], [mhd_cv_func_attribute_nosanitize_addr=no],
  6426. [
  6427. # Cross-compiling with sanitizers??
  6428. mhd_cv_func_attribute_nosanitize_addr='assuming no'
  6429. ]
  6430. )
  6431. AS_UNSET([ASAN_OPTIONS])
  6432. ]
  6433. )
  6434. AS_VAR_IF([mhd_cv_func_attribute_nosanitize_addr], ["yes"],
  6435. [AC_DEFINE([FUNC_ATTR_NOSANITIZE_WORKS],[1],[Define to '1' if '__attribute__((no_sanitize("address")))' works for pointers compare])]
  6436. )
  6437. ]
  6438. )
  6439. ]
  6440. )
  6441. ]
  6442. )
  6443. ]
  6444. )
  6445. AS_IF([test "x${enable_san_address}" = "xyes" && test "x${mhd_cv_cc_sanitizer_address}" != "xyes"],
  6446. [AC_MSG_ERROR([Address sanitizer cannot be enabled])]
  6447. )
  6448. enable_san_address="${mhd_cv_cc_sanitizer_address}"
  6449. ]
  6450. )
  6451. AS_VAR_IF([enable_san_undef], ["no"], [:],
  6452. [
  6453. dnl Ensure that '#' will be processed correctly
  6454. [
  6455. test_undf_prog='
  6456. #include <stdio.h>
  6457. static void func_out_b(char *arr)
  6458. {
  6459. arr[0] = 0;
  6460. arr[16] = 2;
  6461. }
  6462. static unsigned int int_deref(void *ptr)
  6463. {
  6464. return (*((unsigned int*)ptr)) + 2;
  6465. }
  6466. static int func1(void)
  6467. {
  6468. char chr[16];
  6469. func_out_b (chr);
  6470. return (int) (int_deref(chr + 1) + int_deref(chr + 2));
  6471. }
  6472. int main(void)
  6473. {
  6474. unsigned long ulvar;
  6475. signed char ch1;
  6476. ulvar = -1 * func1();
  6477. ch1 = ulvar * 6UL;
  6478. printf("%lu\n", ulvar + ch1);
  6479. return 0;
  6480. }
  6481. '
  6482. ]
  6483. AC_CACHE_CHECK([for undefined behavior sanitizer], [mhd_cv_cc_sanitizer_undefined],
  6484. [
  6485. CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined ${user_CFLAGS}"
  6486. AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])],
  6487. [mhd_cv_cc_sanitizer_undefined=yes], [mhd_cv_cc_sanitizer_undefined=no])
  6488. ]
  6489. )
  6490. AS_VAR_IF([mhd_cv_cc_sanitizer_undefined],["yes"],
  6491. [
  6492. AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS])
  6493. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
  6494. ],
  6495. [
  6496. AS_CASE([${enable_san_undef}], [yes|auto-fallback],
  6497. [
  6498. AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-undefined-trap-on-error'], [mhd_cv_cc_sanitizer_undefined_trap],
  6499. [
  6500. CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-undefined-trap-on-error ${user_CFLAGS}"
  6501. AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])],
  6502. [mhd_cv_cc_sanitizer_undefined_trap=yes], [mhd_cv_cc_sanitizer_undefined_trap=no])
  6503. ]
  6504. )
  6505. AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap], ["yes"],
  6506. [
  6507. AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS])
  6508. AX_APPEND_FLAG([-fsanitize-undefined-trap-on-error], [san_FLAGS])
  6509. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
  6510. AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited])
  6511. ],
  6512. [
  6513. AS_IF([test -z "${enabled_sanitizers}"],
  6514. [
  6515. # Last resort
  6516. AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-trap=all'], [mhd_cv_cc_sanitizer_undefined_trap_all],
  6517. [
  6518. CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all ${user_CFLAGS}"
  6519. AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])],
  6520. [mhd_cv_cc_sanitizer_undefined_trap_all=yes], [mhd_cv_cc_sanitizer_undefined_trap_all=no])
  6521. ]
  6522. )
  6523. AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap_all],["yes"],
  6524. [
  6525. AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS])
  6526. AX_APPEND_FLAG([-fsanitize-trap=all], [san_FLAGS])
  6527. CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all ${user_CFLAGS}"
  6528. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
  6529. AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited])
  6530. ]
  6531. )
  6532. ]
  6533. )
  6534. ]
  6535. )
  6536. AS_CASE(["$enabled_sanitizers"], [*undefined],
  6537. [
  6538. AS_VAR_IF([mhd_cv_cc_sanitizer_undefined], ["yes"],[],
  6539. [
  6540. # A workaround for broken clang which is trying to use UBSan lib
  6541. # even when instructed to not use it
  6542. CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}"
  6543. AX_APPEND_LINK_FLAGS([-fsanitize-trap=implicit-conversion],
  6544. [san_FLAGS], [], [AC_LANG_SOURCE([${test_undf_prog}])])
  6545. ]
  6546. )
  6547. ]
  6548. )
  6549. ]
  6550. )
  6551. ]
  6552. )
  6553. AS_CASE(["$enabled_sanitizers"], [*undefined],
  6554. [
  6555. CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}"
  6556. AX_APPEND_LINK_FLAGS([-fsanitize=bounds-strict -fsanitize=local-bounds -fsanitize=implicit-conversion -fsanitize=nullability-arg],
  6557. [san_CFLAGS], [], [AC_LANG_SOURCE([${test_undf_prog}])])
  6558. ]
  6559. )
  6560. AS_UNSET([test_undf_prog])
  6561. AS_CASE(["$enabled_sanitizers"],
  6562. [*undefined], [enable_san_undef="yes"],
  6563. [
  6564. AS_VAR_IF([enable_san_undef], [yes], [AC_MSG_ERROR([Undefined behavior sanitizer cannot be enabled])])
  6565. enable_san_undef="no"
  6566. ]
  6567. )
  6568. ]
  6569. )
  6570. AS_VAR_IF([enable_san_leak], ["no"], [:],
  6571. [
  6572. AC_CACHE_CHECK([for leak sanitizer], [mhd_cv_cc_sanitizer_leak],
  6573. [
  6574. CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=leak ${user_CFLAGS}"
  6575. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
  6576. [mhd_cv_cc_sanitizer_leak=yes], [mhd_cv_cc_sanitizer_leak=no])
  6577. ]
  6578. )
  6579. AS_VAR_IF([mhd_cv_cc_sanitizer_leak],["yes"],
  6580. [
  6581. AX_APPEND_FLAG([-fsanitize=leak], [san_FLAGS])
  6582. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }leak"
  6583. ]
  6584. )
  6585. AS_IF([test "x${enable_san_leak}" = "xyes" && test "x${mhd_cv_cc_sanitizer_leak}" != "xyes"],
  6586. [AC_MSG_ERROR([User poison cannot be enabled])]
  6587. )
  6588. enable_san_leak="${mhd_cv_cc_sanitizer_leak}"
  6589. ]
  6590. )
  6591. AS_IF([test -z "${enabled_sanitizers}"],
  6592. [
  6593. AS_VAR_IF([enable_sanitizers], ["auto-optional"],
  6594. [
  6595. san_FLAGS=""
  6596. san_CFLAGS=""
  6597. ],
  6598. [
  6599. AC_MSG_ERROR([cannot find any sanitizer supported by $CC])
  6600. ]
  6601. )
  6602. ],
  6603. [
  6604. AS_VAR_IF([enable_san_upoison], ["no"], [:],
  6605. [
  6606. AC_MSG_CHECKING([whether to enable user memory poisoning])
  6607. AS_IF([test "x${mhd_cv_cc_sanitizer_address}" = "xyes" && test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes" && \
  6608. (test "x${mhd_cv_func_u_p_attribute_needed}" != "xyes" || test "x${mhd_cv_func_attribute_nosanitize_ptr}" = "xyes" || \
  6609. test "x${mhd_cv_func_attribute_nosanitize_addr}" = "xyes")],
  6610. [
  6611. AC_DEFINE([MHD_ASAN_POISON_ACTIVE], [1], [Define to '1' if user memory poison is used])
  6612. enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }user-poison"
  6613. enable_san_upoison="yes"
  6614. AC_MSG_RESULT([yes])
  6615. ],
  6616. [
  6617. AC_MSG_RESULT([no])
  6618. AS_VAR_IF([enable_san_upoison], ["yes"],
  6619. [AC_MSG_ERROR([User memory poisoning cannot be enabled])])
  6620. enable_san_upoison="no"
  6621. ]
  6622. )
  6623. ]
  6624. )
  6625. AS_VAR_IF([enable_san_address], ["yes"],
  6626. [
  6627. CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}"
  6628. AC_CHECK_DECL([_FORTIFY_SOURCE],
  6629. [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-U_FORTIFY_SOURCE])],
  6630. [],[/* no includes */])
  6631. AX_APPEND_FLAG([-D_FORTIFY_SOURCE=0], [san_CFLAGS])
  6632. ],
  6633. [
  6634. AS_CASE([$enable_sanitizers], [auto|auto-fallback],
  6635. [AC_MSG_WARN([$CC does not support address sanitizer])])
  6636. ]
  6637. )
  6638. CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}"
  6639. # Always stop on sanitizer error
  6640. AX_APPEND_COMPILE_FLAGS([-fno-sanitize-recover=all], [san_CFLAGS])
  6641. # Get a better output for sanitizers error reporting
  6642. AX_APPEND_COMPILE_FLAGS([-fno-omit-frame-pointer -fno-optimize-sibling-calls],
  6643. [san_CFLAGS])
  6644. AS_VAR_IF([enable_san_address], ["yes"],
  6645. [
  6646. AM_ASAN_OPTIONS="exitcode=88:strict_string_checks=1:detect_stack_use_after_return=1"
  6647. AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:check_initialization_order=1:strict_init_order=1:redzone=64"
  6648. AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:max_free_fill_size=1024:detect_invalid_pointer_pairs=3"
  6649. AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:handle_ioctl=1:halt_on_error=1"
  6650. AS_VAR_IF([enable_san_upoison], ["yes"], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:allow_user_poisoning=1"])
  6651. AS_VAR_IF([enable_san_leak], ["yes"],
  6652. [AS_VAR_IF([mhd_cv_cc_sanitizer_address_leak], ["yes"],
  6653. [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=1"])
  6654. ], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=0"]
  6655. )
  6656. ]
  6657. )
  6658. AS_VAR_IF([enable_san_undef], [yes],
  6659. [AM_UBSAN_OPTIONS="exitcode=87:print_stacktrace=1:halt_on_error=1"])
  6660. AS_VAR_IF([enable_san_leak], ["yes"],
  6661. [AM_LSAN_OPTIONS="use_unaligned=1"]
  6662. )
  6663. TESTS_ENVIRONMENT_ac='\
  6664. ASAN_OPTIONS="$(AM_ASAN_OPTIONS)" ; export ASAN_OPTIONS ; \
  6665. UBSAN_OPTIONS="$(AM_UBSAN_OPTIONS)" ; export UBSAN_OPTIONS ; \
  6666. LSAN_OPTIONS="$(AM_LSAN_OPTIONS)" ; export LSAN_OPTIONS ;'
  6667. ]
  6668. )
  6669. ]
  6670. )
  6671. CFLAGS_ac="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS}"
  6672. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  6673. ]
  6674. )
  6675. # fuzzing tests
  6676. run_zzuf_tests="no"
  6677. zzuf_socat_mandatory="no"
  6678. AS_VAR_IF([use_heavy_tests],["yes"],
  6679. [
  6680. AS_VAR_IF([enable_curl],["yes"],
  6681. [
  6682. AC_PATH_PROG([ZZUF],[zzuf],[no])
  6683. AS_VAR_IF([ZZUF],["no"],
  6684. [
  6685. run_zzuf_tests="no"
  6686. run_zzuf_tests_MSG="no, zzuf tool not found"
  6687. ],
  6688. [
  6689. AC_PATH_PROG([SOCAT],[socat],[no])
  6690. AS_IF([test "x${ac_cv_func_accept4}" = "xyes" && test "x${enable_asserts}" = "xno"],
  6691. [
  6692. zzuf_socat_mandatory="yes"
  6693. AS_VAR_IF([SOCAT],["no"],
  6694. [run_zzuf_tests_MSG="no, socat not found, but required for fuzzing tests on this platform without asserts enabled"],
  6695. [
  6696. run_zzuf_tests="yes"
  6697. run_zzuf_tests_MSG="yes, with zzuf and socat tools"
  6698. ]
  6699. )
  6700. ],
  6701. [test -n "${enabled_sanitizers}"],
  6702. [
  6703. zzuf_socat_mandatory="yes"
  6704. AS_VAR_IF([SOCAT],["no"],
  6705. [run_zzuf_tests_MSG="no, socat not found, but required for fuzzing tests when sanitizers enabled"],
  6706. [
  6707. run_zzuf_tests="yes"
  6708. run_zzuf_tests_MSG="yes, with zzuf and socat tools"
  6709. ]
  6710. )
  6711. ],
  6712. [
  6713. run_zzuf_tests="yes"
  6714. run_zzuf_tests_MSG="yes, with zzuf tool"
  6715. ]
  6716. )
  6717. ]
  6718. )
  6719. ],
  6720. [
  6721. run_zzuf_tests="no"
  6722. run_zzuf_tests_MSG="no, tests with libcurl are not enabled"
  6723. ]
  6724. )
  6725. ],
  6726. [
  6727. run_zzuf_tests="no"
  6728. run_zzuf_tests_MSG="no, heavy tests are not enabled"
  6729. ]
  6730. )
  6731. AM_CONDITIONAL([RUN_ZZUF_TESTS],[test "x$run_zzuf_tests" = "xyes"])
  6732. AM_CONDITIONAL([FORCE_USE_ZZUF_SOCAT],[test "x$zzuf_socat_mandatory" = "xyes"])
  6733. # Final flags that may interfere with autoconf detections
  6734. AS_CASE([${enable_build_type}],[debug|debugger],
  6735. [ # Debug build or build for walking with debugger
  6736. CFLAGS="${user_CFLAGS}"
  6737. MHD_CHECK_ADD_CC_CFLAGS([-Wextra-semi -Wextra-semi-stmt], [CFLAGS_ac])
  6738. CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
  6739. ]
  6740. )
  6741. AM_CONDITIONAL([USE_SANITIZERS],
  6742. [test -n "$enabled_sanitizers" && test "x$mhd_cv_cc_sanitizer_works" = "xyes"])
  6743. AC_SUBST([AM_ASAN_OPTIONS])
  6744. AC_SUBST([AM_UBSAN_OPTIONS])
  6745. AC_SUBST([AM_LSAN_OPTIONS])
  6746. AC_SUBST([TESTS_ENVIRONMENT_ac])
  6747. MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS"
  6748. AC_SUBST([CPU_COUNT])
  6749. AC_SUBST([HEAVY_TESTS_NOTPARALLEL])
  6750. AM_SUBST_NOTMAKE([HEAVY_TESTS_NOTPARALLEL])
  6751. AC_SUBST(MHD_LIB_CPPFLAGS)
  6752. AC_SUBST(MHD_LIB_CFLAGS)
  6753. AC_SUBST(MHD_LIB_LDFLAGS)
  6754. AC_SUBST(MHD_LIBDEPS)
  6755. AC_SUBST(MHD_TLS_LIB_CPPFLAGS)
  6756. AC_SUBST(MHD_TLS_LIB_CFLAGS)
  6757. AC_SUBST(MHD_TLS_LIB_LDFLAGS)
  6758. AC_SUBST(MHD_TLS_LIBDEPS)
  6759. # for pkg-config
  6760. AC_SUBST([MHD_REQ_PRIVATE])
  6761. AC_SUBST([MHD_LIBDEPS_PKGCFG])
  6762. # Restore flags as set by the user
  6763. CFLAGS="${user_CFLAGS}"
  6764. LDFLAGS="${user_LDFLAGS}"
  6765. CPPFLAGS="${user_CPPFLAGS}"
  6766. AC_SUBST([CFLAGS])
  6767. AC_SUBST([LDFLAGS])
  6768. AC_SUBST([CPPFLAGS])
  6769. AC_SUBST([LIBS])
  6770. # Configure-defined flags
  6771. AC_SUBST([CFLAGS_ac])
  6772. AC_SUBST([LDFLAGS_ac])
  6773. AC_SUBST([CPPFLAGS_ac])
  6774. # Used for 'po' directory staff
  6775. AC_SUBST([ac_configure_args])
  6776. AC_SUBST([EMPTY_VAR],[])
  6777. AC_SUBST([MHD_AUX_DIR])
  6778. AC_CONFIG_FILES([po/po-configure.ac])
  6779. AC_CONFIG_COMMANDS([po/Makefile.in],
  6780. [
  6781. echo "Skipping update of po/Makefile.in"
  6782. echo "Real update of po/Makefile.in for 'make dist' is performed by po-config.status"
  6783. ]
  6784. )
  6785. AC_CONFIG_COMMANDS([po-directories],
  6786. [
  6787. echo "Skipping po-directories command."
  6788. echo "Real po-directories command for 'make dist' is implemented in po-config.status"
  6789. ]
  6790. )
  6791. # We define the paths here, because MinGW/GCC expands paths
  6792. # passed through the command line ("-DDIR=..."). This would
  6793. # lead to hard-coded paths ("C:\mingw\mingw\bin...") that do
  6794. # not contain the actual installation.
  6795. AC_DEFINE_DIR([MHD_PLUGIN_INSTALL_PREFIX], [libdir/libmicrohttpd], [tls plugins])
  6796. AC_SUBST([ZZUF])
  6797. AC_SUBST([SOCAT])
  6798. # should experimental code be compiled (code that may not yet compile)?
  6799. AC_MSG_CHECKING(whether to compile experimental code)
  6800. AC_ARG_ENABLE([experimental],
  6801. [AS_HELP_STRING([--enable-experimental], [enable compiling experimental code])],
  6802. [enable_experimental=${enableval}],
  6803. [enable_experimental=no])
  6804. AC_MSG_RESULT($enable_experimental)
  6805. AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
  6806. AC_CONFIG_FILES([libmicrohttpd.pc
  6807. w32/common/microhttpd_dll_res_vc.rc
  6808. Makefile
  6809. contrib/Makefile
  6810. doc/Makefile
  6811. doc/doxygen/libmicrohttpd.doxy
  6812. doc/doxygen/Makefile
  6813. doc/examples/Makefile
  6814. m4/Makefile
  6815. src/Makefile
  6816. src/incl_priv/Makefile
  6817. src/include/Makefile
  6818. src/mhd2/Makefile
  6819. src/tests/Makefile
  6820. src/tests/basic/Makefile
  6821. src/tests/client_server/Makefile
  6822. src/microhttpd_ws/Makefile
  6823. src/examples/Makefile
  6824. src/tools/Makefile
  6825. src/testcurl/Makefile
  6826. src/testcurl/https/Makefile
  6827. src/testzzuf/Makefile])
  6828. AC_OUTPUT
  6829. # Finally: summary
  6830. # Format flags without extra spaces for visual beauty
  6831. fin_CPPFLAGS="$user_CPPFLAGS"
  6832. fin_CFLAGS="$user_CFLAGS"
  6833. fin_LDFLAGS="$user_LDFLAGS"
  6834. MHD_PREPEND_FLAG_TO_VAR([fin_CPPFLAGS],[$CPPFLAGS_ac])
  6835. MHD_PREPEND_FLAG_TO_VAR([fin_CFLAGS],[$CFLAGS_ac])
  6836. MHD_PREPEND_FLAG_TO_VAR([fin_LDFLAGS],[$LDFLAGS_ac])
  6837. fin_lib_CPPFLAGS="$user_CPPFLAGS"
  6838. fin_lib_CFLAGS="$user_CFLAGS"
  6839. fin_lib_LDFLAGS="$user_LDFLAGS"
  6840. MHD_PREPEND_FLAG_TO_VAR([fin_lib_CPPFLAGS],[$MHD_LIB_CPPFLAGS])
  6841. MHD_PREPEND_FLAG_TO_VAR([fin_lib_CFLAGS],[$MHD_LIB_CFLAGS])
  6842. MHD_PREPEND_FLAG_TO_VAR([fin_lib_LDFLAGS],[$MHD_LIB_LDFLAGS])
  6843. MHD_PREPEND_FLAG_TO_VAR([fin_lib_CPPFLAGS],[$CPPFLAGS_ac])
  6844. MHD_PREPEND_FLAG_TO_VAR([fin_lib_CFLAGS],[$CFLAGS_ac])
  6845. MHD_PREPEND_FLAG_TO_VAR([fin_lib_LDFLAGS],[$LDFLAGS_ac])
  6846. AC_MSG_NOTICE([Toolchain settings:
  6847. CC=$CC
  6848. User/system/default flags:
  6849. CPPFLAGS="$user_CPPFLAGS"
  6850. CFLAGS= "$user_CFLAGS"
  6851. LDFLAGS= "$user_LDFLAGS"
  6852. Final set of the flags for tests and examples:
  6853. CPPFLAGS="$fin_CPPFLAGS"
  6854. CFLAGS= "$fin_CFLAGS"
  6855. LDFLAGS= "$fin_LDFLAGS"
  6856. Final set of the flags for ${PACKAGE_NAME} library:
  6857. CPPFLAGS="$fin_lib_CPPFLAGS"
  6858. CFLAGS= "$fin_lib_CFLAGS"
  6859. LDFLAGS= "$fin_lib_LDFLAGS"
  6860. ])
  6861. AS_UNSET([fin_CPPFLAGS])
  6862. AS_UNSET([fin_CFLAGS])
  6863. AS_UNSET([fin_LDFLAGS])
  6864. AS_UNSET([fin_lib_CPPFLAGS])
  6865. AS_UNSET([fin_lib_CFLAGS])
  6866. AS_UNSET([fin_lib_LDFLAGS])
  6867. AS_VAR_IF([os_is_windows], ["yes"],
  6868. [os_ver_msg="
  6869. Target W32 ver: ${mhd_w32_ver_msg}"], [AS_UNSET([[os_ver_msg]])])
  6870. AC_MSG_NOTICE([GNU libmicrohttpd ${PACKAGE_VERSION} Configuration Summary:
  6871. Target directory: ${prefix}
  6872. Cross-compiling: ${cross_compiling}
  6873. Operating System: ${mhd_host_os}${os_ver_msg}
  6874. Threading lib: ${USE_THREADS}
  6875. Inter-thread comm: ${use_itc}
  6876. Shutdown of listening socket triggers select: ${mhd_cv_host_shtdwn_trgr_select}
  6877. select() support: ${enable_select}
  6878. poll() support: ${enable_poll=no}
  6879. epoll support: ${enable_epoll=no}
  6880. sendfile used: ${found_sendfile}
  6881. HTTPS support: ${MSG_HTTPS}
  6882. Logging support: ${enable_log_messages}
  6883. Verbose auto replies: ${enable_http_messages}
  6884. Cookie parsing: ${enable_cookie}
  6885. Postproc: ${enable_postprocessor}
  6886. Basic auth.: ${enable_bauth}
  6887. Digest auth.: ${enable_dauth}
  6888. Digest auth. defaults: ${dauth_defs_MSG}
  6889. MD5: ${enable_md5_MSG}
  6890. SHA-256: ${enable_sha256_MSG}
  6891. SHA-512/256: ${enable_sha512_256_MSG}
  6892. HTTP "Upgrade": ${enable_httpupgrade}
  6893. Compact code: ${enable_compact_code} (${compact_code_MSG})
  6894. Use thread names: ${enable_thread_names}
  6895. Use debug asserts: ${use_asserts_MSG=no}
  6896. Use sanitizers: ${enabled_sanitizers:=no}
  6897. Build static lib: ${enable_static}
  6898. Build shared lib: ${enable_shared}
  6899. Build docs: ${enable_doc}
  6900. Build examples: ${enable_examples}
  6901. Build tools: ${enable_tools}
  6902. Test with libcurl: ${MSG_CURL}
  6903. Heavy tests: ${use_heavy_tests_MSG}
  6904. Fuzzing tests: ${run_zzuf_tests_MSG=no}
  6905. ])
  6906. AS_IF([test "x$enable_https" = "xyes"],
  6907. [AC_MSG_NOTICE([HTTPS subsystem configuration:
  6908. License : LGPL version 2.1 or any later version
  6909. ])],
  6910. [AC_MSG_NOTICE([
  6911. License : LGPLv2.1+ or eCos
  6912. ])])
  6913. AS_IF([test "x$enable_bauth" != "xyes" || \
  6914. test "x$enable_dauth" != "xyes" || \
  6915. test "x${enable_md5}" = "xno" || \
  6916. test "x${enable_sha256}" = "xno" || \
  6917. test "x${enable_sha512_256}" != "xyes" || \
  6918. test "x${USE_THREADS}" = "xnone" || \
  6919. test "x$enable_httpupgrade" != "xyes" || \
  6920. test "x$enable_cookie" != "xyes" || \
  6921. test "x$enable_httpupgrade" != "xyes" || \
  6922. test "x$enable_postprocessor" != "xyes"],
  6923. [AC_MSG_WARN([This will be a custom build with missing symbols. Do NOT use this build in a distribution. Building with these kinds of configure options is only for custom builds for embedded systems.])]
  6924. )