configure.ac 222 KB

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