configure.ac 228 KB

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