configure 163 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362
  1. #!/bin/sh
  2. #
  3. # qemu configure script (c) 2003 Fabrice Bellard
  4. #
  5. # Unset some variables known to interfere with behavior of common tools,
  6. # just as autoconf does.
  7. CLICOLOR_FORCE= GREP_OPTIONS=
  8. unset CLICOLOR_FORCE GREP_OPTIONS
  9. # Don't allow CCACHE, if present, to use cached results of compile tests!
  10. export CCACHE_RECACHE=yes
  11. # Temporary directory used for files created while
  12. # configure runs. Since it is in the build directory
  13. # we can safely blow away any previous version of it
  14. # (and we need not jump through hoops to try to delete
  15. # it when configure exits.)
  16. TMPDIR1="config-temp"
  17. rm -rf "${TMPDIR1}"
  18. mkdir -p "${TMPDIR1}"
  19. if [ $? -ne 0 ]; then
  20. echo "ERROR: failed to create temporary directory"
  21. exit 1
  22. fi
  23. TMPB="qemu-conf"
  24. TMPC="${TMPDIR1}/${TMPB}.c"
  25. TMPO="${TMPDIR1}/${TMPB}.o"
  26. TMPCXX="${TMPDIR1}/${TMPB}.cxx"
  27. TMPE="${TMPDIR1}/${TMPB}.exe"
  28. TMPMO="${TMPDIR1}/${TMPB}.mo"
  29. rm -f config.log
  30. # Print a helpful header at the top of config.log
  31. echo "# QEMU configure log $(date)" >> config.log
  32. printf "# Configured with:" >> config.log
  33. printf " '%s'" "$0" "$@" >> config.log
  34. echo >> config.log
  35. echo "#" >> config.log
  36. error_exit() {
  37. echo
  38. echo "ERROR: $1"
  39. while test -n "$2"; do
  40. echo " $2"
  41. shift
  42. done
  43. echo
  44. exit 1
  45. }
  46. do_compiler() {
  47. # Run the compiler, capturing its output to the log. First argument
  48. # is compiler binary to execute.
  49. local compiler="$1"
  50. shift
  51. echo $compiler "$@" >> config.log
  52. $compiler "$@" >> config.log 2>&1 || return $?
  53. # Test passed. If this is an --enable-werror build, rerun
  54. # the test with -Werror and bail out if it fails. This
  55. # makes warning-generating-errors in configure test code
  56. # obvious to developers.
  57. if test "$werror" != "yes"; then
  58. return 0
  59. fi
  60. # Don't bother rerunning the compile if we were already using -Werror
  61. case "$*" in
  62. *-Werror*)
  63. return 0
  64. ;;
  65. esac
  66. echo $compiler -Werror "$@" >> config.log
  67. $compiler -Werror "$@" >> config.log 2>&1 && return $?
  68. error_exit "configure test passed without -Werror but failed with -Werror." \
  69. "This is probably a bug in the configure script. The failing command" \
  70. "will be at the bottom of config.log." \
  71. "You can run configure with --disable-werror to bypass this check."
  72. }
  73. do_cc() {
  74. do_compiler "$cc" "$@"
  75. }
  76. do_cxx() {
  77. do_compiler "$cxx" "$@"
  78. }
  79. update_cxxflags() {
  80. # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
  81. # options which some versions of GCC's C++ compiler complain about
  82. # because they only make sense for C programs.
  83. QEMU_CXXFLAGS=
  84. for arg in $QEMU_CFLAGS; do
  85. case $arg in
  86. -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
  87. -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
  88. ;;
  89. *)
  90. QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
  91. ;;
  92. esac
  93. done
  94. }
  95. compile_object() {
  96. local_cflags="$1"
  97. do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
  98. }
  99. compile_prog() {
  100. local_cflags="$1"
  101. local_ldflags="$2"
  102. do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
  103. }
  104. # symbolically link $1 to $2. Portable version of "ln -sf".
  105. symlink() {
  106. rm -rf "$2"
  107. mkdir -p "$(dirname "$2")"
  108. ln -s "$1" "$2"
  109. }
  110. # check whether a command is available to this shell (may be either an
  111. # executable or a builtin)
  112. has() {
  113. type "$1" >/dev/null 2>&1
  114. }
  115. # search for an executable in PATH
  116. path_of() {
  117. local_command="$1"
  118. local_ifs="$IFS"
  119. local_dir=""
  120. # pathname has a dir component?
  121. if [ "${local_command#*/}" != "$local_command" ]; then
  122. if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
  123. echo "$local_command"
  124. return 0
  125. fi
  126. fi
  127. if [ -z "$local_command" ]; then
  128. return 1
  129. fi
  130. IFS=:
  131. for local_dir in $PATH; do
  132. if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
  133. echo "$local_dir/$local_command"
  134. IFS="${local_ifs:-$(printf ' \t\n')}"
  135. return 0
  136. fi
  137. done
  138. # not found
  139. IFS="${local_ifs:-$(printf ' \t\n')}"
  140. return 1
  141. }
  142. have_backend () {
  143. echo "$trace_backends" | grep "$1" >/dev/null
  144. }
  145. # default parameters
  146. source_path=$(dirname "$0")
  147. cpu=""
  148. iasl="iasl"
  149. interp_prefix="/usr/gnemul/qemu-%M"
  150. static="no"
  151. cross_prefix=""
  152. audio_drv_list=""
  153. block_drv_rw_whitelist=""
  154. block_drv_ro_whitelist=""
  155. host_cc="cc"
  156. libs_softmmu=""
  157. libs_tools=""
  158. audio_pt_int=""
  159. audio_win_int=""
  160. cc_i386=i386-pc-linux-gnu-gcc
  161. libs_qga=""
  162. debug_info="yes"
  163. stack_protector=""
  164. # Don't accept a target_list environment variable.
  165. unset target_list
  166. # Default value for a variable defining feature "foo".
  167. # * foo="no" feature will only be used if --enable-foo arg is given
  168. # * foo="" feature will be searched for, and if found, will be used
  169. # unless --disable-foo is given
  170. # * foo="yes" this value will only be set by --enable-foo flag.
  171. # feature will searched for,
  172. # if not found, configure exits with error
  173. #
  174. # Always add --enable-foo and --disable-foo command line args.
  175. # Distributions want to ensure that several features are compiled in, and it
  176. # is impossible without a --enable-foo that exits if a feature is not found.
  177. bluez=""
  178. brlapi=""
  179. curl=""
  180. curses=""
  181. docs=""
  182. fdt=""
  183. netmap="no"
  184. pixman=""
  185. sdl=""
  186. sdlabi=""
  187. virtfs=""
  188. vnc="yes"
  189. sparse="no"
  190. vde=""
  191. vnc_sasl=""
  192. vnc_jpeg=""
  193. vnc_png=""
  194. xen=""
  195. xen_ctrl_version=""
  196. xen_pv_domain_build="no"
  197. xen_pci_passthrough=""
  198. linux_aio=""
  199. cap_ng=""
  200. attr=""
  201. libattr=""
  202. xfs=""
  203. vhost_net="no"
  204. vhost_scsi="no"
  205. vhost_vsock="no"
  206. kvm="no"
  207. hax="no"
  208. rdma=""
  209. gprof="no"
  210. debug_tcg="no"
  211. debug="no"
  212. fortify_source=""
  213. strip_opt="yes"
  214. tcg_interpreter="no"
  215. bigendian="no"
  216. mingw32="no"
  217. gcov="no"
  218. gcov_tool="gcov"
  219. EXESUF=""
  220. DSOSUF=".so"
  221. LDFLAGS_SHARED="-shared"
  222. modules="no"
  223. prefix="/usr/local"
  224. mandir="\${prefix}/share/man"
  225. datadir="\${prefix}/share"
  226. qemu_docdir="\${prefix}/share/doc/qemu"
  227. bindir="\${prefix}/bin"
  228. libdir="\${prefix}/lib"
  229. libexecdir="\${prefix}/libexec"
  230. includedir="\${prefix}/include"
  231. sysconfdir="\${prefix}/etc"
  232. local_statedir="\${prefix}/var"
  233. confsuffix="/qemu"
  234. slirp="yes"
  235. oss_lib=""
  236. bsd="no"
  237. linux="no"
  238. solaris="no"
  239. profiler="no"
  240. cocoa="no"
  241. softmmu="yes"
  242. linux_user="no"
  243. bsd_user="no"
  244. aix="no"
  245. blobs="yes"
  246. pkgversion=""
  247. pie=""
  248. qom_cast_debug="yes"
  249. trace_backends="log"
  250. trace_file="trace"
  251. spice=""
  252. rbd=""
  253. smartcard=""
  254. libusb=""
  255. usb_redir=""
  256. opengl=""
  257. opengl_dmabuf="no"
  258. avx2_opt="no"
  259. zlib="yes"
  260. lzo=""
  261. snappy=""
  262. bzip2=""
  263. guest_agent=""
  264. guest_agent_with_vss="no"
  265. guest_agent_ntddscsi="no"
  266. guest_agent_msi=""
  267. vss_win32_sdk=""
  268. win_sdk="no"
  269. want_tools="yes"
  270. libiscsi=""
  271. libnfs=""
  272. coroutine=""
  273. coroutine_pool=""
  274. debug_stack_usage="no"
  275. seccomp=""
  276. glusterfs=""
  277. glusterfs_xlator_opt="no"
  278. glusterfs_discard="no"
  279. glusterfs_zerofill="no"
  280. gtk=""
  281. gtkabi=""
  282. gtk_gl="no"
  283. tls_priority="NORMAL"
  284. gnutls=""
  285. gnutls_rnd=""
  286. nettle=""
  287. nettle_kdf="no"
  288. gcrypt=""
  289. gcrypt_hmac="no"
  290. gcrypt_kdf="no"
  291. vte=""
  292. virglrenderer=""
  293. tpm="yes"
  294. libssh2=""
  295. numa=""
  296. tcmalloc="no"
  297. jemalloc="no"
  298. replication="yes"
  299. supported_cpu="no"
  300. supported_os="no"
  301. bogus_os="no"
  302. # parse CC options first
  303. for opt do
  304. optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
  305. case "$opt" in
  306. --cross-prefix=*) cross_prefix="$optarg"
  307. ;;
  308. --cc=*) CC="$optarg"
  309. ;;
  310. --cxx=*) CXX="$optarg"
  311. ;;
  312. --source-path=*) source_path="$optarg"
  313. ;;
  314. --cpu=*) cpu="$optarg"
  315. ;;
  316. --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
  317. EXTRA_CFLAGS="$optarg"
  318. ;;
  319. --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
  320. EXTRA_LDFLAGS="$optarg"
  321. ;;
  322. --enable-debug-info) debug_info="yes"
  323. ;;
  324. --disable-debug-info) debug_info="no"
  325. ;;
  326. esac
  327. done
  328. # OS specific
  329. # Using uname is really, really broken. Once we have the right set of checks
  330. # we can eliminate its usage altogether.
  331. # Preferred compiler:
  332. # ${CC} (if set)
  333. # ${cross_prefix}gcc (if cross-prefix specified)
  334. # system compiler
  335. if test -z "${CC}${cross_prefix}"; then
  336. cc="$host_cc"
  337. else
  338. cc="${CC-${cross_prefix}gcc}"
  339. fi
  340. if test -z "${CXX}${cross_prefix}"; then
  341. cxx="c++"
  342. else
  343. cxx="${CXX-${cross_prefix}g++}"
  344. fi
  345. ar="${AR-${cross_prefix}ar}"
  346. as="${AS-${cross_prefix}as}"
  347. ccas="${CCAS-$cc}"
  348. cpp="${CPP-$cc -E}"
  349. objcopy="${OBJCOPY-${cross_prefix}objcopy}"
  350. ld="${LD-${cross_prefix}ld}"
  351. nm="${NM-${cross_prefix}nm}"
  352. strip="${STRIP-${cross_prefix}strip}"
  353. windres="${WINDRES-${cross_prefix}windres}"
  354. pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
  355. query_pkg_config() {
  356. "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
  357. }
  358. pkg_config=query_pkg_config
  359. sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
  360. sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
  361. # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
  362. ARFLAGS="${ARFLAGS-rv}"
  363. # default flags for all hosts
  364. # We use -fwrapv to tell the compiler that we require a C dialect where
  365. # left shift of signed integers is well defined and has the expected
  366. # 2s-complement style results. (Both clang and gcc agree that it
  367. # provides these semantics.)
  368. QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
  369. QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
  370. QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
  371. QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
  372. QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
  373. if test "$debug_info" = "yes"; then
  374. CFLAGS="-g $CFLAGS"
  375. LDFLAGS="-g $LDFLAGS"
  376. fi
  377. # make source path absolute
  378. source_path=$(cd "$source_path"; pwd)
  379. # running configure in the source tree?
  380. # we know that's the case if configure is there.
  381. if test -f "./configure"; then
  382. pwd_is_source_path="y"
  383. else
  384. pwd_is_source_path="n"
  385. fi
  386. check_define() {
  387. cat > $TMPC <<EOF
  388. #if !defined($1)
  389. #error $1 not defined
  390. #endif
  391. int main(void) { return 0; }
  392. EOF
  393. compile_object
  394. }
  395. check_include() {
  396. cat > $TMPC <<EOF
  397. #include <$1>
  398. int main(void) { return 0; }
  399. EOF
  400. compile_object
  401. }
  402. write_c_skeleton() {
  403. cat > $TMPC <<EOF
  404. int main(void) { return 0; }
  405. EOF
  406. }
  407. if check_define __linux__ ; then
  408. targetos="Linux"
  409. elif check_define _WIN32 ; then
  410. targetos='MINGW32'
  411. elif check_define __OpenBSD__ ; then
  412. targetos='OpenBSD'
  413. elif check_define __sun__ ; then
  414. targetos='SunOS'
  415. elif check_define __HAIKU__ ; then
  416. targetos='Haiku'
  417. else
  418. targetos=$(uname -s)
  419. fi
  420. # Some host OSes need non-standard checks for which CPU to use.
  421. # Note that these checks are broken for cross-compilation: if you're
  422. # cross-compiling to one of these OSes then you'll need to specify
  423. # the correct CPU with the --cpu option.
  424. case $targetos in
  425. Darwin)
  426. # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
  427. # run 64-bit userspace code.
  428. # If the user didn't specify a CPU explicitly and the kernel says this is
  429. # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
  430. if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
  431. cpu="x86_64"
  432. fi
  433. ;;
  434. SunOS)
  435. # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
  436. if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
  437. cpu="x86_64"
  438. fi
  439. esac
  440. if test ! -z "$cpu" ; then
  441. # command line argument
  442. :
  443. elif check_define __i386__ ; then
  444. cpu="i386"
  445. elif check_define __x86_64__ ; then
  446. if check_define __ILP32__ ; then
  447. cpu="x32"
  448. else
  449. cpu="x86_64"
  450. fi
  451. elif check_define __sparc__ ; then
  452. if check_define __arch64__ ; then
  453. cpu="sparc64"
  454. else
  455. cpu="sparc"
  456. fi
  457. elif check_define _ARCH_PPC ; then
  458. if check_define _ARCH_PPC64 ; then
  459. cpu="ppc64"
  460. else
  461. cpu="ppc"
  462. fi
  463. elif check_define __mips__ ; then
  464. cpu="mips"
  465. elif check_define __ia64__ ; then
  466. cpu="ia64"
  467. elif check_define __s390__ ; then
  468. if check_define __s390x__ ; then
  469. cpu="s390x"
  470. else
  471. cpu="s390"
  472. fi
  473. elif check_define __arm__ ; then
  474. cpu="arm"
  475. elif check_define __aarch64__ ; then
  476. cpu="aarch64"
  477. else
  478. cpu=$(uname -m)
  479. fi
  480. ARCH=
  481. # Normalise host CPU name and set ARCH.
  482. # Note that this case should only have supported host CPUs, not guests.
  483. case "$cpu" in
  484. ppc|ppc64|s390|s390x|sparc64|x32)
  485. cpu="$cpu"
  486. supported_cpu="yes"
  487. ;;
  488. ia64)
  489. cpu="$cpu"
  490. ;;
  491. i386|i486|i586|i686|i86pc|BePC)
  492. cpu="i386"
  493. supported_cpu="yes"
  494. ;;
  495. x86_64|amd64)
  496. cpu="x86_64"
  497. supported_cpu="yes"
  498. ;;
  499. armv*b|armv*l|arm)
  500. cpu="arm"
  501. supported_cpu="yes"
  502. ;;
  503. aarch64)
  504. cpu="aarch64"
  505. supported_cpu="yes"
  506. ;;
  507. mips*)
  508. cpu="mips"
  509. supported_cpu="yes"
  510. ;;
  511. sparc|sun4[cdmuv])
  512. cpu="sparc"
  513. supported_cpu="yes"
  514. ;;
  515. *)
  516. # This will result in either an error or falling back to TCI later
  517. ARCH=unknown
  518. ;;
  519. esac
  520. if test -z "$ARCH"; then
  521. ARCH="$cpu"
  522. fi
  523. # OS specific
  524. # host *BSD for user mode
  525. HOST_VARIANT_DIR=""
  526. case $targetos in
  527. MINGW32*)
  528. mingw32="yes"
  529. hax="yes"
  530. audio_possible_drivers="dsound sdl"
  531. if check_include dsound.h; then
  532. audio_drv_list="dsound"
  533. else
  534. audio_drv_list=""
  535. fi
  536. supported_os="yes"
  537. ;;
  538. GNU/kFreeBSD)
  539. bsd="yes"
  540. audio_drv_list="oss"
  541. audio_possible_drivers="oss sdl pa"
  542. ;;
  543. FreeBSD)
  544. bsd="yes"
  545. make="${MAKE-gmake}"
  546. audio_drv_list="oss"
  547. audio_possible_drivers="oss sdl pa"
  548. # needed for kinfo_getvmmap(3) in libutil.h
  549. LIBS="-lutil $LIBS"
  550. # needed for kinfo_getproc
  551. libs_qga="-lutil $libs_qga"
  552. netmap="" # enable netmap autodetect
  553. HOST_VARIANT_DIR="freebsd"
  554. supported_os="yes"
  555. ;;
  556. DragonFly)
  557. bsd="yes"
  558. make="${MAKE-gmake}"
  559. audio_drv_list="oss"
  560. audio_possible_drivers="oss sdl pa"
  561. HOST_VARIANT_DIR="dragonfly"
  562. ;;
  563. NetBSD)
  564. bsd="yes"
  565. make="${MAKE-gmake}"
  566. audio_drv_list="oss"
  567. audio_possible_drivers="oss sdl"
  568. oss_lib="-lossaudio"
  569. HOST_VARIANT_DIR="netbsd"
  570. ;;
  571. OpenBSD)
  572. bsd="yes"
  573. make="${MAKE-gmake}"
  574. audio_drv_list="sdl"
  575. audio_possible_drivers="sdl"
  576. HOST_VARIANT_DIR="openbsd"
  577. ;;
  578. Darwin)
  579. bsd="yes"
  580. darwin="yes"
  581. hax="yes"
  582. LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
  583. if [ "$cpu" = "x86_64" ] ; then
  584. QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
  585. LDFLAGS="-arch x86_64 $LDFLAGS"
  586. fi
  587. cocoa="yes"
  588. audio_drv_list="coreaudio"
  589. audio_possible_drivers="coreaudio sdl"
  590. LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
  591. libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
  592. # Disable attempts to use ObjectiveC features in os/object.h since they
  593. # won't work when we're compiling with gcc as a C compiler.
  594. QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
  595. HOST_VARIANT_DIR="darwin"
  596. supported_os="yes"
  597. ;;
  598. SunOS)
  599. solaris="yes"
  600. make="${MAKE-gmake}"
  601. install="${INSTALL-ginstall}"
  602. ld="gld"
  603. smbd="${SMBD-/usr/sfw/sbin/smbd}"
  604. needs_libsunmath="no"
  605. solarisrev=$(uname -r | cut -f2 -d.)
  606. if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
  607. if test "$solarisrev" -le 9 ; then
  608. if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
  609. needs_libsunmath="yes"
  610. QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
  611. LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
  612. LIBS="-lsunmath $LIBS"
  613. else
  614. error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
  615. "libsunmath from the Sun Studio compilers tools, due to a lack of" \
  616. "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
  617. "Studio 11 can be downloaded from www.sun.com."
  618. fi
  619. fi
  620. fi
  621. if test -f /usr/include/sys/soundcard.h ; then
  622. audio_drv_list="oss"
  623. fi
  624. audio_possible_drivers="oss sdl"
  625. # needed for CMSG_ macros in sys/socket.h
  626. QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
  627. # needed for TIOCWIN* defines in termios.h
  628. QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
  629. QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
  630. solarisnetlibs="-lsocket -lnsl -lresolv"
  631. LIBS="$solarisnetlibs $LIBS"
  632. libs_qga="$solarisnetlibs $libs_qga"
  633. ;;
  634. AIX)
  635. aix="yes"
  636. make="${MAKE-gmake}"
  637. ;;
  638. Haiku)
  639. haiku="yes"
  640. QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
  641. LIBS="-lposix_error_mapper -lnetwork $LIBS"
  642. ;;
  643. Linux)
  644. audio_drv_list="oss"
  645. audio_possible_drivers="oss alsa sdl pa"
  646. linux="yes"
  647. linux_user="yes"
  648. kvm="yes"
  649. vhost_net="yes"
  650. vhost_scsi="yes"
  651. vhost_vsock="yes"
  652. QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
  653. supported_os="yes"
  654. ;;
  655. *)
  656. # This is a fatal error, but don't report it yet, because we
  657. # might be going to just print the --help text, or it might
  658. # be the result of a missing compiler.
  659. bogus_os="yes"
  660. ;;
  661. esac
  662. if [ "$bsd" = "yes" ] ; then
  663. if [ "$darwin" != "yes" ] ; then
  664. bsd_user="yes"
  665. fi
  666. fi
  667. : ${make=${MAKE-make}}
  668. : ${install=${INSTALL-install}}
  669. : ${python=${PYTHON-python}}
  670. : ${smbd=${SMBD-/usr/sbin/smbd}}
  671. # Default objcc to clang if available, otherwise use CC
  672. if has clang; then
  673. objcc=clang
  674. else
  675. objcc="$cc"
  676. fi
  677. if test "$mingw32" = "yes" ; then
  678. EXESUF=".exe"
  679. DSOSUF=".dll"
  680. QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
  681. # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
  682. QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
  683. # MinGW needs -mthreads for TLS and macro _MT.
  684. QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
  685. LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
  686. write_c_skeleton;
  687. if compile_prog "" "-liberty" ; then
  688. LIBS="-liberty $LIBS"
  689. fi
  690. prefix="c:/Program Files/QEMU"
  691. mandir="\${prefix}"
  692. datadir="\${prefix}"
  693. qemu_docdir="\${prefix}"
  694. bindir="\${prefix}"
  695. sysconfdir="\${prefix}"
  696. local_statedir=
  697. confsuffix=""
  698. libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi -lnetapi32 $libs_qga"
  699. fi
  700. werror=""
  701. for opt do
  702. optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
  703. case "$opt" in
  704. --help|-h) show_help=yes
  705. ;;
  706. --version|-V) exec cat $source_path/VERSION
  707. ;;
  708. --prefix=*) prefix="$optarg"
  709. ;;
  710. --interp-prefix=*) interp_prefix="$optarg"
  711. ;;
  712. --source-path=*)
  713. ;;
  714. --cross-prefix=*)
  715. ;;
  716. --cc=*)
  717. ;;
  718. --host-cc=*) host_cc="$optarg"
  719. ;;
  720. --cxx=*)
  721. ;;
  722. --iasl=*) iasl="$optarg"
  723. ;;
  724. --objcc=*) objcc="$optarg"
  725. ;;
  726. --make=*) make="$optarg"
  727. ;;
  728. --install=*) install="$optarg"
  729. ;;
  730. --python=*) python="$optarg"
  731. ;;
  732. --gcov=*) gcov_tool="$optarg"
  733. ;;
  734. --smbd=*) smbd="$optarg"
  735. ;;
  736. --extra-cflags=*)
  737. ;;
  738. --extra-ldflags=*)
  739. ;;
  740. --enable-debug-info)
  741. ;;
  742. --disable-debug-info)
  743. ;;
  744. --enable-modules)
  745. modules="yes"
  746. ;;
  747. --disable-modules)
  748. modules="no"
  749. ;;
  750. --cpu=*)
  751. ;;
  752. --target-list=*) target_list="$optarg"
  753. ;;
  754. --enable-trace-backends=*) trace_backends="$optarg"
  755. ;;
  756. # XXX: backwards compatibility
  757. --enable-trace-backend=*) trace_backends="$optarg"
  758. ;;
  759. --with-trace-file=*) trace_file="$optarg"
  760. ;;
  761. --enable-gprof) gprof="yes"
  762. ;;
  763. --enable-gcov) gcov="yes"
  764. ;;
  765. --static)
  766. static="yes"
  767. LDFLAGS="-static $LDFLAGS"
  768. QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
  769. ;;
  770. --mandir=*) mandir="$optarg"
  771. ;;
  772. --bindir=*) bindir="$optarg"
  773. ;;
  774. --libdir=*) libdir="$optarg"
  775. ;;
  776. --libexecdir=*) libexecdir="$optarg"
  777. ;;
  778. --includedir=*) includedir="$optarg"
  779. ;;
  780. --datadir=*) datadir="$optarg"
  781. ;;
  782. --with-confsuffix=*) confsuffix="$optarg"
  783. ;;
  784. --docdir=*) qemu_docdir="$optarg"
  785. ;;
  786. --sysconfdir=*) sysconfdir="$optarg"
  787. ;;
  788. --localstatedir=*) local_statedir="$optarg"
  789. ;;
  790. --sbindir=*|--sharedstatedir=*|\
  791. --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
  792. --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
  793. # These switches are silently ignored, for compatibility with
  794. # autoconf-generated configure scripts. This allows QEMU's
  795. # configure to be used by RPM and similar macros that set
  796. # lots of directory switches by default.
  797. ;;
  798. --with-system-pixman) pixman="system"
  799. ;;
  800. --without-system-pixman) pixman="internal"
  801. ;;
  802. --without-pixman) pixman="none"
  803. ;;
  804. --disable-sdl) sdl="no"
  805. ;;
  806. --enable-sdl) sdl="yes"
  807. ;;
  808. --with-sdlabi=*) sdlabi="$optarg"
  809. ;;
  810. --disable-qom-cast-debug) qom_cast_debug="no"
  811. ;;
  812. --enable-qom-cast-debug) qom_cast_debug="yes"
  813. ;;
  814. --disable-virtfs) virtfs="no"
  815. ;;
  816. --enable-virtfs) virtfs="yes"
  817. ;;
  818. --disable-vnc) vnc="no"
  819. ;;
  820. --enable-vnc) vnc="yes"
  821. ;;
  822. --oss-lib=*) oss_lib="$optarg"
  823. ;;
  824. --audio-drv-list=*) audio_drv_list="$optarg"
  825. ;;
  826. --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
  827. ;;
  828. --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
  829. ;;
  830. --enable-debug-tcg) debug_tcg="yes"
  831. ;;
  832. --disable-debug-tcg) debug_tcg="no"
  833. ;;
  834. --enable-debug)
  835. # Enable debugging options that aren't excessively noisy
  836. debug_tcg="yes"
  837. debug="yes"
  838. strip_opt="no"
  839. fortify_source="no"
  840. ;;
  841. --enable-sparse) sparse="yes"
  842. ;;
  843. --disable-sparse) sparse="no"
  844. ;;
  845. --disable-strip) strip_opt="no"
  846. ;;
  847. --disable-vnc-sasl) vnc_sasl="no"
  848. ;;
  849. --enable-vnc-sasl) vnc_sasl="yes"
  850. ;;
  851. --disable-vnc-jpeg) vnc_jpeg="no"
  852. ;;
  853. --enable-vnc-jpeg) vnc_jpeg="yes"
  854. ;;
  855. --disable-vnc-png) vnc_png="no"
  856. ;;
  857. --enable-vnc-png) vnc_png="yes"
  858. ;;
  859. --disable-slirp) slirp="no"
  860. ;;
  861. --disable-vde) vde="no"
  862. ;;
  863. --enable-vde) vde="yes"
  864. ;;
  865. --disable-netmap) netmap="no"
  866. ;;
  867. --enable-netmap) netmap="yes"
  868. ;;
  869. --disable-xen) xen="no"
  870. ;;
  871. --enable-xen) xen="yes"
  872. ;;
  873. --disable-xen-pci-passthrough) xen_pci_passthrough="no"
  874. ;;
  875. --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
  876. ;;
  877. --disable-xen-pv-domain-build) xen_pv_domain_build="no"
  878. ;;
  879. --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
  880. ;;
  881. --disable-brlapi) brlapi="no"
  882. ;;
  883. --enable-brlapi) brlapi="yes"
  884. ;;
  885. --disable-bluez) bluez="no"
  886. ;;
  887. --enable-bluez) bluez="yes"
  888. ;;
  889. --disable-kvm) kvm="no"
  890. ;;
  891. --enable-kvm) kvm="yes"
  892. ;;
  893. --disable-hax) hax="no"
  894. ;;
  895. --enable-hax) hax="yes"
  896. ;;
  897. --disable-tcg-interpreter) tcg_interpreter="no"
  898. ;;
  899. --enable-tcg-interpreter) tcg_interpreter="yes"
  900. ;;
  901. --disable-cap-ng) cap_ng="no"
  902. ;;
  903. --enable-cap-ng) cap_ng="yes"
  904. ;;
  905. --disable-spice) spice="no"
  906. ;;
  907. --enable-spice) spice="yes"
  908. ;;
  909. --disable-libiscsi) libiscsi="no"
  910. ;;
  911. --enable-libiscsi) libiscsi="yes"
  912. ;;
  913. --disable-libnfs) libnfs="no"
  914. ;;
  915. --enable-libnfs) libnfs="yes"
  916. ;;
  917. --enable-profiler) profiler="yes"
  918. ;;
  919. --disable-cocoa) cocoa="no"
  920. ;;
  921. --enable-cocoa)
  922. cocoa="yes" ;
  923. audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
  924. ;;
  925. --disable-system) softmmu="no"
  926. ;;
  927. --enable-system) softmmu="yes"
  928. ;;
  929. --disable-user)
  930. linux_user="no" ;
  931. bsd_user="no" ;
  932. ;;
  933. --enable-user) ;;
  934. --disable-linux-user) linux_user="no"
  935. ;;
  936. --enable-linux-user) linux_user="yes"
  937. ;;
  938. --disable-bsd-user) bsd_user="no"
  939. ;;
  940. --enable-bsd-user) bsd_user="yes"
  941. ;;
  942. --enable-pie) pie="yes"
  943. ;;
  944. --disable-pie) pie="no"
  945. ;;
  946. --enable-werror) werror="yes"
  947. ;;
  948. --disable-werror) werror="no"
  949. ;;
  950. --enable-stack-protector) stack_protector="yes"
  951. ;;
  952. --disable-stack-protector) stack_protector="no"
  953. ;;
  954. --disable-curses) curses="no"
  955. ;;
  956. --enable-curses) curses="yes"
  957. ;;
  958. --disable-curl) curl="no"
  959. ;;
  960. --enable-curl) curl="yes"
  961. ;;
  962. --disable-fdt) fdt="no"
  963. ;;
  964. --enable-fdt) fdt="yes"
  965. ;;
  966. --disable-linux-aio) linux_aio="no"
  967. ;;
  968. --enable-linux-aio) linux_aio="yes"
  969. ;;
  970. --disable-attr) attr="no"
  971. ;;
  972. --enable-attr) attr="yes"
  973. ;;
  974. --disable-blobs) blobs="no"
  975. ;;
  976. --with-pkgversion=*) pkgversion=" ($optarg)"
  977. ;;
  978. --with-coroutine=*) coroutine="$optarg"
  979. ;;
  980. --disable-coroutine-pool) coroutine_pool="no"
  981. ;;
  982. --enable-coroutine-pool) coroutine_pool="yes"
  983. ;;
  984. --enable-debug-stack-usage) debug_stack_usage="yes"
  985. ;;
  986. --disable-docs) docs="no"
  987. ;;
  988. --enable-docs) docs="yes"
  989. ;;
  990. --disable-vhost-net) vhost_net="no"
  991. ;;
  992. --enable-vhost-net) vhost_net="yes"
  993. ;;
  994. --disable-vhost-scsi) vhost_scsi="no"
  995. ;;
  996. --enable-vhost-scsi) vhost_scsi="yes"
  997. ;;
  998. --disable-vhost-vsock) vhost_vsock="no"
  999. ;;
  1000. --enable-vhost-vsock) vhost_vsock="yes"
  1001. ;;
  1002. --disable-opengl) opengl="no"
  1003. ;;
  1004. --enable-opengl) opengl="yes"
  1005. ;;
  1006. --disable-rbd) rbd="no"
  1007. ;;
  1008. --enable-rbd) rbd="yes"
  1009. ;;
  1010. --disable-xfsctl) xfs="no"
  1011. ;;
  1012. --enable-xfsctl) xfs="yes"
  1013. ;;
  1014. --disable-smartcard) smartcard="no"
  1015. ;;
  1016. --enable-smartcard) smartcard="yes"
  1017. ;;
  1018. --disable-libusb) libusb="no"
  1019. ;;
  1020. --enable-libusb) libusb="yes"
  1021. ;;
  1022. --disable-usb-redir) usb_redir="no"
  1023. ;;
  1024. --enable-usb-redir) usb_redir="yes"
  1025. ;;
  1026. --disable-zlib-test) zlib="no"
  1027. ;;
  1028. --disable-lzo) lzo="no"
  1029. ;;
  1030. --enable-lzo) lzo="yes"
  1031. ;;
  1032. --disable-snappy) snappy="no"
  1033. ;;
  1034. --enable-snappy) snappy="yes"
  1035. ;;
  1036. --disable-bzip2) bzip2="no"
  1037. ;;
  1038. --enable-bzip2) bzip2="yes"
  1039. ;;
  1040. --enable-guest-agent) guest_agent="yes"
  1041. ;;
  1042. --disable-guest-agent) guest_agent="no"
  1043. ;;
  1044. --enable-guest-agent-msi) guest_agent_msi="yes"
  1045. ;;
  1046. --disable-guest-agent-msi) guest_agent_msi="no"
  1047. ;;
  1048. --with-vss-sdk) vss_win32_sdk=""
  1049. ;;
  1050. --with-vss-sdk=*) vss_win32_sdk="$optarg"
  1051. ;;
  1052. --without-vss-sdk) vss_win32_sdk="no"
  1053. ;;
  1054. --with-win-sdk) win_sdk=""
  1055. ;;
  1056. --with-win-sdk=*) win_sdk="$optarg"
  1057. ;;
  1058. --without-win-sdk) win_sdk="no"
  1059. ;;
  1060. --enable-tools) want_tools="yes"
  1061. ;;
  1062. --disable-tools) want_tools="no"
  1063. ;;
  1064. --enable-seccomp) seccomp="yes"
  1065. ;;
  1066. --disable-seccomp) seccomp="no"
  1067. ;;
  1068. --disable-glusterfs) glusterfs="no"
  1069. ;;
  1070. --enable-glusterfs) glusterfs="yes"
  1071. ;;
  1072. --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
  1073. echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
  1074. ;;
  1075. --enable-vhdx|--disable-vhdx)
  1076. echo "$0: $opt is obsolete, VHDX driver is always built" >&2
  1077. ;;
  1078. --enable-uuid|--disable-uuid)
  1079. echo "$0: $opt is obsolete, UUID support is always built" >&2
  1080. ;;
  1081. --disable-gtk) gtk="no"
  1082. ;;
  1083. --enable-gtk) gtk="yes"
  1084. ;;
  1085. --tls-priority=*) tls_priority="$optarg"
  1086. ;;
  1087. --disable-gnutls) gnutls="no"
  1088. ;;
  1089. --enable-gnutls) gnutls="yes"
  1090. ;;
  1091. --disable-nettle) nettle="no"
  1092. ;;
  1093. --enable-nettle) nettle="yes"
  1094. ;;
  1095. --disable-gcrypt) gcrypt="no"
  1096. ;;
  1097. --enable-gcrypt) gcrypt="yes"
  1098. ;;
  1099. --enable-rdma) rdma="yes"
  1100. ;;
  1101. --disable-rdma) rdma="no"
  1102. ;;
  1103. --with-gtkabi=*) gtkabi="$optarg"
  1104. ;;
  1105. --disable-vte) vte="no"
  1106. ;;
  1107. --enable-vte) vte="yes"
  1108. ;;
  1109. --disable-virglrenderer) virglrenderer="no"
  1110. ;;
  1111. --enable-virglrenderer) virglrenderer="yes"
  1112. ;;
  1113. --disable-tpm) tpm="no"
  1114. ;;
  1115. --enable-tpm) tpm="yes"
  1116. ;;
  1117. --disable-libssh2) libssh2="no"
  1118. ;;
  1119. --enable-libssh2) libssh2="yes"
  1120. ;;
  1121. --disable-numa) numa="no"
  1122. ;;
  1123. --enable-numa) numa="yes"
  1124. ;;
  1125. --disable-tcmalloc) tcmalloc="no"
  1126. ;;
  1127. --enable-tcmalloc) tcmalloc="yes"
  1128. ;;
  1129. --disable-jemalloc) jemalloc="no"
  1130. ;;
  1131. --enable-jemalloc) jemalloc="yes"
  1132. ;;
  1133. --disable-replication) replication="no"
  1134. ;;
  1135. --enable-replication) replication="yes"
  1136. ;;
  1137. *)
  1138. echo "ERROR: unknown option $opt"
  1139. echo "Try '$0 --help' for more information"
  1140. exit 1
  1141. ;;
  1142. esac
  1143. done
  1144. if ! has $python; then
  1145. error_exit "Python not found. Use --python=/path/to/python"
  1146. fi
  1147. # Note that if the Python conditional here evaluates True we will exit
  1148. # with status 1 which is a shell 'false' value.
  1149. if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
  1150. error_exit "Cannot use '$python', Python 2.6 or later is required." \
  1151. "Note that Python 3 or later is not yet supported." \
  1152. "Use --python=/path/to/python to specify a supported Python."
  1153. fi
  1154. # Suppress writing compiled files
  1155. python="$python -B"
  1156. case "$cpu" in
  1157. ppc)
  1158. CPU_CFLAGS="-m32"
  1159. LDFLAGS="-m32 $LDFLAGS"
  1160. ;;
  1161. ppc64)
  1162. CPU_CFLAGS="-m64"
  1163. LDFLAGS="-m64 $LDFLAGS"
  1164. ;;
  1165. sparc)
  1166. LDFLAGS="-m32 $LDFLAGS"
  1167. CPU_CFLAGS="-m32 -mcpu=ultrasparc"
  1168. ;;
  1169. sparc64)
  1170. LDFLAGS="-m64 $LDFLAGS"
  1171. CPU_CFLAGS="-m64 -mcpu=ultrasparc"
  1172. ;;
  1173. s390)
  1174. CPU_CFLAGS="-m31"
  1175. LDFLAGS="-m31 $LDFLAGS"
  1176. ;;
  1177. s390x)
  1178. CPU_CFLAGS="-m64"
  1179. LDFLAGS="-m64 $LDFLAGS"
  1180. ;;
  1181. i386)
  1182. CPU_CFLAGS="-m32"
  1183. LDFLAGS="-m32 $LDFLAGS"
  1184. cc_i386='$(CC) -m32'
  1185. ;;
  1186. x86_64)
  1187. # ??? Only extremely old AMD cpus do not have cmpxchg16b.
  1188. # If we truly care, we should simply detect this case at
  1189. # runtime and generate the fallback to serial emulation.
  1190. CPU_CFLAGS="-m64 -mcx16"
  1191. LDFLAGS="-m64 $LDFLAGS"
  1192. cc_i386='$(CC) -m32'
  1193. ;;
  1194. x32)
  1195. CPU_CFLAGS="-mx32"
  1196. LDFLAGS="-mx32 $LDFLAGS"
  1197. cc_i386='$(CC) -m32'
  1198. ;;
  1199. # No special flags required for other host CPUs
  1200. esac
  1201. QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
  1202. EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
  1203. # For user-mode emulation the host arch has to be one we explicitly
  1204. # support, even if we're using TCI.
  1205. if [ "$ARCH" = "unknown" ]; then
  1206. bsd_user="no"
  1207. linux_user="no"
  1208. fi
  1209. default_target_list=""
  1210. mak_wilds=""
  1211. if [ "$softmmu" = "yes" ]; then
  1212. mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
  1213. fi
  1214. if [ "$linux_user" = "yes" ]; then
  1215. mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
  1216. fi
  1217. if [ "$bsd_user" = "yes" ]; then
  1218. mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
  1219. fi
  1220. for config in $mak_wilds; do
  1221. default_target_list="${default_target_list} $(basename "$config" .mak)"
  1222. done
  1223. if test x"$show_help" = x"yes" ; then
  1224. cat << EOF
  1225. Usage: configure [options]
  1226. Options: [defaults in brackets after descriptions]
  1227. Standard options:
  1228. --help print this message
  1229. --prefix=PREFIX install in PREFIX [$prefix]
  1230. --interp-prefix=PREFIX where to find shared libraries, etc.
  1231. use %M for cpu name [$interp_prefix]
  1232. --target-list=LIST set target list (default: build everything)
  1233. $(echo Available targets: $default_target_list | \
  1234. fold -s -w 53 | sed -e 's/^/ /')
  1235. Advanced options (experts only):
  1236. --source-path=PATH path of source code [$source_path]
  1237. --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
  1238. --cc=CC use C compiler CC [$cc]
  1239. --iasl=IASL use ACPI compiler IASL [$iasl]
  1240. --host-cc=CC use C compiler CC [$host_cc] for code run at
  1241. build time
  1242. --cxx=CXX use C++ compiler CXX [$cxx]
  1243. --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
  1244. --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
  1245. --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
  1246. --make=MAKE use specified make [$make]
  1247. --install=INSTALL use specified install [$install]
  1248. --python=PYTHON use specified python [$python]
  1249. --smbd=SMBD use specified smbd [$smbd]
  1250. --static enable static build [$static]
  1251. --mandir=PATH install man pages in PATH
  1252. --datadir=PATH install firmware in PATH$confsuffix
  1253. --docdir=PATH install documentation in PATH$confsuffix
  1254. --bindir=PATH install binaries in PATH
  1255. --libdir=PATH install libraries in PATH
  1256. --sysconfdir=PATH install config in PATH$confsuffix
  1257. --localstatedir=PATH install local state in PATH (set at runtime on win32)
  1258. --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
  1259. --enable-debug enable common debug build options
  1260. --disable-strip disable stripping binaries
  1261. --disable-werror disable compilation abort on warning
  1262. --disable-stack-protector disable compiler-provided stack protection
  1263. --audio-drv-list=LIST set audio drivers list:
  1264. Available drivers: $audio_possible_drivers
  1265. --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
  1266. --block-drv-rw-whitelist=L
  1267. set block driver read-write whitelist
  1268. (affects only QEMU, not qemu-img)
  1269. --block-drv-ro-whitelist=L
  1270. set block driver read-only whitelist
  1271. (affects only QEMU, not qemu-img)
  1272. --enable-trace-backends=B Set trace backend
  1273. Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
  1274. --with-trace-file=NAME Full PATH,NAME of file to store traces
  1275. Default:trace-<pid>
  1276. --disable-slirp disable SLIRP userspace network connectivity
  1277. --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
  1278. --oss-lib path to OSS library
  1279. --cpu=CPU Build for host CPU [$cpu]
  1280. --with-coroutine=BACKEND coroutine backend. Supported options:
  1281. gthread, ucontext, sigaltstack, windows
  1282. --enable-gcov enable test coverage analysis with gcov
  1283. --gcov=GCOV use specified gcov [$gcov_tool]
  1284. --disable-blobs disable installing provided firmware blobs
  1285. --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
  1286. --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
  1287. --tls-priority default TLS protocol/cipher priority string
  1288. --enable-gprof QEMU profiling with gprof
  1289. --enable-profiler profiler support
  1290. --enable-xen-pv-domain-build
  1291. xen pv domain builder
  1292. --enable-debug-stack-usage
  1293. track the maximum stack usage of stacks created by qemu_alloc_stack
  1294. Optional features, enabled with --enable-FEATURE and
  1295. disabled with --disable-FEATURE, default is enabled if available:
  1296. system all system emulation targets
  1297. user supported user emulation targets
  1298. linux-user all linux usermode emulation targets
  1299. bsd-user all BSD usermode emulation targets
  1300. docs build documentation
  1301. guest-agent build the QEMU Guest Agent
  1302. guest-agent-msi build guest agent Windows MSI installation package
  1303. pie Position Independent Executables
  1304. modules modules support
  1305. debug-tcg TCG debugging (default is disabled)
  1306. debug-info debugging information
  1307. sparse sparse checker
  1308. gnutls GNUTLS cryptography support
  1309. nettle nettle cryptography support
  1310. gcrypt libgcrypt cryptography support
  1311. sdl SDL UI
  1312. --with-sdlabi select preferred SDL ABI 1.2 or 2.0
  1313. gtk gtk UI
  1314. --with-gtkabi select preferred GTK ABI 2.0 or 3.0
  1315. vte vte support for the gtk UI
  1316. curses curses UI
  1317. vnc VNC UI support
  1318. vnc-sasl SASL encryption for VNC server
  1319. vnc-jpeg JPEG lossy compression for VNC server
  1320. vnc-png PNG compression for VNC server
  1321. cocoa Cocoa UI (Mac OS X only)
  1322. virtfs VirtFS
  1323. xen xen backend driver support
  1324. xen-pci-passthrough
  1325. brlapi BrlAPI (Braile)
  1326. curl curl connectivity
  1327. fdt fdt device tree
  1328. bluez bluez stack connectivity
  1329. kvm KVM acceleration support
  1330. hax HAX acceleration support
  1331. rdma RDMA-based migration support
  1332. vde support for vde network
  1333. netmap support for netmap network
  1334. linux-aio Linux AIO support
  1335. cap-ng libcap-ng support
  1336. attr attr and xattr support
  1337. vhost-net vhost-net acceleration support
  1338. spice spice
  1339. rbd rados block device (rbd)
  1340. libiscsi iscsi support
  1341. libnfs nfs support
  1342. smartcard smartcard support (libcacard)
  1343. libusb libusb (for usb passthrough)
  1344. usb-redir usb network redirection support
  1345. lzo support of lzo compression library
  1346. snappy support of snappy compression library
  1347. bzip2 support of bzip2 compression library
  1348. (for reading bzip2-compressed dmg images)
  1349. seccomp seccomp support
  1350. coroutine-pool coroutine freelist (better performance)
  1351. glusterfs GlusterFS backend
  1352. tpm TPM support
  1353. libssh2 ssh block device support
  1354. numa libnuma support
  1355. tcmalloc tcmalloc support
  1356. jemalloc jemalloc support
  1357. replication replication support
  1358. vhost-vsock virtio sockets device support
  1359. opengl opengl support
  1360. virglrenderer virgl rendering support
  1361. xfsctl xfsctl support
  1362. qom-cast-debug cast debugging support
  1363. tools build qemu-io, qemu-nbd and qemu-image tools
  1364. NOTE: The object files are built at the place where configure is launched
  1365. EOF
  1366. exit 0
  1367. fi
  1368. # Now we have handled --enable-tcg-interpreter and know we're not just
  1369. # printing the help message, bail out if the host CPU isn't supported.
  1370. if test "$ARCH" = "unknown"; then
  1371. if test "$tcg_interpreter" = "yes" ; then
  1372. echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
  1373. else
  1374. error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
  1375. fi
  1376. fi
  1377. # Consult white-list to determine whether to enable werror
  1378. # by default. Only enable by default for git builds
  1379. if test -z "$werror" ; then
  1380. if test -d "$source_path/.git" -a \
  1381. \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
  1382. werror="yes"
  1383. else
  1384. werror="no"
  1385. fi
  1386. fi
  1387. # check that the C compiler works.
  1388. write_c_skeleton;
  1389. if compile_object ; then
  1390. : C compiler works ok
  1391. else
  1392. error_exit "\"$cc\" either does not exist or does not work"
  1393. fi
  1394. if ! compile_prog ; then
  1395. error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
  1396. fi
  1397. if test "$bogus_os" = "yes"; then
  1398. # Now that we know that we're not printing the help and that
  1399. # the compiler works (so the results of the check_defines we used
  1400. # to identify the OS are reliable), if we didn't recognize the
  1401. # host OS we should stop now.
  1402. error_exit "Unrecognized host OS $targetos"
  1403. fi
  1404. # Check that the C++ compiler exists and works with the C compiler
  1405. if has $cxx; then
  1406. cat > $TMPC <<EOF
  1407. int c_function(void);
  1408. int main(void) { return c_function(); }
  1409. EOF
  1410. compile_object
  1411. cat > $TMPCXX <<EOF
  1412. extern "C" {
  1413. int c_function(void);
  1414. }
  1415. int c_function(void) { return 42; }
  1416. EOF
  1417. update_cxxflags
  1418. if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
  1419. # C++ compiler $cxx works ok with C compiler $cc
  1420. :
  1421. else
  1422. echo "C++ compiler $cxx does not work with C compiler $cc"
  1423. echo "Disabling C++ specific optional code"
  1424. cxx=
  1425. fi
  1426. else
  1427. echo "No C++ compiler available; disabling C++ specific optional code"
  1428. cxx=
  1429. fi
  1430. gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
  1431. gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
  1432. gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
  1433. gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
  1434. gcc_flags="-Wno-initializer-overrides $gcc_flags"
  1435. gcc_flags="-Wno-string-plus-int $gcc_flags"
  1436. # Note that we do not add -Werror to gcc_flags here, because that would
  1437. # enable it for all configure tests. If a configure test failed due
  1438. # to -Werror this would just silently disable some features,
  1439. # so it's too error prone.
  1440. cc_has_warning_flag() {
  1441. write_c_skeleton;
  1442. # Use the positive sense of the flag when testing for -Wno-wombat
  1443. # support (gcc will happily accept the -Wno- form of unknown
  1444. # warning options).
  1445. optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
  1446. compile_prog "-Werror $optflag" ""
  1447. }
  1448. for flag in $gcc_flags; do
  1449. if cc_has_warning_flag $flag ; then
  1450. QEMU_CFLAGS="$QEMU_CFLAGS $flag"
  1451. fi
  1452. done
  1453. if test "$stack_protector" != "no"; then
  1454. cat > $TMPC << EOF
  1455. int main(int argc, char *argv[])
  1456. {
  1457. char arr[64], *p = arr, *c = argv[0];
  1458. while (*c) {
  1459. *p++ = *c++;
  1460. }
  1461. return 0;
  1462. }
  1463. EOF
  1464. gcc_flags="-fstack-protector-strong -fstack-protector-all"
  1465. sp_on=0
  1466. for flag in $gcc_flags; do
  1467. # We need to check both a compile and a link, since some compiler
  1468. # setups fail only on a .c->.o compile and some only at link time
  1469. if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
  1470. compile_prog "-Werror $flag" ""; then
  1471. QEMU_CFLAGS="$QEMU_CFLAGS $flag"
  1472. sp_on=1
  1473. break
  1474. fi
  1475. done
  1476. if test "$stack_protector" = yes; then
  1477. if test $sp_on = 0; then
  1478. error_exit "Stack protector not supported"
  1479. fi
  1480. fi
  1481. fi
  1482. # Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
  1483. # large functions that use global variables. The bug is in all releases of
  1484. # GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
  1485. # 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
  1486. cat > $TMPC << EOF
  1487. #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
  1488. int main(void) { return 0; }
  1489. #else
  1490. #error No bug in this compiler.
  1491. #endif
  1492. EOF
  1493. if compile_prog "-Werror -fno-gcse" "" ; then
  1494. TRANSLATE_OPT_CFLAGS=-fno-gcse
  1495. fi
  1496. if test "$static" = "yes" ; then
  1497. if test "$modules" = "yes" ; then
  1498. error_exit "static and modules are mutually incompatible"
  1499. fi
  1500. if test "$pie" = "yes" ; then
  1501. error_exit "static and pie are mutually incompatible"
  1502. else
  1503. pie="no"
  1504. fi
  1505. fi
  1506. # Unconditional check for compiler __thread support
  1507. cat > $TMPC << EOF
  1508. static __thread int tls_var;
  1509. int main(void) { return tls_var; }
  1510. EOF
  1511. if ! compile_prog "-Werror" "" ; then
  1512. error_exit "Your compiler does not support the __thread specifier for " \
  1513. "Thread-Local Storage (TLS). Please upgrade to a version that does."
  1514. fi
  1515. if test "$pie" = ""; then
  1516. case "$cpu-$targetos" in
  1517. i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
  1518. ;;
  1519. *)
  1520. pie="no"
  1521. ;;
  1522. esac
  1523. fi
  1524. if test "$pie" != "no" ; then
  1525. cat > $TMPC << EOF
  1526. #ifdef __linux__
  1527. # define THREAD __thread
  1528. #else
  1529. # define THREAD
  1530. #endif
  1531. static THREAD int tls_var;
  1532. int main(void) { return tls_var; }
  1533. EOF
  1534. if compile_prog "-fPIE -DPIE" "-pie"; then
  1535. QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
  1536. LDFLAGS="-pie $LDFLAGS"
  1537. pie="yes"
  1538. if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
  1539. LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
  1540. fi
  1541. else
  1542. if test "$pie" = "yes"; then
  1543. error_exit "PIE not available due to missing toolchain support"
  1544. else
  1545. echo "Disabling PIE due to missing toolchain support"
  1546. pie="no"
  1547. fi
  1548. fi
  1549. if compile_prog "-Werror -fno-pie" "-nopie"; then
  1550. CFLAGS_NOPIE="-fno-pie"
  1551. LDFLAGS_NOPIE="-nopie"
  1552. fi
  1553. fi
  1554. ##########################################
  1555. # __sync_fetch_and_and requires at least -march=i486. Many toolchains
  1556. # use i686 as default anyway, but for those that don't, an explicit
  1557. # specification is necessary
  1558. if test "$cpu" = "i386"; then
  1559. cat > $TMPC << EOF
  1560. static int sfaa(int *ptr)
  1561. {
  1562. return __sync_fetch_and_and(ptr, 0);
  1563. }
  1564. int main(void)
  1565. {
  1566. int val = 42;
  1567. val = __sync_val_compare_and_swap(&val, 0, 1);
  1568. sfaa(&val);
  1569. return val;
  1570. }
  1571. EOF
  1572. if ! compile_prog "" "" ; then
  1573. QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
  1574. fi
  1575. fi
  1576. #########################################
  1577. # Solaris specific configure tool chain decisions
  1578. if test "$solaris" = "yes" ; then
  1579. if has $install; then
  1580. :
  1581. else
  1582. error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
  1583. "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
  1584. "to get ginstall which is used by default (which lives in /opt/csw/bin)"
  1585. fi
  1586. if test "$(path_of $install)" = "/usr/sbin/install" ; then
  1587. error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
  1588. "try ginstall from the GNU fileutils available from www.blastwave.org" \
  1589. "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
  1590. fi
  1591. if has ar; then
  1592. :
  1593. else
  1594. if test -f /usr/ccs/bin/ar ; then
  1595. error_exit "No path includes ar" \
  1596. "Add /usr/ccs/bin to your path and rerun configure"
  1597. fi
  1598. error_exit "No path includes ar"
  1599. fi
  1600. fi
  1601. if test -z "${target_list+xxx}" ; then
  1602. target_list="$default_target_list"
  1603. else
  1604. target_list=$(echo "$target_list" | sed -e 's/,/ /g')
  1605. fi
  1606. # Check that we recognised the target name; this allows a more
  1607. # friendly error message than if we let it fall through.
  1608. for target in $target_list; do
  1609. case " $default_target_list " in
  1610. *" $target "*)
  1611. ;;
  1612. *)
  1613. error_exit "Unknown target name '$target'"
  1614. ;;
  1615. esac
  1616. done
  1617. # see if system emulation was really requested
  1618. case " $target_list " in
  1619. *"-softmmu "*) softmmu=yes
  1620. ;;
  1621. *) softmmu=no
  1622. ;;
  1623. esac
  1624. feature_not_found() {
  1625. feature=$1
  1626. remedy=$2
  1627. error_exit "User requested feature $feature" \
  1628. "configure was not able to find it." \
  1629. "$remedy"
  1630. }
  1631. # ---
  1632. # big/little endian test
  1633. cat > $TMPC << EOF
  1634. short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
  1635. short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
  1636. extern int foo(short *, short *);
  1637. int main(int argc, char *argv[]) {
  1638. return foo(big_endian, little_endian);
  1639. }
  1640. EOF
  1641. if compile_object ; then
  1642. if grep -q BiGeNdIaN $TMPO ; then
  1643. bigendian="yes"
  1644. elif grep -q LiTtLeEnDiAn $TMPO ; then
  1645. bigendian="no"
  1646. else
  1647. echo big/little test failed
  1648. fi
  1649. else
  1650. echo big/little test failed
  1651. fi
  1652. ##########################################
  1653. # cocoa implies not SDL or GTK
  1654. # (the cocoa UI code currently assumes it is always the active UI
  1655. # and doesn't interact well with other UI frontend code)
  1656. if test "$cocoa" = "yes"; then
  1657. if test "$sdl" = "yes"; then
  1658. error_exit "Cocoa and SDL UIs cannot both be enabled at once"
  1659. fi
  1660. if test "$gtk" = "yes"; then
  1661. error_exit "Cocoa and GTK UIs cannot both be enabled at once"
  1662. fi
  1663. gtk=no
  1664. sdl=no
  1665. fi
  1666. # Some versions of Mac OS X incorrectly define SIZE_MAX
  1667. cat > $TMPC << EOF
  1668. #include <stdint.h>
  1669. #include <stdio.h>
  1670. int main(int argc, char *argv[]) {
  1671. return printf("%zu", SIZE_MAX);
  1672. }
  1673. EOF
  1674. have_broken_size_max=no
  1675. if ! compile_object -Werror ; then
  1676. have_broken_size_max=yes
  1677. fi
  1678. ##########################################
  1679. # L2TPV3 probe
  1680. cat > $TMPC <<EOF
  1681. #include <sys/socket.h>
  1682. #include <linux/ip.h>
  1683. int main(void) { return sizeof(struct mmsghdr); }
  1684. EOF
  1685. if compile_prog "" "" ; then
  1686. l2tpv3=yes
  1687. else
  1688. l2tpv3=no
  1689. fi
  1690. ##########################################
  1691. # MinGW / Mingw-w64 localtime_r/gmtime_r check
  1692. if test "$mingw32" = "yes"; then
  1693. # Some versions of MinGW / Mingw-w64 lack localtime_r
  1694. # and gmtime_r entirely.
  1695. #
  1696. # Some versions of Mingw-w64 define a macro for
  1697. # localtime_r/gmtime_r.
  1698. #
  1699. # Some versions of Mingw-w64 will define functions
  1700. # for localtime_r/gmtime_r, but only if you have
  1701. # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
  1702. # though, unistd.h and pthread.h both define
  1703. # that for you.
  1704. #
  1705. # So this #undef localtime_r and #include <unistd.h>
  1706. # are not in fact redundant.
  1707. cat > $TMPC << EOF
  1708. #include <unistd.h>
  1709. #include <time.h>
  1710. #undef localtime_r
  1711. int main(void) { localtime_r(NULL, NULL); return 0; }
  1712. EOF
  1713. if compile_prog "" "" ; then
  1714. localtime_r="yes"
  1715. else
  1716. localtime_r="no"
  1717. fi
  1718. fi
  1719. ##########################################
  1720. # pkg-config probe
  1721. if ! has "$pkg_config_exe"; then
  1722. error_exit "pkg-config binary '$pkg_config_exe' not found"
  1723. fi
  1724. ##########################################
  1725. # NPTL probe
  1726. if test "$linux_user" = "yes"; then
  1727. cat > $TMPC <<EOF
  1728. #include <sched.h>
  1729. #include <linux/futex.h>
  1730. int main(void) {
  1731. #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
  1732. #error bork
  1733. #endif
  1734. return 0;
  1735. }
  1736. EOF
  1737. if ! compile_object ; then
  1738. feature_not_found "nptl" "Install glibc and linux kernel headers."
  1739. fi
  1740. fi
  1741. ##########################################
  1742. # avx2 optimization requirement check
  1743. cat > $TMPC << EOF
  1744. #pragma GCC push_options
  1745. #pragma GCC target("avx2")
  1746. #include <cpuid.h>
  1747. #include <immintrin.h>
  1748. static int bar(void *a) {
  1749. __m256i x = *(__m256i *)a;
  1750. return _mm256_testz_si256(x, x);
  1751. }
  1752. int main(int argc, char *argv[]) { return bar(argv[0]); }
  1753. EOF
  1754. if compile_object "" ; then
  1755. avx2_opt="yes"
  1756. fi
  1757. #########################################
  1758. # zlib check
  1759. if test "$zlib" != "no" ; then
  1760. cat > $TMPC << EOF
  1761. #include <zlib.h>
  1762. int main(void) { zlibVersion(); return 0; }
  1763. EOF
  1764. if compile_prog "" "-lz" ; then
  1765. :
  1766. else
  1767. error_exit "zlib check failed" \
  1768. "Make sure to have the zlib libs and headers installed."
  1769. fi
  1770. fi
  1771. LIBS="$LIBS -lz"
  1772. ##########################################
  1773. # lzo check
  1774. if test "$lzo" != "no" ; then
  1775. cat > $TMPC << EOF
  1776. #include <lzo/lzo1x.h>
  1777. int main(void) { lzo_version(); return 0; }
  1778. EOF
  1779. if compile_prog "" "-llzo2" ; then
  1780. libs_softmmu="$libs_softmmu -llzo2"
  1781. lzo="yes"
  1782. else
  1783. if test "$lzo" = "yes"; then
  1784. feature_not_found "liblzo2" "Install liblzo2 devel"
  1785. fi
  1786. lzo="no"
  1787. fi
  1788. fi
  1789. ##########################################
  1790. # snappy check
  1791. if test "$snappy" != "no" ; then
  1792. cat > $TMPC << EOF
  1793. #include <snappy-c.h>
  1794. int main(void) { snappy_max_compressed_length(4096); return 0; }
  1795. EOF
  1796. if compile_prog "" "-lsnappy" ; then
  1797. libs_softmmu="$libs_softmmu -lsnappy"
  1798. snappy="yes"
  1799. else
  1800. if test "$snappy" = "yes"; then
  1801. feature_not_found "libsnappy" "Install libsnappy devel"
  1802. fi
  1803. snappy="no"
  1804. fi
  1805. fi
  1806. ##########################################
  1807. # bzip2 check
  1808. if test "$bzip2" != "no" ; then
  1809. cat > $TMPC << EOF
  1810. #include <bzlib.h>
  1811. int main(void) { BZ2_bzlibVersion(); return 0; }
  1812. EOF
  1813. if compile_prog "" "-lbz2" ; then
  1814. bzip2="yes"
  1815. else
  1816. if test "$bzip2" = "yes"; then
  1817. feature_not_found "libbzip2" "Install libbzip2 devel"
  1818. fi
  1819. bzip2="no"
  1820. fi
  1821. fi
  1822. ##########################################
  1823. # libseccomp check
  1824. if test "$seccomp" != "no" ; then
  1825. case "$cpu" in
  1826. i386|x86_64)
  1827. libseccomp_minver="2.1.0"
  1828. ;;
  1829. mips)
  1830. libseccomp_minver="2.2.0"
  1831. ;;
  1832. arm|aarch64)
  1833. libseccomp_minver="2.2.3"
  1834. ;;
  1835. ppc|ppc64)
  1836. libseccomp_minver="2.3.0"
  1837. ;;
  1838. *)
  1839. libseccomp_minver=""
  1840. ;;
  1841. esac
  1842. if test "$libseccomp_minver" != "" &&
  1843. $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
  1844. libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
  1845. QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libseccomp)"
  1846. seccomp="yes"
  1847. else
  1848. if test "$seccomp" = "yes" ; then
  1849. if test "$libseccomp_minver" != "" ; then
  1850. feature_not_found "libseccomp" \
  1851. "Install libseccomp devel >= $libseccomp_minver"
  1852. else
  1853. feature_not_found "libseccomp" \
  1854. "libseccomp is not supported for host cpu $cpu"
  1855. fi
  1856. fi
  1857. seccomp="no"
  1858. fi
  1859. fi
  1860. ##########################################
  1861. # xen probe
  1862. if test "$xen" != "no" ; then
  1863. xen_libs="-lxenstore -lxenctrl -lxenguest"
  1864. xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
  1865. # First we test whether Xen headers and libraries are available.
  1866. # If no, we are done and there is no Xen support.
  1867. # If yes, more tests are run to detect the Xen version.
  1868. # Xen (any)
  1869. cat > $TMPC <<EOF
  1870. #include <xenctrl.h>
  1871. int main(void) {
  1872. return 0;
  1873. }
  1874. EOF
  1875. if ! compile_prog "" "$xen_libs" ; then
  1876. # Xen not found
  1877. if test "$xen" = "yes" ; then
  1878. feature_not_found "xen" "Install xen devel"
  1879. fi
  1880. xen=no
  1881. # Xen unstable
  1882. elif
  1883. cat > $TMPC <<EOF &&
  1884. /*
  1885. * If we have stable libs the we don't want the libxc compat
  1886. * layers, regardless of what CFLAGS we may have been given.
  1887. *
  1888. * Also, check if xengnttab_grant_copy_segment_t is defined and
  1889. * grant copy operation is implemented.
  1890. */
  1891. #undef XC_WANT_COMPAT_EVTCHN_API
  1892. #undef XC_WANT_COMPAT_GNTTAB_API
  1893. #undef XC_WANT_COMPAT_MAP_FOREIGN_API
  1894. #include <xenctrl.h>
  1895. #include <xenstore.h>
  1896. #include <xenevtchn.h>
  1897. #include <xengnttab.h>
  1898. #include <xenforeignmemory.h>
  1899. #include <stdint.h>
  1900. #include <xen/hvm/hvm_info_table.h>
  1901. #if !defined(HVM_MAX_VCPUS)
  1902. # error HVM_MAX_VCPUS not defined
  1903. #endif
  1904. int main(void) {
  1905. xc_interface *xc = NULL;
  1906. xenforeignmemory_handle *xfmem;
  1907. xenevtchn_handle *xe;
  1908. xengnttab_handle *xg;
  1909. xen_domain_handle_t handle;
  1910. xengnttab_grant_copy_segment_t* seg = NULL;
  1911. xs_daemon_open();
  1912. xc = xc_interface_open(0, 0, 0);
  1913. xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
  1914. xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  1915. xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  1916. xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
  1917. xc_domain_create(xc, 0, handle, 0, NULL, NULL);
  1918. xfmem = xenforeignmemory_open(0, 0);
  1919. xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
  1920. xe = xenevtchn_open(0, 0);
  1921. xenevtchn_fd(xe);
  1922. xg = xengnttab_open(0, 0);
  1923. xengnttab_grant_copy(xg, 0, seg);
  1924. return 0;
  1925. }
  1926. EOF
  1927. compile_prog "" "$xen_libs $xen_stable_libs"
  1928. then
  1929. xen_ctrl_version=480
  1930. xen=yes
  1931. elif
  1932. cat > $TMPC <<EOF &&
  1933. /*
  1934. * If we have stable libs the we don't want the libxc compat
  1935. * layers, regardless of what CFLAGS we may have been given.
  1936. */
  1937. #undef XC_WANT_COMPAT_EVTCHN_API
  1938. #undef XC_WANT_COMPAT_GNTTAB_API
  1939. #undef XC_WANT_COMPAT_MAP_FOREIGN_API
  1940. #include <xenctrl.h>
  1941. #include <xenstore.h>
  1942. #include <xenevtchn.h>
  1943. #include <xengnttab.h>
  1944. #include <xenforeignmemory.h>
  1945. #include <stdint.h>
  1946. #include <xen/hvm/hvm_info_table.h>
  1947. #if !defined(HVM_MAX_VCPUS)
  1948. # error HVM_MAX_VCPUS not defined
  1949. #endif
  1950. int main(void) {
  1951. xc_interface *xc = NULL;
  1952. xenforeignmemory_handle *xfmem;
  1953. xenevtchn_handle *xe;
  1954. xengnttab_handle *xg;
  1955. xen_domain_handle_t handle;
  1956. xs_daemon_open();
  1957. xc = xc_interface_open(0, 0, 0);
  1958. xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
  1959. xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  1960. xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  1961. xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
  1962. xc_domain_create(xc, 0, handle, 0, NULL, NULL);
  1963. xfmem = xenforeignmemory_open(0, 0);
  1964. xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
  1965. xe = xenevtchn_open(0, 0);
  1966. xenevtchn_fd(xe);
  1967. xg = xengnttab_open(0, 0);
  1968. xengnttab_map_grant_ref(xg, 0, 0, 0);
  1969. return 0;
  1970. }
  1971. EOF
  1972. compile_prog "" "$xen_libs $xen_stable_libs"
  1973. then
  1974. xen_ctrl_version=471
  1975. xen=yes
  1976. elif
  1977. cat > $TMPC <<EOF &&
  1978. #include <xenctrl.h>
  1979. #include <stdint.h>
  1980. int main(void) {
  1981. xc_interface *xc = NULL;
  1982. xen_domain_handle_t handle;
  1983. xc_domain_create(xc, 0, handle, 0, NULL, NULL);
  1984. return 0;
  1985. }
  1986. EOF
  1987. compile_prog "" "$xen_libs"
  1988. then
  1989. xen_ctrl_version=470
  1990. xen=yes
  1991. # Xen 4.6
  1992. elif
  1993. cat > $TMPC <<EOF &&
  1994. #include <xenctrl.h>
  1995. #include <xenstore.h>
  1996. #include <stdint.h>
  1997. #include <xen/hvm/hvm_info_table.h>
  1998. #if !defined(HVM_MAX_VCPUS)
  1999. # error HVM_MAX_VCPUS not defined
  2000. #endif
  2001. int main(void) {
  2002. xc_interface *xc;
  2003. xs_daemon_open();
  2004. xc = xc_interface_open(0, 0, 0);
  2005. xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
  2006. xc_gnttab_open(NULL, 0);
  2007. xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  2008. xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  2009. xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
  2010. xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
  2011. return 0;
  2012. }
  2013. EOF
  2014. compile_prog "" "$xen_libs"
  2015. then
  2016. xen_ctrl_version=460
  2017. xen=yes
  2018. # Xen 4.5
  2019. elif
  2020. cat > $TMPC <<EOF &&
  2021. #include <xenctrl.h>
  2022. #include <xenstore.h>
  2023. #include <stdint.h>
  2024. #include <xen/hvm/hvm_info_table.h>
  2025. #if !defined(HVM_MAX_VCPUS)
  2026. # error HVM_MAX_VCPUS not defined
  2027. #endif
  2028. int main(void) {
  2029. xc_interface *xc;
  2030. xs_daemon_open();
  2031. xc = xc_interface_open(0, 0, 0);
  2032. xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
  2033. xc_gnttab_open(NULL, 0);
  2034. xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  2035. xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  2036. xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
  2037. return 0;
  2038. }
  2039. EOF
  2040. compile_prog "" "$xen_libs"
  2041. then
  2042. xen_ctrl_version=450
  2043. xen=yes
  2044. elif
  2045. cat > $TMPC <<EOF &&
  2046. #include <xenctrl.h>
  2047. #include <xenstore.h>
  2048. #include <stdint.h>
  2049. #include <xen/hvm/hvm_info_table.h>
  2050. #if !defined(HVM_MAX_VCPUS)
  2051. # error HVM_MAX_VCPUS not defined
  2052. #endif
  2053. int main(void) {
  2054. xc_interface *xc;
  2055. xs_daemon_open();
  2056. xc = xc_interface_open(0, 0, 0);
  2057. xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
  2058. xc_gnttab_open(NULL, 0);
  2059. xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  2060. xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  2061. return 0;
  2062. }
  2063. EOF
  2064. compile_prog "" "$xen_libs"
  2065. then
  2066. xen_ctrl_version=420
  2067. xen=yes
  2068. else
  2069. if test "$xen" = "yes" ; then
  2070. feature_not_found "xen (unsupported version)" \
  2071. "Install a supported xen (xen 4.2 or newer)"
  2072. fi
  2073. xen=no
  2074. fi
  2075. if test "$xen" = yes; then
  2076. if test $xen_ctrl_version -ge 471 ; then
  2077. libs_softmmu="$xen_stable_libs $libs_softmmu"
  2078. fi
  2079. libs_softmmu="$xen_libs $libs_softmmu"
  2080. fi
  2081. fi
  2082. if test "$xen_pci_passthrough" != "no"; then
  2083. if test "$xen" = "yes" && test "$linux" = "yes"; then
  2084. xen_pci_passthrough=yes
  2085. else
  2086. if test "$xen_pci_passthrough" = "yes"; then
  2087. error_exit "User requested feature Xen PCI Passthrough" \
  2088. " but this feature requires /sys from Linux"
  2089. fi
  2090. xen_pci_passthrough=no
  2091. fi
  2092. fi
  2093. if test "$xen_pv_domain_build" = "yes" &&
  2094. test "$xen" != "yes"; then
  2095. error_exit "User requested Xen PV domain builder support" \
  2096. "which requires Xen support."
  2097. fi
  2098. ##########################################
  2099. # Sparse probe
  2100. if test "$sparse" != "no" ; then
  2101. if has cgcc; then
  2102. sparse=yes
  2103. else
  2104. if test "$sparse" = "yes" ; then
  2105. feature_not_found "sparse" "Install sparse binary"
  2106. fi
  2107. sparse=no
  2108. fi
  2109. fi
  2110. ##########################################
  2111. # X11 probe
  2112. x11_cflags=
  2113. x11_libs=-lX11
  2114. if $pkg_config --exists "x11"; then
  2115. x11_cflags=$($pkg_config --cflags x11)
  2116. x11_libs=$($pkg_config --libs x11)
  2117. fi
  2118. ##########################################
  2119. # GTK probe
  2120. if test "$gtkabi" = ""; then
  2121. # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
  2122. # Use 3.0 as a fallback if that is available.
  2123. if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
  2124. gtkabi=2.0
  2125. elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
  2126. gtkabi=3.0
  2127. else
  2128. gtkabi=2.0
  2129. fi
  2130. fi
  2131. if test "$gtk" != "no"; then
  2132. gtkpackage="gtk+-$gtkabi"
  2133. gtkx11package="gtk+-x11-$gtkabi"
  2134. if test "$gtkabi" = "3.0" ; then
  2135. gtkversion="3.0.0"
  2136. else
  2137. gtkversion="2.18.0"
  2138. fi
  2139. if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
  2140. gtk_cflags=$($pkg_config --cflags $gtkpackage)
  2141. gtk_libs=$($pkg_config --libs $gtkpackage)
  2142. gtk_version=$($pkg_config --modversion $gtkpackage)
  2143. if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
  2144. gtk_cflags="$gtk_cflags $x11_cflags"
  2145. gtk_libs="$gtk_libs $x11_libs"
  2146. fi
  2147. libs_softmmu="$gtk_libs $libs_softmmu"
  2148. gtk="yes"
  2149. elif test "$gtk" = "yes"; then
  2150. feature_not_found "gtk" "Install gtk2 or gtk3 devel"
  2151. else
  2152. gtk="no"
  2153. fi
  2154. fi
  2155. ##########################################
  2156. # GNUTLS probe
  2157. gnutls_works() {
  2158. # Unfortunately some distros have bad pkg-config information for gnutls
  2159. # such that it claims to exist but you get a compiler error if you try
  2160. # to use the options returned by --libs. Specifically, Ubuntu for --static
  2161. # builds doesn't work:
  2162. # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
  2163. #
  2164. # So sanity check the cflags/libs before assuming gnutls can be used.
  2165. if ! $pkg_config --exists "gnutls"; then
  2166. return 1
  2167. fi
  2168. write_c_skeleton
  2169. compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
  2170. }
  2171. gnutls_gcrypt=no
  2172. gnutls_nettle=no
  2173. if test "$gnutls" != "no"; then
  2174. if gnutls_works; then
  2175. gnutls_cflags=$($pkg_config --cflags gnutls)
  2176. gnutls_libs=$($pkg_config --libs gnutls)
  2177. libs_softmmu="$gnutls_libs $libs_softmmu"
  2178. libs_tools="$gnutls_libs $libs_tools"
  2179. QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
  2180. gnutls="yes"
  2181. # gnutls_rnd requires >= 2.11.0
  2182. if $pkg_config --exists "gnutls >= 2.11.0"; then
  2183. gnutls_rnd="yes"
  2184. else
  2185. gnutls_rnd="no"
  2186. fi
  2187. if $pkg_config --exists 'gnutls >= 3.0'; then
  2188. gnutls_gcrypt=no
  2189. gnutls_nettle=yes
  2190. elif $pkg_config --exists 'gnutls >= 2.12'; then
  2191. case $($pkg_config --libs --static gnutls) in
  2192. *gcrypt*)
  2193. gnutls_gcrypt=yes
  2194. gnutls_nettle=no
  2195. ;;
  2196. *nettle*)
  2197. gnutls_gcrypt=no
  2198. gnutls_nettle=yes
  2199. ;;
  2200. *)
  2201. gnutls_gcrypt=yes
  2202. gnutls_nettle=no
  2203. ;;
  2204. esac
  2205. else
  2206. gnutls_gcrypt=yes
  2207. gnutls_nettle=no
  2208. fi
  2209. elif test "$gnutls" = "yes"; then
  2210. feature_not_found "gnutls" "Install gnutls devel"
  2211. else
  2212. gnutls="no"
  2213. gnutls_rnd="no"
  2214. fi
  2215. else
  2216. gnutls_rnd="no"
  2217. fi
  2218. # If user didn't give a --disable/enable-gcrypt flag,
  2219. # then mark as disabled if user requested nettle
  2220. # explicitly, or if gnutls links to nettle
  2221. if test -z "$gcrypt"
  2222. then
  2223. if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
  2224. then
  2225. gcrypt="no"
  2226. fi
  2227. fi
  2228. # If user didn't give a --disable/enable-nettle flag,
  2229. # then mark as disabled if user requested gcrypt
  2230. # explicitly, or if gnutls links to gcrypt
  2231. if test -z "$nettle"
  2232. then
  2233. if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
  2234. then
  2235. nettle="no"
  2236. fi
  2237. fi
  2238. has_libgcrypt_config() {
  2239. if ! has "libgcrypt-config"
  2240. then
  2241. return 1
  2242. fi
  2243. if test -n "$cross_prefix"
  2244. then
  2245. host=$(libgcrypt-config --host)
  2246. if test "$host-" != $cross_prefix
  2247. then
  2248. return 1
  2249. fi
  2250. fi
  2251. return 0
  2252. }
  2253. if test "$gcrypt" != "no"; then
  2254. if has_libgcrypt_config; then
  2255. gcrypt_cflags=$(libgcrypt-config --cflags)
  2256. gcrypt_libs=$(libgcrypt-config --libs)
  2257. # Debian has remove -lgpg-error from libgcrypt-config
  2258. # as it "spreads unnecessary dependencies" which in
  2259. # turn breaks static builds...
  2260. if test "$static" = "yes"
  2261. then
  2262. gcrypt_libs="$gcrypt_libs -lgpg-error"
  2263. fi
  2264. libs_softmmu="$gcrypt_libs $libs_softmmu"
  2265. libs_tools="$gcrypt_libs $libs_tools"
  2266. QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
  2267. gcrypt="yes"
  2268. if test -z "$nettle"; then
  2269. nettle="no"
  2270. fi
  2271. cat > $TMPC << EOF
  2272. #include <gcrypt.h>
  2273. int main(void) {
  2274. gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
  2275. GCRY_MD_SHA256,
  2276. NULL, 0, 0, 0, NULL);
  2277. return 0;
  2278. }
  2279. EOF
  2280. if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
  2281. gcrypt_kdf=yes
  2282. fi
  2283. cat > $TMPC << EOF
  2284. #include <gcrypt.h>
  2285. int main(void) {
  2286. gcry_mac_hd_t handle;
  2287. gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
  2288. GCRY_MAC_FLAG_SECURE, NULL);
  2289. return 0;
  2290. }
  2291. EOF
  2292. if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
  2293. gcrypt_hmac=yes
  2294. fi
  2295. else
  2296. if test "$gcrypt" = "yes"; then
  2297. feature_not_found "gcrypt" "Install gcrypt devel"
  2298. else
  2299. gcrypt="no"
  2300. fi
  2301. fi
  2302. fi
  2303. if test "$nettle" != "no"; then
  2304. if $pkg_config --exists "nettle"; then
  2305. nettle_cflags=$($pkg_config --cflags nettle)
  2306. nettle_libs=$($pkg_config --libs nettle)
  2307. nettle_version=$($pkg_config --modversion nettle)
  2308. libs_softmmu="$nettle_libs $libs_softmmu"
  2309. libs_tools="$nettle_libs $libs_tools"
  2310. QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
  2311. nettle="yes"
  2312. cat > $TMPC << EOF
  2313. #include <stddef.h>
  2314. #include <nettle/pbkdf2.h>
  2315. int main(void) {
  2316. pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
  2317. return 0;
  2318. }
  2319. EOF
  2320. if compile_prog "$nettle_cflags" "$nettle_libs" ; then
  2321. nettle_kdf=yes
  2322. fi
  2323. else
  2324. if test "$nettle" = "yes"; then
  2325. feature_not_found "nettle" "Install nettle devel"
  2326. else
  2327. nettle="no"
  2328. fi
  2329. fi
  2330. fi
  2331. if test "$gcrypt" = "yes" && test "$nettle" = "yes"
  2332. then
  2333. error_exit "Only one of gcrypt & nettle can be enabled"
  2334. fi
  2335. ##########################################
  2336. # libtasn1 - only for the TLS creds/session test suite
  2337. tasn1=yes
  2338. tasn1_cflags=""
  2339. tasn1_libs=""
  2340. if $pkg_config --exists "libtasn1"; then
  2341. tasn1_cflags=$($pkg_config --cflags libtasn1)
  2342. tasn1_libs=$($pkg_config --libs libtasn1)
  2343. else
  2344. tasn1=no
  2345. fi
  2346. ##########################################
  2347. # getifaddrs (for tests/test-io-channel-socket )
  2348. have_ifaddrs_h=yes
  2349. if ! check_include "ifaddrs.h" ; then
  2350. have_ifaddrs_h=no
  2351. fi
  2352. ##########################################
  2353. # VTE probe
  2354. if test "$vte" != "no"; then
  2355. if test "$gtkabi" = "3.0"; then
  2356. vteminversion="0.32.0"
  2357. if $pkg_config --exists "vte-2.91"; then
  2358. vtepackage="vte-2.91"
  2359. else
  2360. vtepackage="vte-2.90"
  2361. fi
  2362. else
  2363. vtepackage="vte"
  2364. vteminversion="0.24.0"
  2365. fi
  2366. if $pkg_config --exists "$vtepackage >= $vteminversion"; then
  2367. vte_cflags=$($pkg_config --cflags $vtepackage)
  2368. vte_libs=$($pkg_config --libs $vtepackage)
  2369. vteversion=$($pkg_config --modversion $vtepackage)
  2370. libs_softmmu="$vte_libs $libs_softmmu"
  2371. vte="yes"
  2372. elif test "$vte" = "yes"; then
  2373. if test "$gtkabi" = "3.0"; then
  2374. feature_not_found "vte" "Install libvte-2.90/2.91 devel"
  2375. else
  2376. feature_not_found "vte" "Install libvte devel"
  2377. fi
  2378. else
  2379. vte="no"
  2380. fi
  2381. fi
  2382. ##########################################
  2383. # SDL probe
  2384. # Look for sdl configuration program (pkg-config or sdl-config). Try
  2385. # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
  2386. if test "$sdlabi" = ""; then
  2387. if $pkg_config --exists "sdl"; then
  2388. sdlabi=1.2
  2389. elif $pkg_config --exists "sdl2"; then
  2390. sdlabi=2.0
  2391. else
  2392. sdlabi=1.2
  2393. fi
  2394. fi
  2395. if test $sdlabi = "2.0"; then
  2396. sdl_config=$sdl2_config
  2397. sdlname=sdl2
  2398. sdlconfigname=sdl2_config
  2399. elif test $sdlabi = "1.2"; then
  2400. sdlname=sdl
  2401. sdlconfigname=sdl_config
  2402. else
  2403. error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
  2404. fi
  2405. if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
  2406. sdl_config=$sdlconfigname
  2407. fi
  2408. if $pkg_config $sdlname --exists; then
  2409. sdlconfig="$pkg_config $sdlname"
  2410. sdlversion=$($sdlconfig --modversion 2>/dev/null)
  2411. elif has ${sdl_config}; then
  2412. sdlconfig="$sdl_config"
  2413. sdlversion=$($sdlconfig --version)
  2414. else
  2415. if test "$sdl" = "yes" ; then
  2416. feature_not_found "sdl" "Install SDL devel"
  2417. fi
  2418. sdl=no
  2419. fi
  2420. if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
  2421. echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
  2422. fi
  2423. sdl_too_old=no
  2424. if test "$sdl" != "no" ; then
  2425. cat > $TMPC << EOF
  2426. #include <SDL.h>
  2427. #undef main /* We don't want SDL to override our main() */
  2428. int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
  2429. EOF
  2430. sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
  2431. if test "$static" = "yes" ; then
  2432. sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
  2433. else
  2434. sdl_libs=$($sdlconfig --libs 2>/dev/null)
  2435. fi
  2436. if compile_prog "$sdl_cflags" "$sdl_libs" ; then
  2437. if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
  2438. sdl_too_old=yes
  2439. else
  2440. sdl=yes
  2441. fi
  2442. # static link with sdl ? (note: sdl.pc's --static --libs is broken)
  2443. if test "$sdl" = "yes" -a "$static" = "yes" ; then
  2444. if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
  2445. sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
  2446. sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
  2447. fi
  2448. if compile_prog "$sdl_cflags" "$sdl_libs" ; then
  2449. :
  2450. else
  2451. sdl=no
  2452. fi
  2453. fi # static link
  2454. else # sdl not found
  2455. if test "$sdl" = "yes" ; then
  2456. feature_not_found "sdl" "Install SDL devel"
  2457. fi
  2458. sdl=no
  2459. fi # sdl compile test
  2460. fi
  2461. if test "$sdl" = "yes" ; then
  2462. cat > $TMPC <<EOF
  2463. #include <SDL.h>
  2464. #if defined(SDL_VIDEO_DRIVER_X11)
  2465. #include <X11/XKBlib.h>
  2466. #else
  2467. #error No x11 support
  2468. #endif
  2469. int main(void) { return 0; }
  2470. EOF
  2471. if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
  2472. sdl_cflags="$sdl_cflags $x11_cflags"
  2473. sdl_libs="$sdl_libs $x11_libs"
  2474. fi
  2475. libs_softmmu="$sdl_libs $libs_softmmu"
  2476. fi
  2477. ##########################################
  2478. # RDMA needs OpenFabrics libraries
  2479. if test "$rdma" != "no" ; then
  2480. cat > $TMPC <<EOF
  2481. #include <rdma/rdma_cma.h>
  2482. int main(void) { return 0; }
  2483. EOF
  2484. rdma_libs="-lrdmacm -libverbs"
  2485. if compile_prog "" "$rdma_libs" ; then
  2486. rdma="yes"
  2487. libs_softmmu="$libs_softmmu $rdma_libs"
  2488. else
  2489. if test "$rdma" = "yes" ; then
  2490. error_exit \
  2491. " OpenFabrics librdmacm/libibverbs not present." \
  2492. " Your options:" \
  2493. " (1) Fast: Install infiniband packages from your distro." \
  2494. " (2) Cleanest: Install libraries from www.openfabrics.org" \
  2495. " (3) Also: Install softiwarp if you don't have RDMA hardware"
  2496. fi
  2497. rdma="no"
  2498. fi
  2499. fi
  2500. ##########################################
  2501. # VNC SASL detection
  2502. if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
  2503. cat > $TMPC <<EOF
  2504. #include <sasl/sasl.h>
  2505. #include <stdio.h>
  2506. int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
  2507. EOF
  2508. # Assuming Cyrus-SASL installed in /usr prefix
  2509. vnc_sasl_cflags=""
  2510. vnc_sasl_libs="-lsasl2"
  2511. if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
  2512. vnc_sasl=yes
  2513. libs_softmmu="$vnc_sasl_libs $libs_softmmu"
  2514. QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
  2515. else
  2516. if test "$vnc_sasl" = "yes" ; then
  2517. feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
  2518. fi
  2519. vnc_sasl=no
  2520. fi
  2521. fi
  2522. ##########################################
  2523. # VNC JPEG detection
  2524. if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
  2525. cat > $TMPC <<EOF
  2526. #include <stdio.h>
  2527. #include <jpeglib.h>
  2528. int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
  2529. EOF
  2530. vnc_jpeg_cflags=""
  2531. vnc_jpeg_libs="-ljpeg"
  2532. if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
  2533. vnc_jpeg=yes
  2534. libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
  2535. QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
  2536. else
  2537. if test "$vnc_jpeg" = "yes" ; then
  2538. feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
  2539. fi
  2540. vnc_jpeg=no
  2541. fi
  2542. fi
  2543. ##########################################
  2544. # VNC PNG detection
  2545. if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
  2546. cat > $TMPC <<EOF
  2547. //#include <stdio.h>
  2548. #include <png.h>
  2549. #include <stddef.h>
  2550. int main(void) {
  2551. png_structp png_ptr;
  2552. png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
  2553. return png_ptr != 0;
  2554. }
  2555. EOF
  2556. if $pkg_config libpng --exists; then
  2557. vnc_png_cflags=$($pkg_config libpng --cflags)
  2558. vnc_png_libs=$($pkg_config libpng --libs)
  2559. else
  2560. vnc_png_cflags=""
  2561. vnc_png_libs="-lpng"
  2562. fi
  2563. if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
  2564. vnc_png=yes
  2565. libs_softmmu="$vnc_png_libs $libs_softmmu"
  2566. QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
  2567. else
  2568. if test "$vnc_png" = "yes" ; then
  2569. feature_not_found "vnc-png" "Install libpng devel"
  2570. fi
  2571. vnc_png=no
  2572. fi
  2573. fi
  2574. ##########################################
  2575. # fnmatch() probe, used for ACL routines
  2576. fnmatch="no"
  2577. cat > $TMPC << EOF
  2578. #include <fnmatch.h>
  2579. int main(void)
  2580. {
  2581. fnmatch("foo", "foo", 0);
  2582. return 0;
  2583. }
  2584. EOF
  2585. if compile_prog "" "" ; then
  2586. fnmatch="yes"
  2587. fi
  2588. ##########################################
  2589. # xfsctl() probe, used for file-posix.c
  2590. if test "$xfs" != "no" ; then
  2591. cat > $TMPC << EOF
  2592. #include <stddef.h> /* NULL */
  2593. #include <xfs/xfs.h>
  2594. int main(void)
  2595. {
  2596. xfsctl(NULL, 0, 0, NULL);
  2597. return 0;
  2598. }
  2599. EOF
  2600. if compile_prog "" "" ; then
  2601. xfs="yes"
  2602. else
  2603. if test "$xfs" = "yes" ; then
  2604. feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
  2605. fi
  2606. xfs=no
  2607. fi
  2608. fi
  2609. ##########################################
  2610. # vde libraries probe
  2611. if test "$vde" != "no" ; then
  2612. vde_libs="-lvdeplug"
  2613. cat > $TMPC << EOF
  2614. #include <libvdeplug.h>
  2615. int main(void)
  2616. {
  2617. struct vde_open_args a = {0, 0, 0};
  2618. char s[] = "";
  2619. vde_open(s, s, &a);
  2620. return 0;
  2621. }
  2622. EOF
  2623. if compile_prog "" "$vde_libs" ; then
  2624. vde=yes
  2625. libs_softmmu="$vde_libs $libs_softmmu"
  2626. libs_tools="$vde_libs $libs_tools"
  2627. else
  2628. if test "$vde" = "yes" ; then
  2629. feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
  2630. fi
  2631. vde=no
  2632. fi
  2633. fi
  2634. ##########################################
  2635. # netmap support probe
  2636. # Apart from looking for netmap headers, we make sure that the host API version
  2637. # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
  2638. # a minor/major version number. Minor new features will be marked with values up
  2639. # to 15, and if something happens that requires a change to the backend we will
  2640. # move above 15, submit the backend fixes and modify this two bounds.
  2641. if test "$netmap" != "no" ; then
  2642. cat > $TMPC << EOF
  2643. #include <inttypes.h>
  2644. #include <net/if.h>
  2645. #include <net/netmap.h>
  2646. #include <net/netmap_user.h>
  2647. #if (NETMAP_API < 11) || (NETMAP_API > 15)
  2648. #error
  2649. #endif
  2650. int main(void) { return 0; }
  2651. EOF
  2652. if compile_prog "" "" ; then
  2653. netmap=yes
  2654. else
  2655. if test "$netmap" = "yes" ; then
  2656. feature_not_found "netmap"
  2657. fi
  2658. netmap=no
  2659. fi
  2660. fi
  2661. ##########################################
  2662. # libcap-ng library probe
  2663. if test "$cap_ng" != "no" ; then
  2664. cap_libs="-lcap-ng"
  2665. cat > $TMPC << EOF
  2666. #include <cap-ng.h>
  2667. int main(void)
  2668. {
  2669. capng_capability_to_name(CAPNG_EFFECTIVE);
  2670. return 0;
  2671. }
  2672. EOF
  2673. if compile_prog "" "$cap_libs" ; then
  2674. cap_ng=yes
  2675. libs_tools="$cap_libs $libs_tools"
  2676. else
  2677. if test "$cap_ng" = "yes" ; then
  2678. feature_not_found "cap_ng" "Install libcap-ng devel"
  2679. fi
  2680. cap_ng=no
  2681. fi
  2682. fi
  2683. ##########################################
  2684. # Sound support libraries probe
  2685. audio_drv_probe()
  2686. {
  2687. drv=$1
  2688. hdr=$2
  2689. lib=$3
  2690. exp=$4
  2691. cfl=$5
  2692. cat > $TMPC << EOF
  2693. #include <$hdr>
  2694. int main(void) { $exp }
  2695. EOF
  2696. if compile_prog "$cfl" "$lib" ; then
  2697. :
  2698. else
  2699. error_exit "$drv check failed" \
  2700. "Make sure to have the $drv libs and headers installed."
  2701. fi
  2702. }
  2703. audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
  2704. for drv in $audio_drv_list; do
  2705. case $drv in
  2706. alsa)
  2707. audio_drv_probe $drv alsa/asoundlib.h -lasound \
  2708. "return snd_pcm_close((snd_pcm_t *)0);"
  2709. libs_softmmu="-lasound $libs_softmmu"
  2710. ;;
  2711. pa)
  2712. audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
  2713. "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
  2714. libs_softmmu="-lpulse $libs_softmmu"
  2715. audio_pt_int="yes"
  2716. ;;
  2717. sdl)
  2718. if test "$sdl" = "no"; then
  2719. error_exit "sdl not found or disabled, can not use sdl audio driver"
  2720. fi
  2721. ;;
  2722. coreaudio)
  2723. libs_softmmu="-framework CoreAudio $libs_softmmu"
  2724. ;;
  2725. dsound)
  2726. libs_softmmu="-lole32 -ldxguid $libs_softmmu"
  2727. audio_win_int="yes"
  2728. ;;
  2729. oss)
  2730. libs_softmmu="$oss_lib $libs_softmmu"
  2731. ;;
  2732. wav)
  2733. # XXX: Probes for CoreAudio, DirectSound
  2734. ;;
  2735. *)
  2736. echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
  2737. error_exit "Unknown driver '$drv' selected" \
  2738. "Possible drivers are: $audio_possible_drivers"
  2739. }
  2740. ;;
  2741. esac
  2742. done
  2743. ##########################################
  2744. # BrlAPI probe
  2745. if test "$brlapi" != "no" ; then
  2746. brlapi_libs="-lbrlapi"
  2747. cat > $TMPC << EOF
  2748. #include <brlapi.h>
  2749. #include <stddef.h>
  2750. int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
  2751. EOF
  2752. if compile_prog "" "$brlapi_libs" ; then
  2753. brlapi=yes
  2754. libs_softmmu="$brlapi_libs $libs_softmmu"
  2755. else
  2756. if test "$brlapi" = "yes" ; then
  2757. feature_not_found "brlapi" "Install brlapi devel"
  2758. fi
  2759. brlapi=no
  2760. fi
  2761. fi
  2762. ##########################################
  2763. # curses probe
  2764. if test "$curses" != "no" ; then
  2765. if test "$mingw32" = "yes" ; then
  2766. curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
  2767. curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
  2768. else
  2769. curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
  2770. curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
  2771. fi
  2772. curses_found=no
  2773. cat > $TMPC << EOF
  2774. #include <locale.h>
  2775. #include <curses.h>
  2776. #include <wchar.h>
  2777. int main(void) {
  2778. const char *s = curses_version();
  2779. wchar_t wch = L'w';
  2780. setlocale(LC_ALL, "");
  2781. resize_term(0, 0);
  2782. addwstr(L"wide chars\n");
  2783. addnwstr(&wch, 1);
  2784. add_wch(WACS_DEGREE);
  2785. return s != 0;
  2786. }
  2787. EOF
  2788. IFS=:
  2789. for curses_inc in $curses_inc_list; do
  2790. IFS=:
  2791. for curses_lib in $curses_lib_list; do
  2792. unset IFS
  2793. if compile_prog "$curses_inc" "$curses_lib" ; then
  2794. curses_found=yes
  2795. QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
  2796. libs_softmmu="$curses_lib $libs_softmmu"
  2797. break
  2798. fi
  2799. done
  2800. if test "$curses_found" = yes ; then
  2801. break
  2802. fi
  2803. done
  2804. unset IFS
  2805. if test "$curses_found" = "yes" ; then
  2806. curses=yes
  2807. else
  2808. if test "$curses" = "yes" ; then
  2809. feature_not_found "curses" "Install ncurses devel"
  2810. fi
  2811. curses=no
  2812. fi
  2813. fi
  2814. ##########################################
  2815. # curl probe
  2816. if test "$curl" != "no" ; then
  2817. if $pkg_config libcurl --exists; then
  2818. curlconfig="$pkg_config libcurl"
  2819. else
  2820. curlconfig=curl-config
  2821. fi
  2822. cat > $TMPC << EOF
  2823. #include <curl/curl.h>
  2824. int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
  2825. EOF
  2826. curl_cflags=$($curlconfig --cflags 2>/dev/null)
  2827. curl_libs=$($curlconfig --libs 2>/dev/null)
  2828. if compile_prog "$curl_cflags" "$curl_libs" ; then
  2829. curl=yes
  2830. else
  2831. if test "$curl" = "yes" ; then
  2832. feature_not_found "curl" "Install libcurl devel"
  2833. fi
  2834. curl=no
  2835. fi
  2836. fi # test "$curl"
  2837. ##########################################
  2838. # bluez support probe
  2839. if test "$bluez" != "no" ; then
  2840. cat > $TMPC << EOF
  2841. #include <bluetooth/bluetooth.h>
  2842. int main(void) { return bt_error(0); }
  2843. EOF
  2844. bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
  2845. bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
  2846. if compile_prog "$bluez_cflags" "$bluez_libs" ; then
  2847. bluez=yes
  2848. libs_softmmu="$bluez_libs $libs_softmmu"
  2849. else
  2850. if test "$bluez" = "yes" ; then
  2851. feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
  2852. fi
  2853. bluez="no"
  2854. fi
  2855. fi
  2856. ##########################################
  2857. # glib support probe
  2858. if test "$mingw32" = yes; then
  2859. glib_req_ver=2.30
  2860. else
  2861. glib_req_ver=2.22
  2862. fi
  2863. glib_modules=gthread-2.0
  2864. if test "$modules" = yes; then
  2865. glib_modules="$glib_modules gmodule-2.0"
  2866. fi
  2867. # This workaround is required due to a bug in pkg-config file for glib as it
  2868. # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
  2869. if test "$static" = yes -a "$mingw32" = yes; then
  2870. QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
  2871. fi
  2872. for i in $glib_modules; do
  2873. if $pkg_config --atleast-version=$glib_req_ver $i; then
  2874. glib_cflags=$($pkg_config --cflags $i)
  2875. glib_libs=$($pkg_config --libs $i)
  2876. QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
  2877. LIBS="$glib_libs $LIBS"
  2878. libs_qga="$glib_libs $libs_qga"
  2879. else
  2880. error_exit "glib-$glib_req_ver $i is required to compile QEMU"
  2881. fi
  2882. done
  2883. # Sanity check that the current size_t matches the
  2884. # size that glib thinks it should be. This catches
  2885. # problems on multi-arch where people try to build
  2886. # 32-bit QEMU while pointing at 64-bit glib headers
  2887. cat > $TMPC <<EOF
  2888. #include <glib.h>
  2889. #include <unistd.h>
  2890. #define QEMU_BUILD_BUG_ON(x) \
  2891. typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
  2892. int main(void) {
  2893. QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
  2894. return 0;
  2895. }
  2896. EOF
  2897. if ! compile_prog "$CFLAGS" "$LIBS" ; then
  2898. error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
  2899. "You probably need to set PKG_CONFIG_LIBDIR"\
  2900. "to point to the right pkg-config files for your"\
  2901. "build target"
  2902. fi
  2903. # g_test_trap_subprocess added in 2.38. Used by some tests.
  2904. glib_subprocess=yes
  2905. if ! $pkg_config --atleast-version=2.38 glib-2.0; then
  2906. glib_subprocess=no
  2907. fi
  2908. # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
  2909. cat > $TMPC << EOF
  2910. #include <glib.h>
  2911. int main(void) { return 0; }
  2912. EOF
  2913. if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
  2914. if cc_has_warning_flag "-Wno-unknown-attributes"; then
  2915. glib_cflags="-Wno-unknown-attributes $glib_cflags"
  2916. CFLAGS="-Wno-unknown-attributes $CFLAGS"
  2917. fi
  2918. fi
  2919. ##########################################
  2920. # SHA command probe for modules
  2921. if test "$modules" = yes; then
  2922. shacmd_probe="sha1sum sha1 shasum"
  2923. for c in $shacmd_probe; do
  2924. if has $c; then
  2925. shacmd="$c"
  2926. break
  2927. fi
  2928. done
  2929. if test "$shacmd" = ""; then
  2930. error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
  2931. fi
  2932. fi
  2933. ##########################################
  2934. # pixman support probe
  2935. if test "$pixman" = ""; then
  2936. if test "$want_tools" = "no" -a "$softmmu" = "no"; then
  2937. pixman="none"
  2938. elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
  2939. pixman="system"
  2940. else
  2941. pixman="internal"
  2942. fi
  2943. fi
  2944. if test "$pixman" = "none"; then
  2945. if test "$want_tools" != "no" -o "$softmmu" != "no"; then
  2946. error_exit "pixman disabled but system emulation or tools build" \
  2947. "enabled. You can turn off pixman only if you also" \
  2948. "disable all system emulation targets and the tools" \
  2949. "build with '--disable-tools --disable-system'."
  2950. fi
  2951. pixman_cflags=
  2952. pixman_libs=
  2953. elif test "$pixman" = "system"; then
  2954. # pixman version has been checked above
  2955. pixman_cflags=$($pkg_config --cflags pixman-1)
  2956. pixman_libs=$($pkg_config --libs pixman-1)
  2957. else
  2958. if test ! -d ${source_path}/pixman/pixman; then
  2959. error_exit "pixman >= 0.21.8 not present. Your options:" \
  2960. " (1) Preferred: Install the pixman devel package (any recent" \
  2961. " distro should have packages as Xorg needs pixman too)." \
  2962. " (2) Fetch the pixman submodule, using:" \
  2963. " git submodule update --init pixman"
  2964. fi
  2965. mkdir -p pixman/pixman
  2966. pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
  2967. pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
  2968. fi
  2969. ##########################################
  2970. # libcap probe
  2971. if test "$cap" != "no" ; then
  2972. cat > $TMPC <<EOF
  2973. #include <stdio.h>
  2974. #include <sys/capability.h>
  2975. int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
  2976. EOF
  2977. if compile_prog "" "-lcap" ; then
  2978. cap=yes
  2979. else
  2980. cap=no
  2981. fi
  2982. fi
  2983. ##########################################
  2984. # pthread probe
  2985. PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
  2986. pthread=no
  2987. cat > $TMPC << EOF
  2988. #include <pthread.h>
  2989. static void *f(void *p) { return NULL; }
  2990. int main(void) {
  2991. pthread_t thread;
  2992. pthread_create(&thread, 0, f, 0);
  2993. return 0;
  2994. }
  2995. EOF
  2996. if compile_prog "" "" ; then
  2997. pthread=yes
  2998. else
  2999. for pthread_lib in $PTHREADLIBS_LIST; do
  3000. if compile_prog "" "$pthread_lib" ; then
  3001. pthread=yes
  3002. found=no
  3003. for lib_entry in $LIBS; do
  3004. if test "$lib_entry" = "$pthread_lib"; then
  3005. found=yes
  3006. break
  3007. fi
  3008. done
  3009. if test "$found" = "no"; then
  3010. LIBS="$pthread_lib $LIBS"
  3011. fi
  3012. PTHREAD_LIB="$pthread_lib"
  3013. break
  3014. fi
  3015. done
  3016. fi
  3017. if test "$mingw32" != yes -a "$pthread" = no; then
  3018. error_exit "pthread check failed" \
  3019. "Make sure to have the pthread libs and headers installed."
  3020. fi
  3021. # check for pthread_setname_np
  3022. pthread_setname_np=no
  3023. cat > $TMPC << EOF
  3024. #include <pthread.h>
  3025. static void *f(void *p) { return NULL; }
  3026. int main(void)
  3027. {
  3028. pthread_t thread;
  3029. pthread_create(&thread, 0, f, 0);
  3030. pthread_setname_np(thread, "QEMU");
  3031. return 0;
  3032. }
  3033. EOF
  3034. if compile_prog "" "$pthread_lib" ; then
  3035. pthread_setname_np=yes
  3036. fi
  3037. ##########################################
  3038. # rbd probe
  3039. if test "$rbd" != "no" ; then
  3040. cat > $TMPC <<EOF
  3041. #include <stdio.h>
  3042. #include <rbd/librbd.h>
  3043. int main(void) {
  3044. rados_t cluster;
  3045. rados_create(&cluster, NULL);
  3046. return 0;
  3047. }
  3048. EOF
  3049. rbd_libs="-lrbd -lrados"
  3050. if compile_prog "" "$rbd_libs" ; then
  3051. rbd=yes
  3052. else
  3053. if test "$rbd" = "yes" ; then
  3054. feature_not_found "rados block device" "Install librbd/ceph devel"
  3055. fi
  3056. rbd=no
  3057. fi
  3058. fi
  3059. ##########################################
  3060. # libssh2 probe
  3061. min_libssh2_version=1.2.8
  3062. if test "$libssh2" != "no" ; then
  3063. if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
  3064. libssh2_cflags=$($pkg_config libssh2 --cflags)
  3065. libssh2_libs=$($pkg_config libssh2 --libs)
  3066. libssh2=yes
  3067. else
  3068. if test "$libssh2" = "yes" ; then
  3069. error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
  3070. fi
  3071. libssh2=no
  3072. fi
  3073. fi
  3074. ##########################################
  3075. # libssh2_sftp_fsync probe
  3076. if test "$libssh2" = "yes"; then
  3077. cat > $TMPC <<EOF
  3078. #include <stdio.h>
  3079. #include <libssh2.h>
  3080. #include <libssh2_sftp.h>
  3081. int main(void) {
  3082. LIBSSH2_SESSION *session;
  3083. LIBSSH2_SFTP *sftp;
  3084. LIBSSH2_SFTP_HANDLE *sftp_handle;
  3085. session = libssh2_session_init ();
  3086. sftp = libssh2_sftp_init (session);
  3087. sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
  3088. libssh2_sftp_fsync (sftp_handle);
  3089. return 0;
  3090. }
  3091. EOF
  3092. # libssh2_cflags/libssh2_libs defined in previous test.
  3093. if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
  3094. QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
  3095. fi
  3096. fi
  3097. ##########################################
  3098. # linux-aio probe
  3099. if test "$linux_aio" != "no" ; then
  3100. cat > $TMPC <<EOF
  3101. #include <libaio.h>
  3102. #include <sys/eventfd.h>
  3103. #include <stddef.h>
  3104. int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
  3105. EOF
  3106. if compile_prog "" "-laio" ; then
  3107. linux_aio=yes
  3108. else
  3109. if test "$linux_aio" = "yes" ; then
  3110. feature_not_found "linux AIO" "Install libaio devel"
  3111. fi
  3112. linux_aio=no
  3113. fi
  3114. fi
  3115. ##########################################
  3116. # TPM passthrough is only on x86 Linux
  3117. if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
  3118. tpm_passthrough=$tpm
  3119. else
  3120. tpm_passthrough=no
  3121. fi
  3122. ##########################################
  3123. # attr probe
  3124. if test "$attr" != "no" ; then
  3125. cat > $TMPC <<EOF
  3126. #include <stdio.h>
  3127. #include <sys/types.h>
  3128. #ifdef CONFIG_LIBATTR
  3129. #include <attr/xattr.h>
  3130. #else
  3131. #include <sys/xattr.h>
  3132. #endif
  3133. int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
  3134. EOF
  3135. if compile_prog "" "" ; then
  3136. attr=yes
  3137. # Older distros have <attr/xattr.h>, and need -lattr:
  3138. elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
  3139. attr=yes
  3140. LIBS="-lattr $LIBS"
  3141. libattr=yes
  3142. else
  3143. if test "$attr" = "yes" ; then
  3144. feature_not_found "ATTR" "Install libc6 or libattr devel"
  3145. fi
  3146. attr=no
  3147. fi
  3148. fi
  3149. ##########################################
  3150. # iovec probe
  3151. cat > $TMPC <<EOF
  3152. #include <sys/types.h>
  3153. #include <sys/uio.h>
  3154. #include <unistd.h>
  3155. int main(void) { return sizeof(struct iovec); }
  3156. EOF
  3157. iovec=no
  3158. if compile_prog "" "" ; then
  3159. iovec=yes
  3160. fi
  3161. ##########################################
  3162. # preadv probe
  3163. cat > $TMPC <<EOF
  3164. #include <sys/types.h>
  3165. #include <sys/uio.h>
  3166. #include <unistd.h>
  3167. int main(void) { return preadv(0, 0, 0, 0); }
  3168. EOF
  3169. preadv=no
  3170. if compile_prog "" "" ; then
  3171. preadv=yes
  3172. fi
  3173. ##########################################
  3174. # fdt probe
  3175. # fdt support is mandatory for at least some target architectures,
  3176. # so insist on it if we're building those system emulators.
  3177. fdt_required=no
  3178. for target in $target_list; do
  3179. case $target in
  3180. aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
  3181. fdt_required=yes
  3182. ;;
  3183. esac
  3184. done
  3185. if test "$fdt_required" = "yes"; then
  3186. if test "$fdt" = "no"; then
  3187. error_exit "fdt disabled but some requested targets require it." \
  3188. "You can turn off fdt only if you also disable all the system emulation" \
  3189. "targets which need it (by specifying a cut down --target-list)."
  3190. fi
  3191. fdt=yes
  3192. fi
  3193. if test "$fdt" != "no" ; then
  3194. fdt_libs="-lfdt"
  3195. # explicitly check for libfdt_env.h as it is missing in some stable installs
  3196. # and test for required functions to make sure we are on a version >= 1.4.2
  3197. cat > $TMPC << EOF
  3198. #include <libfdt.h>
  3199. #include <libfdt_env.h>
  3200. int main(void) { fdt_first_subnode(0, 0); return 0; }
  3201. EOF
  3202. if compile_prog "" "$fdt_libs" ; then
  3203. # system DTC is good - use it
  3204. fdt=yes
  3205. elif test -d ${source_path}/dtc/libfdt ; then
  3206. # have submodule DTC - use it
  3207. fdt=yes
  3208. dtc_internal="yes"
  3209. mkdir -p dtc
  3210. if [ "$pwd_is_source_path" != "y" ] ; then
  3211. symlink "$source_path/dtc/Makefile" "dtc/Makefile"
  3212. symlink "$source_path/dtc/scripts" "dtc/scripts"
  3213. fi
  3214. fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
  3215. fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
  3216. elif test "$fdt" = "yes" ; then
  3217. # have neither and want - prompt for system/submodule install
  3218. error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:" \
  3219. " (1) Preferred: Install the DTC (libfdt) devel package" \
  3220. " (2) Fetch the DTC submodule, using:" \
  3221. " git submodule update --init dtc"
  3222. else
  3223. # don't have and don't want
  3224. fdt_libs=
  3225. fdt=no
  3226. fi
  3227. fi
  3228. libs_softmmu="$libs_softmmu $fdt_libs"
  3229. ##########################################
  3230. # opengl probe (for sdl2, gtk, milkymist-tmu2)
  3231. if test "$opengl" != "no" ; then
  3232. opengl_pkgs="epoxy libdrm gbm"
  3233. if $pkg_config $opengl_pkgs x11; then
  3234. opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
  3235. opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
  3236. opengl=yes
  3237. if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
  3238. gtk_gl="yes"
  3239. fi
  3240. QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
  3241. else
  3242. if test "$opengl" = "yes" ; then
  3243. feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
  3244. fi
  3245. opengl_cflags=""
  3246. opengl_libs=""
  3247. opengl=no
  3248. fi
  3249. fi
  3250. if test "$opengl" = "yes"; then
  3251. cat > $TMPC << EOF
  3252. #include <epoxy/egl.h>
  3253. #ifndef EGL_MESA_image_dma_buf_export
  3254. # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
  3255. #endif
  3256. int main(void) { return 0; }
  3257. EOF
  3258. if compile_prog "" "" ; then
  3259. opengl_dmabuf=yes
  3260. fi
  3261. fi
  3262. ##########################################
  3263. # glusterfs probe
  3264. if test "$glusterfs" != "no" ; then
  3265. if $pkg_config --atleast-version=3 glusterfs-api; then
  3266. glusterfs="yes"
  3267. glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
  3268. glusterfs_libs=$($pkg_config --libs glusterfs-api)
  3269. if $pkg_config --atleast-version=4 glusterfs-api; then
  3270. glusterfs_xlator_opt="yes"
  3271. fi
  3272. if $pkg_config --atleast-version=5 glusterfs-api; then
  3273. glusterfs_discard="yes"
  3274. fi
  3275. if $pkg_config --atleast-version=6 glusterfs-api; then
  3276. glusterfs_zerofill="yes"
  3277. fi
  3278. else
  3279. if test "$glusterfs" = "yes" ; then
  3280. feature_not_found "GlusterFS backend support" \
  3281. "Install glusterfs-api devel >= 3"
  3282. fi
  3283. glusterfs="no"
  3284. fi
  3285. fi
  3286. # Check for inotify functions when we are building linux-user
  3287. # emulator. This is done because older glibc versions don't
  3288. # have syscall stubs for these implemented. In that case we
  3289. # don't provide them even if kernel supports them.
  3290. #
  3291. inotify=no
  3292. cat > $TMPC << EOF
  3293. #include <sys/inotify.h>
  3294. int
  3295. main(void)
  3296. {
  3297. /* try to start inotify */
  3298. return inotify_init();
  3299. }
  3300. EOF
  3301. if compile_prog "" "" ; then
  3302. inotify=yes
  3303. fi
  3304. inotify1=no
  3305. cat > $TMPC << EOF
  3306. #include <sys/inotify.h>
  3307. int
  3308. main(void)
  3309. {
  3310. /* try to start inotify */
  3311. return inotify_init1(0);
  3312. }
  3313. EOF
  3314. if compile_prog "" "" ; then
  3315. inotify1=yes
  3316. fi
  3317. # check if utimensat and futimens are supported
  3318. utimens=no
  3319. cat > $TMPC << EOF
  3320. #define _ATFILE_SOURCE
  3321. #include <stddef.h>
  3322. #include <fcntl.h>
  3323. #include <sys/stat.h>
  3324. int main(void)
  3325. {
  3326. utimensat(AT_FDCWD, "foo", NULL, 0);
  3327. futimens(0, NULL);
  3328. return 0;
  3329. }
  3330. EOF
  3331. if compile_prog "" "" ; then
  3332. utimens=yes
  3333. fi
  3334. # check if pipe2 is there
  3335. pipe2=no
  3336. cat > $TMPC << EOF
  3337. #include <unistd.h>
  3338. #include <fcntl.h>
  3339. int main(void)
  3340. {
  3341. int pipefd[2];
  3342. return pipe2(pipefd, O_CLOEXEC);
  3343. }
  3344. EOF
  3345. if compile_prog "" "" ; then
  3346. pipe2=yes
  3347. fi
  3348. # check if accept4 is there
  3349. accept4=no
  3350. cat > $TMPC << EOF
  3351. #include <sys/socket.h>
  3352. #include <stddef.h>
  3353. int main(void)
  3354. {
  3355. accept4(0, NULL, NULL, SOCK_CLOEXEC);
  3356. return 0;
  3357. }
  3358. EOF
  3359. if compile_prog "" "" ; then
  3360. accept4=yes
  3361. fi
  3362. # check if tee/splice is there. vmsplice was added same time.
  3363. splice=no
  3364. cat > $TMPC << EOF
  3365. #include <unistd.h>
  3366. #include <fcntl.h>
  3367. #include <limits.h>
  3368. int main(void)
  3369. {
  3370. int len, fd = 0;
  3371. len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
  3372. splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
  3373. return 0;
  3374. }
  3375. EOF
  3376. if compile_prog "" "" ; then
  3377. splice=yes
  3378. fi
  3379. ##########################################
  3380. # libnuma probe
  3381. if test "$numa" != "no" ; then
  3382. cat > $TMPC << EOF
  3383. #include <numa.h>
  3384. int main(void) { return numa_available(); }
  3385. EOF
  3386. if compile_prog "" "-lnuma" ; then
  3387. numa=yes
  3388. libs_softmmu="-lnuma $libs_softmmu"
  3389. else
  3390. if test "$numa" = "yes" ; then
  3391. feature_not_found "numa" "install numactl devel"
  3392. fi
  3393. numa=no
  3394. fi
  3395. fi
  3396. if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
  3397. echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
  3398. exit 1
  3399. fi
  3400. ##########################################
  3401. # tcmalloc probe
  3402. if test "$tcmalloc" = "yes" ; then
  3403. cat > $TMPC << EOF
  3404. #include <stdlib.h>
  3405. int main(void) { malloc(1); return 0; }
  3406. EOF
  3407. if compile_prog "" "-ltcmalloc" ; then
  3408. LIBS="-ltcmalloc $LIBS"
  3409. else
  3410. feature_not_found "tcmalloc" "install gperftools devel"
  3411. fi
  3412. fi
  3413. ##########################################
  3414. # jemalloc probe
  3415. if test "$jemalloc" = "yes" ; then
  3416. cat > $TMPC << EOF
  3417. #include <stdlib.h>
  3418. int main(void) { malloc(1); return 0; }
  3419. EOF
  3420. if compile_prog "" "-ljemalloc" ; then
  3421. LIBS="-ljemalloc $LIBS"
  3422. else
  3423. feature_not_found "jemalloc" "install jemalloc devel"
  3424. fi
  3425. fi
  3426. ##########################################
  3427. # signalfd probe
  3428. signalfd="no"
  3429. cat > $TMPC << EOF
  3430. #include <unistd.h>
  3431. #include <sys/syscall.h>
  3432. #include <signal.h>
  3433. int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
  3434. EOF
  3435. if compile_prog "" "" ; then
  3436. signalfd=yes
  3437. fi
  3438. # check if eventfd is supported
  3439. eventfd=no
  3440. cat > $TMPC << EOF
  3441. #include <sys/eventfd.h>
  3442. int main(void)
  3443. {
  3444. return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
  3445. }
  3446. EOF
  3447. if compile_prog "" "" ; then
  3448. eventfd=yes
  3449. fi
  3450. # check if memfd is supported
  3451. memfd=no
  3452. cat > $TMPC << EOF
  3453. #include <sys/memfd.h>
  3454. int main(void)
  3455. {
  3456. return memfd_create("foo", MFD_ALLOW_SEALING);
  3457. }
  3458. EOF
  3459. if compile_prog "" "" ; then
  3460. memfd=yes
  3461. fi
  3462. # check for fallocate
  3463. fallocate=no
  3464. cat > $TMPC << EOF
  3465. #include <fcntl.h>
  3466. int main(void)
  3467. {
  3468. fallocate(0, 0, 0, 0);
  3469. return 0;
  3470. }
  3471. EOF
  3472. if compile_prog "" "" ; then
  3473. fallocate=yes
  3474. fi
  3475. # check for fallocate hole punching
  3476. fallocate_punch_hole=no
  3477. cat > $TMPC << EOF
  3478. #include <fcntl.h>
  3479. #include <linux/falloc.h>
  3480. int main(void)
  3481. {
  3482. fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
  3483. return 0;
  3484. }
  3485. EOF
  3486. if compile_prog "" "" ; then
  3487. fallocate_punch_hole=yes
  3488. fi
  3489. # check that fallocate supports range zeroing inside the file
  3490. fallocate_zero_range=no
  3491. cat > $TMPC << EOF
  3492. #include <fcntl.h>
  3493. #include <linux/falloc.h>
  3494. int main(void)
  3495. {
  3496. fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
  3497. return 0;
  3498. }
  3499. EOF
  3500. if compile_prog "" "" ; then
  3501. fallocate_zero_range=yes
  3502. fi
  3503. # check for posix_fallocate
  3504. posix_fallocate=no
  3505. cat > $TMPC << EOF
  3506. #include <fcntl.h>
  3507. int main(void)
  3508. {
  3509. posix_fallocate(0, 0, 0);
  3510. return 0;
  3511. }
  3512. EOF
  3513. if compile_prog "" "" ; then
  3514. posix_fallocate=yes
  3515. fi
  3516. # check for sync_file_range
  3517. sync_file_range=no
  3518. cat > $TMPC << EOF
  3519. #include <fcntl.h>
  3520. int main(void)
  3521. {
  3522. sync_file_range(0, 0, 0, 0);
  3523. return 0;
  3524. }
  3525. EOF
  3526. if compile_prog "" "" ; then
  3527. sync_file_range=yes
  3528. fi
  3529. # check for linux/fiemap.h and FS_IOC_FIEMAP
  3530. fiemap=no
  3531. cat > $TMPC << EOF
  3532. #include <sys/ioctl.h>
  3533. #include <linux/fs.h>
  3534. #include <linux/fiemap.h>
  3535. int main(void)
  3536. {
  3537. ioctl(0, FS_IOC_FIEMAP, 0);
  3538. return 0;
  3539. }
  3540. EOF
  3541. if compile_prog "" "" ; then
  3542. fiemap=yes
  3543. fi
  3544. # check for dup3
  3545. dup3=no
  3546. cat > $TMPC << EOF
  3547. #include <unistd.h>
  3548. int main(void)
  3549. {
  3550. dup3(0, 0, 0);
  3551. return 0;
  3552. }
  3553. EOF
  3554. if compile_prog "" "" ; then
  3555. dup3=yes
  3556. fi
  3557. # check for ppoll support
  3558. ppoll=no
  3559. cat > $TMPC << EOF
  3560. #include <poll.h>
  3561. int main(void)
  3562. {
  3563. struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
  3564. ppoll(&pfd, 1, 0, 0);
  3565. return 0;
  3566. }
  3567. EOF
  3568. if compile_prog "" "" ; then
  3569. ppoll=yes
  3570. fi
  3571. # check for prctl(PR_SET_TIMERSLACK , ... ) support
  3572. prctl_pr_set_timerslack=no
  3573. cat > $TMPC << EOF
  3574. #include <sys/prctl.h>
  3575. int main(void)
  3576. {
  3577. prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
  3578. return 0;
  3579. }
  3580. EOF
  3581. if compile_prog "" "" ; then
  3582. prctl_pr_set_timerslack=yes
  3583. fi
  3584. # check for epoll support
  3585. epoll=no
  3586. cat > $TMPC << EOF
  3587. #include <sys/epoll.h>
  3588. int main(void)
  3589. {
  3590. epoll_create(0);
  3591. return 0;
  3592. }
  3593. EOF
  3594. if compile_prog "" "" ; then
  3595. epoll=yes
  3596. fi
  3597. # epoll_create1 is a later addition
  3598. # so we must check separately for its presence
  3599. epoll_create1=no
  3600. cat > $TMPC << EOF
  3601. #include <sys/epoll.h>
  3602. int main(void)
  3603. {
  3604. /* Note that we use epoll_create1 as a value, not as
  3605. * a function being called. This is necessary so that on
  3606. * old SPARC glibc versions where the function was present in
  3607. * the library but not declared in the header file we will
  3608. * fail the configure check. (Otherwise we will get a compiler
  3609. * warning but not an error, and will proceed to fail the
  3610. * qemu compile where we compile with -Werror.)
  3611. */
  3612. return (int)(uintptr_t)&epoll_create1;
  3613. }
  3614. EOF
  3615. if compile_prog "" "" ; then
  3616. epoll_create1=yes
  3617. fi
  3618. # check for sendfile support
  3619. sendfile=no
  3620. cat > $TMPC << EOF
  3621. #include <sys/sendfile.h>
  3622. int main(void)
  3623. {
  3624. return sendfile(0, 0, 0, 0);
  3625. }
  3626. EOF
  3627. if compile_prog "" "" ; then
  3628. sendfile=yes
  3629. fi
  3630. # check for timerfd support (glibc 2.8 and newer)
  3631. timerfd=no
  3632. cat > $TMPC << EOF
  3633. #include <sys/timerfd.h>
  3634. int main(void)
  3635. {
  3636. return(timerfd_create(CLOCK_REALTIME, 0));
  3637. }
  3638. EOF
  3639. if compile_prog "" "" ; then
  3640. timerfd=yes
  3641. fi
  3642. # check for setns and unshare support
  3643. setns=no
  3644. cat > $TMPC << EOF
  3645. #include <sched.h>
  3646. int main(void)
  3647. {
  3648. int ret;
  3649. ret = setns(0, 0);
  3650. ret = unshare(0);
  3651. return ret;
  3652. }
  3653. EOF
  3654. if compile_prog "" "" ; then
  3655. setns=yes
  3656. fi
  3657. # clock_adjtime probe
  3658. clock_adjtime=no
  3659. cat > $TMPC <<EOF
  3660. #include <time.h>
  3661. int main(void)
  3662. {
  3663. return clock_adjtime(0, 0);
  3664. }
  3665. EOF
  3666. clock_adjtime=no
  3667. if compile_prog "" "" ; then
  3668. clock_adjtime=yes
  3669. fi
  3670. # syncfs probe
  3671. syncfs=no
  3672. cat > $TMPC <<EOF
  3673. #include <unistd.h>
  3674. int main(void)
  3675. {
  3676. return syncfs(0);
  3677. }
  3678. EOF
  3679. syncfs=no
  3680. if compile_prog "" "" ; then
  3681. syncfs=yes
  3682. fi
  3683. # Check if tools are available to build documentation.
  3684. if test "$docs" != "no" ; then
  3685. if has makeinfo && has pod2man; then
  3686. docs=yes
  3687. else
  3688. if test "$docs" = "yes" ; then
  3689. feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
  3690. fi
  3691. docs=no
  3692. fi
  3693. fi
  3694. # Search for bswap_32 function
  3695. byteswap_h=no
  3696. cat > $TMPC << EOF
  3697. #include <byteswap.h>
  3698. int main(void) { return bswap_32(0); }
  3699. EOF
  3700. if compile_prog "" "" ; then
  3701. byteswap_h=yes
  3702. fi
  3703. # Search for bswap32 function
  3704. bswap_h=no
  3705. cat > $TMPC << EOF
  3706. #include <sys/endian.h>
  3707. #include <sys/types.h>
  3708. #include <machine/bswap.h>
  3709. int main(void) { return bswap32(0); }
  3710. EOF
  3711. if compile_prog "" "" ; then
  3712. bswap_h=yes
  3713. fi
  3714. ##########################################
  3715. # Do we have libiscsi >= 1.9.0
  3716. if test "$libiscsi" != "no" ; then
  3717. if $pkg_config --atleast-version=1.9.0 libiscsi; then
  3718. libiscsi="yes"
  3719. libiscsi_cflags=$($pkg_config --cflags libiscsi)
  3720. libiscsi_libs=$($pkg_config --libs libiscsi)
  3721. else
  3722. if test "$libiscsi" = "yes" ; then
  3723. feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
  3724. fi
  3725. libiscsi="no"
  3726. fi
  3727. fi
  3728. ##########################################
  3729. # Do we need libm
  3730. cat > $TMPC << EOF
  3731. #include <math.h>
  3732. int main(int argc, char **argv) { return isnan(sin((double)argc)); }
  3733. EOF
  3734. if compile_prog "" "" ; then
  3735. :
  3736. elif compile_prog "" "-lm" ; then
  3737. LIBS="-lm $LIBS"
  3738. libs_qga="-lm $libs_qga"
  3739. else
  3740. error_exit "libm check failed"
  3741. fi
  3742. ##########################################
  3743. # Do we need librt
  3744. # uClibc provides 2 versions of clock_gettime(), one with realtime
  3745. # support and one without. This means that the clock_gettime() don't
  3746. # need -lrt. We still need it for timer_create() so we check for this
  3747. # function in addition.
  3748. cat > $TMPC <<EOF
  3749. #include <signal.h>
  3750. #include <time.h>
  3751. int main(void) {
  3752. timer_create(CLOCK_REALTIME, NULL, NULL);
  3753. return clock_gettime(CLOCK_REALTIME, NULL);
  3754. }
  3755. EOF
  3756. if compile_prog "" "" ; then
  3757. :
  3758. # we need pthread for static linking. use previous pthread test result
  3759. elif compile_prog "" "$pthread_lib -lrt" ; then
  3760. LIBS="$LIBS -lrt"
  3761. libs_qga="$libs_qga -lrt"
  3762. fi
  3763. if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
  3764. "$aix" != "yes" -a "$haiku" != "yes" ; then
  3765. libs_softmmu="-lutil $libs_softmmu"
  3766. fi
  3767. ##########################################
  3768. # spice probe
  3769. if test "$spice" != "no" ; then
  3770. cat > $TMPC << EOF
  3771. #include <spice.h>
  3772. int main(void) { spice_server_new(); return 0; }
  3773. EOF
  3774. spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
  3775. spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
  3776. if $pkg_config --atleast-version=0.12.0 spice-server && \
  3777. $pkg_config --atleast-version=0.12.3 spice-protocol && \
  3778. compile_prog "$spice_cflags" "$spice_libs" ; then
  3779. spice="yes"
  3780. libs_softmmu="$libs_softmmu $spice_libs"
  3781. QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
  3782. spice_protocol_version=$($pkg_config --modversion spice-protocol)
  3783. spice_server_version=$($pkg_config --modversion spice-server)
  3784. else
  3785. if test "$spice" = "yes" ; then
  3786. feature_not_found "spice" \
  3787. "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
  3788. fi
  3789. spice="no"
  3790. fi
  3791. fi
  3792. # check for smartcard support
  3793. smartcard_cflags=""
  3794. if test "$smartcard" != "no"; then
  3795. if $pkg_config libcacard; then
  3796. libcacard_cflags=$($pkg_config --cflags libcacard)
  3797. libcacard_libs=$($pkg_config --libs libcacard)
  3798. QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
  3799. libs_softmmu="$libs_softmmu $libcacard_libs"
  3800. smartcard="yes"
  3801. else
  3802. if test "$smartcard" = "yes"; then
  3803. feature_not_found "smartcard" "Install libcacard devel"
  3804. fi
  3805. smartcard="no"
  3806. fi
  3807. fi
  3808. # check for libusb
  3809. if test "$libusb" != "no" ; then
  3810. if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
  3811. libusb="yes"
  3812. libusb_cflags=$($pkg_config --cflags libusb-1.0)
  3813. libusb_libs=$($pkg_config --libs libusb-1.0)
  3814. QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
  3815. libs_softmmu="$libs_softmmu $libusb_libs"
  3816. else
  3817. if test "$libusb" = "yes"; then
  3818. feature_not_found "libusb" "Install libusb devel >= 1.0.13"
  3819. fi
  3820. libusb="no"
  3821. fi
  3822. fi
  3823. # check for usbredirparser for usb network redirection support
  3824. if test "$usb_redir" != "no" ; then
  3825. if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
  3826. usb_redir="yes"
  3827. usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
  3828. usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
  3829. QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
  3830. libs_softmmu="$libs_softmmu $usb_redir_libs"
  3831. else
  3832. if test "$usb_redir" = "yes"; then
  3833. feature_not_found "usb-redir" "Install usbredir devel"
  3834. fi
  3835. usb_redir="no"
  3836. fi
  3837. fi
  3838. ##########################################
  3839. # check if we have VSS SDK headers for win
  3840. if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
  3841. case "$vss_win32_sdk" in
  3842. "") vss_win32_include="-isystem $source_path" ;;
  3843. *\ *) # The SDK is installed in "Program Files" by default, but we cannot
  3844. # handle path with spaces. So we symlink the headers into ".sdk/vss".
  3845. vss_win32_include="-isystem $source_path/.sdk/vss"
  3846. symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
  3847. ;;
  3848. *) vss_win32_include="-isystem $vss_win32_sdk"
  3849. esac
  3850. cat > $TMPC << EOF
  3851. #define __MIDL_user_allocate_free_DEFINED__
  3852. #include <inc/win2003/vss.h>
  3853. int main(void) { return VSS_CTX_BACKUP; }
  3854. EOF
  3855. if compile_prog "$vss_win32_include" "" ; then
  3856. guest_agent_with_vss="yes"
  3857. QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
  3858. libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
  3859. qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
  3860. else
  3861. if test "$vss_win32_sdk" != "" ; then
  3862. echo "ERROR: Please download and install Microsoft VSS SDK:"
  3863. echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
  3864. echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
  3865. echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
  3866. echo "ERROR: The headers are extracted in the directory \`inc'."
  3867. feature_not_found "VSS support"
  3868. fi
  3869. guest_agent_with_vss="no"
  3870. fi
  3871. fi
  3872. ##########################################
  3873. # lookup Windows platform SDK (if not specified)
  3874. # The SDK is needed only to build .tlb (type library) file of guest agent
  3875. # VSS provider from the source. It is usually unnecessary because the
  3876. # pre-compiled .tlb file is included.
  3877. if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
  3878. if test -z "$win_sdk"; then
  3879. programfiles="$PROGRAMFILES"
  3880. test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
  3881. if test -n "$programfiles"; then
  3882. win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
  3883. else
  3884. feature_not_found "Windows SDK"
  3885. fi
  3886. elif test "$win_sdk" = "no"; then
  3887. win_sdk=""
  3888. fi
  3889. fi
  3890. ##########################################
  3891. # check if mingw environment provides a recent ntddscsi.h
  3892. if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
  3893. cat > $TMPC << EOF
  3894. #include <windows.h>
  3895. #include <ntddscsi.h>
  3896. int main(void) {
  3897. #if !defined(IOCTL_SCSI_GET_ADDRESS)
  3898. #error Missing required ioctl definitions
  3899. #endif
  3900. SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
  3901. return addr.Lun;
  3902. }
  3903. EOF
  3904. if compile_prog "" "" ; then
  3905. guest_agent_ntddscsi=yes
  3906. libs_qga="-lsetupapi $libs_qga"
  3907. fi
  3908. fi
  3909. ##########################################
  3910. # virgl renderer probe
  3911. if test "$virglrenderer" != "no" ; then
  3912. cat > $TMPC << EOF
  3913. #include <virglrenderer.h>
  3914. int main(void) { virgl_renderer_poll(); return 0; }
  3915. EOF
  3916. virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
  3917. virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
  3918. if $pkg_config virglrenderer >/dev/null 2>&1 && \
  3919. compile_prog "$virgl_cflags" "$virgl_libs" ; then
  3920. virglrenderer="yes"
  3921. else
  3922. if test "$virglrenderer" = "yes" ; then
  3923. feature_not_found "virglrenderer"
  3924. fi
  3925. virglrenderer="no"
  3926. fi
  3927. fi
  3928. ##########################################
  3929. # check if we have fdatasync
  3930. fdatasync=no
  3931. cat > $TMPC << EOF
  3932. #include <unistd.h>
  3933. int main(void) {
  3934. #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
  3935. return fdatasync(0);
  3936. #else
  3937. #error Not supported
  3938. #endif
  3939. }
  3940. EOF
  3941. if compile_prog "" "" ; then
  3942. fdatasync=yes
  3943. fi
  3944. ##########################################
  3945. # check if we have madvise
  3946. madvise=no
  3947. cat > $TMPC << EOF
  3948. #include <sys/types.h>
  3949. #include <sys/mman.h>
  3950. #include <stddef.h>
  3951. int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
  3952. EOF
  3953. if compile_prog "" "" ; then
  3954. madvise=yes
  3955. fi
  3956. ##########################################
  3957. # check if we have posix_madvise
  3958. posix_madvise=no
  3959. cat > $TMPC << EOF
  3960. #include <sys/mman.h>
  3961. #include <stddef.h>
  3962. int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
  3963. EOF
  3964. if compile_prog "" "" ; then
  3965. posix_madvise=yes
  3966. fi
  3967. ##########################################
  3968. # check if we have posix_syslog
  3969. posix_syslog=no
  3970. cat > $TMPC << EOF
  3971. #include <syslog.h>
  3972. int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
  3973. EOF
  3974. if compile_prog "" "" ; then
  3975. posix_syslog=yes
  3976. fi
  3977. ##########################################
  3978. # check if trace backend exists
  3979. $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
  3980. if test "$?" -ne 0 ; then
  3981. error_exit "invalid trace backends" \
  3982. "Please choose supported trace backends."
  3983. fi
  3984. ##########################################
  3985. # For 'ust' backend, test if ust headers are present
  3986. if have_backend "ust"; then
  3987. cat > $TMPC << EOF
  3988. #include <lttng/tracepoint.h>
  3989. int main(void) { return 0; }
  3990. EOF
  3991. if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
  3992. if $pkg_config lttng-ust --exists; then
  3993. lttng_ust_libs=$($pkg_config --libs lttng-ust)
  3994. else
  3995. lttng_ust_libs="-llttng-ust -ldl"
  3996. fi
  3997. if $pkg_config liburcu-bp --exists; then
  3998. urcu_bp_libs=$($pkg_config --libs liburcu-bp)
  3999. else
  4000. urcu_bp_libs="-lurcu-bp"
  4001. fi
  4002. LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
  4003. libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
  4004. else
  4005. error_exit "Trace backend 'ust' missing lttng-ust header files"
  4006. fi
  4007. fi
  4008. ##########################################
  4009. # For 'dtrace' backend, test if 'dtrace' command is present
  4010. if have_backend "dtrace"; then
  4011. if ! has 'dtrace' ; then
  4012. error_exit "dtrace command is not found in PATH $PATH"
  4013. fi
  4014. trace_backend_stap="no"
  4015. if has 'stap' ; then
  4016. trace_backend_stap="yes"
  4017. fi
  4018. fi
  4019. ##########################################
  4020. # check and set a backend for coroutine
  4021. # We prefer ucontext, but it's not always possible. The fallback
  4022. # is sigcontext. gthread is not selectable except explicitly, because
  4023. # it is not functional enough to run QEMU proper. (It is occasionally
  4024. # useful for debugging purposes.) On Windows the only valid backend
  4025. # is the Windows-specific one.
  4026. ucontext_works=no
  4027. if test "$darwin" != "yes"; then
  4028. cat > $TMPC << EOF
  4029. #include <ucontext.h>
  4030. #ifdef __stub_makecontext
  4031. #error Ignoring glibc stub makecontext which will always fail
  4032. #endif
  4033. int main(void) { makecontext(0, 0, 0); return 0; }
  4034. EOF
  4035. if compile_prog "" "" ; then
  4036. ucontext_works=yes
  4037. fi
  4038. fi
  4039. if test "$coroutine" = ""; then
  4040. if test "$mingw32" = "yes"; then
  4041. coroutine=win32
  4042. elif test "$ucontext_works" = "yes"; then
  4043. coroutine=ucontext
  4044. else
  4045. coroutine=sigaltstack
  4046. fi
  4047. else
  4048. case $coroutine in
  4049. windows)
  4050. if test "$mingw32" != "yes"; then
  4051. error_exit "'windows' coroutine backend only valid for Windows"
  4052. fi
  4053. # Unfortunately the user visible backend name doesn't match the
  4054. # coroutine-*.c filename for this case, so we have to adjust it here.
  4055. coroutine=win32
  4056. ;;
  4057. ucontext)
  4058. if test "$ucontext_works" != "yes"; then
  4059. feature_not_found "ucontext"
  4060. fi
  4061. ;;
  4062. gthread|sigaltstack)
  4063. if test "$mingw32" = "yes"; then
  4064. error_exit "only the 'windows' coroutine backend is valid for Windows"
  4065. fi
  4066. ;;
  4067. *)
  4068. error_exit "unknown coroutine backend $coroutine"
  4069. ;;
  4070. esac
  4071. fi
  4072. if test "$coroutine_pool" = ""; then
  4073. if test "$coroutine" = "gthread"; then
  4074. coroutine_pool=no
  4075. else
  4076. coroutine_pool=yes
  4077. fi
  4078. fi
  4079. if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
  4080. error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
  4081. fi
  4082. if test "$debug_stack_usage" = "yes"; then
  4083. if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
  4084. error_exit "stack usage debugging is not supported for $cpu"
  4085. fi
  4086. if test "$coroutine_pool" = "yes"; then
  4087. echo "WARN: disabling coroutine pool for stack usage debugging"
  4088. coroutine_pool=no
  4089. fi
  4090. fi
  4091. ##########################################
  4092. # check if we have open_by_handle_at
  4093. open_by_handle_at=no
  4094. cat > $TMPC << EOF
  4095. #include <fcntl.h>
  4096. #if !defined(AT_EMPTY_PATH)
  4097. # error missing definition
  4098. #else
  4099. int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
  4100. #endif
  4101. EOF
  4102. if compile_prog "" "" ; then
  4103. open_by_handle_at=yes
  4104. fi
  4105. ########################################
  4106. # check if we have linux/magic.h
  4107. linux_magic_h=no
  4108. cat > $TMPC << EOF
  4109. #include <linux/magic.h>
  4110. int main(void) {
  4111. return 0;
  4112. }
  4113. EOF
  4114. if compile_prog "" "" ; then
  4115. linux_magic_h=yes
  4116. fi
  4117. ########################################
  4118. # check whether we can disable warning option with a pragma (this is needed
  4119. # to silence warnings in the headers of some versions of external libraries).
  4120. # This test has to be compiled with -Werror as otherwise an unknown pragma is
  4121. # only a warning.
  4122. #
  4123. # If we can't selectively disable warning in the code, disable -Werror so that
  4124. # the build doesn't fail anyway.
  4125. pragma_disable_unused_but_set=no
  4126. cat > $TMPC << EOF
  4127. #pragma GCC diagnostic push
  4128. #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
  4129. #pragma GCC diagnostic ignored "-Wstrict-prototypes"
  4130. #pragma GCC diagnostic pop
  4131. int main(void) {
  4132. return 0;
  4133. }
  4134. EOF
  4135. if compile_prog "-Werror" "" ; then
  4136. pragma_diagnostic_available=yes
  4137. else
  4138. werror=no
  4139. fi
  4140. ########################################
  4141. # check if we have valgrind/valgrind.h
  4142. valgrind_h=no
  4143. cat > $TMPC << EOF
  4144. #include <valgrind/valgrind.h>
  4145. int main(void) {
  4146. return 0;
  4147. }
  4148. EOF
  4149. if compile_prog "" "" ; then
  4150. valgrind_h=yes
  4151. fi
  4152. ########################################
  4153. # check if environ is declared
  4154. has_environ=no
  4155. cat > $TMPC << EOF
  4156. #include <unistd.h>
  4157. int main(void) {
  4158. environ = 0;
  4159. return 0;
  4160. }
  4161. EOF
  4162. if compile_prog "" "" ; then
  4163. has_environ=yes
  4164. fi
  4165. ########################################
  4166. # check if cpuid.h is usable.
  4167. cpuid_h=no
  4168. cat > $TMPC << EOF
  4169. #include <cpuid.h>
  4170. int main(void) {
  4171. unsigned a, b, c, d;
  4172. int max = __get_cpuid_max(0, 0);
  4173. if (max >= 1) {
  4174. __cpuid(1, a, b, c, d);
  4175. }
  4176. if (max >= 7) {
  4177. __cpuid_count(7, 0, a, b, c, d);
  4178. }
  4179. return 0;
  4180. }
  4181. EOF
  4182. if compile_prog "" "" ; then
  4183. cpuid_h=yes
  4184. fi
  4185. ########################################
  4186. # check if __[u]int128_t is usable.
  4187. int128=no
  4188. cat > $TMPC << EOF
  4189. #if defined(__clang_major__) && defined(__clang_minor__)
  4190. # if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
  4191. # error __int128_t does not work in CLANG before 3.2
  4192. # endif
  4193. #endif
  4194. __int128_t a;
  4195. __uint128_t b;
  4196. int main (void) {
  4197. a = a + b;
  4198. b = a * b;
  4199. a = a * a;
  4200. return 0;
  4201. }
  4202. EOF
  4203. if compile_prog "" "" ; then
  4204. int128=yes
  4205. fi
  4206. #########################################
  4207. # See if 128-bit atomic operations are supported.
  4208. atomic128=no
  4209. if test "$int128" = "yes"; then
  4210. cat > $TMPC << EOF
  4211. int main(void)
  4212. {
  4213. unsigned __int128 x = 0, y = 0;
  4214. y = __atomic_load_16(&x, 0);
  4215. __atomic_store_16(&x, y, 0);
  4216. __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
  4217. return 0;
  4218. }
  4219. EOF
  4220. if compile_prog "" "" ; then
  4221. atomic128=yes
  4222. fi
  4223. fi
  4224. #########################################
  4225. # See if 64-bit atomic operations are supported.
  4226. # Note that without __atomic builtins, we can only
  4227. # assume atomic loads/stores max at pointer size.
  4228. cat > $TMPC << EOF
  4229. #include <stdint.h>
  4230. int main(void)
  4231. {
  4232. uint64_t x = 0, y = 0;
  4233. #ifdef __ATOMIC_RELAXED
  4234. y = __atomic_load_8(&x, 0);
  4235. __atomic_store_8(&x, y, 0);
  4236. __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
  4237. __atomic_exchange_8(&x, y, 0);
  4238. __atomic_fetch_add_8(&x, y, 0);
  4239. #else
  4240. typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
  4241. __sync_lock_test_and_set(&x, y);
  4242. __sync_val_compare_and_swap(&x, y, 0);
  4243. __sync_fetch_and_add(&x, y);
  4244. #endif
  4245. return 0;
  4246. }
  4247. EOF
  4248. if compile_prog "" "" ; then
  4249. atomic64=yes
  4250. fi
  4251. ########################################
  4252. # check if getauxval is available.
  4253. getauxval=no
  4254. cat > $TMPC << EOF
  4255. #include <sys/auxv.h>
  4256. int main(void) {
  4257. return getauxval(AT_HWCAP) == 0;
  4258. }
  4259. EOF
  4260. if compile_prog "" "" ; then
  4261. getauxval=yes
  4262. fi
  4263. ########################################
  4264. # check if ccache is interfering with
  4265. # semantic analysis of macros
  4266. unset CCACHE_CPP2
  4267. ccache_cpp2=no
  4268. cat > $TMPC << EOF
  4269. static const int Z = 1;
  4270. #define fn() ({ Z; })
  4271. #define TAUT(X) ((X) == Z)
  4272. #define PAREN(X, Y) (X == Y)
  4273. #define ID(X) (X)
  4274. int main(int argc, char *argv[])
  4275. {
  4276. int x = 0, y = 0;
  4277. x = ID(x);
  4278. x = fn();
  4279. fn();
  4280. if (PAREN(x, y)) return 0;
  4281. if (TAUT(Z)) return 0;
  4282. return 0;
  4283. }
  4284. EOF
  4285. if ! compile_object "-Werror"; then
  4286. ccache_cpp2=yes
  4287. fi
  4288. #################################################
  4289. # clang does not support glibc + FORTIFY_SOURCE.
  4290. if test "$fortify_source" != "no"; then
  4291. if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
  4292. fortify_source="no";
  4293. elif test -n "$cxx" &&
  4294. echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
  4295. fortify_source="no";
  4296. else
  4297. fortify_source="yes"
  4298. fi
  4299. fi
  4300. ##########################################
  4301. # check if struct fsxattr is available via linux/fs.h
  4302. have_fsxattr=no
  4303. cat > $TMPC << EOF
  4304. #include <linux/fs.h>
  4305. struct fsxattr foo;
  4306. int main(void) {
  4307. return 0;
  4308. }
  4309. EOF
  4310. if compile_prog "" "" ; then
  4311. have_fsxattr=yes
  4312. fi
  4313. ##########################################
  4314. # check if rtnetlink.h exists and is useful
  4315. have_rtnetlink=no
  4316. cat > $TMPC << EOF
  4317. #include <linux/rtnetlink.h>
  4318. int main(void) {
  4319. return IFLA_PROTO_DOWN;
  4320. }
  4321. EOF
  4322. if compile_prog "" "" ; then
  4323. have_rtnetlink=yes
  4324. fi
  4325. ##########################################
  4326. # check for usable AF_VSOCK environment
  4327. have_af_vsock=no
  4328. cat > $TMPC << EOF
  4329. #include <errno.h>
  4330. #include <sys/types.h>
  4331. #include <sys/socket.h>
  4332. #if !defined(AF_VSOCK)
  4333. # error missing AF_VSOCK flag
  4334. #endif
  4335. #include <linux/vm_sockets.h>
  4336. int main(void) {
  4337. int sock, ret;
  4338. struct sockaddr_vm svm;
  4339. socklen_t len = sizeof(svm);
  4340. sock = socket(AF_VSOCK, SOCK_STREAM, 0);
  4341. ret = getpeername(sock, (struct sockaddr *)&svm, &len);
  4342. if ((ret == -1) && (errno == ENOTCONN)) {
  4343. return 0;
  4344. }
  4345. return -1;
  4346. }
  4347. EOF
  4348. if compile_prog "" "" ; then
  4349. have_af_vsock=yes
  4350. fi
  4351. #################################################
  4352. # Sparc implicitly links with --relax, which is
  4353. # incompatible with -r, so --no-relax should be
  4354. # given. It does no harm to give it on other
  4355. # platforms too.
  4356. # Note: the prototype is needed since QEMU_CFLAGS
  4357. # contains -Wmissing-prototypes
  4358. cat > $TMPC << EOF
  4359. extern int foo(void);
  4360. int foo(void) { return 0; }
  4361. EOF
  4362. if ! compile_object ""; then
  4363. error_exit "Failed to compile object file for LD_REL_FLAGS test"
  4364. fi
  4365. for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
  4366. if do_cc -nostdlib $i -o $TMPMO $TMPO; then
  4367. LD_REL_FLAGS=$i
  4368. break
  4369. fi
  4370. done
  4371. if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
  4372. feature_not_found "modules" "Cannot find how to build relocatable objects"
  4373. fi
  4374. ##########################################
  4375. # check for sysmacros.h
  4376. have_sysmacros=no
  4377. cat > $TMPC << EOF
  4378. #include <sys/sysmacros.h>
  4379. int main(void) {
  4380. return makedev(0, 0);
  4381. }
  4382. EOF
  4383. if compile_prog "" "" ; then
  4384. have_sysmacros=yes
  4385. fi
  4386. ##########################################
  4387. # End of CC checks
  4388. # After here, no more $cc or $ld runs
  4389. if test "$gcov" = "yes" ; then
  4390. CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
  4391. LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
  4392. elif test "$fortify_source" = "yes" ; then
  4393. CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
  4394. elif test "$debug" = "no"; then
  4395. CFLAGS="-O2 $CFLAGS"
  4396. fi
  4397. ##########################################
  4398. # Do we have libnfs
  4399. if test "$libnfs" != "no" ; then
  4400. if $pkg_config --atleast-version=1.9.3 libnfs; then
  4401. libnfs="yes"
  4402. libnfs_libs=$($pkg_config --libs libnfs)
  4403. else
  4404. if test "$libnfs" = "yes" ; then
  4405. feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
  4406. fi
  4407. libnfs="no"
  4408. fi
  4409. fi
  4410. # Now we've finished running tests it's OK to add -Werror to the compiler flags
  4411. if test "$werror" = "yes"; then
  4412. QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
  4413. fi
  4414. if test "$solaris" = "no" ; then
  4415. if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
  4416. LDFLAGS="-Wl,--warn-common $LDFLAGS"
  4417. fi
  4418. fi
  4419. # test if pod2man has --utf8 option
  4420. if pod2man --help | grep -q utf8; then
  4421. POD2MAN="pod2man --utf8"
  4422. else
  4423. POD2MAN="pod2man"
  4424. fi
  4425. # Use ASLR, no-SEH and DEP if available
  4426. if test "$mingw32" = "yes" ; then
  4427. for flag in --dynamicbase --no-seh --nxcompat; do
  4428. if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
  4429. LDFLAGS="-Wl,$flag $LDFLAGS"
  4430. fi
  4431. done
  4432. fi
  4433. qemu_confdir=$sysconfdir$confsuffix
  4434. qemu_moddir=$libdir$confsuffix
  4435. qemu_datadir=$datadir$confsuffix
  4436. qemu_localedir="$datadir/locale"
  4437. tools=""
  4438. if test "$want_tools" = "yes" ; then
  4439. tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
  4440. if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
  4441. tools="qemu-nbd\$(EXESUF) $tools"
  4442. tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
  4443. fi
  4444. fi
  4445. if test "$softmmu" = yes ; then
  4446. if test "$virtfs" != no ; then
  4447. if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
  4448. virtfs=yes
  4449. tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
  4450. else
  4451. if test "$virtfs" = yes; then
  4452. error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
  4453. fi
  4454. virtfs=no
  4455. fi
  4456. fi
  4457. fi
  4458. # Probe for guest agent support/options
  4459. if [ "$guest_agent" != "no" ]; then
  4460. if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
  4461. tools="qemu-ga $tools"
  4462. guest_agent=yes
  4463. elif [ "$guest_agent" != yes ]; then
  4464. guest_agent=no
  4465. else
  4466. error_exit "Guest agent is not supported on this platform"
  4467. fi
  4468. fi
  4469. # Guest agent Window MSI package
  4470. if test "$guest_agent" != yes; then
  4471. if test "$guest_agent_msi" = yes; then
  4472. error_exit "MSI guest agent package requires guest agent enabled"
  4473. fi
  4474. guest_agent_msi=no
  4475. elif test "$mingw32" != "yes"; then
  4476. if test "$guest_agent_msi" = "yes"; then
  4477. error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
  4478. fi
  4479. guest_agent_msi=no
  4480. elif ! has wixl; then
  4481. if test "$guest_agent_msi" = "yes"; then
  4482. error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
  4483. fi
  4484. guest_agent_msi=no
  4485. else
  4486. # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
  4487. # disabled explicitly
  4488. if test "$guest_agent_msi" != "no"; then
  4489. guest_agent_msi=yes
  4490. fi
  4491. fi
  4492. if test "$guest_agent_msi" = "yes"; then
  4493. if test "$guest_agent_with_vss" = "yes"; then
  4494. QEMU_GA_MSI_WITH_VSS="-D InstallVss"
  4495. fi
  4496. if test "$QEMU_GA_MANUFACTURER" = ""; then
  4497. QEMU_GA_MANUFACTURER=QEMU
  4498. fi
  4499. if test "$QEMU_GA_DISTRO" = ""; then
  4500. QEMU_GA_DISTRO=Linux
  4501. fi
  4502. if test "$QEMU_GA_VERSION" = ""; then
  4503. QEMU_GA_VERSION=$(cat $source_path/VERSION)
  4504. fi
  4505. QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
  4506. case "$cpu" in
  4507. x86_64)
  4508. QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
  4509. ;;
  4510. i386)
  4511. QEMU_GA_MSI_ARCH="-D Arch=32"
  4512. ;;
  4513. *)
  4514. error_exit "CPU $cpu not supported for building installation package"
  4515. ;;
  4516. esac
  4517. fi
  4518. # Mac OS X ships with a broken assembler
  4519. roms=
  4520. if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
  4521. "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
  4522. "$softmmu" = yes ; then
  4523. # Different host OS linkers have different ideas about the name of the ELF
  4524. # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
  4525. # variant; and Windows uses i386pe.
  4526. for emu in elf_i386 elf_i386_fbsd i386pe; do
  4527. if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
  4528. ld_i386_emulation="$emu"
  4529. roms="optionrom"
  4530. break
  4531. fi
  4532. done
  4533. fi
  4534. if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
  4535. roms="$roms spapr-rtas"
  4536. fi
  4537. if test "$cpu" = "s390x" ; then
  4538. roms="$roms s390-ccw"
  4539. fi
  4540. # Probe for the need for relocating the user-only binary.
  4541. if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
  4542. textseg_addr=
  4543. case "$cpu" in
  4544. arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
  4545. # ??? Rationale for choosing this address
  4546. textseg_addr=0x60000000
  4547. ;;
  4548. mips)
  4549. # A 256M aligned address, high in the address space, with enough
  4550. # room for the code_gen_buffer above it before the stack.
  4551. textseg_addr=0x60000000
  4552. ;;
  4553. esac
  4554. if [ -n "$textseg_addr" ]; then
  4555. cat > $TMPC <<EOF
  4556. int main(void) { return 0; }
  4557. EOF
  4558. textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
  4559. if ! compile_prog "" "$textseg_ldflags"; then
  4560. # In case ld does not support -Ttext-segment, edit the default linker
  4561. # script via sed to set the .text start addr. This is needed on FreeBSD
  4562. # at least.
  4563. if ! $ld --verbose >/dev/null 2>&1; then
  4564. error_exit \
  4565. "We need to link the QEMU user mode binaries at a" \
  4566. "specific text address. Unfortunately your linker" \
  4567. "doesn't support either the -Ttext-segment option or" \
  4568. "printing the default linker script with --verbose." \
  4569. "If you don't want the user mode binaries, pass the" \
  4570. "--disable-user option to configure."
  4571. fi
  4572. $ld --verbose | sed \
  4573. -e '1,/==================================================/d' \
  4574. -e '/==================================================/,$d' \
  4575. -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
  4576. -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
  4577. textseg_ldflags="-Wl,-T../config-host.ld"
  4578. fi
  4579. fi
  4580. fi
  4581. echo_version() {
  4582. if test "$1" = "yes" ; then
  4583. echo "($2)"
  4584. fi
  4585. }
  4586. # prepend pixman and ftd flags after all config tests are done
  4587. QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
  4588. libs_softmmu="$pixman_libs $libs_softmmu"
  4589. echo "Install prefix $prefix"
  4590. echo "BIOS directory $(eval echo $qemu_datadir)"
  4591. echo "binary directory $(eval echo $bindir)"
  4592. echo "library directory $(eval echo $libdir)"
  4593. echo "module directory $(eval echo $qemu_moddir)"
  4594. echo "libexec directory $(eval echo $libexecdir)"
  4595. echo "include directory $(eval echo $includedir)"
  4596. echo "config directory $(eval echo $sysconfdir)"
  4597. if test "$mingw32" = "no" ; then
  4598. echo "local state directory $(eval echo $local_statedir)"
  4599. echo "Manual directory $(eval echo $mandir)"
  4600. echo "ELF interp prefix $interp_prefix"
  4601. else
  4602. echo "local state directory queried at runtime"
  4603. echo "Windows SDK $win_sdk"
  4604. fi
  4605. echo "Source path $source_path"
  4606. echo "C compiler $cc"
  4607. echo "Host C compiler $host_cc"
  4608. echo "C++ compiler $cxx"
  4609. echo "Objective-C compiler $objcc"
  4610. echo "ARFLAGS $ARFLAGS"
  4611. echo "CFLAGS $CFLAGS"
  4612. echo "QEMU_CFLAGS $QEMU_CFLAGS"
  4613. echo "LDFLAGS $LDFLAGS"
  4614. echo "make $make"
  4615. echo "install $install"
  4616. echo "python $python"
  4617. if test "$slirp" = "yes" ; then
  4618. echo "smbd $smbd"
  4619. fi
  4620. echo "module support $modules"
  4621. echo "host CPU $cpu"
  4622. echo "host big endian $bigendian"
  4623. echo "target list $target_list"
  4624. echo "tcg debug enabled $debug_tcg"
  4625. echo "gprof enabled $gprof"
  4626. echo "sparse enabled $sparse"
  4627. echo "strip binaries $strip_opt"
  4628. echo "profiler $profiler"
  4629. echo "static build $static"
  4630. if test "$darwin" = "yes" ; then
  4631. echo "Cocoa support $cocoa"
  4632. fi
  4633. echo "pixman $pixman"
  4634. echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
  4635. echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
  4636. echo "GTK GL support $gtk_gl"
  4637. echo "VTE support $vte $(echo_version $vte $vteversion)"
  4638. echo "TLS priority $tls_priority"
  4639. echo "GNUTLS support $gnutls"
  4640. echo "GNUTLS rnd $gnutls_rnd"
  4641. echo "libgcrypt $gcrypt"
  4642. echo "libgcrypt kdf $gcrypt_kdf"
  4643. echo "nettle $nettle $(echo_version $nettle $nettle_version)"
  4644. echo "nettle kdf $nettle_kdf"
  4645. echo "libtasn1 $tasn1"
  4646. echo "curses support $curses"
  4647. echo "virgl support $virglrenderer"
  4648. echo "curl support $curl"
  4649. echo "mingw32 support $mingw32"
  4650. echo "Audio drivers $audio_drv_list"
  4651. echo "Block whitelist (rw) $block_drv_rw_whitelist"
  4652. echo "Block whitelist (ro) $block_drv_ro_whitelist"
  4653. echo "VirtFS support $virtfs"
  4654. echo "VNC support $vnc"
  4655. if test "$vnc" = "yes" ; then
  4656. echo "VNC SASL support $vnc_sasl"
  4657. echo "VNC JPEG support $vnc_jpeg"
  4658. echo "VNC PNG support $vnc_png"
  4659. fi
  4660. if test -n "$sparc_cpu"; then
  4661. echo "Target Sparc Arch $sparc_cpu"
  4662. fi
  4663. echo "xen support $xen"
  4664. if test "$xen" = "yes" ; then
  4665. echo "xen ctrl version $xen_ctrl_version"
  4666. echo "pv dom build $xen_pv_domain_build"
  4667. fi
  4668. echo "brlapi support $brlapi"
  4669. echo "bluez support $bluez"
  4670. echo "Documentation $docs"
  4671. echo "PIE $pie"
  4672. echo "vde support $vde"
  4673. echo "netmap support $netmap"
  4674. echo "Linux AIO support $linux_aio"
  4675. echo "ATTR/XATTR support $attr"
  4676. echo "Install blobs $blobs"
  4677. echo "KVM support $kvm"
  4678. echo "HAX support $hax"
  4679. echo "RDMA support $rdma"
  4680. echo "TCG interpreter $tcg_interpreter"
  4681. echo "fdt support $fdt"
  4682. echo "preadv support $preadv"
  4683. echo "fdatasync $fdatasync"
  4684. echo "madvise $madvise"
  4685. echo "posix_madvise $posix_madvise"
  4686. echo "libcap-ng support $cap_ng"
  4687. echo "vhost-net support $vhost_net"
  4688. echo "vhost-scsi support $vhost_scsi"
  4689. echo "vhost-vsock support $vhost_vsock"
  4690. echo "Trace backends $trace_backends"
  4691. if have_backend "simple"; then
  4692. echo "Trace output file $trace_file-<pid>"
  4693. fi
  4694. echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
  4695. echo "rbd support $rbd"
  4696. echo "xfsctl support $xfs"
  4697. echo "smartcard support $smartcard"
  4698. echo "libusb $libusb"
  4699. echo "usb net redir $usb_redir"
  4700. echo "OpenGL support $opengl"
  4701. echo "OpenGL dmabufs $opengl_dmabuf"
  4702. echo "libiscsi support $libiscsi"
  4703. echo "libnfs support $libnfs"
  4704. echo "build guest agent $guest_agent"
  4705. echo "QGA VSS support $guest_agent_with_vss"
  4706. echo "QGA w32 disk info $guest_agent_ntddscsi"
  4707. echo "QGA MSI support $guest_agent_msi"
  4708. echo "seccomp support $seccomp"
  4709. echo "coroutine backend $coroutine"
  4710. echo "coroutine pool $coroutine_pool"
  4711. echo "debug stack usage $debug_stack_usage"
  4712. echo "GlusterFS support $glusterfs"
  4713. echo "gcov $gcov_tool"
  4714. echo "gcov enabled $gcov"
  4715. echo "TPM support $tpm"
  4716. echo "libssh2 support $libssh2"
  4717. echo "TPM passthrough $tpm_passthrough"
  4718. echo "QOM debugging $qom_cast_debug"
  4719. echo "lzo support $lzo"
  4720. echo "snappy support $snappy"
  4721. echo "bzip2 support $bzip2"
  4722. echo "NUMA host support $numa"
  4723. echo "tcmalloc support $tcmalloc"
  4724. echo "jemalloc support $jemalloc"
  4725. echo "avx2 optimization $avx2_opt"
  4726. echo "replication support $replication"
  4727. if test "$sdl_too_old" = "yes"; then
  4728. echo "-> Your SDL version is too old - please upgrade to have SDL support"
  4729. fi
  4730. if test "$supported_cpu" = "no"; then
  4731. echo
  4732. echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
  4733. echo
  4734. echo "CPU host architecture $cpu support is not currently maintained."
  4735. echo "The QEMU project intends to remove support for this host CPU in"
  4736. echo "a future release if nobody volunteers to maintain it and to"
  4737. echo "provide a build host for our continuous integration setup."
  4738. echo "configure has succeeded and you can continue to build, but"
  4739. echo "if you care about QEMU on this platform you should contact"
  4740. echo "us upstream at qemu-devel@nongnu.org."
  4741. fi
  4742. if test "$supported_os" = "no"; then
  4743. echo
  4744. echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
  4745. echo
  4746. echo "Host OS $targetos support is not currently maintained."
  4747. echo "The QEMU project intends to remove support for this host OS in"
  4748. echo "a future release if nobody volunteers to maintain it and to"
  4749. echo "provide a build host for our continuous integration setup."
  4750. echo "configure has succeeded and you can continue to build, but"
  4751. echo "if you care about QEMU on this platform you should contact"
  4752. echo "us upstream at qemu-devel@nongnu.org."
  4753. fi
  4754. config_host_mak="config-host.mak"
  4755. echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
  4756. echo "# Automatically generated by configure - do not modify" > $config_host_mak
  4757. echo >> $config_host_mak
  4758. echo all: >> $config_host_mak
  4759. echo "prefix=$prefix" >> $config_host_mak
  4760. echo "bindir=$bindir" >> $config_host_mak
  4761. echo "libdir=$libdir" >> $config_host_mak
  4762. echo "libexecdir=$libexecdir" >> $config_host_mak
  4763. echo "includedir=$includedir" >> $config_host_mak
  4764. echo "mandir=$mandir" >> $config_host_mak
  4765. echo "sysconfdir=$sysconfdir" >> $config_host_mak
  4766. echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
  4767. echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
  4768. echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
  4769. echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
  4770. if test "$mingw32" = "no" ; then
  4771. echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
  4772. fi
  4773. echo "qemu_helperdir=$libexecdir" >> $config_host_mak
  4774. echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
  4775. echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
  4776. echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
  4777. echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
  4778. echo "ARCH=$ARCH" >> $config_host_mak
  4779. if test "$debug_tcg" = "yes" ; then
  4780. echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
  4781. fi
  4782. if test "$strip_opt" = "yes" ; then
  4783. echo "STRIP=${strip}" >> $config_host_mak
  4784. fi
  4785. if test "$bigendian" = "yes" ; then
  4786. echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
  4787. fi
  4788. if test "$mingw32" = "yes" ; then
  4789. echo "CONFIG_WIN32=y" >> $config_host_mak
  4790. rc_version=$(cat $source_path/VERSION)
  4791. version_major=${rc_version%%.*}
  4792. rc_version=${rc_version#*.}
  4793. version_minor=${rc_version%%.*}
  4794. rc_version=${rc_version#*.}
  4795. version_subminor=${rc_version%%.*}
  4796. version_micro=0
  4797. echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
  4798. echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
  4799. if test "$guest_agent_with_vss" = "yes" ; then
  4800. echo "CONFIG_QGA_VSS=y" >> $config_host_mak
  4801. echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
  4802. echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
  4803. fi
  4804. if test "$guest_agent_ntddscsi" = "yes" ; then
  4805. echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
  4806. fi
  4807. if test "$guest_agent_msi" = "yes"; then
  4808. echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
  4809. echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
  4810. echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
  4811. echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
  4812. echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
  4813. echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
  4814. echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
  4815. fi
  4816. else
  4817. echo "CONFIG_POSIX=y" >> $config_host_mak
  4818. fi
  4819. if test "$linux" = "yes" ; then
  4820. echo "CONFIG_LINUX=y" >> $config_host_mak
  4821. fi
  4822. if test "$darwin" = "yes" ; then
  4823. echo "CONFIG_DARWIN=y" >> $config_host_mak
  4824. fi
  4825. if test "$aix" = "yes" ; then
  4826. echo "CONFIG_AIX=y" >> $config_host_mak
  4827. fi
  4828. if test "$solaris" = "yes" ; then
  4829. echo "CONFIG_SOLARIS=y" >> $config_host_mak
  4830. echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
  4831. if test "$needs_libsunmath" = "yes" ; then
  4832. echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
  4833. fi
  4834. fi
  4835. if test "$haiku" = "yes" ; then
  4836. echo "CONFIG_HAIKU=y" >> $config_host_mak
  4837. fi
  4838. if test "$static" = "yes" ; then
  4839. echo "CONFIG_STATIC=y" >> $config_host_mak
  4840. fi
  4841. if test "$profiler" = "yes" ; then
  4842. echo "CONFIG_PROFILER=y" >> $config_host_mak
  4843. fi
  4844. if test "$slirp" = "yes" ; then
  4845. echo "CONFIG_SLIRP=y" >> $config_host_mak
  4846. echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
  4847. fi
  4848. if test "$vde" = "yes" ; then
  4849. echo "CONFIG_VDE=y" >> $config_host_mak
  4850. fi
  4851. if test "$netmap" = "yes" ; then
  4852. echo "CONFIG_NETMAP=y" >> $config_host_mak
  4853. fi
  4854. if test "$l2tpv3" = "yes" ; then
  4855. echo "CONFIG_L2TPV3=y" >> $config_host_mak
  4856. fi
  4857. if test "$cap_ng" = "yes" ; then
  4858. echo "CONFIG_LIBCAP=y" >> $config_host_mak
  4859. fi
  4860. echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
  4861. for drv in $audio_drv_list; do
  4862. def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
  4863. echo "$def=y" >> $config_host_mak
  4864. done
  4865. if test "$audio_pt_int" = "yes" ; then
  4866. echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
  4867. fi
  4868. if test "$audio_win_int" = "yes" ; then
  4869. echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
  4870. fi
  4871. echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
  4872. echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
  4873. if test "$vnc" = "yes" ; then
  4874. echo "CONFIG_VNC=y" >> $config_host_mak
  4875. fi
  4876. if test "$vnc_sasl" = "yes" ; then
  4877. echo "CONFIG_VNC_SASL=y" >> $config_host_mak
  4878. fi
  4879. if test "$vnc_jpeg" = "yes" ; then
  4880. echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
  4881. fi
  4882. if test "$vnc_png" = "yes" ; then
  4883. echo "CONFIG_VNC_PNG=y" >> $config_host_mak
  4884. fi
  4885. if test "$fnmatch" = "yes" ; then
  4886. echo "CONFIG_FNMATCH=y" >> $config_host_mak
  4887. fi
  4888. if test "$xfs" = "yes" ; then
  4889. echo "CONFIG_XFS=y" >> $config_host_mak
  4890. fi
  4891. qemu_version=$(head $source_path/VERSION)
  4892. echo "VERSION=$qemu_version" >>$config_host_mak
  4893. echo "PKGVERSION=$pkgversion" >>$config_host_mak
  4894. echo "SRC_PATH=$source_path" >> $config_host_mak
  4895. echo "TARGET_DIRS=$target_list" >> $config_host_mak
  4896. if [ "$docs" = "yes" ] ; then
  4897. echo "BUILD_DOCS=yes" >> $config_host_mak
  4898. fi
  4899. if test "$modules" = "yes"; then
  4900. # $shacmd can generate a hash started with digit, which the compiler doesn't
  4901. # like as an symbol. So prefix it with an underscore
  4902. echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
  4903. echo "CONFIG_MODULES=y" >> $config_host_mak
  4904. fi
  4905. if test "$sdl" = "yes" ; then
  4906. echo "CONFIG_SDL=y" >> $config_host_mak
  4907. echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
  4908. echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
  4909. fi
  4910. if test "$cocoa" = "yes" ; then
  4911. echo "CONFIG_COCOA=y" >> $config_host_mak
  4912. fi
  4913. if test "$curses" = "yes" ; then
  4914. echo "CONFIG_CURSES=y" >> $config_host_mak
  4915. fi
  4916. if test "$utimens" = "yes" ; then
  4917. echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
  4918. fi
  4919. if test "$pipe2" = "yes" ; then
  4920. echo "CONFIG_PIPE2=y" >> $config_host_mak
  4921. fi
  4922. if test "$accept4" = "yes" ; then
  4923. echo "CONFIG_ACCEPT4=y" >> $config_host_mak
  4924. fi
  4925. if test "$splice" = "yes" ; then
  4926. echo "CONFIG_SPLICE=y" >> $config_host_mak
  4927. fi
  4928. if test "$eventfd" = "yes" ; then
  4929. echo "CONFIG_EVENTFD=y" >> $config_host_mak
  4930. fi
  4931. if test "$memfd" = "yes" ; then
  4932. echo "CONFIG_MEMFD=y" >> $config_host_mak
  4933. fi
  4934. if test "$fallocate" = "yes" ; then
  4935. echo "CONFIG_FALLOCATE=y" >> $config_host_mak
  4936. fi
  4937. if test "$fallocate_punch_hole" = "yes" ; then
  4938. echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
  4939. fi
  4940. if test "$fallocate_zero_range" = "yes" ; then
  4941. echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
  4942. fi
  4943. if test "$posix_fallocate" = "yes" ; then
  4944. echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
  4945. fi
  4946. if test "$sync_file_range" = "yes" ; then
  4947. echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
  4948. fi
  4949. if test "$fiemap" = "yes" ; then
  4950. echo "CONFIG_FIEMAP=y" >> $config_host_mak
  4951. fi
  4952. if test "$dup3" = "yes" ; then
  4953. echo "CONFIG_DUP3=y" >> $config_host_mak
  4954. fi
  4955. if test "$ppoll" = "yes" ; then
  4956. echo "CONFIG_PPOLL=y" >> $config_host_mak
  4957. fi
  4958. if test "$prctl_pr_set_timerslack" = "yes" ; then
  4959. echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
  4960. fi
  4961. if test "$epoll" = "yes" ; then
  4962. echo "CONFIG_EPOLL=y" >> $config_host_mak
  4963. fi
  4964. if test "$epoll_create1" = "yes" ; then
  4965. echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
  4966. fi
  4967. if test "$sendfile" = "yes" ; then
  4968. echo "CONFIG_SENDFILE=y" >> $config_host_mak
  4969. fi
  4970. if test "$timerfd" = "yes" ; then
  4971. echo "CONFIG_TIMERFD=y" >> $config_host_mak
  4972. fi
  4973. if test "$setns" = "yes" ; then
  4974. echo "CONFIG_SETNS=y" >> $config_host_mak
  4975. fi
  4976. if test "$clock_adjtime" = "yes" ; then
  4977. echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
  4978. fi
  4979. if test "$syncfs" = "yes" ; then
  4980. echo "CONFIG_SYNCFS=y" >> $config_host_mak
  4981. fi
  4982. if test "$inotify" = "yes" ; then
  4983. echo "CONFIG_INOTIFY=y" >> $config_host_mak
  4984. fi
  4985. if test "$inotify1" = "yes" ; then
  4986. echo "CONFIG_INOTIFY1=y" >> $config_host_mak
  4987. fi
  4988. if test "$byteswap_h" = "yes" ; then
  4989. echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
  4990. fi
  4991. if test "$bswap_h" = "yes" ; then
  4992. echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
  4993. fi
  4994. if test "$curl" = "yes" ; then
  4995. echo "CONFIG_CURL=m" >> $config_host_mak
  4996. echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
  4997. echo "CURL_LIBS=$curl_libs" >> $config_host_mak
  4998. fi
  4999. if test "$brlapi" = "yes" ; then
  5000. echo "CONFIG_BRLAPI=y" >> $config_host_mak
  5001. fi
  5002. if test "$bluez" = "yes" ; then
  5003. echo "CONFIG_BLUEZ=y" >> $config_host_mak
  5004. echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
  5005. fi
  5006. if test "$glib_subprocess" = "yes" ; then
  5007. echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
  5008. fi
  5009. if test "$gtk" = "yes" ; then
  5010. echo "CONFIG_GTK=y" >> $config_host_mak
  5011. echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
  5012. echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
  5013. echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
  5014. if test "$gtk_gl" = "yes" ; then
  5015. echo "CONFIG_GTK_GL=y" >> $config_host_mak
  5016. fi
  5017. fi
  5018. echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
  5019. if test "$gnutls" = "yes" ; then
  5020. echo "CONFIG_GNUTLS=y" >> $config_host_mak
  5021. fi
  5022. if test "$gnutls_rnd" = "yes" ; then
  5023. echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
  5024. fi
  5025. if test "$gcrypt" = "yes" ; then
  5026. echo "CONFIG_GCRYPT=y" >> $config_host_mak
  5027. if test "$gcrypt_hmac" = "yes" ; then
  5028. echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
  5029. fi
  5030. if test "$gcrypt_kdf" = "yes" ; then
  5031. echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
  5032. fi
  5033. fi
  5034. if test "$nettle" = "yes" ; then
  5035. echo "CONFIG_NETTLE=y" >> $config_host_mak
  5036. echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
  5037. if test "$nettle_kdf" = "yes" ; then
  5038. echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
  5039. fi
  5040. fi
  5041. if test "$tasn1" = "yes" ; then
  5042. echo "CONFIG_TASN1=y" >> $config_host_mak
  5043. fi
  5044. if test "$have_ifaddrs_h" = "yes" ; then
  5045. echo "HAVE_IFADDRS_H=y" >> $config_host_mak
  5046. fi
  5047. if test "$have_broken_size_max" = "yes" ; then
  5048. echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
  5049. fi
  5050. # Work around a system header bug with some kernel/XFS header
  5051. # versions where they both try to define 'struct fsxattr':
  5052. # xfs headers will not try to redefine structs from linux headers
  5053. # if this macro is set.
  5054. if test "$have_fsxattr" = "yes" ; then
  5055. echo "HAVE_FSXATTR=y" >> $config_host_mak
  5056. fi
  5057. if test "$vte" = "yes" ; then
  5058. echo "CONFIG_VTE=y" >> $config_host_mak
  5059. echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
  5060. fi
  5061. if test "$virglrenderer" = "yes" ; then
  5062. echo "CONFIG_VIRGL=y" >> $config_host_mak
  5063. echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
  5064. echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
  5065. fi
  5066. if test "$xen" = "yes" ; then
  5067. echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
  5068. echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
  5069. if test "$xen_pv_domain_build" = "yes" ; then
  5070. echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
  5071. fi
  5072. fi
  5073. if test "$linux_aio" = "yes" ; then
  5074. echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
  5075. fi
  5076. if test "$attr" = "yes" ; then
  5077. echo "CONFIG_ATTR=y" >> $config_host_mak
  5078. fi
  5079. if test "$libattr" = "yes" ; then
  5080. echo "CONFIG_LIBATTR=y" >> $config_host_mak
  5081. fi
  5082. if test "$virtfs" = "yes" ; then
  5083. echo "CONFIG_VIRTFS=y" >> $config_host_mak
  5084. fi
  5085. if test "$vhost_scsi" = "yes" ; then
  5086. echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
  5087. fi
  5088. if test "$vhost_net" = "yes" ; then
  5089. echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
  5090. fi
  5091. if test "$vhost_vsock" = "yes" ; then
  5092. echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
  5093. fi
  5094. if test "$blobs" = "yes" ; then
  5095. echo "INSTALL_BLOBS=yes" >> $config_host_mak
  5096. fi
  5097. if test "$iovec" = "yes" ; then
  5098. echo "CONFIG_IOVEC=y" >> $config_host_mak
  5099. fi
  5100. if test "$preadv" = "yes" ; then
  5101. echo "CONFIG_PREADV=y" >> $config_host_mak
  5102. fi
  5103. if test "$fdt" = "yes" ; then
  5104. echo "CONFIG_FDT=y" >> $config_host_mak
  5105. fi
  5106. if test "$signalfd" = "yes" ; then
  5107. echo "CONFIG_SIGNALFD=y" >> $config_host_mak
  5108. fi
  5109. if test "$tcg_interpreter" = "yes" ; then
  5110. echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
  5111. fi
  5112. if test "$fdatasync" = "yes" ; then
  5113. echo "CONFIG_FDATASYNC=y" >> $config_host_mak
  5114. fi
  5115. if test "$madvise" = "yes" ; then
  5116. echo "CONFIG_MADVISE=y" >> $config_host_mak
  5117. fi
  5118. if test "$posix_madvise" = "yes" ; then
  5119. echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
  5120. fi
  5121. if test "$spice" = "yes" ; then
  5122. echo "CONFIG_SPICE=y" >> $config_host_mak
  5123. fi
  5124. if test "$smartcard" = "yes" ; then
  5125. echo "CONFIG_SMARTCARD=y" >> $config_host_mak
  5126. fi
  5127. if test "$libusb" = "yes" ; then
  5128. echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
  5129. fi
  5130. if test "$usb_redir" = "yes" ; then
  5131. echo "CONFIG_USB_REDIR=y" >> $config_host_mak
  5132. fi
  5133. if test "$opengl" = "yes" ; then
  5134. echo "CONFIG_OPENGL=y" >> $config_host_mak
  5135. echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
  5136. if test "$opengl_dmabuf" = "yes" ; then
  5137. echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
  5138. fi
  5139. fi
  5140. if test "$avx2_opt" = "yes" ; then
  5141. echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
  5142. fi
  5143. if test "$lzo" = "yes" ; then
  5144. echo "CONFIG_LZO=y" >> $config_host_mak
  5145. fi
  5146. if test "$snappy" = "yes" ; then
  5147. echo "CONFIG_SNAPPY=y" >> $config_host_mak
  5148. fi
  5149. if test "$bzip2" = "yes" ; then
  5150. echo "CONFIG_BZIP2=y" >> $config_host_mak
  5151. echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
  5152. fi
  5153. if test "$libiscsi" = "yes" ; then
  5154. echo "CONFIG_LIBISCSI=m" >> $config_host_mak
  5155. echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
  5156. echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
  5157. fi
  5158. if test "$libnfs" = "yes" ; then
  5159. echo "CONFIG_LIBNFS=m" >> $config_host_mak
  5160. echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
  5161. fi
  5162. if test "$seccomp" = "yes"; then
  5163. echo "CONFIG_SECCOMP=y" >> $config_host_mak
  5164. fi
  5165. # XXX: suppress that
  5166. if [ "$bsd" = "yes" ] ; then
  5167. echo "CONFIG_BSD=y" >> $config_host_mak
  5168. fi
  5169. if test "$localtime_r" = "yes" ; then
  5170. echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
  5171. fi
  5172. if test "$qom_cast_debug" = "yes" ; then
  5173. echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
  5174. fi
  5175. if test "$rbd" = "yes" ; then
  5176. echo "CONFIG_RBD=m" >> $config_host_mak
  5177. echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
  5178. echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
  5179. fi
  5180. echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
  5181. if test "$coroutine_pool" = "yes" ; then
  5182. echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
  5183. else
  5184. echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
  5185. fi
  5186. if test "$debug_stack_usage" = "yes" ; then
  5187. echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
  5188. fi
  5189. if test "$open_by_handle_at" = "yes" ; then
  5190. echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
  5191. fi
  5192. if test "$linux_magic_h" = "yes" ; then
  5193. echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
  5194. fi
  5195. if test "$pragma_diagnostic_available" = "yes" ; then
  5196. echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
  5197. fi
  5198. if test "$valgrind_h" = "yes" ; then
  5199. echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
  5200. fi
  5201. if test "$has_environ" = "yes" ; then
  5202. echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
  5203. fi
  5204. if test "$cpuid_h" = "yes" ; then
  5205. echo "CONFIG_CPUID_H=y" >> $config_host_mak
  5206. fi
  5207. if test "$int128" = "yes" ; then
  5208. echo "CONFIG_INT128=y" >> $config_host_mak
  5209. fi
  5210. if test "$atomic128" = "yes" ; then
  5211. echo "CONFIG_ATOMIC128=y" >> $config_host_mak
  5212. fi
  5213. if test "$atomic64" = "yes" ; then
  5214. echo "CONFIG_ATOMIC64=y" >> $config_host_mak
  5215. fi
  5216. if test "$getauxval" = "yes" ; then
  5217. echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
  5218. fi
  5219. if test "$glusterfs" = "yes" ; then
  5220. echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
  5221. echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
  5222. echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
  5223. fi
  5224. if test "$glusterfs_xlator_opt" = "yes" ; then
  5225. echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
  5226. fi
  5227. if test "$glusterfs_discard" = "yes" ; then
  5228. echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
  5229. fi
  5230. if test "$glusterfs_zerofill" = "yes" ; then
  5231. echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
  5232. fi
  5233. if test "$libssh2" = "yes" ; then
  5234. echo "CONFIG_LIBSSH2=m" >> $config_host_mak
  5235. echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
  5236. echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
  5237. fi
  5238. # USB host support
  5239. if test "$libusb" = "yes"; then
  5240. echo "HOST_USB=libusb legacy" >> $config_host_mak
  5241. else
  5242. echo "HOST_USB=stub" >> $config_host_mak
  5243. fi
  5244. # TPM passthrough support?
  5245. if test "$tpm" = "yes"; then
  5246. echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
  5247. if test "$tpm_passthrough" = "yes"; then
  5248. echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
  5249. fi
  5250. fi
  5251. echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
  5252. if have_backend "nop"; then
  5253. echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
  5254. fi
  5255. if have_backend "simple"; then
  5256. echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
  5257. # Set the appropriate trace file.
  5258. trace_file="\"$trace_file-\" FMT_pid"
  5259. fi
  5260. if have_backend "log"; then
  5261. echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
  5262. fi
  5263. if have_backend "ust"; then
  5264. echo "CONFIG_TRACE_UST=y" >> $config_host_mak
  5265. fi
  5266. if have_backend "dtrace"; then
  5267. echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
  5268. if test "$trace_backend_stap" = "yes" ; then
  5269. echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
  5270. fi
  5271. fi
  5272. if have_backend "ftrace"; then
  5273. if test "$linux" = "yes" ; then
  5274. echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
  5275. else
  5276. feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
  5277. fi
  5278. fi
  5279. if have_backend "syslog"; then
  5280. if test "$posix_syslog" = "yes" ; then
  5281. echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
  5282. else
  5283. feature_not_found "syslog(trace backend)" "syslog not available"
  5284. fi
  5285. fi
  5286. echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
  5287. if test "$rdma" = "yes" ; then
  5288. echo "CONFIG_RDMA=y" >> $config_host_mak
  5289. fi
  5290. if test "$have_rtnetlink" = "yes" ; then
  5291. echo "CONFIG_RTNETLINK=y" >> $config_host_mak
  5292. fi
  5293. if test "$replication" = "yes" ; then
  5294. echo "CONFIG_REPLICATION=y" >> $config_host_mak
  5295. fi
  5296. if test "$have_af_vsock" = "yes" ; then
  5297. echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
  5298. fi
  5299. if test "$have_sysmacros" = "yes" ; then
  5300. echo "CONFIG_SYSMACROS=y" >> $config_host_mak
  5301. fi
  5302. # Hold two types of flag:
  5303. # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
  5304. # a thread we have a handle to
  5305. # CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
  5306. # platform
  5307. if test "$pthread_setname_np" = "yes" ; then
  5308. echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
  5309. echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
  5310. fi
  5311. if test "$tcg_interpreter" = "yes"; then
  5312. QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
  5313. elif test "$ARCH" = "sparc64" ; then
  5314. QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
  5315. elif test "$ARCH" = "s390x" ; then
  5316. QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
  5317. elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
  5318. QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
  5319. elif test "$ARCH" = "ppc64" ; then
  5320. QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
  5321. else
  5322. QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
  5323. fi
  5324. QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
  5325. echo "TOOLS=$tools" >> $config_host_mak
  5326. echo "ROMS=$roms" >> $config_host_mak
  5327. echo "MAKE=$make" >> $config_host_mak
  5328. echo "INSTALL=$install" >> $config_host_mak
  5329. echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
  5330. echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
  5331. echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
  5332. echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
  5333. echo "PYTHON=$python" >> $config_host_mak
  5334. echo "CC=$cc" >> $config_host_mak
  5335. if $iasl -h > /dev/null 2>&1; then
  5336. echo "IASL=$iasl" >> $config_host_mak
  5337. fi
  5338. echo "CC_I386=$cc_i386" >> $config_host_mak
  5339. echo "HOST_CC=$host_cc" >> $config_host_mak
  5340. echo "CXX=$cxx" >> $config_host_mak
  5341. echo "OBJCC=$objcc" >> $config_host_mak
  5342. echo "AR=$ar" >> $config_host_mak
  5343. echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
  5344. echo "AS=$as" >> $config_host_mak
  5345. echo "CCAS=$ccas" >> $config_host_mak
  5346. echo "CPP=$cpp" >> $config_host_mak
  5347. echo "OBJCOPY=$objcopy" >> $config_host_mak
  5348. echo "LD=$ld" >> $config_host_mak
  5349. echo "NM=$nm" >> $config_host_mak
  5350. echo "WINDRES=$windres" >> $config_host_mak
  5351. echo "CFLAGS=$CFLAGS" >> $config_host_mak
  5352. echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
  5353. echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
  5354. echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
  5355. if test "$sparse" = "yes" ; then
  5356. echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
  5357. echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
  5358. echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
  5359. echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
  5360. echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
  5361. fi
  5362. if test "$cross_prefix" != ""; then
  5363. echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
  5364. else
  5365. echo "AUTOCONF_HOST := " >> $config_host_mak
  5366. fi
  5367. echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
  5368. echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
  5369. echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
  5370. echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
  5371. echo "LIBS+=$LIBS" >> $config_host_mak
  5372. echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
  5373. echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
  5374. echo "EXESUF=$EXESUF" >> $config_host_mak
  5375. echo "DSOSUF=$DSOSUF" >> $config_host_mak
  5376. echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
  5377. echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
  5378. echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
  5379. echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
  5380. echo "POD2MAN=$POD2MAN" >> $config_host_mak
  5381. echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
  5382. if test "$gcov" = "yes" ; then
  5383. echo "CONFIG_GCOV=y" >> $config_host_mak
  5384. echo "GCOV=$gcov_tool" >> $config_host_mak
  5385. fi
  5386. # use included Linux headers
  5387. if test "$linux" = "yes" ; then
  5388. mkdir -p linux-headers
  5389. case "$cpu" in
  5390. i386|x86_64|x32)
  5391. linux_arch=x86
  5392. ;;
  5393. ppcemb|ppc|ppc64)
  5394. linux_arch=powerpc
  5395. ;;
  5396. s390x)
  5397. linux_arch=s390
  5398. ;;
  5399. aarch64)
  5400. linux_arch=arm64
  5401. ;;
  5402. mips64)
  5403. linux_arch=mips
  5404. ;;
  5405. *)
  5406. # For most CPUs the kernel architecture name and QEMU CPU name match.
  5407. linux_arch="$cpu"
  5408. ;;
  5409. esac
  5410. # For non-KVM architectures we will not have asm headers
  5411. if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
  5412. symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
  5413. fi
  5414. fi
  5415. for target in $target_list; do
  5416. target_dir="$target"
  5417. config_target_mak=$target_dir/config-target.mak
  5418. target_name=$(echo $target | cut -d '-' -f 1)
  5419. target_bigendian="no"
  5420. case "$target_name" in
  5421. armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
  5422. target_bigendian=yes
  5423. ;;
  5424. esac
  5425. target_softmmu="no"
  5426. target_user_only="no"
  5427. target_linux_user="no"
  5428. target_bsd_user="no"
  5429. case "$target" in
  5430. ${target_name}-softmmu)
  5431. target_softmmu="yes"
  5432. ;;
  5433. ${target_name}-linux-user)
  5434. if test "$linux" != "yes" ; then
  5435. error_exit "Target '$target' is only available on a Linux host"
  5436. fi
  5437. target_user_only="yes"
  5438. target_linux_user="yes"
  5439. ;;
  5440. ${target_name}-bsd-user)
  5441. if test "$bsd" != "yes" ; then
  5442. error_exit "Target '$target' is only available on a BSD host"
  5443. fi
  5444. target_user_only="yes"
  5445. target_bsd_user="yes"
  5446. ;;
  5447. *)
  5448. error_exit "Target '$target' not recognised"
  5449. exit 1
  5450. ;;
  5451. esac
  5452. mkdir -p $target_dir
  5453. echo "# Automatically generated by configure - do not modify" > $config_target_mak
  5454. bflt="no"
  5455. mttcg="no"
  5456. interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
  5457. gdb_xml_files=""
  5458. TARGET_ARCH="$target_name"
  5459. TARGET_BASE_ARCH=""
  5460. TARGET_ABI_DIR=""
  5461. case "$target_name" in
  5462. i386)
  5463. ;;
  5464. x86_64)
  5465. TARGET_BASE_ARCH=i386
  5466. ;;
  5467. alpha)
  5468. mttcg="yes"
  5469. ;;
  5470. arm|armeb)
  5471. TARGET_ARCH=arm
  5472. bflt="yes"
  5473. mttcg="yes"
  5474. gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
  5475. ;;
  5476. aarch64)
  5477. TARGET_BASE_ARCH=arm
  5478. bflt="yes"
  5479. mttcg="yes"
  5480. gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
  5481. ;;
  5482. cris)
  5483. ;;
  5484. hppa)
  5485. ;;
  5486. lm32)
  5487. ;;
  5488. m68k)
  5489. bflt="yes"
  5490. gdb_xml_files="cf-core.xml cf-fp.xml"
  5491. ;;
  5492. microblaze|microblazeel)
  5493. TARGET_ARCH=microblaze
  5494. bflt="yes"
  5495. ;;
  5496. mips|mipsel)
  5497. TARGET_ARCH=mips
  5498. echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
  5499. ;;
  5500. mipsn32|mipsn32el)
  5501. TARGET_ARCH=mips64
  5502. TARGET_BASE_ARCH=mips
  5503. echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
  5504. echo "TARGET_ABI32=y" >> $config_target_mak
  5505. ;;
  5506. mips64|mips64el)
  5507. TARGET_ARCH=mips64
  5508. TARGET_BASE_ARCH=mips
  5509. echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
  5510. ;;
  5511. moxie)
  5512. ;;
  5513. nios2)
  5514. ;;
  5515. or1k)
  5516. TARGET_ARCH=openrisc
  5517. TARGET_BASE_ARCH=openrisc
  5518. ;;
  5519. ppc)
  5520. gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
  5521. ;;
  5522. ppcemb)
  5523. TARGET_BASE_ARCH=ppc
  5524. TARGET_ABI_DIR=ppc
  5525. gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
  5526. ;;
  5527. ppc64)
  5528. TARGET_BASE_ARCH=ppc
  5529. TARGET_ABI_DIR=ppc
  5530. gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
  5531. ;;
  5532. ppc64le)
  5533. TARGET_ARCH=ppc64
  5534. TARGET_BASE_ARCH=ppc
  5535. TARGET_ABI_DIR=ppc
  5536. gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
  5537. ;;
  5538. ppc64abi32)
  5539. TARGET_ARCH=ppc64
  5540. TARGET_BASE_ARCH=ppc
  5541. TARGET_ABI_DIR=ppc
  5542. echo "TARGET_ABI32=y" >> $config_target_mak
  5543. gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
  5544. ;;
  5545. sh4|sh4eb)
  5546. TARGET_ARCH=sh4
  5547. bflt="yes"
  5548. ;;
  5549. sparc)
  5550. ;;
  5551. sparc64)
  5552. TARGET_BASE_ARCH=sparc
  5553. ;;
  5554. sparc32plus)
  5555. TARGET_ARCH=sparc64
  5556. TARGET_BASE_ARCH=sparc
  5557. TARGET_ABI_DIR=sparc
  5558. echo "TARGET_ABI32=y" >> $config_target_mak
  5559. ;;
  5560. s390x)
  5561. gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
  5562. ;;
  5563. tilegx)
  5564. ;;
  5565. tricore)
  5566. ;;
  5567. unicore32)
  5568. ;;
  5569. xtensa|xtensaeb)
  5570. TARGET_ARCH=xtensa
  5571. ;;
  5572. *)
  5573. error_exit "Unsupported target CPU"
  5574. ;;
  5575. esac
  5576. # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
  5577. if [ "$TARGET_BASE_ARCH" = "" ]; then
  5578. TARGET_BASE_ARCH=$TARGET_ARCH
  5579. fi
  5580. symlink "$source_path/Makefile.target" "$target_dir/Makefile"
  5581. upper() {
  5582. echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
  5583. }
  5584. target_arch_name="$(upper $TARGET_ARCH)"
  5585. echo "TARGET_$target_arch_name=y" >> $config_target_mak
  5586. echo "TARGET_NAME=$target_name" >> $config_target_mak
  5587. echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
  5588. if [ "$TARGET_ABI_DIR" = "" ]; then
  5589. TARGET_ABI_DIR=$TARGET_ARCH
  5590. fi
  5591. echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
  5592. if [ "$HOST_VARIANT_DIR" != "" ]; then
  5593. echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
  5594. fi
  5595. case "$target_name" in
  5596. i386|x86_64)
  5597. if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
  5598. echo "CONFIG_XEN=y" >> $config_target_mak
  5599. if test "$xen_pci_passthrough" = yes; then
  5600. echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
  5601. fi
  5602. fi
  5603. ;;
  5604. *)
  5605. esac
  5606. case "$target_name" in
  5607. aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x|mipsel|mips)
  5608. # Make sure the target and host cpus are compatible
  5609. if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
  5610. \( "$target_name" = "$cpu" -o \
  5611. \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
  5612. \( "$target_name" = "ppc64" -a "$cpu" = "ppc" \) -o \
  5613. \( "$target_name" = "ppc" -a "$cpu" = "ppc64" \) -o \
  5614. \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
  5615. \( "$target_name" = "mipsel" -a "$cpu" = "mips" \) -o \
  5616. \( "$target_name" = "x86_64" -a "$cpu" = "i386" \) -o \
  5617. \( "$target_name" = "i386" -a "$cpu" = "x86_64" \) -o \
  5618. \( "$target_name" = "x86_64" -a "$cpu" = "x32" \) -o \
  5619. \( "$target_name" = "i386" -a "$cpu" = "x32" \) \) ; then
  5620. echo "CONFIG_KVM=y" >> $config_target_mak
  5621. if test "$vhost_net" = "yes" ; then
  5622. echo "CONFIG_VHOST_NET=y" >> $config_target_mak
  5623. echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
  5624. fi
  5625. fi
  5626. esac
  5627. if test "$hax" = "yes" ; then
  5628. if test "$target_softmmu" = "yes" ; then
  5629. case "$target_name" in
  5630. i386|x86_64)
  5631. echo "CONFIG_HAX=y" >> $config_target_mak
  5632. ;;
  5633. esac
  5634. fi
  5635. fi
  5636. if test "$target_bigendian" = "yes" ; then
  5637. echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
  5638. fi
  5639. if test "$target_softmmu" = "yes" ; then
  5640. echo "CONFIG_SOFTMMU=y" >> $config_target_mak
  5641. if test "$mttcg" = "yes" ; then
  5642. echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
  5643. fi
  5644. fi
  5645. if test "$target_user_only" = "yes" ; then
  5646. echo "CONFIG_USER_ONLY=y" >> $config_target_mak
  5647. echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
  5648. fi
  5649. if test "$target_linux_user" = "yes" ; then
  5650. echo "CONFIG_LINUX_USER=y" >> $config_target_mak
  5651. fi
  5652. list=""
  5653. if test ! -z "$gdb_xml_files" ; then
  5654. for x in $gdb_xml_files; do
  5655. list="$list $source_path/gdb-xml/$x"
  5656. done
  5657. echo "TARGET_XML_FILES=$list" >> $config_target_mak
  5658. fi
  5659. if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
  5660. echo "TARGET_HAS_BFLT=y" >> $config_target_mak
  5661. fi
  5662. if test "$target_bsd_user" = "yes" ; then
  5663. echo "CONFIG_BSD_USER=y" >> $config_target_mak
  5664. fi
  5665. # generate QEMU_CFLAGS/LDFLAGS for targets
  5666. cflags=""
  5667. ldflags=""
  5668. disas_config() {
  5669. echo "CONFIG_${1}_DIS=y" >> $config_target_mak
  5670. echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
  5671. }
  5672. for i in $ARCH $TARGET_BASE_ARCH ; do
  5673. case "$i" in
  5674. alpha)
  5675. disas_config "ALPHA"
  5676. ;;
  5677. aarch64)
  5678. if test -n "${cxx}"; then
  5679. disas_config "ARM_A64"
  5680. fi
  5681. ;;
  5682. arm)
  5683. disas_config "ARM"
  5684. if test -n "${cxx}"; then
  5685. disas_config "ARM_A64"
  5686. fi
  5687. ;;
  5688. cris)
  5689. disas_config "CRIS"
  5690. ;;
  5691. hppa)
  5692. disas_config "HPPA"
  5693. ;;
  5694. i386|x86_64|x32)
  5695. disas_config "I386"
  5696. ;;
  5697. ia64*)
  5698. disas_config "IA64"
  5699. ;;
  5700. lm32)
  5701. disas_config "LM32"
  5702. ;;
  5703. m68k)
  5704. disas_config "M68K"
  5705. ;;
  5706. microblaze*)
  5707. disas_config "MICROBLAZE"
  5708. ;;
  5709. mips*)
  5710. disas_config "MIPS"
  5711. ;;
  5712. moxie*)
  5713. disas_config "MOXIE"
  5714. ;;
  5715. nios2)
  5716. disas_config "NIOS2"
  5717. ;;
  5718. or1k)
  5719. disas_config "OPENRISC"
  5720. ;;
  5721. ppc*)
  5722. disas_config "PPC"
  5723. ;;
  5724. s390*)
  5725. disas_config "S390"
  5726. ;;
  5727. sh4)
  5728. disas_config "SH4"
  5729. ;;
  5730. sparc*)
  5731. disas_config "SPARC"
  5732. ;;
  5733. xtensa*)
  5734. disas_config "XTENSA"
  5735. ;;
  5736. esac
  5737. done
  5738. if test "$tcg_interpreter" = "yes" ; then
  5739. disas_config "TCI"
  5740. fi
  5741. case "$ARCH" in
  5742. alpha)
  5743. # Ensure there's only a single GP
  5744. cflags="-msmall-data $cflags"
  5745. ;;
  5746. esac
  5747. if test "$gprof" = "yes" ; then
  5748. echo "TARGET_GPROF=yes" >> $config_target_mak
  5749. if test "$target_linux_user" = "yes" ; then
  5750. cflags="-p $cflags"
  5751. ldflags="-p $ldflags"
  5752. fi
  5753. if test "$target_softmmu" = "yes" ; then
  5754. ldflags="-p $ldflags"
  5755. echo "GPROF_CFLAGS=-p" >> $config_target_mak
  5756. fi
  5757. fi
  5758. if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
  5759. ldflags="$ldflags $textseg_ldflags"
  5760. fi
  5761. echo "LDFLAGS+=$ldflags" >> $config_target_mak
  5762. echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
  5763. done # for target in $targets
  5764. if [ "$pixman" = "internal" ]; then
  5765. echo "config-host.h: subdir-pixman" >> $config_host_mak
  5766. fi
  5767. if [ "$dtc_internal" = "yes" ]; then
  5768. echo "config-host.h: subdir-dtc" >> $config_host_mak
  5769. fi
  5770. if test "$numa" = "yes"; then
  5771. echo "CONFIG_NUMA=y" >> $config_host_mak
  5772. fi
  5773. if test "$ccache_cpp2" = "yes"; then
  5774. echo "export CCACHE_CPP2=y" >> $config_host_mak
  5775. fi
  5776. # build tree in object directory in case the source is not in the current directory
  5777. DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
  5778. DIRS="$DIRS docs fsdev"
  5779. DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
  5780. DIRS="$DIRS roms/seabios roms/vgabios"
  5781. DIRS="$DIRS qapi-generated"
  5782. FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
  5783. FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
  5784. FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
  5785. FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
  5786. FILES="$FILES pc-bios/spapr-rtas/Makefile"
  5787. FILES="$FILES pc-bios/s390-ccw/Makefile"
  5788. FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
  5789. FILES="$FILES pc-bios/qemu-icon.bmp"
  5790. for bios_file in \
  5791. $source_path/pc-bios/*.bin \
  5792. $source_path/pc-bios/*.lid \
  5793. $source_path/pc-bios/*.aml \
  5794. $source_path/pc-bios/*.rom \
  5795. $source_path/pc-bios/*.dtb \
  5796. $source_path/pc-bios/*.img \
  5797. $source_path/pc-bios/openbios-* \
  5798. $source_path/pc-bios/u-boot.* \
  5799. $source_path/pc-bios/palcode-*
  5800. do
  5801. FILES="$FILES pc-bios/$(basename $bios_file)"
  5802. done
  5803. for test_file in $(find $source_path/tests/acpi-test-data -type f)
  5804. do
  5805. FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
  5806. done
  5807. mkdir -p $DIRS
  5808. for f in $FILES ; do
  5809. if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
  5810. symlink "$source_path/$f" "$f"
  5811. fi
  5812. done
  5813. # temporary config to build submodules
  5814. for rom in seabios vgabios ; do
  5815. config_mak=roms/$rom/config.mak
  5816. echo "# Automatically generated by configure - do not modify" > $config_mak
  5817. echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
  5818. echo "AS=$as" >> $config_mak
  5819. echo "CCAS=$ccas" >> $config_mak
  5820. echo "CC=$cc" >> $config_mak
  5821. echo "BCC=bcc" >> $config_mak
  5822. echo "CPP=$cpp" >> $config_mak
  5823. echo "OBJCOPY=objcopy" >> $config_mak
  5824. echo "IASL=$iasl" >> $config_mak
  5825. echo "LD=$ld" >> $config_mak
  5826. done
  5827. # set up tests data directory
  5828. if [ ! -e tests/data ]; then
  5829. symlink "$source_path/tests/data" tests/data
  5830. fi
  5831. # set up qemu-iotests in this build directory
  5832. iotests_common_env="tests/qemu-iotests/common.env"
  5833. iotests_check="tests/qemu-iotests/check"
  5834. echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
  5835. echo >> "$iotests_common_env"
  5836. echo "export PYTHON='$python'" >> "$iotests_common_env"
  5837. if [ ! -e "$iotests_check" ]; then
  5838. symlink "$source_path/$iotests_check" "$iotests_check"
  5839. fi
  5840. # Save the configure command line for later reuse.
  5841. cat <<EOD >config.status
  5842. #!/bin/sh
  5843. # Generated by configure.
  5844. # Run this file to recreate the current configuration.
  5845. # Compiler output produced by configure, useful for debugging
  5846. # configure, is in config.log if it exists.
  5847. EOD
  5848. printf "exec" >>config.status
  5849. printf " '%s'" "$0" "$@" >>config.status
  5850. echo ' "$@"' >>config.status
  5851. chmod +x config.status
  5852. rm -r "$TMPDIR1"