configure.ac 229 KB

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