configure.ac 227 KB

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