configure.ac 196 KB

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