configure.ac 229 KB

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