meson.build 135 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771
  1. project('qemu', ['c'], meson_version: '>=0.59.3',
  2. default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto',
  3. 'b_staticpic=false', 'stdsplit=false'],
  4. version: files('VERSION'))
  5. add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true)
  6. add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow'])
  7. add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
  8. not_found = dependency('', required: false)
  9. keyval = import('keyval')
  10. ss = import('sourceset')
  11. fs = import('fs')
  12. sh = find_program('sh')
  13. cc = meson.get_compiler('c')
  14. config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
  15. enable_modules = 'CONFIG_MODULES' in config_host
  16. enable_static = 'CONFIG_STATIC' in config_host
  17. # Allow both shared and static libraries unless --enable-static
  18. static_kwargs = enable_static ? {'static': true} : {}
  19. # Temporary directory used for files created while
  20. # configure runs. Since it is in the build directory
  21. # we can safely blow away any previous version of it
  22. # (and we need not jump through hoops to try to delete
  23. # it when configure exits.)
  24. tmpdir = meson.current_build_dir() / 'meson-private/temp'
  25. if get_option('qemu_suffix').startswith('/')
  26. error('qemu_suffix cannot start with a /')
  27. endif
  28. qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
  29. qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
  30. qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
  31. qemu_moddir = get_option('libdir') / get_option('qemu_suffix')
  32. qemu_desktopdir = get_option('datadir') / 'applications'
  33. qemu_icondir = get_option('datadir') / 'icons'
  34. config_host_data = configuration_data()
  35. genh = []
  36. qapi_trace_events = []
  37. bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
  38. supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
  39. supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv', 'x86', 'x86_64',
  40. 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc', 'sparc64']
  41. cpu = host_machine.cpu_family()
  42. # Unify riscv* to a single family.
  43. if cpu in ['riscv32', 'riscv64']
  44. cpu = 'riscv'
  45. endif
  46. targetos = host_machine.system()
  47. target_dirs = config_host['TARGET_DIRS'].split()
  48. have_linux_user = false
  49. have_bsd_user = false
  50. have_system = false
  51. foreach target : target_dirs
  52. have_linux_user = have_linux_user or target.endswith('linux-user')
  53. have_bsd_user = have_bsd_user or target.endswith('bsd-user')
  54. have_system = have_system or target.endswith('-softmmu')
  55. endforeach
  56. have_user = have_linux_user or have_bsd_user
  57. have_tools = get_option('tools') \
  58. .disable_auto_if(not have_system) \
  59. .allowed()
  60. have_ga = get_option('guest_agent') \
  61. .disable_auto_if(not have_system and not have_tools) \
  62. .require(targetos in ['sunos', 'linux', 'windows'],
  63. error_message: 'unsupported OS for QEMU guest agent') \
  64. .allowed()
  65. have_block = have_system or have_tools
  66. python = import('python').find_installation()
  67. if cpu not in supported_cpus
  68. host_arch = 'unknown'
  69. elif cpu == 'x86'
  70. host_arch = 'i386'
  71. elif cpu == 'mips64'
  72. host_arch = 'mips'
  73. else
  74. host_arch = cpu
  75. endif
  76. if cpu in ['x86', 'x86_64']
  77. kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
  78. elif cpu == 'aarch64'
  79. kvm_targets = ['aarch64-softmmu']
  80. elif cpu == 's390x'
  81. kvm_targets = ['s390x-softmmu']
  82. elif cpu in ['ppc', 'ppc64']
  83. kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
  84. elif cpu in ['mips', 'mips64']
  85. kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
  86. elif cpu in ['riscv']
  87. kvm_targets = ['riscv32-softmmu', 'riscv64-softmmu']
  88. else
  89. kvm_targets = []
  90. endif
  91. kvm_targets_c = '""'
  92. if get_option('kvm').allowed() and targetos == 'linux'
  93. kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
  94. endif
  95. config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
  96. accelerator_targets = { 'CONFIG_KVM': kvm_targets }
  97. if cpu in ['aarch64']
  98. accelerator_targets += {
  99. 'CONFIG_HVF': ['aarch64-softmmu']
  100. }
  101. endif
  102. if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
  103. # i386 emulator provides xenpv machine type for multiple architectures
  104. accelerator_targets += {
  105. 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
  106. }
  107. endif
  108. if cpu in ['x86', 'x86_64']
  109. accelerator_targets += {
  110. 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
  111. 'CONFIG_HVF': ['x86_64-softmmu'],
  112. 'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'],
  113. 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
  114. }
  115. endif
  116. modular_tcg = []
  117. # Darwin does not support references to thread-local variables in modules
  118. if targetos != 'darwin'
  119. modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
  120. endif
  121. edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
  122. unpack_edk2_blobs = false
  123. foreach target : edk2_targets
  124. if target in target_dirs
  125. bzip2 = find_program('bzip2', required: get_option('install_blobs'))
  126. unpack_edk2_blobs = bzip2.found()
  127. break
  128. endif
  129. endforeach
  130. dtrace = not_found
  131. stap = not_found
  132. if 'dtrace' in get_option('trace_backends')
  133. dtrace = find_program('dtrace', required: true)
  134. stap = find_program('stap', required: false)
  135. if stap.found()
  136. # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
  137. # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
  138. # instead. QEMU --enable-modules depends on this because the SystemTap
  139. # semaphores are linked into the main binary and not the module's shared
  140. # object.
  141. add_global_arguments('-DSTAP_SDT_V2',
  142. native: false, language: ['c', 'cpp', 'objc'])
  143. endif
  144. endif
  145. ##################
  146. # Compiler flags #
  147. ##################
  148. qemu_cflags = config_host['QEMU_CFLAGS'].split()
  149. qemu_cxxflags = config_host['QEMU_CXXFLAGS'].split()
  150. qemu_objcflags = config_host['QEMU_OBJCFLAGS'].split()
  151. qemu_ldflags = config_host['QEMU_LDFLAGS'].split()
  152. if get_option('gprof')
  153. qemu_cflags += ['-p']
  154. qemu_cxxflags += ['-p']
  155. qemu_objcflags += ['-p']
  156. qemu_ldflags += ['-p']
  157. endif
  158. # Specify linker-script with add_project_link_arguments so that it is not placed
  159. # within a linker --start-group/--end-group pair
  160. if get_option('fuzzing')
  161. add_project_link_arguments(['-Wl,-T,',
  162. (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')],
  163. native: false, language: ['c', 'cpp', 'objc'])
  164. # Specify a filter to only instrument code that is directly related to
  165. # virtual-devices.
  166. configure_file(output: 'instrumentation-filter',
  167. input: 'scripts/oss-fuzz/instrumentation-filter-template',
  168. copy: true)
  169. add_global_arguments(
  170. cc.get_supported_arguments('-fsanitize-coverage-allowlist=instrumentation-filter'),
  171. native: false, language: ['c', 'cpp', 'objc'])
  172. if get_option('fuzzing_engine') == ''
  173. # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
  174. # compiled code. To build non-fuzzer binaries with --enable-fuzzing, link
  175. # everything with fsanitize=fuzzer-no-link. Otherwise, the linker will be
  176. # unable to bind the fuzzer-related callbacks added by instrumentation.
  177. add_global_arguments('-fsanitize=fuzzer-no-link',
  178. native: false, language: ['c', 'cpp', 'objc'])
  179. add_global_link_arguments('-fsanitize=fuzzer-no-link',
  180. native: false, language: ['c', 'cpp', 'objc'])
  181. # For the actual fuzzer binaries, we need to link against the libfuzzer
  182. # library. They need to be configurable, to support OSS-Fuzz
  183. fuzz_exe_ldflags = ['-fsanitize=fuzzer']
  184. else
  185. # LIB_FUZZING_ENGINE was set; assume we are running on OSS-Fuzz, and
  186. # the needed CFLAGS have already been provided
  187. fuzz_exe_ldflags = get_option('fuzzing_engine').split()
  188. endif
  189. endif
  190. add_global_arguments(qemu_cflags, native: false, language: ['c'])
  191. add_global_arguments(qemu_cxxflags, native: false, language: ['cpp'])
  192. add_global_arguments(qemu_objcflags, native: false, language: ['objc'])
  193. add_global_link_arguments(qemu_ldflags, native: false, language: ['c', 'cpp', 'objc'])
  194. if targetos == 'linux'
  195. add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
  196. '-isystem', 'linux-headers',
  197. language: ['c', 'cpp'])
  198. endif
  199. add_project_arguments('-iquote', '.',
  200. '-iquote', meson.current_source_dir(),
  201. '-iquote', meson.current_source_dir() / 'include',
  202. '-iquote', meson.current_source_dir() / 'disas/libvixl',
  203. language: ['c', 'cpp', 'objc'])
  204. link_language = meson.get_external_property('link_language', 'cpp')
  205. if link_language == 'cpp'
  206. add_languages('cpp', required: true, native: false)
  207. cxx = meson.get_compiler('cpp')
  208. linker = cxx
  209. else
  210. linker = cc
  211. endif
  212. if host_machine.system() == 'darwin'
  213. add_languages('objc', required: false, native: false)
  214. endif
  215. sparse = find_program('cgcc', required: get_option('sparse'))
  216. if sparse.found()
  217. run_target('sparse',
  218. command: [find_program('scripts/check_sparse.py'),
  219. 'compile_commands.json', sparse.full_path(), '-Wbitwise',
  220. '-Wno-transparent-union', '-Wno-old-initializer',
  221. '-Wno-non-pointer-null'])
  222. endif
  223. ###########################################
  224. # Target-specific checks and dependencies #
  225. ###########################################
  226. # Fuzzing
  227. if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
  228. not cc.links('''
  229. #include <stdint.h>
  230. #include <sys/types.h>
  231. int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
  232. int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
  233. ''',
  234. args: ['-Werror', '-fsanitize=fuzzer'])
  235. error('Your compiler does not support -fsanitize=fuzzer')
  236. endif
  237. # Tracing backends
  238. if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
  239. error('ftrace is supported only on Linux')
  240. endif
  241. if 'syslog' in get_option('trace_backends') and not cc.compiles('''
  242. #include <syslog.h>
  243. int main(void) {
  244. openlog("qemu", LOG_PID, LOG_DAEMON);
  245. syslog(LOG_INFO, "configure");
  246. return 0;
  247. }''')
  248. error('syslog is not supported on this system')
  249. endif
  250. # Miscellaneous Linux-only features
  251. get_option('mpath') \
  252. .require(targetos == 'linux', error_message: 'Multipath is supported only on Linux')
  253. multiprocess_allowed = get_option('multiprocess') \
  254. .require(targetos == 'linux', error_message: 'Multiprocess QEMU is supported only on Linux') \
  255. .allowed()
  256. have_tpm = get_option('tpm') \
  257. .require(targetos != 'windows', error_message: 'TPM emulation only available on POSIX systems') \
  258. .allowed()
  259. # Target-specific libraries and flags
  260. libm = cc.find_library('m', required: false)
  261. threads = dependency('threads')
  262. util = cc.find_library('util', required: false)
  263. winmm = []
  264. socket = []
  265. version_res = []
  266. coref = []
  267. iokit = []
  268. emulator_link_args = []
  269. nvmm =not_found
  270. hvf = not_found
  271. midl = not_found
  272. widl = not_found
  273. host_dsosuf = '.so'
  274. if targetos == 'windows'
  275. midl = find_program('midl', required: false)
  276. widl = find_program('widl', required: false)
  277. socket = cc.find_library('ws2_32')
  278. winmm = cc.find_library('winmm')
  279. win = import('windows')
  280. version_res = win.compile_resources('version.rc',
  281. depend_files: files('pc-bios/qemu-nsis.ico'),
  282. include_directories: include_directories('.'))
  283. host_dsosuf = '.dll'
  284. elif targetos == 'darwin'
  285. coref = dependency('appleframeworks', modules: 'CoreFoundation')
  286. iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
  287. host_dsosuf = '.dylib'
  288. elif targetos == 'sunos'
  289. socket = [cc.find_library('socket'),
  290. cc.find_library('nsl'),
  291. cc.find_library('resolv')]
  292. elif targetos == 'haiku'
  293. socket = [cc.find_library('posix_error_mapper'),
  294. cc.find_library('network'),
  295. cc.find_library('bsd')]
  296. elif targetos == 'openbsd'
  297. if get_option('tcg').allowed() and target_dirs.length() > 0
  298. # Disable OpenBSD W^X if available
  299. emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
  300. endif
  301. endif
  302. # Target-specific configuration of accelerators
  303. accelerators = []
  304. if get_option('kvm').allowed() and targetos == 'linux'
  305. accelerators += 'CONFIG_KVM'
  306. endif
  307. if get_option('xen').allowed() and 'CONFIG_XEN_BACKEND' in config_host
  308. accelerators += 'CONFIG_XEN'
  309. have_xen_pci_passthrough = get_option('xen_pci_passthrough').allowed() and targetos == 'linux'
  310. else
  311. have_xen_pci_passthrough = false
  312. endif
  313. if get_option('whpx').allowed() and targetos == 'windows'
  314. if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
  315. error('WHPX requires 64-bit host')
  316. elif cc.has_header('WinHvPlatform.h', required: get_option('whpx')) and \
  317. cc.has_header('WinHvEmulation.h', required: get_option('whpx'))
  318. accelerators += 'CONFIG_WHPX'
  319. endif
  320. endif
  321. if get_option('hvf').allowed()
  322. hvf = dependency('appleframeworks', modules: 'Hypervisor',
  323. required: get_option('hvf'))
  324. if hvf.found()
  325. accelerators += 'CONFIG_HVF'
  326. endif
  327. endif
  328. if get_option('hax').allowed()
  329. if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
  330. accelerators += 'CONFIG_HAX'
  331. endif
  332. endif
  333. if targetos == 'netbsd'
  334. nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
  335. if nvmm.found()
  336. accelerators += 'CONFIG_NVMM'
  337. endif
  338. endif
  339. tcg_arch = host_arch
  340. if get_option('tcg').allowed()
  341. if host_arch == 'unknown'
  342. if get_option('tcg_interpreter')
  343. warning('Unsupported CPU @0@, will use TCG with TCI (slow)'.format(cpu))
  344. else
  345. error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
  346. endif
  347. elif get_option('tcg_interpreter')
  348. warning('Use of the TCG interpreter is not recommended on this host')
  349. warning('architecture. There is a native TCG execution backend available')
  350. warning('which provides substantially better performance and reliability.')
  351. warning('It is strongly recommended to remove the --enable-tcg-interpreter')
  352. warning('configuration option on this architecture to use the native')
  353. warning('backend.')
  354. endif
  355. if get_option('tcg_interpreter')
  356. tcg_arch = 'tci'
  357. elif host_arch == 'sparc64'
  358. tcg_arch = 'sparc'
  359. elif host_arch == 'x86_64'
  360. tcg_arch = 'i386'
  361. elif host_arch == 'ppc64'
  362. tcg_arch = 'ppc'
  363. endif
  364. add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
  365. language: ['c', 'cpp', 'objc'])
  366. accelerators += 'CONFIG_TCG'
  367. config_host += { 'CONFIG_TCG': 'y' }
  368. endif
  369. if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
  370. error('KVM not available on this platform')
  371. endif
  372. if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
  373. error('HVF not available on this platform')
  374. endif
  375. if 'CONFIG_NVMM' not in accelerators and get_option('nvmm').enabled()
  376. error('NVMM not available on this platform')
  377. endif
  378. if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
  379. error('WHPX not available on this platform')
  380. endif
  381. if not have_xen_pci_passthrough and get_option('xen_pci_passthrough').enabled()
  382. if 'CONFIG_XEN' in accelerators
  383. error('Xen PCI passthrough not available on this platform')
  384. else
  385. error('Xen PCI passthrough requested but Xen not enabled')
  386. endif
  387. endif
  388. ################
  389. # Dependencies #
  390. ################
  391. # The path to glib.h is added to all compilation commands. This was
  392. # grandfathered in from the QEMU Makefiles.
  393. add_project_arguments(config_host['GLIB_CFLAGS'].split(),
  394. native: false, language: ['c', 'cpp', 'objc'])
  395. glib = declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split(),
  396. link_args: config_host['GLIB_LIBS'].split(),
  397. version: config_host['GLIB_VERSION'])
  398. # override glib dep with the configure results (for subprojects)
  399. meson.override_dependency('glib-2.0', glib)
  400. gio = not_found
  401. if 'CONFIG_GIO' in config_host
  402. gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
  403. link_args: config_host['GIO_LIBS'].split(),
  404. version: config_host['GLIB_VERSION'])
  405. endif
  406. lttng = not_found
  407. if 'ust' in get_option('trace_backends')
  408. lttng = dependency('lttng-ust', required: true, version: '>= 2.1',
  409. method: 'pkg-config', kwargs: static_kwargs)
  410. endif
  411. pixman = not_found
  412. if have_system or have_tools
  413. pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
  414. method: 'pkg-config', kwargs: static_kwargs)
  415. endif
  416. zlib = dependency('zlib', required: true, kwargs: static_kwargs)
  417. libaio = not_found
  418. if not get_option('linux_aio').auto() or have_block
  419. libaio = cc.find_library('aio', has_headers: ['libaio.h'],
  420. required: get_option('linux_aio'),
  421. kwargs: static_kwargs)
  422. endif
  423. linux_io_uring = not_found
  424. if not get_option('linux_io_uring').auto() or have_block
  425. linux_io_uring = dependency('liburing', version: '>=0.3',
  426. required: get_option('linux_io_uring'),
  427. method: 'pkg-config', kwargs: static_kwargs)
  428. endif
  429. libnfs = not_found
  430. if not get_option('libnfs').auto() or have_block
  431. libnfs = dependency('libnfs', version: '>=1.9.3',
  432. required: get_option('libnfs'),
  433. method: 'pkg-config', kwargs: static_kwargs)
  434. endif
  435. libattr_test = '''
  436. #include <stddef.h>
  437. #include <sys/types.h>
  438. #ifdef CONFIG_LIBATTR
  439. #include <attr/xattr.h>
  440. #else
  441. #include <sys/xattr.h>
  442. #endif
  443. int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }'''
  444. libattr = not_found
  445. have_old_libattr = false
  446. if get_option('attr').allowed()
  447. if cc.links(libattr_test)
  448. libattr = declare_dependency()
  449. else
  450. libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'],
  451. required: get_option('attr'),
  452. kwargs: static_kwargs)
  453. if libattr.found() and not \
  454. cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR')
  455. libattr = not_found
  456. if get_option('attr').enabled()
  457. error('could not link libattr')
  458. else
  459. warning('could not link libattr, disabling')
  460. endif
  461. else
  462. have_old_libattr = libattr.found()
  463. endif
  464. endif
  465. endif
  466. cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa'))
  467. if cocoa.found() and get_option('sdl').enabled()
  468. error('Cocoa and SDL cannot be enabled at the same time')
  469. endif
  470. if cocoa.found() and get_option('gtk').enabled()
  471. error('Cocoa and GTK+ cannot be enabled at the same time')
  472. endif
  473. seccomp = not_found
  474. if not get_option('seccomp').auto() or have_system or have_tools
  475. seccomp = dependency('libseccomp', version: '>=2.3.0',
  476. required: get_option('seccomp'),
  477. method: 'pkg-config', kwargs: static_kwargs)
  478. endif
  479. libcap_ng = not_found
  480. if not get_option('cap_ng').auto() or have_system or have_tools
  481. libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'],
  482. required: get_option('cap_ng'),
  483. kwargs: static_kwargs)
  484. endif
  485. if libcap_ng.found() and not cc.links('''
  486. #include <cap-ng.h>
  487. int main(void)
  488. {
  489. capng_capability_to_name(CAPNG_EFFECTIVE);
  490. return 0;
  491. }''', dependencies: libcap_ng)
  492. libcap_ng = not_found
  493. if get_option('cap_ng').enabled()
  494. error('could not link libcap-ng')
  495. else
  496. warning('could not link libcap-ng, disabling')
  497. endif
  498. endif
  499. if get_option('xkbcommon').auto() and not have_system and not have_tools
  500. xkbcommon = not_found
  501. else
  502. xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
  503. method: 'pkg-config', kwargs: static_kwargs)
  504. endif
  505. vde = not_found
  506. if not get_option('vde').auto() or have_system or have_tools
  507. vde = cc.find_library('vdeplug', has_headers: ['libvdeplug.h'],
  508. required: get_option('vde'),
  509. kwargs: static_kwargs)
  510. endif
  511. if vde.found() and not cc.links('''
  512. #include <libvdeplug.h>
  513. int main(void)
  514. {
  515. struct vde_open_args a = {0, 0, 0};
  516. char s[] = "";
  517. vde_open(s, s, &a);
  518. return 0;
  519. }''', dependencies: vde)
  520. vde = not_found
  521. if get_option('cap_ng').enabled()
  522. error('could not link libvdeplug')
  523. else
  524. warning('could not link libvdeplug, disabling')
  525. endif
  526. endif
  527. pulse = not_found
  528. if not get_option('pa').auto() or (targetos == 'linux' and have_system)
  529. pulse = dependency('libpulse', required: get_option('pa'),
  530. method: 'pkg-config', kwargs: static_kwargs)
  531. endif
  532. alsa = not_found
  533. if not get_option('alsa').auto() or (targetos == 'linux' and have_system)
  534. alsa = dependency('alsa', required: get_option('alsa'),
  535. method: 'pkg-config', kwargs: static_kwargs)
  536. endif
  537. jack = not_found
  538. if not get_option('jack').auto() or have_system
  539. jack = dependency('jack', required: get_option('jack'),
  540. method: 'pkg-config', kwargs: static_kwargs)
  541. endif
  542. spice_protocol = not_found
  543. if not get_option('spice_protocol').auto() or have_system
  544. spice_protocol = dependency('spice-protocol', version: '>=0.12.3',
  545. required: get_option('spice_protocol'),
  546. method: 'pkg-config', kwargs: static_kwargs)
  547. endif
  548. spice = not_found
  549. if not get_option('spice').auto() or have_system
  550. spice = dependency('spice-server', version: '>=0.12.5',
  551. required: get_option('spice'),
  552. method: 'pkg-config', kwargs: static_kwargs)
  553. endif
  554. spice_headers = spice.partial_dependency(compile_args: true, includes: true)
  555. rt = cc.find_library('rt', required: false)
  556. libiscsi = not_found
  557. if not get_option('libiscsi').auto() or have_block
  558. libiscsi = dependency('libiscsi', version: '>=1.9.0',
  559. required: get_option('libiscsi'),
  560. method: 'pkg-config', kwargs: static_kwargs)
  561. endif
  562. zstd = not_found
  563. if not get_option('zstd').auto() or have_block
  564. zstd = dependency('libzstd', version: '>=1.4.0',
  565. required: get_option('zstd'),
  566. method: 'pkg-config', kwargs: static_kwargs)
  567. endif
  568. virgl = not_found
  569. have_vhost_user_gpu = have_tools and targetos == 'linux' and pixman.found()
  570. if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu
  571. virgl = dependency('virglrenderer',
  572. method: 'pkg-config',
  573. required: get_option('virglrenderer'),
  574. kwargs: static_kwargs)
  575. endif
  576. curl = not_found
  577. if not get_option('curl').auto() or have_block
  578. curl = dependency('libcurl', version: '>=7.29.0',
  579. method: 'pkg-config',
  580. required: get_option('curl'),
  581. kwargs: static_kwargs)
  582. endif
  583. libudev = not_found
  584. if targetos == 'linux' and (have_system or have_tools)
  585. libudev = dependency('libudev',
  586. method: 'pkg-config',
  587. required: get_option('libudev'),
  588. kwargs: static_kwargs)
  589. endif
  590. mpathlibs = [libudev]
  591. mpathpersist = not_found
  592. mpathpersist_new_api = false
  593. if targetos == 'linux' and have_tools and get_option('mpath').allowed()
  594. mpath_test_source_new = '''
  595. #include <libudev.h>
  596. #include <mpath_persist.h>
  597. unsigned mpath_mx_alloc_len = 1024;
  598. int logsink;
  599. static struct config *multipath_conf;
  600. extern struct udev *udev;
  601. extern struct config *get_multipath_config(void);
  602. extern void put_multipath_config(struct config *conf);
  603. struct udev *udev;
  604. struct config *get_multipath_config(void) { return multipath_conf; }
  605. void put_multipath_config(struct config *conf) { }
  606. int main(void) {
  607. udev = udev_new();
  608. multipath_conf = mpath_lib_init();
  609. return 0;
  610. }'''
  611. mpath_test_source_old = '''
  612. #include <libudev.h>
  613. #include <mpath_persist.h>
  614. unsigned mpath_mx_alloc_len = 1024;
  615. int logsink;
  616. int main(void) {
  617. struct udev *udev = udev_new();
  618. mpath_lib_init(udev);
  619. return 0;
  620. }'''
  621. libmpathpersist = cc.find_library('mpathpersist',
  622. required: get_option('mpath'),
  623. kwargs: static_kwargs)
  624. if libmpathpersist.found()
  625. mpathlibs += libmpathpersist
  626. if enable_static
  627. mpathlibs += cc.find_library('devmapper',
  628. required: get_option('mpath'),
  629. kwargs: static_kwargs)
  630. endif
  631. mpathlibs += cc.find_library('multipath',
  632. required: get_option('mpath'),
  633. kwargs: static_kwargs)
  634. foreach lib: mpathlibs
  635. if not lib.found()
  636. mpathlibs = []
  637. break
  638. endif
  639. endforeach
  640. if mpathlibs.length() == 0
  641. msg = 'Dependencies missing for libmpathpersist'
  642. elif cc.links(mpath_test_source_new, dependencies: mpathlibs)
  643. mpathpersist = declare_dependency(dependencies: mpathlibs)
  644. mpathpersist_new_api = true
  645. elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
  646. mpathpersist = declare_dependency(dependencies: mpathlibs)
  647. else
  648. msg = 'Cannot detect libmpathpersist API'
  649. endif
  650. if not mpathpersist.found()
  651. if get_option('mpath').enabled()
  652. error(msg)
  653. else
  654. warning(msg + ', disabling')
  655. endif
  656. endif
  657. endif
  658. endif
  659. iconv = not_found
  660. curses = not_found
  661. if have_system and get_option('curses').allowed()
  662. curses_test = '''
  663. #if defined(__APPLE__) || defined(__OpenBSD__)
  664. #define _XOPEN_SOURCE_EXTENDED 1
  665. #endif
  666. #include <locale.h>
  667. #include <curses.h>
  668. #include <wchar.h>
  669. int main(void) {
  670. wchar_t wch = L'w';
  671. setlocale(LC_ALL, "");
  672. resize_term(0, 0);
  673. addwstr(L"wide chars\n");
  674. addnwstr(&wch, 1);
  675. add_wch(WACS_DEGREE);
  676. return 0;
  677. }'''
  678. curses_dep_list = targetos == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
  679. foreach curses_dep : curses_dep_list
  680. if not curses.found()
  681. curses = dependency(curses_dep,
  682. required: false,
  683. method: 'pkg-config',
  684. kwargs: static_kwargs)
  685. endif
  686. endforeach
  687. msg = get_option('curses').enabled() ? 'curses library not found' : ''
  688. curses_compile_args = ['-DNCURSES_WIDECHAR=1']
  689. if curses.found()
  690. if cc.links(curses_test, args: curses_compile_args, dependencies: [curses])
  691. curses = declare_dependency(compile_args: curses_compile_args, dependencies: [curses])
  692. else
  693. msg = 'curses package not usable'
  694. curses = not_found
  695. endif
  696. endif
  697. if not curses.found()
  698. has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
  699. if targetos != 'windows' and not has_curses_h
  700. message('Trying with /usr/include/ncursesw')
  701. curses_compile_args += ['-I/usr/include/ncursesw']
  702. has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
  703. endif
  704. if has_curses_h
  705. curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
  706. foreach curses_libname : curses_libname_list
  707. libcurses = cc.find_library(curses_libname,
  708. required: false,
  709. kwargs: static_kwargs)
  710. if libcurses.found()
  711. if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
  712. curses = declare_dependency(compile_args: curses_compile_args,
  713. dependencies: [libcurses])
  714. break
  715. else
  716. msg = 'curses library not usable'
  717. endif
  718. endif
  719. endforeach
  720. endif
  721. endif
  722. if get_option('iconv').allowed()
  723. foreach link_args : [ ['-liconv'], [] ]
  724. # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
  725. # We need to use libiconv if available because mixing libiconv's headers with
  726. # the system libc does not work.
  727. # However, without adding glib to the dependencies -L/usr/local/lib will not be
  728. # included in the command line and libiconv will not be found.
  729. if cc.links('''
  730. #include <iconv.h>
  731. int main(void) {
  732. iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
  733. return conv != (iconv_t) -1;
  734. }''', args: config_host['GLIB_CFLAGS'].split() + config_host['GLIB_LIBS'].split() + link_args)
  735. iconv = declare_dependency(link_args: link_args, dependencies: glib)
  736. break
  737. endif
  738. endforeach
  739. endif
  740. if curses.found() and not iconv.found()
  741. if get_option('iconv').enabled()
  742. error('iconv not available')
  743. endif
  744. msg = 'iconv required for curses UI but not available'
  745. curses = not_found
  746. endif
  747. if not curses.found() and msg != ''
  748. if get_option('curses').enabled()
  749. error(msg)
  750. else
  751. warning(msg + ', disabling')
  752. endif
  753. endif
  754. endif
  755. brlapi = not_found
  756. if not get_option('brlapi').auto() or have_system
  757. brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'],
  758. required: get_option('brlapi'),
  759. kwargs: static_kwargs)
  760. if brlapi.found() and not cc.links('''
  761. #include <brlapi.h>
  762. #include <stddef.h>
  763. int main(void) { return brlapi__openConnection (NULL, NULL, NULL); }''', dependencies: brlapi)
  764. brlapi = not_found
  765. if get_option('brlapi').enabled()
  766. error('could not link brlapi')
  767. else
  768. warning('could not link brlapi, disabling')
  769. endif
  770. endif
  771. endif
  772. sdl = not_found
  773. if not get_option('sdl').auto() or (have_system and not cocoa.found())
  774. sdl = dependency('sdl2', required: get_option('sdl'), kwargs: static_kwargs)
  775. sdl_image = not_found
  776. endif
  777. if sdl.found()
  778. # work around 2.0.8 bug
  779. sdl = declare_dependency(compile_args: '-Wno-undef',
  780. dependencies: sdl)
  781. sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
  782. method: 'pkg-config', kwargs: static_kwargs)
  783. else
  784. if get_option('sdl_image').enabled()
  785. error('sdl-image required, but SDL was @0@'.format(
  786. get_option('sdl').disabled() ? 'disabled' : 'not found'))
  787. endif
  788. sdl_image = not_found
  789. endif
  790. rbd = not_found
  791. if not get_option('rbd').auto() or have_block
  792. librados = cc.find_library('rados', required: get_option('rbd'),
  793. kwargs: static_kwargs)
  794. librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
  795. required: get_option('rbd'),
  796. kwargs: static_kwargs)
  797. if librados.found() and librbd.found()
  798. if cc.links('''
  799. #include <stdio.h>
  800. #include <rbd/librbd.h>
  801. int main(void) {
  802. rados_t cluster;
  803. rados_create(&cluster, NULL);
  804. #if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 12, 0)
  805. #error
  806. #endif
  807. return 0;
  808. }''', dependencies: [librbd, librados])
  809. rbd = declare_dependency(dependencies: [librbd, librados])
  810. elif get_option('rbd').enabled()
  811. error('librbd >= 1.12.0 required')
  812. else
  813. warning('librbd >= 1.12.0 not found, disabling')
  814. endif
  815. endif
  816. endif
  817. glusterfs = not_found
  818. glusterfs_ftruncate_has_stat = false
  819. glusterfs_iocb_has_stat = false
  820. if not get_option('glusterfs').auto() or have_block
  821. glusterfs = dependency('glusterfs-api', version: '>=3',
  822. required: get_option('glusterfs'),
  823. method: 'pkg-config', kwargs: static_kwargs)
  824. if glusterfs.found()
  825. glusterfs_ftruncate_has_stat = cc.links('''
  826. #include <glusterfs/api/glfs.h>
  827. int
  828. main(void)
  829. {
  830. /* new glfs_ftruncate() passes two additional args */
  831. return glfs_ftruncate(NULL, 0, NULL, NULL);
  832. }
  833. ''', dependencies: glusterfs)
  834. glusterfs_iocb_has_stat = cc.links('''
  835. #include <glusterfs/api/glfs.h>
  836. /* new glfs_io_cbk() passes two additional glfs_stat structs */
  837. static void
  838. glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
  839. {}
  840. int
  841. main(void)
  842. {
  843. glfs_io_cbk iocb = &glusterfs_iocb;
  844. iocb(NULL, 0 , NULL, NULL, NULL);
  845. return 0;
  846. }
  847. ''', dependencies: glusterfs)
  848. endif
  849. endif
  850. libssh = not_found
  851. if not get_option('libssh').auto() or have_block
  852. libssh = dependency('libssh', version: '>=0.8.7',
  853. method: 'pkg-config',
  854. required: get_option('libssh'),
  855. kwargs: static_kwargs)
  856. endif
  857. libbzip2 = not_found
  858. if not get_option('bzip2').auto() or have_block
  859. libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
  860. required: get_option('bzip2'),
  861. kwargs: static_kwargs)
  862. if libbzip2.found() and not cc.links('''
  863. #include <bzlib.h>
  864. int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2)
  865. libbzip2 = not_found
  866. if get_option('bzip2').enabled()
  867. error('could not link libbzip2')
  868. else
  869. warning('could not link libbzip2, disabling')
  870. endif
  871. endif
  872. endif
  873. liblzfse = not_found
  874. if not get_option('lzfse').auto() or have_block
  875. liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'],
  876. required: get_option('lzfse'),
  877. kwargs: static_kwargs)
  878. endif
  879. if liblzfse.found() and not cc.links('''
  880. #include <lzfse.h>
  881. int main(void) { lzfse_decode_scratch_size(); return 0; }''', dependencies: liblzfse)
  882. liblzfse = not_found
  883. if get_option('lzfse').enabled()
  884. error('could not link liblzfse')
  885. else
  886. warning('could not link liblzfse, disabling')
  887. endif
  888. endif
  889. oss = not_found
  890. if get_option('oss').allowed() and have_system
  891. if not cc.has_header('sys/soundcard.h')
  892. # not found
  893. elif targetos == 'netbsd'
  894. oss = cc.find_library('ossaudio', required: get_option('oss'),
  895. kwargs: static_kwargs)
  896. else
  897. oss = declare_dependency()
  898. endif
  899. if not oss.found()
  900. if get_option('oss').enabled()
  901. error('OSS not found')
  902. endif
  903. endif
  904. endif
  905. dsound = not_found
  906. if not get_option('dsound').auto() or (targetos == 'windows' and have_system)
  907. if cc.has_header('dsound.h')
  908. dsound = declare_dependency(link_args: ['-lole32', '-ldxguid'])
  909. endif
  910. if not dsound.found()
  911. if get_option('dsound').enabled()
  912. error('DirectSound not found')
  913. endif
  914. endif
  915. endif
  916. coreaudio = not_found
  917. if not get_option('coreaudio').auto() or (targetos == 'darwin' and have_system)
  918. coreaudio = dependency('appleframeworks', modules: 'CoreAudio',
  919. required: get_option('coreaudio'))
  920. endif
  921. opengl = not_found
  922. if 'CONFIG_OPENGL' in config_host
  923. opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
  924. link_args: config_host['OPENGL_LIBS'].split())
  925. endif
  926. gbm = not_found
  927. if (have_system or have_tools) and (virgl.found() or opengl.found())
  928. gbm = dependency('gbm', method: 'pkg-config', required: false,
  929. kwargs: static_kwargs)
  930. endif
  931. have_vhost_user_gpu = have_vhost_user_gpu and virgl.found() and gbm.found()
  932. gnutls = not_found
  933. gnutls_crypto = not_found
  934. if get_option('gnutls').enabled() or (get_option('gnutls').auto() and have_system)
  935. # For general TLS support our min gnutls matches
  936. # that implied by our platform support matrix
  937. #
  938. # For the crypto backends, we look for a newer
  939. # gnutls:
  940. #
  941. # Version 3.6.8 is needed to get XTS
  942. # Version 3.6.13 is needed to get PBKDF
  943. # Version 3.6.14 is needed to get HW accelerated XTS
  944. #
  945. # If newer enough gnutls isn't available, we can
  946. # still use a different crypto backend to satisfy
  947. # the platform support requirements
  948. gnutls_crypto = dependency('gnutls', version: '>=3.6.14',
  949. method: 'pkg-config',
  950. required: false,
  951. kwargs: static_kwargs)
  952. if gnutls_crypto.found()
  953. gnutls = gnutls_crypto
  954. else
  955. # Our min version if all we need is TLS
  956. gnutls = dependency('gnutls', version: '>=3.5.18',
  957. method: 'pkg-config',
  958. required: get_option('gnutls'),
  959. kwargs: static_kwargs)
  960. endif
  961. endif
  962. # We prefer use of gnutls for crypto, unless the options
  963. # explicitly asked for nettle or gcrypt.
  964. #
  965. # If gnutls isn't available for crypto, then we'll prefer
  966. # gcrypt over nettle for performance reasons.
  967. gcrypt = not_found
  968. nettle = not_found
  969. xts = 'none'
  970. if get_option('nettle').enabled() and get_option('gcrypt').enabled()
  971. error('Only one of gcrypt & nettle can be enabled')
  972. endif
  973. # Explicit nettle/gcrypt request, so ignore gnutls for crypto
  974. if get_option('nettle').enabled() or get_option('gcrypt').enabled()
  975. gnutls_crypto = not_found
  976. endif
  977. if not gnutls_crypto.found()
  978. if (not get_option('gcrypt').auto() or have_system) and not get_option('nettle').enabled()
  979. gcrypt = dependency('libgcrypt', version: '>=1.8',
  980. method: 'config-tool',
  981. required: get_option('gcrypt'),
  982. kwargs: static_kwargs)
  983. # Debian has removed -lgpg-error from libgcrypt-config
  984. # as it "spreads unnecessary dependencies" which in
  985. # turn breaks static builds...
  986. if gcrypt.found() and enable_static
  987. gcrypt = declare_dependency(dependencies: [
  988. gcrypt,
  989. cc.find_library('gpg-error', required: true, kwargs: static_kwargs)])
  990. endif
  991. endif
  992. if (not get_option('nettle').auto() or have_system) and not gcrypt.found()
  993. nettle = dependency('nettle', version: '>=3.4',
  994. method: 'pkg-config',
  995. required: get_option('nettle'),
  996. kwargs: static_kwargs)
  997. if nettle.found() and not cc.has_header('nettle/xts.h', dependencies: nettle)
  998. xts = 'private'
  999. endif
  1000. endif
  1001. endif
  1002. gtk = not_found
  1003. gtkx11 = not_found
  1004. vte = not_found
  1005. if not get_option('gtk').auto() or (have_system and not cocoa.found())
  1006. gtk = dependency('gtk+-3.0', version: '>=3.22.0',
  1007. method: 'pkg-config',
  1008. required: get_option('gtk'),
  1009. kwargs: static_kwargs)
  1010. if gtk.found()
  1011. gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0',
  1012. method: 'pkg-config',
  1013. required: false,
  1014. kwargs: static_kwargs)
  1015. gtk = declare_dependency(dependencies: [gtk, gtkx11])
  1016. if not get_option('vte').auto() or have_system
  1017. vte = dependency('vte-2.91',
  1018. method: 'pkg-config',
  1019. required: get_option('vte'),
  1020. kwargs: static_kwargs)
  1021. endif
  1022. endif
  1023. endif
  1024. x11 = not_found
  1025. if gtkx11.found()
  1026. x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found(),
  1027. kwargs: static_kwargs)
  1028. endif
  1029. vnc = not_found
  1030. png = not_found
  1031. jpeg = not_found
  1032. sasl = not_found
  1033. if get_option('vnc').allowed() and have_system
  1034. vnc = declare_dependency() # dummy dependency
  1035. png = dependency('libpng', required: get_option('vnc_png'),
  1036. method: 'pkg-config', kwargs: static_kwargs)
  1037. jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'),
  1038. method: 'pkg-config', kwargs: static_kwargs)
  1039. sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
  1040. required: get_option('vnc_sasl'),
  1041. kwargs: static_kwargs)
  1042. if sasl.found()
  1043. sasl = declare_dependency(dependencies: sasl,
  1044. compile_args: '-DSTRUCT_IOVEC_DEFINED')
  1045. endif
  1046. endif
  1047. pam = not_found
  1048. if not get_option('auth_pam').auto() or have_system
  1049. pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
  1050. required: get_option('auth_pam'),
  1051. kwargs: static_kwargs)
  1052. endif
  1053. if pam.found() and not cc.links('''
  1054. #include <stddef.h>
  1055. #include <security/pam_appl.h>
  1056. int main(void) {
  1057. const char *service_name = "qemu";
  1058. const char *user = "frank";
  1059. const struct pam_conv pam_conv = { 0 };
  1060. pam_handle_t *pamh = NULL;
  1061. pam_start(service_name, user, &pam_conv, &pamh);
  1062. return 0;
  1063. }''', dependencies: pam)
  1064. pam = not_found
  1065. if get_option('auth_pam').enabled()
  1066. error('could not link libpam')
  1067. else
  1068. warning('could not link libpam, disabling')
  1069. endif
  1070. endif
  1071. snappy = not_found
  1072. if not get_option('snappy').auto() or have_system
  1073. snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
  1074. required: get_option('snappy'),
  1075. kwargs: static_kwargs)
  1076. endif
  1077. if snappy.found() and not linker.links('''
  1078. #include <snappy-c.h>
  1079. int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy)
  1080. snappy = not_found
  1081. if get_option('snappy').enabled()
  1082. error('could not link libsnappy')
  1083. else
  1084. warning('could not link libsnappy, disabling')
  1085. endif
  1086. endif
  1087. lzo = not_found
  1088. if not get_option('lzo').auto() or have_system
  1089. lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'],
  1090. required: get_option('lzo'),
  1091. kwargs: static_kwargs)
  1092. endif
  1093. if lzo.found() and not cc.links('''
  1094. #include <lzo/lzo1x.h>
  1095. int main(void) { lzo_version(); return 0; }''', dependencies: lzo)
  1096. lzo = not_found
  1097. if get_option('lzo').enabled()
  1098. error('could not link liblzo2')
  1099. else
  1100. warning('could not link liblzo2, disabling')
  1101. endif
  1102. endif
  1103. numa = not_found
  1104. if not get_option('numa').auto() or have_system or have_tools
  1105. numa = cc.find_library('numa', has_headers: ['numa.h'],
  1106. required: get_option('numa'),
  1107. kwargs: static_kwargs)
  1108. endif
  1109. if numa.found() and not cc.links('''
  1110. #include <numa.h>
  1111. int main(void) { return numa_available(); }
  1112. ''', dependencies: numa)
  1113. numa = not_found
  1114. if get_option('numa').enabled()
  1115. error('could not link numa')
  1116. else
  1117. warning('could not link numa, disabling')
  1118. endif
  1119. endif
  1120. rdma = not_found
  1121. if 'CONFIG_RDMA' in config_host
  1122. rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
  1123. endif
  1124. xen = not_found
  1125. if 'CONFIG_XEN_BACKEND' in config_host
  1126. xen = declare_dependency(compile_args: config_host['XEN_CFLAGS'].split(),
  1127. link_args: config_host['XEN_LIBS'].split())
  1128. endif
  1129. cacard = not_found
  1130. if not get_option('smartcard').auto() or have_system
  1131. cacard = dependency('libcacard', required: get_option('smartcard'),
  1132. version: '>=2.5.1', method: 'pkg-config',
  1133. kwargs: static_kwargs)
  1134. endif
  1135. u2f = not_found
  1136. if have_system
  1137. u2f = dependency('u2f-emu', required: get_option('u2f'),
  1138. method: 'pkg-config',
  1139. kwargs: static_kwargs)
  1140. endif
  1141. usbredir = not_found
  1142. if not get_option('usb_redir').auto() or have_system
  1143. usbredir = dependency('libusbredirparser-0.5', required: get_option('usb_redir'),
  1144. version: '>=0.6', method: 'pkg-config',
  1145. kwargs: static_kwargs)
  1146. endif
  1147. libusb = not_found
  1148. if not get_option('libusb').auto() or have_system
  1149. libusb = dependency('libusb-1.0', required: get_option('libusb'),
  1150. version: '>=1.0.13', method: 'pkg-config',
  1151. kwargs: static_kwargs)
  1152. endif
  1153. libpmem = not_found
  1154. if not get_option('libpmem').auto() or have_system
  1155. libpmem = dependency('libpmem', required: get_option('libpmem'),
  1156. method: 'pkg-config', kwargs: static_kwargs)
  1157. endif
  1158. libdaxctl = not_found
  1159. if not get_option('libdaxctl').auto() or have_system
  1160. libdaxctl = dependency('libdaxctl', required: get_option('libdaxctl'),
  1161. version: '>=57', method: 'pkg-config',
  1162. kwargs: static_kwargs)
  1163. endif
  1164. tasn1 = not_found
  1165. if gnutls.found()
  1166. tasn1 = dependency('libtasn1',
  1167. method: 'pkg-config',
  1168. kwargs: static_kwargs)
  1169. endif
  1170. keyutils = dependency('libkeyutils', required: false,
  1171. method: 'pkg-config', kwargs: static_kwargs)
  1172. has_gettid = cc.has_function('gettid')
  1173. # libselinux
  1174. selinux = dependency('libselinux',
  1175. required: get_option('selinux'),
  1176. method: 'pkg-config', kwargs: static_kwargs)
  1177. # Malloc tests
  1178. malloc = []
  1179. if get_option('malloc') == 'system'
  1180. has_malloc_trim = \
  1181. get_option('malloc_trim').allowed() and \
  1182. cc.links('''#include <malloc.h>
  1183. int main(void) { malloc_trim(0); return 0; }''')
  1184. else
  1185. has_malloc_trim = false
  1186. malloc = cc.find_library(get_option('malloc'), required: true)
  1187. endif
  1188. if not has_malloc_trim and get_option('malloc_trim').enabled()
  1189. if get_option('malloc') == 'system'
  1190. error('malloc_trim not available on this platform.')
  1191. else
  1192. error('malloc_trim not available with non-libc memory allocator')
  1193. endif
  1194. endif
  1195. # Check whether the glibc provides statx()
  1196. gnu_source_prefix = '''
  1197. #ifndef _GNU_SOURCE
  1198. #define _GNU_SOURCE
  1199. #endif
  1200. '''
  1201. statx_test = gnu_source_prefix + '''
  1202. #include <sys/stat.h>
  1203. int main(void) {
  1204. struct statx statxbuf;
  1205. statx(0, "", 0, STATX_BASIC_STATS, &statxbuf);
  1206. return 0;
  1207. }'''
  1208. has_statx = cc.links(statx_test)
  1209. # Check whether statx() provides mount ID information
  1210. statx_mnt_id_test = gnu_source_prefix + '''
  1211. #include <sys/stat.h>
  1212. int main(void) {
  1213. struct statx statxbuf;
  1214. statx(0, "", 0, STATX_BASIC_STATS | STATX_MNT_ID, &statxbuf);
  1215. return statxbuf.stx_mnt_id;
  1216. }'''
  1217. has_statx_mnt_id = cc.links(statx_mnt_id_test)
  1218. have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
  1219. .require(targetos == 'linux',
  1220. error_message: 'vhost_user_blk_server requires linux') \
  1221. .require('CONFIG_VHOST_USER' in config_host,
  1222. error_message: 'vhost_user_blk_server requires vhost-user support') \
  1223. .disable_auto_if(not have_system) \
  1224. .allowed()
  1225. if get_option('fuse').disabled() and get_option('fuse_lseek').enabled()
  1226. error('Cannot enable fuse-lseek while fuse is disabled')
  1227. endif
  1228. fuse = dependency('fuse3', required: get_option('fuse'),
  1229. version: '>=3.1', method: 'pkg-config',
  1230. kwargs: static_kwargs)
  1231. fuse_lseek = not_found
  1232. if get_option('fuse_lseek').allowed()
  1233. if fuse.version().version_compare('>=3.8')
  1234. # Dummy dependency
  1235. fuse_lseek = declare_dependency()
  1236. elif get_option('fuse_lseek').enabled()
  1237. if fuse.found()
  1238. error('fuse-lseek requires libfuse >=3.8, found ' + fuse.version())
  1239. else
  1240. error('fuse-lseek requires libfuse, which was not found')
  1241. endif
  1242. endif
  1243. endif
  1244. # libbpf
  1245. libbpf = dependency('libbpf', required: get_option('bpf'), method: 'pkg-config')
  1246. if libbpf.found() and not cc.links('''
  1247. #include <bpf/libbpf.h>
  1248. int main(void)
  1249. {
  1250. bpf_object__destroy_skeleton(NULL);
  1251. return 0;
  1252. }''', dependencies: libbpf)
  1253. libbpf = not_found
  1254. if get_option('bpf').enabled()
  1255. error('libbpf skeleton test failed')
  1256. else
  1257. warning('libbpf skeleton test failed, disabling')
  1258. endif
  1259. endif
  1260. #################
  1261. # config-host.h #
  1262. #################
  1263. audio_drivers_selected = []
  1264. if have_system
  1265. audio_drivers_available = {
  1266. 'alsa': alsa.found(),
  1267. 'coreaudio': coreaudio.found(),
  1268. 'dsound': dsound.found(),
  1269. 'jack': jack.found(),
  1270. 'oss': oss.found(),
  1271. 'pa': pulse.found(),
  1272. 'sdl': sdl.found(),
  1273. }
  1274. foreach k, v: audio_drivers_available
  1275. config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
  1276. endforeach
  1277. # Default to native drivers first, OSS second, SDL third
  1278. audio_drivers_priority = \
  1279. [ 'pa', 'coreaudio', 'dsound', 'oss' ] + \
  1280. (targetos == 'linux' ? [] : [ 'sdl' ])
  1281. audio_drivers_default = []
  1282. foreach k: audio_drivers_priority
  1283. if audio_drivers_available[k]
  1284. audio_drivers_default += k
  1285. endif
  1286. endforeach
  1287. foreach k: get_option('audio_drv_list')
  1288. if k == 'default'
  1289. audio_drivers_selected += audio_drivers_default
  1290. elif not audio_drivers_available[k]
  1291. error('Audio driver "@0@" not available.'.format(k))
  1292. else
  1293. audio_drivers_selected += k
  1294. endif
  1295. endforeach
  1296. endif
  1297. config_host_data.set('CONFIG_AUDIO_DRIVERS',
  1298. '"' + '", "'.join(audio_drivers_selected) + '", ')
  1299. if get_option('cfi')
  1300. cfi_flags=[]
  1301. # Check for dependency on LTO
  1302. if not get_option('b_lto')
  1303. error('Selected Control-Flow Integrity but LTO is disabled')
  1304. endif
  1305. if config_host.has_key('CONFIG_MODULES')
  1306. error('Selected Control-Flow Integrity is not compatible with modules')
  1307. endif
  1308. # Check for cfi flags. CFI requires LTO so we can't use
  1309. # get_supported_arguments, but need a more complex "compiles" which allows
  1310. # custom arguments
  1311. if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
  1312. args: ['-flto', '-fsanitize=cfi-icall'] )
  1313. cfi_flags += '-fsanitize=cfi-icall'
  1314. else
  1315. error('-fsanitize=cfi-icall is not supported by the compiler')
  1316. endif
  1317. if cc.compiles('int main () { return 0; }',
  1318. name: '-fsanitize-cfi-icall-generalize-pointers',
  1319. args: ['-flto', '-fsanitize=cfi-icall',
  1320. '-fsanitize-cfi-icall-generalize-pointers'] )
  1321. cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
  1322. else
  1323. error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
  1324. endif
  1325. if get_option('cfi_debug')
  1326. if cc.compiles('int main () { return 0; }',
  1327. name: '-fno-sanitize-trap=cfi-icall',
  1328. args: ['-flto', '-fsanitize=cfi-icall',
  1329. '-fno-sanitize-trap=cfi-icall'] )
  1330. cfi_flags += '-fno-sanitize-trap=cfi-icall'
  1331. else
  1332. error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
  1333. endif
  1334. endif
  1335. add_global_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
  1336. add_global_link_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
  1337. endif
  1338. have_host_block_device = (targetos != 'darwin' or
  1339. cc.has_header('IOKit/storage/IOMedia.h'))
  1340. # FIXME enable_modules shouldn't be necessary, but: https://github.com/mesonbuild/meson/issues/8333
  1341. dbus_display = get_option('dbus_display') \
  1342. .require(gio.version().version_compare('>=2.64'),
  1343. error_message: '-display dbus requires glib>=2.64') \
  1344. .require(enable_modules,
  1345. error_message: '-display dbus requires --enable-modules') \
  1346. .require(config_host.has_key('GDBUS_CODEGEN'),
  1347. error_message: '-display dbus requires gdbus-codegen') \
  1348. .allowed()
  1349. have_virtfs = get_option('virtfs') \
  1350. .require(targetos == 'linux' or targetos == 'darwin',
  1351. error_message: 'virtio-9p (virtfs) requires Linux or macOS') \
  1352. .require(targetos == 'linux' or cc.has_function('pthread_fchdir_np'),
  1353. error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \
  1354. .require(targetos == 'darwin' or (libattr.found() and libcap_ng.found()),
  1355. error_message: 'virtio-9p (virtfs) on Linux requires libcap-ng-devel and libattr-devel') \
  1356. .disable_auto_if(not have_tools and not have_system) \
  1357. .allowed()
  1358. have_virtfs_proxy_helper = targetos != 'darwin' and have_virtfs and have_tools
  1359. foreach k : get_option('trace_backends')
  1360. config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true)
  1361. endforeach
  1362. config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('trace_file'))
  1363. if get_option('iasl') != ''
  1364. config_host_data.set_quoted('CONFIG_IASL', get_option('iasl'))
  1365. endif
  1366. config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
  1367. config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
  1368. config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
  1369. config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
  1370. config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
  1371. config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath'))
  1372. config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
  1373. config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
  1374. config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
  1375. config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
  1376. config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
  1377. config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
  1378. have_slirp_smbd = get_option('slirp_smbd') \
  1379. .require(targetos != 'windows', error_message: 'Host smbd not supported on this platform.') \
  1380. .allowed()
  1381. if have_slirp_smbd
  1382. smbd_path = get_option('smbd')
  1383. if smbd_path == ''
  1384. smbd_path = (targetos == 'solaris' ? '/usr/sfw/sbin/smbd' : '/usr/sbin/smbd')
  1385. endif
  1386. config_host_data.set_quoted('CONFIG_SMBD_COMMAND', smbd_path)
  1387. endif
  1388. config_host_data.set('HOST_' + host_arch.to_upper(), 1)
  1389. config_host_data.set('CONFIG_ATTR', libattr.found())
  1390. config_host_data.set('CONFIG_BDRV_WHITELIST_TOOLS', get_option('block_drv_whitelist_in_tools'))
  1391. config_host_data.set('CONFIG_BRLAPI', brlapi.found())
  1392. config_host_data.set('CONFIG_COCOA', cocoa.found())
  1393. config_host_data.set('CONFIG_FUZZ', get_option('fuzzing'))
  1394. config_host_data.set('CONFIG_GCOV', get_option('b_coverage'))
  1395. config_host_data.set('CONFIG_LIBUDEV', libudev.found())
  1396. config_host_data.set('CONFIG_LZO', lzo.found())
  1397. config_host_data.set('CONFIG_MPATH', mpathpersist.found())
  1398. config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
  1399. config_host_data.set('CONFIG_CURL', curl.found())
  1400. config_host_data.set('CONFIG_CURSES', curses.found())
  1401. config_host_data.set('CONFIG_GBM', gbm.found())
  1402. config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found())
  1403. if glusterfs.found()
  1404. config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().version_compare('>=4'))
  1405. config_host_data.set('CONFIG_GLUSTERFS_DISCARD', glusterfs.version().version_compare('>=5'))
  1406. config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().version_compare('>=6'))
  1407. config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().version_compare('>=6'))
  1408. config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat)
  1409. config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat)
  1410. endif
  1411. config_host_data.set('CONFIG_GTK', gtk.found())
  1412. config_host_data.set('CONFIG_VTE', vte.found())
  1413. config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
  1414. config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
  1415. config_host_data.set('CONFIG_EBPF', libbpf.found())
  1416. config_host_data.set('CONFIG_LIBDAXCTL', libdaxctl.found())
  1417. config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
  1418. config_host_data.set('CONFIG_LIBNFS', libnfs.found())
  1419. config_host_data.set('CONFIG_LIBSSH', libssh.found())
  1420. config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
  1421. config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
  1422. config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
  1423. config_host_data.set('CONFIG_NUMA', numa.found())
  1424. config_host_data.set('CONFIG_PROFILER', get_option('profiler'))
  1425. config_host_data.set('CONFIG_RBD', rbd.found())
  1426. config_host_data.set('CONFIG_SDL', sdl.found())
  1427. config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
  1428. config_host_data.set('CONFIG_SECCOMP', seccomp.found())
  1429. config_host_data.set('CONFIG_SNAPPY', snappy.found())
  1430. config_host_data.set('CONFIG_TPM', have_tpm)
  1431. config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
  1432. config_host_data.set('CONFIG_VDE', vde.found())
  1433. config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
  1434. config_host_data.set('CONFIG_VNC', vnc.found())
  1435. config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
  1436. config_host_data.set('CONFIG_VNC_PNG', png.found())
  1437. config_host_data.set('CONFIG_VNC_SASL', sasl.found())
  1438. config_host_data.set('CONFIG_VIRTFS', have_virtfs)
  1439. config_host_data.set('CONFIG_VTE', vte.found())
  1440. config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
  1441. config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
  1442. config_host_data.set('CONFIG_GETTID', has_gettid)
  1443. config_host_data.set('CONFIG_GNUTLS', gnutls.found())
  1444. config_host_data.set('CONFIG_GNUTLS_CRYPTO', gnutls_crypto.found())
  1445. config_host_data.set('CONFIG_GCRYPT', gcrypt.found())
  1446. config_host_data.set('CONFIG_NETTLE', nettle.found())
  1447. config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts == 'private')
  1448. config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
  1449. config_host_data.set('CONFIG_STATX', has_statx)
  1450. config_host_data.set('CONFIG_STATX_MNT_ID', has_statx_mnt_id)
  1451. config_host_data.set('CONFIG_ZSTD', zstd.found())
  1452. config_host_data.set('CONFIG_FUSE', fuse.found())
  1453. config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found())
  1454. config_host_data.set('CONFIG_SPICE_PROTOCOL', spice_protocol.found())
  1455. if spice_protocol.found()
  1456. config_host_data.set('CONFIG_SPICE_PROTOCOL_MAJOR', spice_protocol.version().split('.')[0])
  1457. config_host_data.set('CONFIG_SPICE_PROTOCOL_MINOR', spice_protocol.version().split('.')[1])
  1458. config_host_data.set('CONFIG_SPICE_PROTOCOL_MICRO', spice_protocol.version().split('.')[2])
  1459. endif
  1460. config_host_data.set('CONFIG_SPICE', spice.found())
  1461. config_host_data.set('CONFIG_X11', x11.found())
  1462. config_host_data.set('CONFIG_DBUS_DISPLAY', dbus_display)
  1463. config_host_data.set('CONFIG_CFI', get_option('cfi'))
  1464. config_host_data.set('CONFIG_SELINUX', selinux.found())
  1465. config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
  1466. config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
  1467. config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
  1468. config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
  1469. config_host_data.set_quoted('CONFIG_HOST_DSOSUF', host_dsosuf)
  1470. config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device)
  1471. have_coroutine_pool = get_option('coroutine_pool')
  1472. if get_option('debug_stack_usage') and have_coroutine_pool
  1473. message('Disabling coroutine pool to measure stack usage')
  1474. have_coroutine_pool = false
  1475. endif
  1476. config_host_data.set10('CONFIG_COROUTINE_POOL', have_coroutine_pool)
  1477. config_host_data.set('CONFIG_DEBUG_MUTEX', get_option('debug_mutex'))
  1478. config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_option('debug_stack_usage'))
  1479. config_host_data.set('CONFIG_GPROF', get_option('gprof'))
  1480. config_host_data.set('CONFIG_LIVE_BLOCK_MIGRATION', get_option('live_block_migration').allowed())
  1481. config_host_data.set('CONFIG_QOM_CAST_DEBUG', get_option('qom_cast_debug'))
  1482. config_host_data.set('CONFIG_REPLICATION', get_option('live_block_migration').allowed())
  1483. # has_header
  1484. config_host_data.set('CONFIG_EPOLL', cc.has_header('sys/epoll.h'))
  1485. config_host_data.set('CONFIG_LINUX_MAGIC_H', cc.has_header('linux/magic.h'))
  1486. config_host_data.set('CONFIG_VALGRIND_H', cc.has_header('valgrind/valgrind.h'))
  1487. config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h'))
  1488. config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
  1489. config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
  1490. config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h'))
  1491. config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
  1492. config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
  1493. # has_function
  1494. config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4'))
  1495. config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime'))
  1496. config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))
  1497. config_host_data.set('CONFIG_FALLOCATE', cc.has_function('fallocate'))
  1498. config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate'))
  1499. # Note that we need to specify prefix: here to avoid incorrectly
  1500. # thinking that Windows has posix_memalign()
  1501. config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include <stdlib.h>'))
  1502. config_host_data.set('CONFIG_ALIGNED_MALLOC', cc.has_function('_aligned_malloc'))
  1503. config_host_data.set('CONFIG_VALLOC', cc.has_function('valloc'))
  1504. config_host_data.set('CONFIG_MEMALIGN', cc.has_function('memalign'))
  1505. config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll'))
  1506. config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
  1507. config_host_data.set('CONFIG_PTHREAD_FCHDIR_NP', cc.has_function('pthread_fchdir_np'))
  1508. config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads))
  1509. config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile'))
  1510. config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare'))
  1511. config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs'))
  1512. config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range'))
  1513. config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create'))
  1514. config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
  1515. config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
  1516. config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))
  1517. config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
  1518. if rdma.found()
  1519. config_host_data.set('HAVE_IBV_ADVISE_MR',
  1520. cc.has_function('ibv_advise_mr',
  1521. args: config_host['RDMA_LIBS'].split(),
  1522. prefix: '#include <infiniband/verbs.h>'))
  1523. endif
  1524. # has_header_symbol
  1525. config_host_data.set('CONFIG_BYTESWAP_H',
  1526. cc.has_header_symbol('byteswap.h', 'bswap_32'))
  1527. config_host_data.set('CONFIG_EPOLL_CREATE1',
  1528. cc.has_header_symbol('sys/epoll.h', 'epoll_create1'))
  1529. config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE',
  1530. cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_PUNCH_HOLE') and
  1531. cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_KEEP_SIZE'))
  1532. config_host_data.set('CONFIG_FALLOCATE_ZERO_RANGE',
  1533. cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_ZERO_RANGE'))
  1534. config_host_data.set('CONFIG_FIEMAP',
  1535. cc.has_header('linux/fiemap.h') and
  1536. cc.has_header_symbol('linux/fs.h', 'FS_IOC_FIEMAP'))
  1537. config_host_data.set('CONFIG_GETRANDOM',
  1538. cc.has_function('getrandom') and
  1539. cc.has_header_symbol('sys/random.h', 'GRND_NONBLOCK'))
  1540. config_host_data.set('CONFIG_INOTIFY',
  1541. cc.has_header_symbol('sys/inotify.h', 'inotify_init'))
  1542. config_host_data.set('CONFIG_INOTIFY1',
  1543. cc.has_header_symbol('sys/inotify.h', 'inotify_init1'))
  1544. config_host_data.set('CONFIG_MACHINE_BSWAP_H',
  1545. cc.has_header_symbol('machine/bswap.h', 'bswap32',
  1546. prefix: '''#include <sys/endian.h>
  1547. #include <sys/types.h>'''))
  1548. config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK',
  1549. cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK'))
  1550. config_host_data.set('CONFIG_RTNETLINK',
  1551. cc.has_header_symbol('linux/rtnetlink.h', 'IFLA_PROTO_DOWN'))
  1552. config_host_data.set('CONFIG_SYSMACROS',
  1553. cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
  1554. config_host_data.set('HAVE_OPTRESET',
  1555. cc.has_header_symbol('getopt.h', 'optreset'))
  1556. config_host_data.set('HAVE_IPPROTO_MPTCP',
  1557. cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
  1558. # has_member
  1559. config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
  1560. cc.has_member('struct sigevent', 'sigev_notify_thread_id',
  1561. prefix: '#include <signal.h>'))
  1562. config_host_data.set('HAVE_STRUCT_STAT_ST_ATIM',
  1563. cc.has_member('struct stat', 'st_atim',
  1564. prefix: '#include <sys/stat.h>'))
  1565. # has_type
  1566. config_host_data.set('CONFIG_IOVEC',
  1567. cc.has_type('struct iovec',
  1568. prefix: '#include <sys/uio.h>'))
  1569. config_host_data.set('HAVE_UTMPX',
  1570. cc.has_type('struct utmpx',
  1571. prefix: '#include <utmpx.h>'))
  1572. config_host_data.set('CONFIG_EVENTFD', cc.links('''
  1573. #include <sys/eventfd.h>
  1574. int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }'''))
  1575. config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + '''
  1576. #include <unistd.h>
  1577. int main(void) {
  1578. #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
  1579. return fdatasync(0);
  1580. #else
  1581. #error Not supported
  1582. #endif
  1583. }'''))
  1584. has_madvise = cc.links(gnu_source_prefix + '''
  1585. #include <sys/types.h>
  1586. #include <sys/mman.h>
  1587. #include <stddef.h>
  1588. int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }''')
  1589. missing_madvise_proto = false
  1590. if has_madvise
  1591. # Some platforms (illumos and Solaris before Solaris 11) provide madvise()
  1592. # but forget to prototype it. In this case, has_madvise will be true (the
  1593. # test program links despite a compile warning). To detect the
  1594. # missing-prototype case, we try again with a definitely-bogus prototype.
  1595. # This will only compile if the system headers don't provide the prototype;
  1596. # otherwise the conflicting prototypes will cause a compiler error.
  1597. missing_madvise_proto = cc.links(gnu_source_prefix + '''
  1598. #include <sys/types.h>
  1599. #include <sys/mman.h>
  1600. #include <stddef.h>
  1601. extern int madvise(int);
  1602. int main(void) { return madvise(0); }''')
  1603. endif
  1604. config_host_data.set('CONFIG_MADVISE', has_madvise)
  1605. config_host_data.set('HAVE_MADVISE_WITHOUT_PROTOTYPE', missing_madvise_proto)
  1606. config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + '''
  1607. #include <sys/mman.h>
  1608. int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }'''))
  1609. config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + '''
  1610. #include <fcntl.h>
  1611. #if !defined(AT_EMPTY_PATH)
  1612. # error missing definition
  1613. #else
  1614. int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
  1615. #endif'''))
  1616. config_host_data.set('CONFIG_PIPE2', cc.links(gnu_source_prefix + '''
  1617. #include <unistd.h>
  1618. #include <fcntl.h>
  1619. int main(void)
  1620. {
  1621. int pipefd[2];
  1622. return pipe2(pipefd, O_CLOEXEC);
  1623. }'''))
  1624. config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + '''
  1625. #include <sys/mman.h>
  1626. #include <stddef.h>
  1627. int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }'''))
  1628. config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(gnu_source_prefix + '''
  1629. #include <pthread.h>
  1630. static void *f(void *p) { return NULL; }
  1631. int main(void)
  1632. {
  1633. pthread_t thread;
  1634. pthread_create(&thread, 0, f, 0);
  1635. pthread_setname_np(thread, "QEMU");
  1636. return 0;
  1637. }''', dependencies: threads))
  1638. config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_prefix + '''
  1639. #include <pthread.h>
  1640. static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
  1641. int main(void)
  1642. {
  1643. pthread_t thread;
  1644. pthread_create(&thread, 0, f, 0);
  1645. return 0;
  1646. }''', dependencies: threads))
  1647. config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + '''
  1648. #include <sys/signalfd.h>
  1649. #include <stddef.h>
  1650. int main(void) { return signalfd(-1, NULL, SFD_CLOEXEC); }'''))
  1651. config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + '''
  1652. #include <unistd.h>
  1653. #include <fcntl.h>
  1654. #include <limits.h>
  1655. int main(void)
  1656. {
  1657. int len, fd = 0;
  1658. len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
  1659. splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
  1660. return 0;
  1661. }'''))
  1662. config_host_data.set('HAVE_MLOCKALL', cc.links(gnu_source_prefix + '''
  1663. #include <sys/mman.h>
  1664. int main(int argc, char *argv[]) {
  1665. return mlockall(MCL_FUTURE);
  1666. }'''))
  1667. have_l2tpv3 = false
  1668. if get_option('l2tpv3').allowed() and have_system
  1669. have_l2tpv3 = cc.has_type('struct mmsghdr',
  1670. prefix: gnu_source_prefix + '''
  1671. #include <sys/socket.h>
  1672. #include <linux/ip.h>''')
  1673. endif
  1674. config_host_data.set('CONFIG_L2TPV3', have_l2tpv3)
  1675. have_netmap = false
  1676. if get_option('netmap').allowed() and have_system
  1677. have_netmap = cc.compiles('''
  1678. #include <inttypes.h>
  1679. #include <net/if.h>
  1680. #include <net/netmap.h>
  1681. #include <net/netmap_user.h>
  1682. #if (NETMAP_API < 11) || (NETMAP_API > 15)
  1683. #error
  1684. #endif
  1685. int main(void) { return 0; }''')
  1686. if not have_netmap and get_option('netmap').enabled()
  1687. error('Netmap headers not available')
  1688. endif
  1689. endif
  1690. config_host_data.set('CONFIG_NETMAP', have_netmap)
  1691. # Work around a system header bug with some kernel/XFS header
  1692. # versions where they both try to define 'struct fsxattr':
  1693. # xfs headers will not try to redefine structs from linux headers
  1694. # if this macro is set.
  1695. config_host_data.set('HAVE_FSXATTR', cc.links('''
  1696. #include <linux/fs.h>
  1697. struct fsxattr foo;
  1698. int main(void) {
  1699. return 0;
  1700. }'''))
  1701. # Some versions of Mac OS X incorrectly define SIZE_MAX
  1702. config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles('''
  1703. #include <stdint.h>
  1704. #include <stdio.h>
  1705. int main(int argc, char *argv[]) {
  1706. return printf("%zu", SIZE_MAX);
  1707. }''', args: ['-Werror']))
  1708. atomic_test = '''
  1709. #include <stdint.h>
  1710. int main(void)
  1711. {
  1712. @0@ x = 0, y = 0;
  1713. y = __atomic_load_n(&x, __ATOMIC_RELAXED);
  1714. __atomic_store_n(&x, y, __ATOMIC_RELAXED);
  1715. __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
  1716. __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
  1717. __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
  1718. return 0;
  1719. }'''
  1720. # See if 64-bit atomic operations are supported.
  1721. # Note that without __atomic builtins, we can only
  1722. # assume atomic loads/stores max at pointer size.
  1723. config_host_data.set('CONFIG_ATOMIC64', cc.links(atomic_test.format('uint64_t')))
  1724. has_int128 = cc.links('''
  1725. __int128_t a;
  1726. __uint128_t b;
  1727. int main (void) {
  1728. a = a + b;
  1729. b = a * b;
  1730. a = a * a;
  1731. return 0;
  1732. }''')
  1733. config_host_data.set('CONFIG_INT128', has_int128)
  1734. if has_int128
  1735. # "do we have 128-bit atomics which are handled inline and specifically not
  1736. # via libatomic". The reason we can't use libatomic is documented in the
  1737. # comment starting "GCC is a house divided" in include/qemu/atomic128.h.
  1738. has_atomic128 = cc.links(atomic_test.format('unsigned __int128'))
  1739. config_host_data.set('CONFIG_ATOMIC128', has_atomic128)
  1740. if not has_atomic128
  1741. has_cmpxchg128 = cc.links('''
  1742. int main(void)
  1743. {
  1744. unsigned __int128 x = 0, y = 0;
  1745. __sync_val_compare_and_swap_16(&x, y, x);
  1746. return 0;
  1747. }
  1748. ''')
  1749. config_host_data.set('CONFIG_CMPXCHG128', has_cmpxchg128)
  1750. endif
  1751. endif
  1752. config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + '''
  1753. #include <sys/auxv.h>
  1754. int main(void) {
  1755. return getauxval(AT_HWCAP) == 0;
  1756. }'''))
  1757. have_cpuid_h = cc.links('''
  1758. #include <cpuid.h>
  1759. int main(void) {
  1760. unsigned a, b, c, d;
  1761. unsigned max = __get_cpuid_max(0, 0);
  1762. if (max >= 1) {
  1763. __cpuid(1, a, b, c, d);
  1764. }
  1765. if (max >= 7) {
  1766. __cpuid_count(7, 0, a, b, c, d);
  1767. }
  1768. return 0;
  1769. }''')
  1770. config_host_data.set('CONFIG_CPUID_H', have_cpuid_h)
  1771. config_host_data.set('CONFIG_AVX2_OPT', get_option('avx2') \
  1772. .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX2') \
  1773. .require(cc.links('''
  1774. #pragma GCC push_options
  1775. #pragma GCC target("avx2")
  1776. #include <cpuid.h>
  1777. #include <immintrin.h>
  1778. static int bar(void *a) {
  1779. __m256i x = *(__m256i *)a;
  1780. return _mm256_testz_si256(x, x);
  1781. }
  1782. int main(int argc, char *argv[]) { return bar(argv[0]); }
  1783. '''), error_message: 'AVX2 not available').allowed())
  1784. config_host_data.set('CONFIG_AVX512F_OPT', get_option('avx512f') \
  1785. .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512F') \
  1786. .require(cc.links('''
  1787. #pragma GCC push_options
  1788. #pragma GCC target("avx512f")
  1789. #include <cpuid.h>
  1790. #include <immintrin.h>
  1791. static int bar(void *a) {
  1792. __m512i x = *(__m512i *)a;
  1793. return _mm512_test_epi64_mask(x, x);
  1794. }
  1795. int main(int argc, char *argv[]) { return bar(argv[0]); }
  1796. '''), error_message: 'AVX512F not available').allowed())
  1797. if get_option('membarrier').disabled()
  1798. have_membarrier = false
  1799. elif targetos == 'windows'
  1800. have_membarrier = true
  1801. elif targetos == 'linux'
  1802. have_membarrier = cc.compiles('''
  1803. #include <linux/membarrier.h>
  1804. #include <sys/syscall.h>
  1805. #include <unistd.h>
  1806. #include <stdlib.h>
  1807. int main(void) {
  1808. syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
  1809. syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
  1810. exit(0);
  1811. }''')
  1812. endif
  1813. config_host_data.set('CONFIG_MEMBARRIER', get_option('membarrier') \
  1814. .require(have_membarrier, error_message: 'membarrier system call not available') \
  1815. .allowed())
  1816. have_afalg = get_option('crypto_afalg') \
  1817. .require(cc.compiles(gnu_source_prefix + '''
  1818. #include <errno.h>
  1819. #include <sys/types.h>
  1820. #include <sys/socket.h>
  1821. #include <linux/if_alg.h>
  1822. int main(void) {
  1823. int sock;
  1824. sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
  1825. return sock;
  1826. }
  1827. '''), error_message: 'AF_ALG requested but could not be detected').allowed()
  1828. config_host_data.set('CONFIG_AF_ALG', have_afalg)
  1829. config_host_data.set('CONFIG_AF_VSOCK', cc.compiles(gnu_source_prefix + '''
  1830. #include <errno.h>
  1831. #include <sys/types.h>
  1832. #include <sys/socket.h>
  1833. #if !defined(AF_VSOCK)
  1834. # error missing AF_VSOCK flag
  1835. #endif
  1836. #include <linux/vm_sockets.h>
  1837. int main(void) {
  1838. int sock, ret;
  1839. struct sockaddr_vm svm;
  1840. socklen_t len = sizeof(svm);
  1841. sock = socket(AF_VSOCK, SOCK_STREAM, 0);
  1842. ret = getpeername(sock, (struct sockaddr *)&svm, &len);
  1843. if ((ret == -1) && (errno == ENOTCONN)) {
  1844. return 0;
  1845. }
  1846. return -1;
  1847. }'''))
  1848. have_vss = false
  1849. have_vss_sdk = false # old xp/2003 SDK
  1850. if targetos == 'windows' and link_language == 'cpp'
  1851. have_vss = cxx.compiles('''
  1852. #define __MIDL_user_allocate_free_DEFINED__
  1853. #include <vss.h>
  1854. int main(void) { return VSS_CTX_BACKUP; }''')
  1855. have_vss_sdk = cxx.has_header('vscoordint.h')
  1856. endif
  1857. config_host_data.set('HAVE_VSS_SDK', have_vss_sdk)
  1858. have_ntddscsi = false
  1859. if targetos == 'windows'
  1860. have_ntddscsi = cc.compiles('''
  1861. #include <windows.h>
  1862. #include <ntddscsi.h>
  1863. int main(void) {
  1864. #if !defined(IOCTL_SCSI_GET_ADDRESS)
  1865. #error Missing required ioctl definitions
  1866. #endif
  1867. SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
  1868. return addr.Lun;
  1869. }
  1870. ''')
  1871. endif
  1872. config_host_data.set('HAVE_NTDDSCSI', have_ntddscsi)
  1873. ignored = ['CONFIG_QEMU_INTERP_PREFIX', # actually per-target
  1874. 'HAVE_GDB_BIN']
  1875. arrays = ['CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
  1876. foreach k, v: config_host
  1877. if ignored.contains(k)
  1878. # do nothing
  1879. elif arrays.contains(k)
  1880. if v != ''
  1881. v = '"' + '", "'.join(v.split()) + '", '
  1882. endif
  1883. config_host_data.set(k, v)
  1884. elif k.startswith('CONFIG_')
  1885. config_host_data.set(k, v == 'y' ? 1 : v)
  1886. endif
  1887. endforeach
  1888. ########################
  1889. # Target configuration #
  1890. ########################
  1891. minikconf = find_program('scripts/minikconf.py')
  1892. config_all = {}
  1893. config_all_devices = {}
  1894. config_all_disas = {}
  1895. config_devices_mak_list = []
  1896. config_devices_h = {}
  1897. config_target_h = {}
  1898. config_target_mak = {}
  1899. disassemblers = {
  1900. 'alpha' : ['CONFIG_ALPHA_DIS'],
  1901. 'arm' : ['CONFIG_ARM_DIS'],
  1902. 'avr' : ['CONFIG_AVR_DIS'],
  1903. 'cris' : ['CONFIG_CRIS_DIS'],
  1904. 'hexagon' : ['CONFIG_HEXAGON_DIS'],
  1905. 'hppa' : ['CONFIG_HPPA_DIS'],
  1906. 'i386' : ['CONFIG_I386_DIS'],
  1907. 'x86_64' : ['CONFIG_I386_DIS'],
  1908. 'm68k' : ['CONFIG_M68K_DIS'],
  1909. 'microblaze' : ['CONFIG_MICROBLAZE_DIS'],
  1910. 'mips' : ['CONFIG_MIPS_DIS'],
  1911. 'nios2' : ['CONFIG_NIOS2_DIS'],
  1912. 'or1k' : ['CONFIG_OPENRISC_DIS'],
  1913. 'ppc' : ['CONFIG_PPC_DIS'],
  1914. 'riscv' : ['CONFIG_RISCV_DIS'],
  1915. 'rx' : ['CONFIG_RX_DIS'],
  1916. 's390' : ['CONFIG_S390_DIS'],
  1917. 'sh4' : ['CONFIG_SH4_DIS'],
  1918. 'sparc' : ['CONFIG_SPARC_DIS'],
  1919. 'xtensa' : ['CONFIG_XTENSA_DIS'],
  1920. }
  1921. if link_language == 'cpp'
  1922. disassemblers += {
  1923. 'aarch64' : [ 'CONFIG_ARM_A64_DIS'],
  1924. 'arm' : [ 'CONFIG_ARM_DIS', 'CONFIG_ARM_A64_DIS'],
  1925. 'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
  1926. }
  1927. endif
  1928. have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
  1929. host_kconfig = \
  1930. (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \
  1931. (have_tpm ? ['CONFIG_TPM=y'] : []) + \
  1932. (spice.found() ? ['CONFIG_SPICE=y'] : []) + \
  1933. (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
  1934. ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
  1935. (x11.found() ? ['CONFIG_X11=y'] : []) + \
  1936. ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
  1937. ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
  1938. ('CONFIG_VHOST_KERNEL' in config_host ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
  1939. (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
  1940. ('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \
  1941. ('CONFIG_PVRDMA' in config_host ? ['CONFIG_PVRDMA=y'] : []) + \
  1942. (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : [])
  1943. ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
  1944. default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
  1945. actual_target_dirs = []
  1946. fdt_required = []
  1947. foreach target : target_dirs
  1948. config_target = { 'TARGET_NAME': target.split('-')[0] }
  1949. if target.endswith('linux-user')
  1950. if targetos != 'linux'
  1951. if default_targets
  1952. continue
  1953. endif
  1954. error('Target @0@ is only available on a Linux host'.format(target))
  1955. endif
  1956. config_target += { 'CONFIG_LINUX_USER': 'y' }
  1957. elif target.endswith('bsd-user')
  1958. if 'CONFIG_BSD' not in config_host
  1959. if default_targets
  1960. continue
  1961. endif
  1962. error('Target @0@ is only available on a BSD host'.format(target))
  1963. endif
  1964. config_target += { 'CONFIG_BSD_USER': 'y' }
  1965. elif target.endswith('softmmu')
  1966. config_target += { 'CONFIG_SOFTMMU': 'y' }
  1967. endif
  1968. if target.endswith('-user')
  1969. config_target += {
  1970. 'CONFIG_USER_ONLY': 'y',
  1971. 'CONFIG_QEMU_INTERP_PREFIX':
  1972. config_host['CONFIG_QEMU_INTERP_PREFIX'].format(config_target['TARGET_NAME'])
  1973. }
  1974. endif
  1975. accel_kconfig = []
  1976. foreach sym: accelerators
  1977. if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
  1978. config_target += { sym: 'y' }
  1979. config_all += { sym: 'y' }
  1980. if sym == 'CONFIG_TCG' and tcg_arch == 'tci'
  1981. config_target += { 'CONFIG_TCG_INTERPRETER': 'y' }
  1982. elif sym == 'CONFIG_XEN' and have_xen_pci_passthrough
  1983. config_target += { 'CONFIG_XEN_PCI_PASSTHROUGH': 'y' }
  1984. endif
  1985. if target in modular_tcg
  1986. config_target += { 'CONFIG_TCG_MODULAR': 'y' }
  1987. else
  1988. config_target += { 'CONFIG_TCG_BUILTIN': 'y' }
  1989. endif
  1990. accel_kconfig += [ sym + '=y' ]
  1991. endif
  1992. endforeach
  1993. if accel_kconfig.length() == 0
  1994. if default_targets
  1995. continue
  1996. endif
  1997. error('No accelerator available for target @0@'.format(target))
  1998. endif
  1999. actual_target_dirs += target
  2000. config_target += keyval.load('configs/targets' / target + '.mak')
  2001. config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
  2002. if 'TARGET_NEED_FDT' in config_target
  2003. fdt_required += target
  2004. endif
  2005. # Add default keys
  2006. if 'TARGET_BASE_ARCH' not in config_target
  2007. config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
  2008. endif
  2009. if 'TARGET_ABI_DIR' not in config_target
  2010. config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']}
  2011. endif
  2012. if 'TARGET_BIG_ENDIAN' not in config_target
  2013. config_target += {'TARGET_BIG_ENDIAN': 'n'}
  2014. endif
  2015. foreach k, v: disassemblers
  2016. if host_arch.startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
  2017. foreach sym: v
  2018. config_target += { sym: 'y' }
  2019. config_all_disas += { sym: 'y' }
  2020. endforeach
  2021. endif
  2022. endforeach
  2023. config_target_data = configuration_data()
  2024. foreach k, v: config_target
  2025. if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
  2026. # do nothing
  2027. elif ignored.contains(k)
  2028. # do nothing
  2029. elif k == 'TARGET_BASE_ARCH'
  2030. # Note that TARGET_BASE_ARCH ends up in config-target.h but it is
  2031. # not used to select files from sourcesets.
  2032. config_target_data.set('TARGET_' + v.to_upper(), 1)
  2033. elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX'
  2034. config_target_data.set_quoted(k, v)
  2035. elif v == 'y'
  2036. config_target_data.set(k, 1)
  2037. elif v == 'n'
  2038. config_target_data.set(k, 0)
  2039. else
  2040. config_target_data.set(k, v)
  2041. endif
  2042. endforeach
  2043. config_target_data.set('QEMU_ARCH',
  2044. 'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper())
  2045. config_target_h += {target: configure_file(output: target + '-config-target.h',
  2046. configuration: config_target_data)}
  2047. if target.endswith('-softmmu')
  2048. config_input = meson.get_external_property(target, 'default')
  2049. config_devices_mak = target + '-config-devices.mak'
  2050. config_devices_mak = configure_file(
  2051. input: ['configs/devices' / target / config_input + '.mak', 'Kconfig'],
  2052. output: config_devices_mak,
  2053. depfile: config_devices_mak + '.d',
  2054. capture: true,
  2055. command: [minikconf,
  2056. get_option('default_devices') ? '--defconfig' : '--allnoconfig',
  2057. config_devices_mak, '@DEPFILE@', '@INPUT@',
  2058. host_kconfig, accel_kconfig,
  2059. 'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'])
  2060. config_devices_data = configuration_data()
  2061. config_devices = keyval.load(config_devices_mak)
  2062. foreach k, v: config_devices
  2063. config_devices_data.set(k, 1)
  2064. endforeach
  2065. config_devices_mak_list += config_devices_mak
  2066. config_devices_h += {target: configure_file(output: target + '-config-devices.h',
  2067. configuration: config_devices_data)}
  2068. config_target += config_devices
  2069. config_all_devices += config_devices
  2070. endif
  2071. config_target_mak += {target: config_target}
  2072. endforeach
  2073. target_dirs = actual_target_dirs
  2074. # This configuration is used to build files that are shared by
  2075. # multiple binaries, and then extracted out of the "common"
  2076. # static_library target.
  2077. #
  2078. # We do not use all_sources()/all_dependencies(), because it would
  2079. # build literally all source files, including devices only used by
  2080. # targets that are not built for this compilation. The CONFIG_ALL
  2081. # pseudo symbol replaces it.
  2082. config_all += config_all_devices
  2083. config_all += config_host
  2084. config_all += config_all_disas
  2085. config_all += {
  2086. 'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
  2087. 'CONFIG_SOFTMMU': have_system,
  2088. 'CONFIG_USER_ONLY': have_user,
  2089. 'CONFIG_ALL': true,
  2090. }
  2091. target_configs_h = []
  2092. foreach target: target_dirs
  2093. target_configs_h += config_target_h[target]
  2094. target_configs_h += config_devices_h.get(target, [])
  2095. endforeach
  2096. genh += custom_target('config-poison.h',
  2097. input: [target_configs_h],
  2098. output: 'config-poison.h',
  2099. capture: true,
  2100. command: [find_program('scripts/make-config-poison.sh'),
  2101. target_configs_h])
  2102. ##############
  2103. # Submodules #
  2104. ##############
  2105. capstone = not_found
  2106. capstone_opt = get_option('capstone')
  2107. if capstone_opt in ['enabled', 'auto', 'system']
  2108. have_internal = fs.exists(meson.current_source_dir() / 'capstone/Makefile')
  2109. capstone = dependency('capstone', version: '>=4.0',
  2110. kwargs: static_kwargs, method: 'pkg-config',
  2111. required: capstone_opt == 'system' or
  2112. capstone_opt == 'enabled' and not have_internal)
  2113. # Some versions of capstone have broken pkg-config file
  2114. # that reports a wrong -I path, causing the #include to
  2115. # fail later. If the system has such a broken version
  2116. # do not use it.
  2117. if capstone.found() and not cc.compiles('#include <capstone.h>',
  2118. dependencies: [capstone])
  2119. capstone = not_found
  2120. if capstone_opt == 'system'
  2121. error('system capstone requested, it does not appear to work')
  2122. endif
  2123. endif
  2124. if capstone.found()
  2125. capstone_opt = 'system'
  2126. elif have_internal
  2127. capstone_opt = 'internal'
  2128. else
  2129. capstone_opt = 'disabled'
  2130. endif
  2131. endif
  2132. if capstone_opt == 'internal'
  2133. capstone_data = configuration_data()
  2134. capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1')
  2135. capstone_files = files(
  2136. 'capstone/cs.c',
  2137. 'capstone/MCInst.c',
  2138. 'capstone/MCInstrDesc.c',
  2139. 'capstone/MCRegisterInfo.c',
  2140. 'capstone/SStream.c',
  2141. 'capstone/utils.c'
  2142. )
  2143. if 'CONFIG_ARM_DIS' in config_all_disas
  2144. capstone_data.set('CAPSTONE_HAS_ARM', '1')
  2145. capstone_files += files(
  2146. 'capstone/arch/ARM/ARMDisassembler.c',
  2147. 'capstone/arch/ARM/ARMInstPrinter.c',
  2148. 'capstone/arch/ARM/ARMMapping.c',
  2149. 'capstone/arch/ARM/ARMModule.c'
  2150. )
  2151. endif
  2152. # FIXME: This config entry currently depends on a c++ compiler.
  2153. # Which is needed for building libvixl, but not for capstone.
  2154. if 'CONFIG_ARM_A64_DIS' in config_all_disas
  2155. capstone_data.set('CAPSTONE_HAS_ARM64', '1')
  2156. capstone_files += files(
  2157. 'capstone/arch/AArch64/AArch64BaseInfo.c',
  2158. 'capstone/arch/AArch64/AArch64Disassembler.c',
  2159. 'capstone/arch/AArch64/AArch64InstPrinter.c',
  2160. 'capstone/arch/AArch64/AArch64Mapping.c',
  2161. 'capstone/arch/AArch64/AArch64Module.c'
  2162. )
  2163. endif
  2164. if 'CONFIG_PPC_DIS' in config_all_disas
  2165. capstone_data.set('CAPSTONE_HAS_POWERPC', '1')
  2166. capstone_files += files(
  2167. 'capstone/arch/PowerPC/PPCDisassembler.c',
  2168. 'capstone/arch/PowerPC/PPCInstPrinter.c',
  2169. 'capstone/arch/PowerPC/PPCMapping.c',
  2170. 'capstone/arch/PowerPC/PPCModule.c'
  2171. )
  2172. endif
  2173. if 'CONFIG_S390_DIS' in config_all_disas
  2174. capstone_data.set('CAPSTONE_HAS_SYSZ', '1')
  2175. capstone_files += files(
  2176. 'capstone/arch/SystemZ/SystemZDisassembler.c',
  2177. 'capstone/arch/SystemZ/SystemZInstPrinter.c',
  2178. 'capstone/arch/SystemZ/SystemZMapping.c',
  2179. 'capstone/arch/SystemZ/SystemZModule.c',
  2180. 'capstone/arch/SystemZ/SystemZMCTargetDesc.c'
  2181. )
  2182. endif
  2183. if 'CONFIG_I386_DIS' in config_all_disas
  2184. capstone_data.set('CAPSTONE_HAS_X86', 1)
  2185. capstone_files += files(
  2186. 'capstone/arch/X86/X86Disassembler.c',
  2187. 'capstone/arch/X86/X86DisassemblerDecoder.c',
  2188. 'capstone/arch/X86/X86ATTInstPrinter.c',
  2189. 'capstone/arch/X86/X86IntelInstPrinter.c',
  2190. 'capstone/arch/X86/X86InstPrinterCommon.c',
  2191. 'capstone/arch/X86/X86Mapping.c',
  2192. 'capstone/arch/X86/X86Module.c'
  2193. )
  2194. endif
  2195. configure_file(output: 'capstone-defs.h', configuration: capstone_data)
  2196. capstone_cargs = [
  2197. # FIXME: There does not seem to be a way to completely replace the c_args
  2198. # that come from add_project_arguments() -- we can only add to them.
  2199. # So: disable all warnings with a big hammer.
  2200. '-Wno-error', '-w',
  2201. # Include all configuration defines via a header file, which will wind up
  2202. # as a dependency on the object file, and thus changes here will result
  2203. # in a rebuild.
  2204. '-include', 'capstone-defs.h'
  2205. ]
  2206. libcapstone = static_library('capstone',
  2207. build_by_default: false,
  2208. sources: capstone_files,
  2209. c_args: capstone_cargs,
  2210. include_directories: 'capstone/include')
  2211. capstone = declare_dependency(link_with: libcapstone,
  2212. include_directories: 'capstone/include/capstone')
  2213. endif
  2214. slirp = not_found
  2215. slirp_opt = 'disabled'
  2216. if have_system
  2217. slirp_opt = get_option('slirp')
  2218. if slirp_opt in ['enabled', 'auto', 'system']
  2219. have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
  2220. slirp = dependency('slirp', kwargs: static_kwargs,
  2221. method: 'pkg-config',
  2222. required: slirp_opt == 'system' or
  2223. slirp_opt == 'enabled' and not have_internal)
  2224. if slirp.found()
  2225. slirp_opt = 'system'
  2226. elif have_internal
  2227. slirp_opt = 'internal'
  2228. else
  2229. slirp_opt = 'disabled'
  2230. endif
  2231. endif
  2232. if slirp_opt == 'internal'
  2233. slirp_deps = []
  2234. if targetos == 'windows'
  2235. slirp_deps = cc.find_library('iphlpapi')
  2236. elif targetos == 'darwin'
  2237. slirp_deps = cc.find_library('resolv')
  2238. endif
  2239. slirp_conf = configuration_data()
  2240. slirp_conf.set('SLIRP_MAJOR_VERSION', meson.project_version().split('.')[0])
  2241. slirp_conf.set('SLIRP_MINOR_VERSION', meson.project_version().split('.')[1])
  2242. slirp_conf.set('SLIRP_MICRO_VERSION', meson.project_version().split('.')[2])
  2243. slirp_conf.set_quoted('SLIRP_VERSION_STRING', meson.project_version())
  2244. slirp_cargs = ['-DG_LOG_DOMAIN="Slirp"']
  2245. slirp_files = [
  2246. 'slirp/src/arp_table.c',
  2247. 'slirp/src/bootp.c',
  2248. 'slirp/src/cksum.c',
  2249. 'slirp/src/dhcpv6.c',
  2250. 'slirp/src/dnssearch.c',
  2251. 'slirp/src/if.c',
  2252. 'slirp/src/ip6_icmp.c',
  2253. 'slirp/src/ip6_input.c',
  2254. 'slirp/src/ip6_output.c',
  2255. 'slirp/src/ip_icmp.c',
  2256. 'slirp/src/ip_input.c',
  2257. 'slirp/src/ip_output.c',
  2258. 'slirp/src/mbuf.c',
  2259. 'slirp/src/misc.c',
  2260. 'slirp/src/ncsi.c',
  2261. 'slirp/src/ndp_table.c',
  2262. 'slirp/src/sbuf.c',
  2263. 'slirp/src/slirp.c',
  2264. 'slirp/src/socket.c',
  2265. 'slirp/src/state.c',
  2266. 'slirp/src/stream.c',
  2267. 'slirp/src/tcp_input.c',
  2268. 'slirp/src/tcp_output.c',
  2269. 'slirp/src/tcp_subr.c',
  2270. 'slirp/src/tcp_timer.c',
  2271. 'slirp/src/tftp.c',
  2272. 'slirp/src/udp.c',
  2273. 'slirp/src/udp6.c',
  2274. 'slirp/src/util.c',
  2275. 'slirp/src/version.c',
  2276. 'slirp/src/vmstate.c',
  2277. ]
  2278. configure_file(
  2279. input : 'slirp/src/libslirp-version.h.in',
  2280. output : 'libslirp-version.h',
  2281. configuration: slirp_conf)
  2282. slirp_inc = include_directories('slirp', 'slirp/src')
  2283. libslirp = static_library('slirp',
  2284. build_by_default: false,
  2285. sources: slirp_files,
  2286. c_args: slirp_cargs,
  2287. include_directories: slirp_inc)
  2288. slirp = declare_dependency(link_with: libslirp,
  2289. dependencies: slirp_deps,
  2290. include_directories: slirp_inc)
  2291. endif
  2292. endif
  2293. # For CFI, we need to compile slirp as a static library together with qemu.
  2294. # This is because we register slirp functions as callbacks for QEMU Timers.
  2295. # When using a system-wide shared libslirp, the type information for the
  2296. # callback is missing and the timer call produces a false positive with CFI.
  2297. #
  2298. # Now that slirp_opt has been defined, check if the selected slirp is compatible
  2299. # with control-flow integrity.
  2300. if get_option('cfi') and slirp_opt == 'system'
  2301. error('Control-Flow Integrity is not compatible with system-wide slirp.' \
  2302. + ' Please configure with --enable-slirp=git')
  2303. endif
  2304. fdt = not_found
  2305. if have_system
  2306. fdt_opt = get_option('fdt')
  2307. if fdt_opt in ['enabled', 'auto', 'system']
  2308. have_internal = fs.exists(meson.current_source_dir() / 'dtc/libfdt/Makefile.libfdt')
  2309. fdt = cc.find_library('fdt', kwargs: static_kwargs,
  2310. required: fdt_opt == 'system' or
  2311. fdt_opt == 'enabled' and not have_internal)
  2312. if fdt.found() and cc.links('''
  2313. #include <libfdt.h>
  2314. #include <libfdt_env.h>
  2315. int main(void) { fdt_find_max_phandle(NULL, NULL); return 0; }''',
  2316. dependencies: fdt)
  2317. fdt_opt = 'system'
  2318. elif fdt_opt == 'system'
  2319. error('system libfdt requested, but it is too old (1.5.1 or newer required)')
  2320. elif have_internal
  2321. fdt_opt = 'internal'
  2322. else
  2323. fdt_opt = 'disabled'
  2324. fdt = not_found
  2325. endif
  2326. endif
  2327. if fdt_opt == 'internal'
  2328. fdt_files = files(
  2329. 'dtc/libfdt/fdt.c',
  2330. 'dtc/libfdt/fdt_ro.c',
  2331. 'dtc/libfdt/fdt_wip.c',
  2332. 'dtc/libfdt/fdt_sw.c',
  2333. 'dtc/libfdt/fdt_rw.c',
  2334. 'dtc/libfdt/fdt_strerror.c',
  2335. 'dtc/libfdt/fdt_empty_tree.c',
  2336. 'dtc/libfdt/fdt_addresses.c',
  2337. 'dtc/libfdt/fdt_overlay.c',
  2338. 'dtc/libfdt/fdt_check.c',
  2339. )
  2340. fdt_inc = include_directories('dtc/libfdt')
  2341. libfdt = static_library('fdt',
  2342. build_by_default: false,
  2343. sources: fdt_files,
  2344. include_directories: fdt_inc)
  2345. fdt = declare_dependency(link_with: libfdt,
  2346. include_directories: fdt_inc)
  2347. endif
  2348. else
  2349. fdt_opt = 'disabled'
  2350. endif
  2351. if not fdt.found() and fdt_required.length() > 0
  2352. error('fdt not available but required by targets ' + ', '.join(fdt_required))
  2353. endif
  2354. config_host_data.set('CONFIG_CAPSTONE', capstone.found())
  2355. config_host_data.set('CONFIG_FDT', fdt.found())
  2356. config_host_data.set('CONFIG_SLIRP', slirp.found())
  2357. #####################
  2358. # Generated sources #
  2359. #####################
  2360. genh += configure_file(output: 'config-host.h', configuration: config_host_data)
  2361. hxtool = find_program('scripts/hxtool')
  2362. shaderinclude = find_program('scripts/shaderinclude.pl')
  2363. qapi_gen = find_program('scripts/qapi-gen.py')
  2364. qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py',
  2365. meson.current_source_dir() / 'scripts/qapi/commands.py',
  2366. meson.current_source_dir() / 'scripts/qapi/common.py',
  2367. meson.current_source_dir() / 'scripts/qapi/error.py',
  2368. meson.current_source_dir() / 'scripts/qapi/events.py',
  2369. meson.current_source_dir() / 'scripts/qapi/expr.py',
  2370. meson.current_source_dir() / 'scripts/qapi/gen.py',
  2371. meson.current_source_dir() / 'scripts/qapi/introspect.py',
  2372. meson.current_source_dir() / 'scripts/qapi/parser.py',
  2373. meson.current_source_dir() / 'scripts/qapi/schema.py',
  2374. meson.current_source_dir() / 'scripts/qapi/source.py',
  2375. meson.current_source_dir() / 'scripts/qapi/types.py',
  2376. meson.current_source_dir() / 'scripts/qapi/visit.py',
  2377. meson.current_source_dir() / 'scripts/qapi/common.py',
  2378. meson.current_source_dir() / 'scripts/qapi-gen.py'
  2379. ]
  2380. tracetool = [
  2381. python, files('scripts/tracetool.py'),
  2382. '--backend=' + ','.join(get_option('trace_backends'))
  2383. ]
  2384. tracetool_depends = files(
  2385. 'scripts/tracetool/backend/log.py',
  2386. 'scripts/tracetool/backend/__init__.py',
  2387. 'scripts/tracetool/backend/dtrace.py',
  2388. 'scripts/tracetool/backend/ftrace.py',
  2389. 'scripts/tracetool/backend/simple.py',
  2390. 'scripts/tracetool/backend/syslog.py',
  2391. 'scripts/tracetool/backend/ust.py',
  2392. 'scripts/tracetool/format/ust_events_c.py',
  2393. 'scripts/tracetool/format/ust_events_h.py',
  2394. 'scripts/tracetool/format/__init__.py',
  2395. 'scripts/tracetool/format/d.py',
  2396. 'scripts/tracetool/format/simpletrace_stap.py',
  2397. 'scripts/tracetool/format/c.py',
  2398. 'scripts/tracetool/format/h.py',
  2399. 'scripts/tracetool/format/log_stap.py',
  2400. 'scripts/tracetool/format/stap.py',
  2401. 'scripts/tracetool/__init__.py',
  2402. 'scripts/tracetool/transform.py',
  2403. 'scripts/tracetool/vcpu.py'
  2404. )
  2405. qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
  2406. meson.current_source_dir(),
  2407. config_host['PKGVERSION'], meson.project_version()]
  2408. qemu_version = custom_target('qemu-version.h',
  2409. output: 'qemu-version.h',
  2410. command: qemu_version_cmd,
  2411. capture: true,
  2412. build_by_default: true,
  2413. build_always_stale: true)
  2414. genh += qemu_version
  2415. hxdep = []
  2416. hx_headers = [
  2417. ['qemu-options.hx', 'qemu-options.def'],
  2418. ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
  2419. ]
  2420. if have_system
  2421. hx_headers += [
  2422. ['hmp-commands.hx', 'hmp-commands.h'],
  2423. ['hmp-commands-info.hx', 'hmp-commands-info.h'],
  2424. ]
  2425. endif
  2426. foreach d : hx_headers
  2427. hxdep += custom_target(d[1],
  2428. input: files(d[0]),
  2429. output: d[1],
  2430. capture: true,
  2431. build_by_default: true, # to be removed when added to a target
  2432. command: [hxtool, '-h', '@INPUT0@'])
  2433. endforeach
  2434. genh += hxdep
  2435. ###################
  2436. # Collect sources #
  2437. ###################
  2438. authz_ss = ss.source_set()
  2439. blockdev_ss = ss.source_set()
  2440. block_ss = ss.source_set()
  2441. chardev_ss = ss.source_set()
  2442. common_ss = ss.source_set()
  2443. crypto_ss = ss.source_set()
  2444. hwcore_ss = ss.source_set()
  2445. io_ss = ss.source_set()
  2446. qmp_ss = ss.source_set()
  2447. qom_ss = ss.source_set()
  2448. softmmu_ss = ss.source_set()
  2449. specific_fuzz_ss = ss.source_set()
  2450. specific_ss = ss.source_set()
  2451. stub_ss = ss.source_set()
  2452. trace_ss = ss.source_set()
  2453. user_ss = ss.source_set()
  2454. util_ss = ss.source_set()
  2455. # accel modules
  2456. qtest_module_ss = ss.source_set()
  2457. tcg_module_ss = ss.source_set()
  2458. modules = {}
  2459. target_modules = {}
  2460. hw_arch = {}
  2461. target_arch = {}
  2462. target_softmmu_arch = {}
  2463. target_user_arch = {}
  2464. ###############
  2465. # Trace files #
  2466. ###############
  2467. # TODO: add each directory to the subdirs from its own meson.build, once
  2468. # we have those
  2469. trace_events_subdirs = [
  2470. 'crypto',
  2471. 'qapi',
  2472. 'qom',
  2473. 'monitor',
  2474. 'util',
  2475. ]
  2476. if have_linux_user
  2477. trace_events_subdirs += [ 'linux-user' ]
  2478. endif
  2479. if have_bsd_user
  2480. trace_events_subdirs += [ 'bsd-user' ]
  2481. endif
  2482. if have_block
  2483. trace_events_subdirs += [
  2484. 'authz',
  2485. 'block',
  2486. 'io',
  2487. 'nbd',
  2488. 'scsi',
  2489. ]
  2490. endif
  2491. if have_system
  2492. trace_events_subdirs += [
  2493. 'accel/kvm',
  2494. 'audio',
  2495. 'backends',
  2496. 'backends/tpm',
  2497. 'chardev',
  2498. 'ebpf',
  2499. 'hw/9pfs',
  2500. 'hw/acpi',
  2501. 'hw/adc',
  2502. 'hw/alpha',
  2503. 'hw/arm',
  2504. 'hw/audio',
  2505. 'hw/block',
  2506. 'hw/block/dataplane',
  2507. 'hw/char',
  2508. 'hw/display',
  2509. 'hw/dma',
  2510. 'hw/hppa',
  2511. 'hw/hyperv',
  2512. 'hw/i2c',
  2513. 'hw/i386',
  2514. 'hw/i386/xen',
  2515. 'hw/ide',
  2516. 'hw/input',
  2517. 'hw/intc',
  2518. 'hw/isa',
  2519. 'hw/mem',
  2520. 'hw/mips',
  2521. 'hw/misc',
  2522. 'hw/misc/macio',
  2523. 'hw/net',
  2524. 'hw/net/can',
  2525. 'hw/nubus',
  2526. 'hw/nvme',
  2527. 'hw/nvram',
  2528. 'hw/pci',
  2529. 'hw/pci-host',
  2530. 'hw/ppc',
  2531. 'hw/rdma',
  2532. 'hw/rdma/vmw',
  2533. 'hw/rtc',
  2534. 'hw/s390x',
  2535. 'hw/scsi',
  2536. 'hw/sd',
  2537. 'hw/sh4',
  2538. 'hw/sparc',
  2539. 'hw/sparc64',
  2540. 'hw/ssi',
  2541. 'hw/timer',
  2542. 'hw/tpm',
  2543. 'hw/usb',
  2544. 'hw/vfio',
  2545. 'hw/virtio',
  2546. 'hw/watchdog',
  2547. 'hw/xen',
  2548. 'hw/gpio',
  2549. 'migration',
  2550. 'net',
  2551. 'softmmu',
  2552. 'ui',
  2553. 'hw/remote',
  2554. ]
  2555. endif
  2556. if have_system or have_user
  2557. trace_events_subdirs += [
  2558. 'accel/tcg',
  2559. 'hw/core',
  2560. 'target/arm',
  2561. 'target/arm/hvf',
  2562. 'target/hppa',
  2563. 'target/i386',
  2564. 'target/i386/kvm',
  2565. 'target/mips/tcg',
  2566. 'target/nios2',
  2567. 'target/ppc',
  2568. 'target/riscv',
  2569. 'target/s390x',
  2570. 'target/s390x/kvm',
  2571. 'target/sparc',
  2572. ]
  2573. endif
  2574. vhost_user = not_found
  2575. if targetos == 'linux' and 'CONFIG_VHOST_USER' in config_host
  2576. libvhost_user = subproject('libvhost-user')
  2577. vhost_user = libvhost_user.get_variable('vhost_user_dep')
  2578. endif
  2579. # NOTE: the trace/ subdirectory needs the qapi_trace_events variable
  2580. # that is filled in by qapi/.
  2581. subdir('qapi')
  2582. subdir('qobject')
  2583. subdir('stubs')
  2584. subdir('trace')
  2585. subdir('util')
  2586. subdir('qom')
  2587. subdir('authz')
  2588. subdir('crypto')
  2589. subdir('ui')
  2590. if enable_modules
  2591. libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
  2592. modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
  2593. endif
  2594. stub_ss = stub_ss.apply(config_all, strict: false)
  2595. util_ss.add_all(trace_ss)
  2596. util_ss = util_ss.apply(config_all, strict: false)
  2597. libqemuutil = static_library('qemuutil',
  2598. sources: util_ss.sources() + stub_ss.sources() + genh,
  2599. dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, pixman])
  2600. qemuutil = declare_dependency(link_with: libqemuutil,
  2601. sources: genh + version_res)
  2602. if have_system or have_user
  2603. decodetree = generator(find_program('scripts/decodetree.py'),
  2604. output: 'decode-@BASENAME@.c.inc',
  2605. arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
  2606. subdir('libdecnumber')
  2607. subdir('target')
  2608. endif
  2609. subdir('audio')
  2610. subdir('io')
  2611. subdir('chardev')
  2612. subdir('fsdev')
  2613. subdir('dump')
  2614. if have_block
  2615. block_ss.add(files(
  2616. 'block.c',
  2617. 'blockjob.c',
  2618. 'job.c',
  2619. 'qemu-io-cmds.c',
  2620. ))
  2621. if config_host_data.get('CONFIG_REPLICATION')
  2622. block_ss.add(files('replication.c'))
  2623. endif
  2624. subdir('nbd')
  2625. subdir('scsi')
  2626. subdir('block')
  2627. blockdev_ss.add(files(
  2628. 'blockdev.c',
  2629. 'blockdev-nbd.c',
  2630. 'iothread.c',
  2631. 'job-qmp.c',
  2632. ), gnutls)
  2633. # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
  2634. # os-win32.c does not
  2635. blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
  2636. softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
  2637. endif
  2638. common_ss.add(files('cpus-common.c'))
  2639. subdir('softmmu')
  2640. common_ss.add(capstone)
  2641. specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)
  2642. # Work around a gcc bug/misfeature wherein constant propagation looks
  2643. # through an alias:
  2644. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99696
  2645. # to guess that a const variable is always zero. Without lto, this is
  2646. # impossible, as the alias is restricted to page-vary-common.c. Indeed,
  2647. # without lto, not even the alias is required -- we simply use different
  2648. # declarations in different compilation units.
  2649. pagevary = files('page-vary-common.c')
  2650. if get_option('b_lto')
  2651. pagevary_flags = ['-fno-lto']
  2652. if get_option('cfi')
  2653. pagevary_flags += '-fno-sanitize=cfi-icall'
  2654. endif
  2655. pagevary = static_library('page-vary-common', sources: pagevary + genh,
  2656. c_args: pagevary_flags)
  2657. pagevary = declare_dependency(link_with: pagevary)
  2658. endif
  2659. common_ss.add(pagevary)
  2660. specific_ss.add(files('page-vary.c'))
  2661. subdir('backends')
  2662. subdir('disas')
  2663. subdir('migration')
  2664. subdir('monitor')
  2665. subdir('net')
  2666. subdir('replay')
  2667. subdir('semihosting')
  2668. subdir('hw')
  2669. subdir('tcg')
  2670. subdir('fpu')
  2671. subdir('accel')
  2672. subdir('plugins')
  2673. subdir('ebpf')
  2674. common_user_inc = []
  2675. subdir('common-user')
  2676. subdir('bsd-user')
  2677. subdir('linux-user')
  2678. # needed for fuzzing binaries
  2679. subdir('tests/qtest/libqos')
  2680. subdir('tests/qtest/fuzz')
  2681. # accel modules
  2682. tcg_real_module_ss = ss.source_set()
  2683. tcg_real_module_ss.add_all(when: 'CONFIG_TCG_MODULAR', if_true: tcg_module_ss)
  2684. specific_ss.add_all(when: 'CONFIG_TCG_BUILTIN', if_true: tcg_module_ss)
  2685. target_modules += { 'accel' : { 'qtest': qtest_module_ss,
  2686. 'tcg': tcg_real_module_ss }}
  2687. ########################
  2688. # Library dependencies #
  2689. ########################
  2690. modinfo_collect = find_program('scripts/modinfo-collect.py')
  2691. modinfo_generate = find_program('scripts/modinfo-generate.py')
  2692. modinfo_files = []
  2693. block_mods = []
  2694. softmmu_mods = []
  2695. foreach d, list : modules
  2696. foreach m, module_ss : list
  2697. if enable_modules and targetos != 'windows'
  2698. module_ss = module_ss.apply(config_all, strict: false)
  2699. sl = static_library(d + '-' + m, [genh, module_ss.sources()],
  2700. dependencies: [modulecommon, module_ss.dependencies()], pic: true)
  2701. if d == 'block'
  2702. block_mods += sl
  2703. else
  2704. softmmu_mods += sl
  2705. endif
  2706. if module_ss.sources() != []
  2707. # FIXME: Should use sl.extract_all_objects(recursive: true) as
  2708. # input. Sources can be used multiple times but objects are
  2709. # unique when it comes to lookup in compile_commands.json.
  2710. # Depnds on a mesion version with
  2711. # https://github.com/mesonbuild/meson/pull/8900
  2712. modinfo_files += custom_target(d + '-' + m + '.modinfo',
  2713. output: d + '-' + m + '.modinfo',
  2714. input: module_ss.sources() + genh,
  2715. capture: true,
  2716. command: [modinfo_collect, module_ss.sources()])
  2717. endif
  2718. else
  2719. if d == 'block'
  2720. block_ss.add_all(module_ss)
  2721. else
  2722. softmmu_ss.add_all(module_ss)
  2723. endif
  2724. endif
  2725. endforeach
  2726. endforeach
  2727. foreach d, list : target_modules
  2728. foreach m, module_ss : list
  2729. if enable_modules and targetos != 'windows'
  2730. foreach target : target_dirs
  2731. if target.endswith('-softmmu')
  2732. config_target = config_target_mak[target]
  2733. config_target += config_host
  2734. target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
  2735. c_args = ['-DNEED_CPU_H',
  2736. '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
  2737. '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
  2738. target_module_ss = module_ss.apply(config_target, strict: false)
  2739. if target_module_ss.sources() != []
  2740. module_name = d + '-' + m + '-' + config_target['TARGET_NAME']
  2741. sl = static_library(module_name,
  2742. [genh, target_module_ss.sources()],
  2743. dependencies: [modulecommon, target_module_ss.dependencies()],
  2744. include_directories: target_inc,
  2745. c_args: c_args,
  2746. pic: true)
  2747. softmmu_mods += sl
  2748. # FIXME: Should use sl.extract_all_objects(recursive: true) too.
  2749. modinfo_files += custom_target(module_name + '.modinfo',
  2750. output: module_name + '.modinfo',
  2751. input: target_module_ss.sources() + genh,
  2752. capture: true,
  2753. command: [modinfo_collect, '--target', target, target_module_ss.sources()])
  2754. endif
  2755. endif
  2756. endforeach
  2757. else
  2758. specific_ss.add_all(module_ss)
  2759. endif
  2760. endforeach
  2761. endforeach
  2762. if enable_modules
  2763. modinfo_src = custom_target('modinfo.c',
  2764. output: 'modinfo.c',
  2765. input: modinfo_files,
  2766. command: [modinfo_generate, '@INPUT@'],
  2767. capture: true)
  2768. modinfo_lib = static_library('modinfo', modinfo_src)
  2769. modinfo_dep = declare_dependency(link_whole: modinfo_lib)
  2770. softmmu_ss.add(modinfo_dep)
  2771. endif
  2772. nm = find_program('nm')
  2773. undefsym = find_program('scripts/undefsym.py')
  2774. block_syms = custom_target('block.syms', output: 'block.syms',
  2775. input: [libqemuutil, block_mods],
  2776. capture: true,
  2777. command: [undefsym, nm, '@INPUT@'])
  2778. qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
  2779. input: [libqemuutil, softmmu_mods],
  2780. capture: true,
  2781. command: [undefsym, nm, '@INPUT@'])
  2782. qom_ss = qom_ss.apply(config_host, strict: false)
  2783. libqom = static_library('qom', qom_ss.sources() + genh,
  2784. dependencies: [qom_ss.dependencies()],
  2785. name_suffix: 'fa')
  2786. qom = declare_dependency(link_whole: libqom)
  2787. authz_ss = authz_ss.apply(config_host, strict: false)
  2788. libauthz = static_library('authz', authz_ss.sources() + genh,
  2789. dependencies: [authz_ss.dependencies()],
  2790. name_suffix: 'fa',
  2791. build_by_default: false)
  2792. authz = declare_dependency(link_whole: libauthz,
  2793. dependencies: qom)
  2794. crypto_ss = crypto_ss.apply(config_host, strict: false)
  2795. libcrypto = static_library('crypto', crypto_ss.sources() + genh,
  2796. dependencies: [crypto_ss.dependencies()],
  2797. name_suffix: 'fa',
  2798. build_by_default: false)
  2799. crypto = declare_dependency(link_whole: libcrypto,
  2800. dependencies: [authz, qom])
  2801. io_ss = io_ss.apply(config_host, strict: false)
  2802. libio = static_library('io', io_ss.sources() + genh,
  2803. dependencies: [io_ss.dependencies()],
  2804. link_with: libqemuutil,
  2805. name_suffix: 'fa',
  2806. build_by_default: false)
  2807. io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])
  2808. libmigration = static_library('migration', sources: migration_files + genh,
  2809. name_suffix: 'fa',
  2810. build_by_default: false)
  2811. migration = declare_dependency(link_with: libmigration,
  2812. dependencies: [zlib, qom, io])
  2813. softmmu_ss.add(migration)
  2814. block_ss = block_ss.apply(config_host, strict: false)
  2815. libblock = static_library('block', block_ss.sources() + genh,
  2816. dependencies: block_ss.dependencies(),
  2817. link_depends: block_syms,
  2818. name_suffix: 'fa',
  2819. build_by_default: false)
  2820. block = declare_dependency(link_whole: [libblock],
  2821. link_args: '@block.syms',
  2822. dependencies: [crypto, io])
  2823. blockdev_ss = blockdev_ss.apply(config_host, strict: false)
  2824. libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
  2825. dependencies: blockdev_ss.dependencies(),
  2826. name_suffix: 'fa',
  2827. build_by_default: false)
  2828. blockdev = declare_dependency(link_whole: [libblockdev],
  2829. dependencies: [block])
  2830. qmp_ss = qmp_ss.apply(config_host, strict: false)
  2831. libqmp = static_library('qmp', qmp_ss.sources() + genh,
  2832. dependencies: qmp_ss.dependencies(),
  2833. name_suffix: 'fa',
  2834. build_by_default: false)
  2835. qmp = declare_dependency(link_whole: [libqmp])
  2836. libchardev = static_library('chardev', chardev_ss.sources() + genh,
  2837. name_suffix: 'fa',
  2838. dependencies: chardev_ss.dependencies(),
  2839. build_by_default: false)
  2840. chardev = declare_dependency(link_whole: libchardev)
  2841. hwcore_ss = hwcore_ss.apply(config_host, strict: false)
  2842. libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
  2843. name_suffix: 'fa',
  2844. build_by_default: false)
  2845. hwcore = declare_dependency(link_whole: libhwcore)
  2846. common_ss.add(hwcore)
  2847. ###########
  2848. # Targets #
  2849. ###########
  2850. emulator_modules = []
  2851. foreach m : block_mods + softmmu_mods
  2852. emulator_modules += shared_module(m.name(),
  2853. build_by_default: true,
  2854. name_prefix: '',
  2855. link_whole: m,
  2856. install: true,
  2857. install_dir: qemu_moddir)
  2858. endforeach
  2859. softmmu_ss.add(authz, blockdev, chardev, crypto, io, qmp)
  2860. common_ss.add(qom, qemuutil)
  2861. common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: [softmmu_ss])
  2862. common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
  2863. common_all = common_ss.apply(config_all, strict: false)
  2864. common_all = static_library('common',
  2865. build_by_default: false,
  2866. sources: common_all.sources() + genh,
  2867. include_directories: common_user_inc,
  2868. implicit_include_directories: false,
  2869. dependencies: common_all.dependencies(),
  2870. name_suffix: 'fa')
  2871. feature_to_c = find_program('scripts/feature_to_c.sh')
  2872. if targetos == 'darwin'
  2873. entitlement = find_program('scripts/entitlement.sh')
  2874. endif
  2875. emulators = {}
  2876. foreach target : target_dirs
  2877. config_target = config_target_mak[target]
  2878. target_name = config_target['TARGET_NAME']
  2879. target_base_arch = config_target['TARGET_BASE_ARCH']
  2880. arch_srcs = [config_target_h[target]]
  2881. arch_deps = []
  2882. c_args = ['-DNEED_CPU_H',
  2883. '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
  2884. '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
  2885. link_args = emulator_link_args
  2886. config_target += config_host
  2887. target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
  2888. if targetos == 'linux'
  2889. target_inc += include_directories('linux-headers', is_system: true)
  2890. endif
  2891. if target.endswith('-softmmu')
  2892. qemu_target_name = 'qemu-system-' + target_name
  2893. target_type='system'
  2894. t = target_softmmu_arch[target_base_arch].apply(config_target, strict: false)
  2895. arch_srcs += t.sources()
  2896. arch_deps += t.dependencies()
  2897. hw_dir = target_name == 'sparc64' ? 'sparc64' : target_base_arch
  2898. hw = hw_arch[hw_dir].apply(config_target, strict: false)
  2899. arch_srcs += hw.sources()
  2900. arch_deps += hw.dependencies()
  2901. arch_srcs += config_devices_h[target]
  2902. link_args += ['@block.syms', '@qemu.syms']
  2903. else
  2904. abi = config_target['TARGET_ABI_DIR']
  2905. target_type='user'
  2906. target_inc += common_user_inc
  2907. qemu_target_name = 'qemu-' + target_name
  2908. if target_base_arch in target_user_arch
  2909. t = target_user_arch[target_base_arch].apply(config_target, strict: false)
  2910. arch_srcs += t.sources()
  2911. arch_deps += t.dependencies()
  2912. endif
  2913. if 'CONFIG_LINUX_USER' in config_target
  2914. base_dir = 'linux-user'
  2915. endif
  2916. if 'CONFIG_BSD_USER' in config_target
  2917. base_dir = 'bsd-user'
  2918. target_inc += include_directories('bsd-user/' / targetos)
  2919. target_inc += include_directories('bsd-user/host/' / host_arch)
  2920. dir = base_dir / abi
  2921. arch_srcs += files(dir / 'signal.c', dir / 'target_arch_cpu.c')
  2922. endif
  2923. target_inc += include_directories(
  2924. base_dir,
  2925. base_dir / abi,
  2926. )
  2927. if 'CONFIG_LINUX_USER' in config_target
  2928. dir = base_dir / abi
  2929. arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
  2930. if config_target.has_key('TARGET_SYSTBL_ABI')
  2931. arch_srcs += \
  2932. syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
  2933. extra_args : config_target['TARGET_SYSTBL_ABI'])
  2934. endif
  2935. endif
  2936. endif
  2937. if 'TARGET_XML_FILES' in config_target
  2938. gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
  2939. output: target + '-gdbstub-xml.c',
  2940. input: files(config_target['TARGET_XML_FILES'].split()),
  2941. command: [feature_to_c, '@INPUT@'],
  2942. capture: true)
  2943. arch_srcs += gdbstub_xml
  2944. endif
  2945. t = target_arch[target_base_arch].apply(config_target, strict: false)
  2946. arch_srcs += t.sources()
  2947. arch_deps += t.dependencies()
  2948. target_common = common_ss.apply(config_target, strict: false)
  2949. objects = common_all.extract_objects(target_common.sources())
  2950. deps = target_common.dependencies()
  2951. target_specific = specific_ss.apply(config_target, strict: false)
  2952. arch_srcs += target_specific.sources()
  2953. arch_deps += target_specific.dependencies()
  2954. lib = static_library('qemu-' + target,
  2955. sources: arch_srcs + genh,
  2956. dependencies: arch_deps,
  2957. objects: objects,
  2958. include_directories: target_inc,
  2959. c_args: c_args,
  2960. build_by_default: false,
  2961. name_suffix: 'fa')
  2962. if target.endswith('-softmmu')
  2963. execs = [{
  2964. 'name': 'qemu-system-' + target_name,
  2965. 'win_subsystem': 'console',
  2966. 'sources': files('softmmu/main.c'),
  2967. 'dependencies': []
  2968. }]
  2969. if targetos == 'windows' and (sdl.found() or gtk.found())
  2970. execs += [{
  2971. 'name': 'qemu-system-' + target_name + 'w',
  2972. 'win_subsystem': 'windows',
  2973. 'sources': files('softmmu/main.c'),
  2974. 'dependencies': []
  2975. }]
  2976. endif
  2977. if get_option('fuzzing')
  2978. specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
  2979. execs += [{
  2980. 'name': 'qemu-fuzz-' + target_name,
  2981. 'win_subsystem': 'console',
  2982. 'sources': specific_fuzz.sources(),
  2983. 'dependencies': specific_fuzz.dependencies(),
  2984. }]
  2985. endif
  2986. else
  2987. execs = [{
  2988. 'name': 'qemu-' + target_name,
  2989. 'win_subsystem': 'console',
  2990. 'sources': [],
  2991. 'dependencies': []
  2992. }]
  2993. endif
  2994. foreach exe: execs
  2995. exe_name = exe['name']
  2996. if targetos == 'darwin'
  2997. exe_name += '-unsigned'
  2998. endif
  2999. emulator = executable(exe_name, exe['sources'],
  3000. install: true,
  3001. c_args: c_args,
  3002. dependencies: arch_deps + deps + exe['dependencies'],
  3003. objects: lib.extract_all_objects(recursive: true),
  3004. link_language: link_language,
  3005. link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
  3006. link_args: link_args,
  3007. win_subsystem: exe['win_subsystem'])
  3008. if targetos == 'darwin'
  3009. icon = 'pc-bios/qemu.rsrc'
  3010. build_input = [emulator, files(icon)]
  3011. install_input = [
  3012. get_option('bindir') / exe_name,
  3013. meson.current_source_dir() / icon
  3014. ]
  3015. if 'CONFIG_HVF' in config_target
  3016. entitlements = 'accel/hvf/entitlements.plist'
  3017. build_input += files(entitlements)
  3018. install_input += meson.current_source_dir() / entitlements
  3019. endif
  3020. emulators += {exe['name'] : custom_target(exe['name'],
  3021. input: build_input,
  3022. output: exe['name'],
  3023. command: [entitlement, '@OUTPUT@', '@INPUT@'])
  3024. }
  3025. meson.add_install_script(entitlement, '--install',
  3026. get_option('bindir') / exe['name'],
  3027. install_input)
  3028. else
  3029. emulators += {exe['name']: emulator}
  3030. endif
  3031. if stap.found()
  3032. foreach stp: [
  3033. {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
  3034. {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
  3035. {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
  3036. {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
  3037. ]
  3038. custom_target(exe['name'] + stp['ext'],
  3039. input: trace_events_all,
  3040. output: exe['name'] + stp['ext'],
  3041. install: stp['install'],
  3042. install_dir: get_option('datadir') / 'systemtap/tapset',
  3043. command: [
  3044. tracetool, '--group=all', '--format=' + stp['fmt'],
  3045. '--binary=' + stp['bin'],
  3046. '--target-name=' + target_name,
  3047. '--target-type=' + target_type,
  3048. '--probe-prefix=qemu.' + target_type + '.' + target_name,
  3049. '@INPUT@', '@OUTPUT@'
  3050. ],
  3051. depend_files: tracetool_depends)
  3052. endforeach
  3053. endif
  3054. endforeach
  3055. endforeach
  3056. # Other build targets
  3057. if 'CONFIG_PLUGIN' in config_host
  3058. install_headers('include/qemu/qemu-plugin.h')
  3059. endif
  3060. subdir('qga')
  3061. # Don't build qemu-keymap if xkbcommon is not explicitly enabled
  3062. # when we don't build tools or system
  3063. if xkbcommon.found()
  3064. # used for the update-keymaps target, so include rules even if !have_tools
  3065. qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
  3066. dependencies: [qemuutil, xkbcommon], install: have_tools)
  3067. endif
  3068. if have_tools
  3069. qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
  3070. dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
  3071. qemu_io = executable('qemu-io', files('qemu-io.c'),
  3072. dependencies: [block, qemuutil], install: true)
  3073. qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
  3074. dependencies: [blockdev, qemuutil, gnutls, selinux],
  3075. install: true)
  3076. subdir('storage-daemon')
  3077. subdir('contrib/rdmacm-mux')
  3078. subdir('contrib/elf2dmp')
  3079. executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
  3080. dependencies: qemuutil,
  3081. install: true)
  3082. if 'CONFIG_VHOST_USER' in config_host
  3083. subdir('contrib/vhost-user-blk')
  3084. subdir('contrib/vhost-user-gpu')
  3085. subdir('contrib/vhost-user-input')
  3086. subdir('contrib/vhost-user-scsi')
  3087. endif
  3088. if targetos == 'linux'
  3089. executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
  3090. dependencies: [qemuutil, libcap_ng],
  3091. install: true,
  3092. install_dir: get_option('libexecdir'))
  3093. executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
  3094. dependencies: [authz, crypto, io, qom, qemuutil,
  3095. libcap_ng, mpathpersist],
  3096. install: true)
  3097. endif
  3098. if have_ivshmem
  3099. subdir('contrib/ivshmem-client')
  3100. subdir('contrib/ivshmem-server')
  3101. endif
  3102. endif
  3103. subdir('scripts')
  3104. subdir('tools')
  3105. subdir('pc-bios')
  3106. subdir('docs')
  3107. subdir('tests')
  3108. if gtk.found()
  3109. subdir('po')
  3110. endif
  3111. if host_machine.system() == 'windows'
  3112. nsis_cmd = [
  3113. find_program('scripts/nsis.py'),
  3114. '@OUTPUT@',
  3115. get_option('prefix'),
  3116. meson.current_source_dir(),
  3117. host_machine.cpu(),
  3118. '--',
  3119. '-DDISPLAYVERSION=' + meson.project_version(),
  3120. ]
  3121. if build_docs
  3122. nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
  3123. endif
  3124. if gtk.found()
  3125. nsis_cmd += '-DCONFIG_GTK=y'
  3126. endif
  3127. nsis = custom_target('nsis',
  3128. output: 'qemu-setup-' + meson.project_version() + '.exe',
  3129. input: files('qemu.nsi'),
  3130. build_always_stale: true,
  3131. command: nsis_cmd + ['@INPUT@'])
  3132. alias_target('installer', nsis)
  3133. endif
  3134. #########################
  3135. # Configuration summary #
  3136. #########################
  3137. # Directories
  3138. summary_info = {}
  3139. summary_info += {'Install prefix': get_option('prefix')}
  3140. summary_info += {'BIOS directory': qemu_datadir}
  3141. summary_info += {'firmware path': get_option('qemu_firmwarepath')}
  3142. summary_info += {'binary directory': get_option('bindir')}
  3143. summary_info += {'library directory': get_option('libdir')}
  3144. summary_info += {'module directory': qemu_moddir}
  3145. summary_info += {'libexec directory': get_option('libexecdir')}
  3146. summary_info += {'include directory': get_option('includedir')}
  3147. summary_info += {'config directory': get_option('sysconfdir')}
  3148. if targetos != 'windows'
  3149. summary_info += {'local state directory': get_option('localstatedir')}
  3150. summary_info += {'Manual directory': get_option('mandir')}
  3151. else
  3152. summary_info += {'local state directory': 'queried at runtime'}
  3153. endif
  3154. summary_info += {'Doc directory': get_option('docdir')}
  3155. summary_info += {'Build directory': meson.current_build_dir()}
  3156. summary_info += {'Source path': meson.current_source_dir()}
  3157. summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
  3158. summary(summary_info, bool_yn: true, section: 'Directories')
  3159. # Host binaries
  3160. summary_info = {}
  3161. summary_info += {'git': config_host['GIT']}
  3162. summary_info += {'make': config_host['MAKE']}
  3163. summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
  3164. summary_info += {'sphinx-build': sphinx_build}
  3165. if config_host.has_key('HAVE_GDB_BIN')
  3166. summary_info += {'gdb': config_host['HAVE_GDB_BIN']}
  3167. endif
  3168. if get_option('iasl') != ''
  3169. summary_info += {'iasl': get_option('iasl')}
  3170. else
  3171. summary_info += {'iasl': false}
  3172. endif
  3173. summary_info += {'genisoimage': config_host['GENISOIMAGE']}
  3174. if targetos == 'windows' and have_ga
  3175. summary_info += {'wixl': wixl}
  3176. endif
  3177. if slirp_opt != 'disabled' and have_system
  3178. summary_info += {'smbd': have_slirp_smbd ? smbd_path : false}
  3179. endif
  3180. summary(summary_info, bool_yn: true, section: 'Host binaries')
  3181. # Configurable features
  3182. summary_info = {}
  3183. summary_info += {'Documentation': build_docs}
  3184. summary_info += {'system-mode emulation': have_system}
  3185. summary_info += {'user-mode emulation': have_user}
  3186. summary_info += {'block layer': have_block}
  3187. summary_info += {'Install blobs': get_option('install_blobs')}
  3188. summary_info += {'module support': config_host.has_key('CONFIG_MODULES')}
  3189. if config_host.has_key('CONFIG_MODULES')
  3190. summary_info += {'alternative module path': config_host.has_key('CONFIG_MODULE_UPGRADES')}
  3191. endif
  3192. summary_info += {'fuzzing support': get_option('fuzzing')}
  3193. if have_system
  3194. summary_info += {'Audio drivers': ' '.join(audio_drivers_selected)}
  3195. endif
  3196. summary_info += {'Trace backends': ','.join(get_option('trace_backends'))}
  3197. if 'simple' in get_option('trace_backends')
  3198. summary_info += {'Trace output file': get_option('trace_file') + '-<pid>'}
  3199. endif
  3200. summary_info += {'D-Bus display': dbus_display}
  3201. summary_info += {'QOM debugging': get_option('qom_cast_debug')}
  3202. summary_info += {'vhost-kernel support': config_host.has_key('CONFIG_VHOST_KERNEL')}
  3203. summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
  3204. summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
  3205. summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
  3206. summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
  3207. summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')}
  3208. summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server}
  3209. summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
  3210. summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
  3211. summary_info += {'build guest agent': have_ga}
  3212. summary(summary_info, bool_yn: true, section: 'Configurable features')
  3213. # Compilation information
  3214. summary_info = {}
  3215. summary_info += {'host CPU': cpu}
  3216. summary_info += {'host endianness': build_machine.endian()}
  3217. summary_info += {'C compiler': ' '.join(meson.get_compiler('c').cmd_array())}
  3218. summary_info += {'Host C compiler': ' '.join(meson.get_compiler('c', native: true).cmd_array())}
  3219. if link_language == 'cpp'
  3220. summary_info += {'C++ compiler': ' '.join(meson.get_compiler('cpp').cmd_array())}
  3221. else
  3222. summary_info += {'C++ compiler': false}
  3223. endif
  3224. if targetos == 'darwin'
  3225. summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
  3226. endif
  3227. summary_info += {'CFLAGS': ' '.join(get_option('c_args')
  3228. + ['-O' + get_option('optimization')]
  3229. + (get_option('debug') ? ['-g'] : []))}
  3230. if link_language == 'cpp'
  3231. summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args')
  3232. + ['-O' + get_option('optimization')]
  3233. + (get_option('debug') ? ['-g'] : []))}
  3234. endif
  3235. if targetos == 'darwin'
  3236. summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args')
  3237. + ['-O' + get_option('optimization')]
  3238. + (get_option('debug') ? ['-g'] : []))}
  3239. endif
  3240. link_args = get_option(link_language + '_link_args')
  3241. if link_args.length() > 0
  3242. summary_info += {'LDFLAGS': ' '.join(link_args)}
  3243. endif
  3244. summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}
  3245. summary_info += {'QEMU_CXXFLAGS': config_host['QEMU_CXXFLAGS']}
  3246. summary_info += {'QEMU_OBJCFLAGS': config_host['QEMU_OBJCFLAGS']}
  3247. summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']}
  3248. summary_info += {'profiler': get_option('profiler')}
  3249. summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
  3250. summary_info += {'PIE': get_option('b_pie')}
  3251. summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
  3252. summary_info += {'malloc trim support': has_malloc_trim}
  3253. summary_info += {'membarrier': have_membarrier}
  3254. summary_info += {'debug stack usage': get_option('debug_stack_usage')}
  3255. summary_info += {'mutex debugging': get_option('debug_mutex')}
  3256. summary_info += {'memory allocator': get_option('malloc')}
  3257. summary_info += {'avx2 optimization': config_host_data.get('CONFIG_AVX2_OPT')}
  3258. summary_info += {'avx512f optimization': config_host_data.get('CONFIG_AVX512F_OPT')}
  3259. summary_info += {'gprof enabled': get_option('gprof')}
  3260. summary_info += {'gcov': get_option('b_coverage')}
  3261. summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
  3262. summary_info += {'CFI support': get_option('cfi')}
  3263. if get_option('cfi')
  3264. summary_info += {'CFI debug support': get_option('cfi_debug')}
  3265. endif
  3266. summary_info += {'strip binaries': get_option('strip')}
  3267. summary_info += {'sparse': sparse}
  3268. summary_info += {'mingw32 support': targetos == 'windows'}
  3269. # snarf the cross-compilation information for tests
  3270. foreach target: target_dirs
  3271. tcg_mak = meson.current_build_dir() / 'tests/tcg' / 'config-' + target + '.mak'
  3272. if fs.exists(tcg_mak)
  3273. config_cross_tcg = keyval.load(tcg_mak)
  3274. target = config_cross_tcg['TARGET_NAME']
  3275. compiler = ''
  3276. if 'DOCKER_CROSS_CC_GUEST' in config_cross_tcg
  3277. summary_info += {target + ' tests': config_cross_tcg['DOCKER_CROSS_CC_GUEST'] +
  3278. ' via ' + config_cross_tcg['DOCKER_IMAGE']}
  3279. elif 'CROSS_CC_GUEST' in config_cross_tcg
  3280. summary_info += {target + ' tests'
  3281. : config_cross_tcg['CROSS_CC_GUEST'] }
  3282. endif
  3283. endif
  3284. endforeach
  3285. summary(summary_info, bool_yn: true, section: 'Compilation')
  3286. # Targets and accelerators
  3287. summary_info = {}
  3288. if have_system
  3289. summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
  3290. summary_info += {'HAX support': config_all.has_key('CONFIG_HAX')}
  3291. summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
  3292. summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
  3293. summary_info += {'NVMM support': config_all.has_key('CONFIG_NVMM')}
  3294. summary_info += {'Xen support': config_host.has_key('CONFIG_XEN_BACKEND')}
  3295. if config_host.has_key('CONFIG_XEN_BACKEND')
  3296. summary_info += {'xen ctrl version': config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
  3297. endif
  3298. endif
  3299. summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
  3300. if config_all.has_key('CONFIG_TCG')
  3301. if get_option('tcg_interpreter')
  3302. summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, slow)'}
  3303. else
  3304. summary_info += {'TCG backend': 'native (@0@)'.format(cpu)}
  3305. endif
  3306. summary_info += {'TCG plugins': config_host.has_key('CONFIG_PLUGIN')}
  3307. summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')}
  3308. endif
  3309. summary_info += {'target list': ' '.join(target_dirs)}
  3310. if have_system
  3311. summary_info += {'default devices': get_option('default_devices')}
  3312. summary_info += {'out of process emulation': multiprocess_allowed}
  3313. endif
  3314. summary(summary_info, bool_yn: true, section: 'Targets and accelerators')
  3315. # Block layer
  3316. summary_info = {}
  3317. summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
  3318. summary_info += {'coroutine pool': have_coroutine_pool}
  3319. if have_block
  3320. summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
  3321. summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
  3322. summary_info += {'Use block whitelist in tools': get_option('block_drv_whitelist_in_tools')}
  3323. summary_info += {'VirtFS support': have_virtfs}
  3324. summary_info += {'build virtiofs daemon': have_virtiofsd}
  3325. summary_info += {'Live block migration': config_host_data.get('CONFIG_LIVE_BLOCK_MIGRATION')}
  3326. summary_info += {'replication support': config_host_data.get('CONFIG_REPLICATION')}
  3327. summary_info += {'bochs support': get_option('bochs').allowed()}
  3328. summary_info += {'cloop support': get_option('cloop').allowed()}
  3329. summary_info += {'dmg support': get_option('dmg').allowed()}
  3330. summary_info += {'qcow v1 support': get_option('qcow1').allowed()}
  3331. summary_info += {'vdi support': get_option('vdi').allowed()}
  3332. summary_info += {'vvfat support': get_option('vvfat').allowed()}
  3333. summary_info += {'qed support': get_option('qed').allowed()}
  3334. summary_info += {'parallels support': get_option('parallels').allowed()}
  3335. summary_info += {'FUSE exports': fuse}
  3336. endif
  3337. summary(summary_info, bool_yn: true, section: 'Block layer support')
  3338. # Crypto
  3339. summary_info = {}
  3340. summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
  3341. summary_info += {'GNUTLS support': gnutls}
  3342. if gnutls.found()
  3343. summary_info += {' GNUTLS crypto': gnutls_crypto.found()}
  3344. endif
  3345. summary_info += {'libgcrypt': gcrypt}
  3346. summary_info += {'nettle': nettle}
  3347. if nettle.found()
  3348. summary_info += {' XTS': xts != 'private'}
  3349. endif
  3350. summary_info += {'AF_ALG support': have_afalg}
  3351. summary_info += {'rng-none': get_option('rng_none')}
  3352. summary_info += {'Linux keyring': config_host.has_key('CONFIG_SECRET_KEYRING')}
  3353. summary(summary_info, bool_yn: true, section: 'Crypto')
  3354. # Libraries
  3355. summary_info = {}
  3356. if targetos == 'darwin'
  3357. summary_info += {'Cocoa support': cocoa}
  3358. endif
  3359. summary_info += {'SDL support': sdl}
  3360. summary_info += {'SDL image support': sdl_image}
  3361. summary_info += {'GTK support': gtk}
  3362. summary_info += {'pixman': pixman}
  3363. summary_info += {'VTE support': vte}
  3364. summary_info += {'slirp support': slirp_opt == 'internal' ? slirp_opt : slirp}
  3365. summary_info += {'libtasn1': tasn1}
  3366. summary_info += {'PAM': pam}
  3367. summary_info += {'iconv support': iconv}
  3368. summary_info += {'curses support': curses}
  3369. summary_info += {'virgl support': virgl}
  3370. summary_info += {'curl support': curl}
  3371. summary_info += {'Multipath support': mpathpersist}
  3372. summary_info += {'VNC support': vnc}
  3373. if vnc.found()
  3374. summary_info += {'VNC SASL support': sasl}
  3375. summary_info += {'VNC JPEG support': jpeg}
  3376. summary_info += {'VNC PNG support': png}
  3377. endif
  3378. if targetos not in ['darwin', 'haiku', 'windows']
  3379. summary_info += {'OSS support': oss}
  3380. elif targetos == 'darwin'
  3381. summary_info += {'CoreAudio support': coreaudio}
  3382. elif targetos == 'windows'
  3383. summary_info += {'DirectSound support': dsound}
  3384. endif
  3385. if targetos == 'linux'
  3386. summary_info += {'ALSA support': alsa}
  3387. summary_info += {'PulseAudio support': pulse}
  3388. endif
  3389. summary_info += {'JACK support': jack}
  3390. summary_info += {'brlapi support': brlapi}
  3391. summary_info += {'vde support': vde}
  3392. summary_info += {'netmap support': have_netmap}
  3393. summary_info += {'l2tpv3 support': have_l2tpv3}
  3394. summary_info += {'Linux AIO support': libaio}
  3395. summary_info += {'Linux io_uring support': linux_io_uring}
  3396. summary_info += {'ATTR/XATTR support': libattr}
  3397. summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
  3398. summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
  3399. summary_info += {'fdt support': fdt_opt == 'disabled' ? false : fdt_opt}
  3400. summary_info += {'libcap-ng support': libcap_ng}
  3401. summary_info += {'bpf support': libbpf}
  3402. summary_info += {'spice protocol support': spice_protocol}
  3403. if spice_protocol.found()
  3404. summary_info += {' spice server support': spice}
  3405. endif
  3406. summary_info += {'rbd support': rbd}
  3407. summary_info += {'smartcard support': cacard}
  3408. summary_info += {'U2F support': u2f}
  3409. summary_info += {'libusb': libusb}
  3410. summary_info += {'usb net redir': usbredir}
  3411. summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
  3412. summary_info += {'GBM': gbm}
  3413. summary_info += {'libiscsi support': libiscsi}
  3414. summary_info += {'libnfs support': libnfs}
  3415. if targetos == 'windows'
  3416. if have_ga
  3417. summary_info += {'QGA VSS support': have_qga_vss}
  3418. summary_info += {'QGA w32 disk info': have_ntddscsi}
  3419. endif
  3420. endif
  3421. summary_info += {'seccomp support': seccomp}
  3422. summary_info += {'GlusterFS support': glusterfs}
  3423. summary_info += {'TPM support': have_tpm}
  3424. summary_info += {'libssh support': libssh}
  3425. summary_info += {'lzo support': lzo}
  3426. summary_info += {'snappy support': snappy}
  3427. summary_info += {'bzip2 support': libbzip2}
  3428. summary_info += {'lzfse support': liblzfse}
  3429. summary_info += {'zstd support': zstd}
  3430. summary_info += {'NUMA host support': numa}
  3431. summary_info += {'capstone': capstone_opt == 'internal' ? capstone_opt : capstone}
  3432. summary_info += {'libpmem support': libpmem}
  3433. summary_info += {'libdaxctl support': libdaxctl}
  3434. summary_info += {'libudev': libudev}
  3435. # Dummy dependency, keep .found()
  3436. summary_info += {'FUSE lseek': fuse_lseek.found()}
  3437. summary_info += {'selinux': selinux}
  3438. summary(summary_info, bool_yn: true, section: 'Dependencies')
  3439. if not supported_cpus.contains(cpu)
  3440. message()
  3441. warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
  3442. message()
  3443. message('CPU host architecture ' + cpu + ' support is not currently maintained.')
  3444. message('The QEMU project intends to remove support for this host CPU in')
  3445. message('a future release if nobody volunteers to maintain it and to')
  3446. message('provide a build host for our continuous integration setup.')
  3447. message('configure has succeeded and you can continue to build, but')
  3448. message('if you care about QEMU on this platform you should contact')
  3449. message('us upstream at qemu-devel@nongnu.org.')
  3450. endif
  3451. if not supported_oses.contains(targetos)
  3452. message()
  3453. warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
  3454. message()
  3455. message('Host OS ' + targetos + 'support is not currently maintained.')
  3456. message('The QEMU project intends to remove support for this host OS in')
  3457. message('a future release if nobody volunteers to maintain it and to')
  3458. message('provide a build host for our continuous integration setup.')
  3459. message('configure has succeeded and you can continue to build, but')
  3460. message('if you care about QEMU on this platform you should contact')
  3461. message('us upstream at qemu-devel@nongnu.org.')
  3462. endif