Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

meson.build 58KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839
  1. # Copyright © 2017-2019 Intel Corporation
  2. # Permission is hereby granted, free of charge, to any person obtaining a copy
  3. # of this software and associated documentation files (the "Software"), to deal
  4. # in the Software without restriction, including without limitation the rights
  5. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6. # copies of the Software, and to permit persons to whom the Software is
  7. # furnished to do so, subject to the following conditions:
  8. # The above copyright notice and this permission notice shall be included in
  9. # all copies or substantial portions of the Software.
  10. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  16. # SOFTWARE.
  17. project(
  18. 'mesa',
  19. ['c', 'cpp'],
  20. version : run_command(
  21. [find_program('python', 'python2', 'python3'), 'bin/meson_get_version.py']
  22. ).stdout(),
  23. license : 'MIT',
  24. meson_version : '>= 0.46',
  25. default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c99', 'cpp_std=c++14']
  26. )
  27. cc = meson.get_compiler('c')
  28. cpp = meson.get_compiler('cpp')
  29. null_dep = dependency('', required : false)
  30. # Arguments for the preprocessor, put these in a separate array from the C and
  31. # C++ (cpp in meson terminology) arguments since they need to be added to the
  32. # default arguments for both C and C++.
  33. pre_args = [
  34. '-D__STDC_CONSTANT_MACROS',
  35. '-D__STDC_FORMAT_MACROS',
  36. '-D__STDC_LIMIT_MACROS',
  37. '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
  38. '-DPACKAGE_BUGREPORT="https://gitlab.freedesktop.org/mesa/mesa/issues"',
  39. ]
  40. with_vulkan_icd_dir = get_option('vulkan-icd-dir')
  41. with_tests = get_option('build-tests')
  42. with_valgrind = get_option('valgrind')
  43. with_libunwind = get_option('libunwind')
  44. with_glx_read_only_text = get_option('glx-read-only-text')
  45. with_glx_direct = get_option('glx-direct')
  46. with_osmesa = get_option('osmesa')
  47. with_swr_arches = get_option('swr-arches')
  48. with_vulkan_overlay_layer = get_option('vulkan-overlay-layer')
  49. with_tools = get_option('tools')
  50. if with_tools.contains('all')
  51. with_tools = [
  52. 'drm-shim',
  53. 'etnaviv',
  54. 'freedreno',
  55. 'glsl',
  56. 'intel',
  57. 'intel-ui',
  58. 'lima',
  59. 'nir',
  60. 'nouveau',
  61. 'xvmc',
  62. ]
  63. endif
  64. with_intel_tools = with_tools.contains('intel') or with_tools.contains('intel-ui')
  65. with_imgui = with_intel_tools or with_vulkan_overlay_layer
  66. dri_drivers_path = get_option('dri-drivers-path')
  67. if dri_drivers_path == ''
  68. dri_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
  69. endif
  70. dri_search_path = get_option('dri-search-path')
  71. if dri_search_path == ''
  72. dri_search_path = dri_drivers_path
  73. endif
  74. with_gles1 = get_option('gles1')
  75. with_gles2 = get_option('gles2')
  76. if host_machine.system() == 'windows'
  77. if with_gles1 == 'auto'
  78. with_gles1 = 'false'
  79. endif
  80. if with_gles2 == 'auto'
  81. with_gles2 = 'false'
  82. endif
  83. endif
  84. with_opengl = get_option('opengl')
  85. # Default shared glapi off for windows, on elsewhere.
  86. _sg = get_option('shared-glapi')
  87. if _sg == 'auto'
  88. with_shared_glapi = host_machine.system() != 'windows'
  89. else
  90. with_shared_glapi = _sg == 'true'
  91. endif
  92. # shared-glapi is required if at least two OpenGL APIs are being built
  93. if not with_shared_glapi
  94. if ((with_gles1 == 'true' and with_gles2 == 'true') or
  95. (with_gles1 == 'true' and with_opengl) or
  96. (with_gles2 == 'true' and with_opengl))
  97. error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x')
  98. endif
  99. with_gles1 = 'false'
  100. with_gles2 = 'false'
  101. endif
  102. # We require OpenGL for OpenGL ES
  103. if not with_opengl
  104. if (with_gles1 == 'true' or with_gles2 == 'true') and not with_opengl
  105. error('building OpenGL ES without OpenGL is not supported.')
  106. endif
  107. with_gles1 = 'false'
  108. with_gles2 = 'false'
  109. endif
  110. with_gles1 = with_gles1 != 'false'
  111. with_gles2 = with_gles2 != 'false'
  112. with_any_opengl = with_opengl or with_gles1 or with_gles2
  113. # Only build shared_glapi if at least one OpenGL API is enabled
  114. with_shared_glapi = with_shared_glapi and with_any_opengl
  115. system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos'].contains(host_machine.system())
  116. dri_drivers = get_option('dri-drivers')
  117. if dri_drivers.contains('auto')
  118. if system_has_kms_drm
  119. # TODO: PPC, Sparc
  120. if ['x86', 'x86_64'].contains(host_machine.cpu_family())
  121. dri_drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau']
  122. elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
  123. dri_drivers = []
  124. else
  125. error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
  126. host_machine.cpu_family()))
  127. endif
  128. elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
  129. # only swrast would make sense here, but gallium swrast is a much better default
  130. dri_drivers = []
  131. else
  132. error('Unknown OS @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format(
  133. host_machine.system()))
  134. endif
  135. endif
  136. with_dri_i915 = dri_drivers.contains('i915')
  137. with_dri_i965 = dri_drivers.contains('i965')
  138. with_dri_r100 = dri_drivers.contains('r100')
  139. with_dri_r200 = dri_drivers.contains('r200')
  140. with_dri_nouveau = dri_drivers.contains('nouveau')
  141. with_dri_swrast = dri_drivers.contains('swrast')
  142. with_dri = dri_drivers.length() != 0 and dri_drivers != ['']
  143. gallium_drivers = get_option('gallium-drivers')
  144. if gallium_drivers.contains('auto')
  145. if system_has_kms_drm
  146. # TODO: PPC, Sparc
  147. if ['x86', 'x86_64'].contains(host_machine.cpu_family())
  148. gallium_drivers = [
  149. 'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'svga', 'swrast'
  150. ]
  151. elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
  152. gallium_drivers = [
  153. 'kmsro', 'v3d', 'vc4', 'freedreno', 'etnaviv', 'nouveau',
  154. 'tegra', 'virgl', 'lima', 'panfrost', 'swrast'
  155. ]
  156. else
  157. error('Unknown architecture @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
  158. host_machine.cpu_family()))
  159. endif
  160. elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
  161. gallium_drivers = ['swrast']
  162. else
  163. error('Unknown OS @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format(
  164. host_machine.system()))
  165. endif
  166. endif
  167. with_gallium_kmsro = gallium_drivers.contains('kmsro')
  168. with_gallium_radeonsi = gallium_drivers.contains('radeonsi')
  169. with_gallium_r300 = gallium_drivers.contains('r300')
  170. with_gallium_r600 = gallium_drivers.contains('r600')
  171. with_gallium_nouveau = gallium_drivers.contains('nouveau')
  172. with_gallium_freedreno = gallium_drivers.contains('freedreno')
  173. with_gallium_softpipe = gallium_drivers.contains('swrast')
  174. with_gallium_vc4 = gallium_drivers.contains('vc4')
  175. with_gallium_v3d = gallium_drivers.contains('v3d')
  176. with_gallium_panfrost = gallium_drivers.contains('panfrost')
  177. with_gallium_etnaviv = gallium_drivers.contains('etnaviv')
  178. with_gallium_tegra = gallium_drivers.contains('tegra')
  179. with_gallium_iris = gallium_drivers.contains('iris')
  180. with_gallium_i915 = gallium_drivers.contains('i915')
  181. with_gallium_svga = gallium_drivers.contains('svga')
  182. with_gallium_virgl = gallium_drivers.contains('virgl')
  183. with_gallium_swr = gallium_drivers.contains('swr')
  184. with_gallium_lima = gallium_drivers.contains('lima')
  185. with_gallium_zink = gallium_drivers.contains('zink')
  186. if cc.get_id().startswith('intel') and meson.version().version_compare('< 0.49.1')
  187. error('Meson does not have sufficient support of ICC before 0.49.1 to compile mesa')
  188. endif
  189. with_gallium = gallium_drivers.length() != 0 and gallium_drivers != ['']
  190. if with_gallium and system_has_kms_drm
  191. _glx = get_option('glx')
  192. _egl = get_option('egl')
  193. if _glx == 'dri' or _egl == 'true' or (_glx == 'disabled' and _egl != 'false')
  194. with_dri = true
  195. endif
  196. endif
  197. _vulkan_drivers = get_option('vulkan-drivers')
  198. if _vulkan_drivers.contains('auto')
  199. if system_has_kms_drm
  200. if host_machine.cpu_family().startswith('x86')
  201. _vulkan_drivers = ['amd', 'intel']
  202. elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
  203. _vulkan_drivers = []
  204. else
  205. error('Unknown architecture @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format(
  206. host_machine.cpu_family()))
  207. endif
  208. elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
  209. # No vulkan driver supports windows or macOS currently
  210. _vulkan_drivers = []
  211. else
  212. error('Unknown OS @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format(
  213. host_machine.system()))
  214. endif
  215. endif
  216. with_intel_vk = _vulkan_drivers.contains('intel')
  217. with_amd_vk = _vulkan_drivers.contains('amd')
  218. with_freedreno_vk = _vulkan_drivers.contains('freedreno')
  219. with_any_vk = _vulkan_drivers.length() != 0 and _vulkan_drivers != ['']
  220. if with_freedreno_vk and get_option('I-love-half-baked-turnips') != true
  221. error('Cannot enable freedreno vulkan driver')
  222. endif
  223. if with_dri_swrast and (with_gallium_softpipe or with_gallium_swr)
  224. error('Only one swrast provider can be built')
  225. endif
  226. if with_dri_i915 and with_gallium_i915
  227. error('Only one i915 provider can be built')
  228. endif
  229. if with_gallium_kmsro and not (with_gallium_v3d or with_gallium_vc4 or with_gallium_etnaviv or with_gallium_freedreno or with_gallium_panfrost or with_gallium_lima)
  230. error('kmsro driver requires one or more renderonly drivers (vc4, etnaviv, freedreno, panfrost, lima)')
  231. endif
  232. if with_gallium_tegra and not with_gallium_nouveau
  233. error('tegra driver requires nouveau driver')
  234. endif
  235. if host_machine.system() == 'darwin'
  236. with_dri_platform = 'apple'
  237. pre_args += '-DBUILDING_MESA'
  238. elif ['windows', 'cygwin'].contains(host_machine.system())
  239. with_dri_platform = 'windows'
  240. elif system_has_kms_drm
  241. with_dri_platform = 'drm'
  242. else
  243. # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should
  244. # assert here that one of those cases has been met.
  245. # FIXME: illumos ends up here as well
  246. with_dri_platform = 'none'
  247. endif
  248. _platforms = get_option('platforms')
  249. if _platforms.contains('auto')
  250. if system_has_kms_drm
  251. _platforms = ['x11', 'wayland', 'drm', 'surfaceless']
  252. elif ['darwin', 'cygwin'].contains(host_machine.system())
  253. _platforms = ['x11', 'surfaceless']
  254. elif ['haiku'].contains(host_machine.system())
  255. _platforms = ['haiku']
  256. elif host_machine.system() == 'windows'
  257. _platforms = ['windows']
  258. else
  259. error('Unknown OS @0@. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.'.format(
  260. host_machine.system()))
  261. endif
  262. endif
  263. with_platform_android = _platforms.contains('android')
  264. with_platform_x11 = _platforms.contains('x11')
  265. with_platform_wayland = _platforms.contains('wayland')
  266. with_platform_drm = _platforms.contains('drm')
  267. with_platform_haiku = _platforms.contains('haiku')
  268. with_platform_surfaceless = _platforms.contains('surfaceless')
  269. with_platform_windows = _platforms.contains('windows')
  270. with_platforms = false
  271. if _platforms.length() != 0 and _platforms != ['']
  272. # sanity check that list contains no empty strings
  273. if _platforms.contains('')
  274. error('Invalid argument list given to -Dplatforms, please fix.')
  275. endif
  276. with_platforms = true
  277. egl_native_platform = _platforms[0]
  278. endif
  279. _xlib_lease = get_option('xlib-lease')
  280. if _xlib_lease == 'auto'
  281. with_xlib_lease = with_platform_x11 and with_platform_drm
  282. else
  283. with_xlib_lease = _xlib_lease == 'true'
  284. endif
  285. with_glx = get_option('glx')
  286. if with_glx == 'auto'
  287. if with_dri
  288. with_glx = 'dri'
  289. elif with_platform_haiku
  290. with_glx = 'disabled'
  291. elif host_machine.system() == 'windows'
  292. with_glx = 'disabled'
  293. elif with_gallium
  294. # Even when building just gallium drivers the user probably wants dri
  295. with_glx = 'dri'
  296. elif with_platform_x11 and with_any_opengl and not with_any_vk
  297. # The automatic behavior should not be to turn on xlib based glx when
  298. # building only vulkan drivers
  299. with_glx = 'xlib'
  300. else
  301. with_glx = 'disabled'
  302. endif
  303. endif
  304. if with_glx == 'dri'
  305. if with_gallium
  306. with_dri = true
  307. endif
  308. endif
  309. if not (with_dri or with_gallium or with_glx != 'disabled')
  310. with_gles1 = false
  311. with_gles2 = false
  312. with_opengl = false
  313. with_any_opengl = false
  314. with_shared_glapi = false
  315. endif
  316. _gbm = get_option('gbm')
  317. if _gbm == 'auto'
  318. with_gbm = system_has_kms_drm and with_dri
  319. else
  320. with_gbm = _gbm == 'true'
  321. endif
  322. if with_gbm and not system_has_kms_drm
  323. error('GBM only supports DRM/KMS platforms')
  324. endif
  325. _egl = get_option('egl')
  326. if _egl == 'auto'
  327. with_egl = (
  328. not ['darwin', 'windows'].contains(host_machine.system()) and
  329. with_dri and with_shared_glapi and with_platforms
  330. )
  331. elif _egl == 'true'
  332. if not with_dri
  333. error('EGL requires dri')
  334. elif not with_shared_glapi
  335. error('EGL requires shared-glapi')
  336. elif not with_platforms
  337. error('No platforms specified, consider -Dplatforms=drm,x11,surfaceless at least')
  338. elif not ['disabled', 'dri'].contains(with_glx)
  339. error('EGL requires dri, but a GLX is being built without dri')
  340. elif ['darwin', 'windows'].contains(host_machine.system())
  341. error('EGL is not available on Windows or MacOS')
  342. endif
  343. with_egl = true
  344. else
  345. with_egl = false
  346. endif
  347. if with_egl and not (with_platform_drm or with_platform_surfaceless or with_platform_android)
  348. if with_gallium_radeonsi
  349. error('RadeonSI requires the drm, surfaceless or android platform when using EGL')
  350. endif
  351. if with_gallium_virgl
  352. error('Virgl requires the drm, surfaceless or android platform when using EGL')
  353. endif
  354. endif
  355. # Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS.
  356. if host_machine.system() != 'windows' and (not with_platform_android or get_option('platform-sdk-version') >= 29)
  357. pre_args += '-DUSE_ELF_TLS'
  358. endif
  359. if with_glx != 'disabled'
  360. if not (with_platform_x11 and with_any_opengl)
  361. error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
  362. elif with_glx == 'gallium-xlib'
  363. if not with_gallium
  364. error('Gallium-xlib based GLX requires at least one gallium driver')
  365. elif not with_gallium_softpipe
  366. error('Gallium-xlib based GLX requires softpipe or llvmpipe.')
  367. elif with_dri
  368. error('gallium-xlib conflicts with any dri driver')
  369. endif
  370. elif with_glx == 'xlib'
  371. if with_dri
  372. error('xlib conflicts with any dri driver')
  373. endif
  374. elif with_glx == 'dri'
  375. if not with_shared_glapi
  376. error('dri based GLX requires shared-glapi')
  377. endif
  378. endif
  379. endif
  380. with_glvnd = get_option('glvnd')
  381. if with_glvnd
  382. if with_platform_windows
  383. error('glvnd cannot be used on Windows')
  384. elif with_glx == 'xlib' or with_glx == 'gallium-xlib'
  385. error('Cannot build glvnd support for GLX that is not DRI based.')
  386. elif with_glx == 'disabled' and not with_egl
  387. error('glvnd requires DRI based GLX and/or EGL')
  388. endif
  389. if get_option('egl-lib-suffix') != ''
  390. error('''EGL lib suffix can't be used with libglvnd''')
  391. endif
  392. endif
  393. if with_vulkan_icd_dir == ''
  394. with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
  395. endif
  396. with_dri2 = (with_dri or with_any_vk) and (with_dri_platform == 'drm' or
  397. host_machine.system() == 'gnu')
  398. _dri3 = get_option('dri3')
  399. if _dri3 == 'auto'
  400. with_dri3 = system_has_kms_drm and with_dri2
  401. else
  402. with_dri3 = _dri3 == 'true'
  403. endif
  404. if with_any_vk and (with_platform_x11 and not with_dri3)
  405. error('Vulkan drivers require dri3 for X11 support')
  406. endif
  407. if with_dri
  408. if with_glx == 'disabled' and not with_egl and not with_gbm and with_osmesa != 'classic'
  409. error('building dri drivers require at least one windowing system or classic osmesa')
  410. endif
  411. endif
  412. prog_pkgconfig = find_program('pkg-config')
  413. _vdpau = get_option('gallium-vdpau')
  414. if not system_has_kms_drm
  415. if _vdpau == 'true'
  416. error('VDPAU state tracker can only be build on unix-like OSes.')
  417. else
  418. _vdpau = 'false'
  419. endif
  420. elif not with_platform_x11
  421. if _vdpau == 'true'
  422. error('VDPAU state tracker requires X11 support.')
  423. else
  424. _vdpau = 'false'
  425. endif
  426. elif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or
  427. with_gallium_nouveau)
  428. if _vdpau == 'true'
  429. error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau.')
  430. else
  431. _vdpau = 'false'
  432. endif
  433. endif
  434. dep_vdpau = null_dep
  435. with_gallium_vdpau = false
  436. if _vdpau != 'false'
  437. dep_vdpau = dependency('vdpau', version : '>= 1.1', required : _vdpau == 'true')
  438. if dep_vdpau.found()
  439. dep_vdpau = declare_dependency(
  440. compile_args : run_command(prog_pkgconfig, ['vdpau', '--cflags']).stdout().split()
  441. )
  442. with_gallium_vdpau = true
  443. endif
  444. endif
  445. if with_gallium_vdpau
  446. pre_args += '-DHAVE_ST_VDPAU'
  447. endif
  448. vdpau_drivers_path = get_option('vdpau-libs-path')
  449. if vdpau_drivers_path == ''
  450. vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
  451. endif
  452. if with_gallium_zink
  453. dep_vulkan = dependency('vulkan')
  454. endif
  455. _xvmc = get_option('gallium-xvmc')
  456. if not system_has_kms_drm
  457. if _xvmc == 'true'
  458. error('XVMC state tracker can only be build on unix-like OSes.')
  459. else
  460. _xvmc = 'false'
  461. endif
  462. elif not with_platform_x11
  463. if _xvmc == 'true'
  464. error('XVMC state tracker requires X11 support.')
  465. else
  466. _xvmc = 'false'
  467. endif
  468. elif not (with_gallium_r600 or with_gallium_nouveau)
  469. if _xvmc == 'true'
  470. error('XVMC state tracker requires at least one of the following gallium drivers: r600, nouveau.')
  471. else
  472. _xvmc = 'false'
  473. endif
  474. endif
  475. dep_xvmc = null_dep
  476. dep_xv = null_dep
  477. with_gallium_xvmc = false
  478. if _xvmc != 'false'
  479. dep_xvmc = dependency('xvmc', version : '>= 1.0.6', required : _xvmc == 'true')
  480. dep_xv = dependency('xv', required : _xvmc == 'true')
  481. with_gallium_xvmc = dep_xvmc.found() and dep_xv.found()
  482. endif
  483. xvmc_drivers_path = get_option('xvmc-libs-path')
  484. if xvmc_drivers_path == ''
  485. xvmc_drivers_path = get_option('libdir')
  486. endif
  487. _omx = get_option('gallium-omx')
  488. if not system_has_kms_drm
  489. if ['auto', 'disabled'].contains(_omx)
  490. _omx = 'disabled'
  491. else
  492. error('OMX state tracker can only be built on unix-like OSes.')
  493. endif
  494. elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
  495. if ['auto', 'disabled'].contains(_omx)
  496. _omx = 'disabled'
  497. else
  498. error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
  499. endif
  500. endif
  501. with_gallium_omx = _omx
  502. dep_omx = null_dep
  503. dep_omx_other = []
  504. if ['auto', 'bellagio'].contains(_omx)
  505. dep_omx = dependency(
  506. 'libomxil-bellagio', required : _omx == 'bellagio'
  507. )
  508. if dep_omx.found()
  509. with_gallium_omx = 'bellagio'
  510. endif
  511. endif
  512. if ['auto', 'tizonia'].contains(_omx)
  513. if with_dri and with_egl
  514. dep_omx = dependency(
  515. 'libtizonia', version : '>= 0.10.0',
  516. required : _omx == 'tizonia',
  517. )
  518. dep_omx_other = [
  519. dependency('libtizplatform', required : _omx == 'tizonia'),
  520. dependency('tizilheaders', required : _omx == 'tizonia'),
  521. ]
  522. if dep_omx.found() and dep_omx_other[0].found() and dep_omx_other[1].found()
  523. with_gallium_omx = 'tizonia'
  524. endif
  525. elif _omx == 'tizonia'
  526. error('OMX-Tizonia state tracker requires dri and egl')
  527. endif
  528. endif
  529. if _omx == 'auto'
  530. with_gallium_omx = 'disabled'
  531. else
  532. with_gallium_omx = _omx
  533. endif
  534. pre_args += [
  535. '-DENABLE_ST_OMX_BELLAGIO=' + (with_gallium_omx == 'bellagio' ? '1' : '0'),
  536. '-DENABLE_ST_OMX_TIZONIA=' + (with_gallium_omx == 'tizonia' ? '1' : '0'),
  537. ]
  538. omx_drivers_path = get_option('omx-libs-path')
  539. if with_gallium_omx != 'disabled'
  540. # Figure out where to put the omx driver.
  541. # FIXME: this could all be vastly simplified by adding a 'defined_variable'
  542. # argument to meson's get_pkgconfig_variable method.
  543. if omx_drivers_path == ''
  544. _omx_libdir = dep_omx.get_pkgconfig_variable('libdir')
  545. _omx_drivers_dir = dep_omx.get_pkgconfig_variable('pluginsdir')
  546. if _omx_libdir == get_option('libdir')
  547. omx_drivers_path = _omx_drivers_dir
  548. else
  549. _omx_base_dir = []
  550. # This will fail on windows. Does OMX run on windows?
  551. _omx_libdir = _omx_libdir.split('/')
  552. _omx_drivers_dir = _omx_drivers_dir.split('/')
  553. foreach o : _omx_drivers_dir
  554. if not _omx_libdir.contains(o)
  555. _omx_base_dir += o
  556. endif
  557. endforeach
  558. omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
  559. endif
  560. endif
  561. endif
  562. _va = get_option('gallium-va')
  563. if not system_has_kms_drm
  564. if _va == 'true'
  565. error('VA state tracker can only be built on unix-like OSes.')
  566. else
  567. _va = 'false'
  568. endif
  569. elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
  570. if _va == 'true'
  571. error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
  572. else
  573. _va = 'false'
  574. endif
  575. endif
  576. with_gallium_va = false
  577. dep_va = null_dep
  578. if _va != 'false'
  579. dep_va = dependency('libva', version : '>= 0.38.0', required : _va == 'true')
  580. if dep_va.found()
  581. dep_va_headers = declare_dependency(
  582. compile_args : run_command(prog_pkgconfig, ['libva', '--cflags']).stdout().split()
  583. )
  584. with_gallium_va = true
  585. endif
  586. endif
  587. va_drivers_path = get_option('va-libs-path')
  588. if va_drivers_path == ''
  589. va_drivers_path = join_paths(get_option('libdir'), 'dri')
  590. endif
  591. _xa = get_option('gallium-xa')
  592. if not system_has_kms_drm
  593. if _xa == 'true'
  594. error('XA state tracker can only be built on unix-like OSes.')
  595. else
  596. _xa = 'false'
  597. endif
  598. elif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915
  599. or with_gallium_svga)
  600. if _xa == 'true'
  601. error('XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.')
  602. else
  603. _xa = 'false'
  604. endif
  605. endif
  606. with_gallium_xa = _xa != 'false'
  607. d3d_drivers_path = get_option('d3d-drivers-path')
  608. if d3d_drivers_path == ''
  609. d3d_drivers_path = join_paths(get_option('prefix'), get_option('libdir'), 'd3d')
  610. endif
  611. with_gallium_st_nine = get_option('gallium-nine')
  612. if with_gallium_st_nine
  613. if not with_gallium_softpipe
  614. error('The nine state tracker requires gallium softpipe/llvmpipe.')
  615. elif not (with_gallium_radeonsi or with_gallium_nouveau or with_gallium_r600
  616. or with_gallium_r300 or with_gallium_svga or with_gallium_i915
  617. or with_gallium_iris)
  618. error('The nine state tracker requires at least one non-swrast gallium driver.')
  619. endif
  620. if not with_dri3
  621. error('Using nine with wine requires dri3')
  622. endif
  623. endif
  624. if get_option('power8') != 'false'
  625. # on old versions of meson the cpu family would return as ppc64le on little
  626. # endian power8, this was changed in 0.48 such that the family would always
  627. # be ppc64 regardless of endianness, and then the machine.endian() value
  628. # should be checked. Since we support versions < 0.48 we need to use
  629. # startswith.
  630. if host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little'
  631. if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8')
  632. error('Altivec is not supported with gcc version < 4.8.')
  633. endif
  634. if cc.compiles('''
  635. #include <altivec.h>
  636. int main() {
  637. vector unsigned char r;
  638. vector unsigned int v = vec_splat_u32 (1);
  639. r = __builtin_vec_vgbbd ((vector unsigned char) v);
  640. return 0;
  641. }''',
  642. args : '-mpower8-vector',
  643. name : 'POWER8 intrinsics')
  644. pre_args += ['-D_ARCH_PWR8', '-mpower8-vector']
  645. elif get_option('power8') == 'true'
  646. error('POWER8 intrinsic support required but not found.')
  647. endif
  648. endif
  649. endif
  650. _opencl = get_option('gallium-opencl')
  651. clover_cpp_std = []
  652. if _opencl != 'disabled'
  653. if not with_gallium
  654. error('OpenCL Clover implementation requires at least one gallium driver.')
  655. endif
  656. dep_clc = dependency('libclc')
  657. with_gallium_opencl = true
  658. with_opencl_icd = _opencl == 'icd'
  659. with_opencl_spirv = get_option('opencl-spirv')
  660. if with_opencl_spirv
  661. dep_spirv_tools = dependency('SPIRV-Tools', required : true, version : '>= 2018.0')
  662. # LLVMSPIRVLib is available at https://github.com/KhronosGroup/SPIRV-LLVM-Translator
  663. dep_llvmspirvlib = dependency('LLVMSPIRVLib', required : true, version : '>= 0.2.1')
  664. else
  665. dep_spirv_tools = null_dep
  666. dep_llvmspirvlib = null_dep
  667. endif
  668. if host_machine.cpu_family().startswith('ppc') and cpp.compiles('''
  669. #if !defined(__VEC__) || !defined(__ALTIVEC__)
  670. #error "AltiVec not enabled"
  671. #endif''',
  672. name : 'Altivec')
  673. clover_cpp_std += ['cpp_std=gnu++11']
  674. endif
  675. else
  676. dep_clc = null_dep
  677. dep_spirv_tools = null_dep
  678. dep_llvmspirvlib = null_dep
  679. with_gallium_opencl = false
  680. with_opencl_icd = false
  681. with_opencl_spirv = false
  682. endif
  683. gl_pkgconfig_c_flags = []
  684. if with_platform_x11
  685. if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
  686. pre_args += '-DHAVE_X11_PLATFORM'
  687. endif
  688. if with_glx == 'xlib' or with_glx == 'gallium-xlib'
  689. pre_args += '-DUSE_XSHM'
  690. else
  691. pre_args += '-DGLX_INDIRECT_RENDERING'
  692. if with_glx_direct
  693. pre_args += '-DGLX_DIRECT_RENDERING'
  694. endif
  695. if with_dri_platform == 'drm'
  696. pre_args += '-DGLX_USE_DRM'
  697. elif with_dri_platform == 'apple'
  698. pre_args += '-DGLX_USE_APPLEGL'
  699. elif with_dri_platform == 'windows'
  700. pre_args += '-DGLX_USE_WINDOWSGL'
  701. endif
  702. endif
  703. else
  704. pre_args += '-DEGL_NO_X11'
  705. gl_pkgconfig_c_flags += '-DEGL_NO_X11'
  706. endif
  707. if with_platform_drm
  708. if with_egl and not with_gbm
  709. error('EGL drm platform requires gbm')
  710. endif
  711. pre_args += '-DHAVE_DRM_PLATFORM'
  712. endif
  713. if with_platform_surfaceless
  714. pre_args += '-DHAVE_SURFACELESS_PLATFORM'
  715. endif
  716. if with_platform_android
  717. dep_android = [
  718. dependency('cutils'),
  719. dependency('hardware'),
  720. dependency('sync'),
  721. ]
  722. if get_option('platform-sdk-version') >= 26
  723. dep_android += dependency('nativewindow')
  724. endif
  725. pre_args += '-DHAVE_ANDROID_PLATFORM'
  726. endif
  727. if with_platform_haiku
  728. pre_args += '-DHAVE_HAIKU_PLATFORM'
  729. endif
  730. if meson.version().version_compare('>=0.50')
  731. prog_python = import('python').find_installation('python3')
  732. else
  733. prog_python = import('python3').find_python()
  734. endif
  735. has_mako = run_command(
  736. prog_python, '-c',
  737. '''
  738. from distutils.version import StrictVersion
  739. import mako
  740. assert StrictVersion(mako.__version__) > StrictVersion("0.8.0")
  741. ''')
  742. if has_mako.returncode() != 0
  743. error('Python (3.x) mako module >= 0.8.0 required to build mesa.')
  744. endif
  745. if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
  746. error('When using GCC, version 4.4.6 or later is required.')
  747. endif
  748. # Support systems without ETIME (e.g. FreeBSD)
  749. if cc.get_define('ETIME', prefix : '#include <errno.h>') == ''
  750. pre_args += '-DETIME=ETIMEDOUT'
  751. endif
  752. # Define DEBUG for debug builds only (debugoptimized is not included on this one)
  753. if get_option('buildtype') == 'debug'
  754. pre_args += '-DDEBUG'
  755. endif
  756. with_shader_cache = false
  757. _shader_cache = get_option('shader-cache')
  758. if _shader_cache != 'false'
  759. if host_machine.system() == 'windows'
  760. if _shader_cache == 'true'
  761. error('Shader Cache does not currently work on Windows')
  762. endif
  763. else
  764. pre_args += '-DENABLE_SHADER_CACHE'
  765. with_shader_cache = true
  766. endif
  767. endif
  768. if with_amd_vk and not with_shader_cache
  769. error('Radv requires shader cache support')
  770. endif
  771. # Check for GCC style builtins
  772. foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
  773. 'ffsll', 'popcount', 'popcountll', 'unreachable']
  774. if cc.has_function(b)
  775. pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
  776. endif
  777. endforeach
  778. # check for GCC __attribute__
  779. foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
  780. 'warn_unused_result', 'weak',]
  781. if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
  782. name : '__attribute__((@0@))'.format(a))
  783. pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
  784. endif
  785. endforeach
  786. if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
  787. name : '__attribute__((format(...)))')
  788. pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
  789. endif
  790. if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
  791. name : '__attribute__((packed))')
  792. pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
  793. endif
  794. if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
  795. name : '__attribute__((returns_nonnull))')
  796. pre_args += '-DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL'
  797. endif
  798. if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
  799. int foo_hid(void) __attribute__((visibility("hidden")));
  800. int foo_int(void) __attribute__((visibility("internal")));
  801. int foo_pro(void) __attribute__((visibility("protected")));''',
  802. name : '__attribute__((visibility(...)))')
  803. pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY'
  804. endif
  805. if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
  806. name : '__attribute__((alias(...)))')
  807. pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
  808. endif
  809. if cc.compiles('int foo(void) __attribute__((__noreturn__));',
  810. name : '__attribute__((__noreturn__))')
  811. pre_args += '-DHAVE_FUNC_ATTRIBUTE_NORETURN'
  812. endif
  813. if cc.compiles('__uint128_t foo(void) { return 0; }',
  814. name : '__uint128_t')
  815. pre_args += '-DHAVE_UINT128'
  816. endif
  817. # TODO: this is very incomplete
  818. if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd'].contains(host_machine.system())
  819. pre_args += '-D_GNU_SOURCE'
  820. elif host_machine.system() == 'sunos'
  821. pre_args += '-D__EXTENSIONS__'
  822. elif host_machine.system() == 'windows'
  823. pre_args += [
  824. '-D_WINDOWS', '-D_WIN32_WINNT=0x0601', '-D_WINVER=0x0601',
  825. '-DPIPE_SUBSYSTEM_WINDOWS_USER',
  826. '-D_USE_MATH_DEFINES', # XXX: scons doesn't use this for mingw
  827. ]
  828. if cc.get_id() == 'msvc'
  829. pre_args += [
  830. '-DVC_EXTRALEAN',
  831. '-D_CRT_SECURE_NO_WARNINGS',
  832. '-D_CRT_SECURE_NO_DEPRECATE',
  833. '-D_SCL_SECURE_NO_WARNINGS',
  834. '-D_SCL_SECURE_NO_DEPRECATE',
  835. '-D_ALLOW_KEYWORD_MACROS',
  836. '-D_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions
  837. ]
  838. else
  839. pre_args += ['-D__MSVCRT_VERSION__=0x0700']
  840. endif
  841. endif
  842. # Check for generic C arguments
  843. c_args = []
  844. c_vis_args = []
  845. c_msvc_compat_args = []
  846. no_override_init_args = []
  847. cpp_args = []
  848. cpp_vis_args = []
  849. cpp_msvc_compat_args = []
  850. if cc.get_id() == 'msvc'
  851. foreach a : ['/wd4018', # signed/unsigned mismatch
  852. '/wd4056', # overflow in floating-point constant arithmetic
  853. '/wd4244', # conversion from 'type1' to 'type2', possible loss of data
  854. '/wd4267', # 'var' : conversion from 'size_t' to 'type', possible loss of data
  855. '/wd4305', # trancation from 'type1' to 'type2'
  856. '/wd4351', # new behavior: elements of array 'array' will be default initialized
  857. '/wd4756', # overflow in constant arithmetic
  858. '/wd4800', # forcing value to bool 'true' or 'false' (performance warning)
  859. '/wd4996', # disabled deprecated POSIX name warnings
  860. '/wd4291'] # no matching operator delete found
  861. if cc.has_argument(a)
  862. c_args += a
  863. endif
  864. if cpp.has_argument(a)
  865. cpp_args += a
  866. endif
  867. endforeach
  868. if cc.has_argument('-Wmicrosoft-enum-value') # Clang
  869. c_args += '-Wno-microsoft-enum-value'
  870. cpp_args += '-Wno-microsoft-enum-value'
  871. endif
  872. else
  873. _trial = [
  874. '-Werror=implicit-function-declaration',
  875. '-Werror=missing-prototypes',
  876. '-Werror=return-type',
  877. '-Werror=empty-body',
  878. '-Werror=incompatible-pointer-types',
  879. '-Wno-missing-field-initializers',
  880. '-Wno-format-truncation',
  881. '-fno-math-errno',
  882. '-fno-trapping-math',
  883. '-Qunused-arguments',
  884. ]
  885. # MinGW chokes on format specifiers and I can't get it all working
  886. if not (cc.get_id() == 'gcc' and host_machine.system() == 'windows')
  887. _trial += ['-Werror=format', '-Wformat-security']
  888. endif
  889. foreach a : _trial
  890. if cc.has_argument(a)
  891. c_args += a
  892. endif
  893. endforeach
  894. _trial = [
  895. '-Werror=return-type',
  896. '-Werror=empty-body',
  897. '-Wno-non-virtual-dtor',
  898. '-Wno-missing-field-initializers',
  899. '-Wno-format-truncation',
  900. '-fno-math-errno',
  901. '-fno-trapping-math',
  902. '-Qunused-arguments',
  903. ]
  904. # MinGW chokes on format specifiers and I can't get it all working
  905. if not (cc.get_id() == 'gcc' and host_machine.system() == 'windows')
  906. _trial += ['-Werror=format', '-Wformat-security']
  907. endif
  908. foreach a : _trial
  909. if cpp.has_argument(a)
  910. cpp_args += a
  911. endif
  912. endforeach
  913. foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
  914. if cc.has_argument(a)
  915. no_override_init_args += a
  916. endif
  917. endforeach
  918. if cc.has_argument('-fvisibility=hidden')
  919. c_vis_args += '-fvisibility=hidden'
  920. endif
  921. # Check for C and C++ arguments for MSVC compatibility. These are only used
  922. # in parts of the mesa code base that need to compile with MSVC, mainly
  923. # common code
  924. foreach a : ['-Werror=pointer-arith', '-Werror=vla', '-Werror=gnu-empty-initializer']
  925. if cc.has_argument(a)
  926. c_msvc_compat_args += a
  927. endif
  928. if cpp.has_argument(a)
  929. cpp_msvc_compat_args += a
  930. endif
  931. endforeach
  932. if cpp.has_argument('-fvisibility=hidden')
  933. cpp_vis_args += '-fvisibility=hidden'
  934. endif
  935. endif
  936. # set linker arguments
  937. if host_machine.system() == 'windows'
  938. if cc.get_id() == 'msvc'
  939. add_project_link_arguments(
  940. '/fixed:no',
  941. '/incremental:no',
  942. '/dynamicbase',
  943. '/nxcompat',
  944. language : ['c', 'cpp'],
  945. )
  946. else
  947. add_project_link_arguments(
  948. '-Wl,--nxcompat',
  949. '-Wl,--dynamicbase',
  950. '-static-libgcc',
  951. '-static-libstdc++',
  952. language : ['c', 'cpp'],
  953. )
  954. endif
  955. endif
  956. if host_machine.cpu_family().startswith('x86') and cc.get_id() != 'msvc'
  957. pre_args += '-DUSE_SSE41'
  958. with_sse41 = true
  959. sse41_args = ['-msse4.1']
  960. # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
  961. # that's not guaranteed
  962. if host_machine.cpu_family() == 'x86'
  963. sse41_args += '-mstackrealign'
  964. endif
  965. else
  966. with_sse41 = false
  967. sse41_args = []
  968. endif
  969. # Check for GCC style atomics
  970. dep_atomic = null_dep
  971. if cc.compiles('''#include <stdint.h>
  972. int main() {
  973. struct {
  974. uint64_t *v;
  975. } x;
  976. return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
  977. (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
  978. }''',
  979. name : 'GCC atomic builtins')
  980. pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
  981. # Not all atomic calls can be turned into lock-free instructions, in which
  982. # GCC will make calls into the libatomic library. Check whether we need to
  983. # link with -latomic.
  984. #
  985. # This can happen for 64-bit atomic operations on 32-bit architectures such
  986. # as ARM.
  987. if not cc.links('''#include <stdint.h>
  988. int main() {
  989. struct {
  990. uint64_t *v;
  991. } x;
  992. return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
  993. (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
  994. }''',
  995. name : 'GCC atomic builtins required -latomic')
  996. dep_atomic = cc.find_library('atomic')
  997. endif
  998. endif
  999. if not cc.links('''#include <stdint.h>
  1000. uint64_t v;
  1001. int main() {
  1002. return __sync_add_and_fetch(&v, (uint64_t)1);
  1003. }''',
  1004. dependencies : dep_atomic,
  1005. name : 'GCC 64bit atomics')
  1006. pre_args += '-DMISSING_64BIT_ATOMICS'
  1007. endif
  1008. dep_ws2_32 = cc.find_library('ws2_32', required : with_platform_windows)
  1009. # TODO: shared/static? Is this even worth doing?
  1010. with_asm_arch = ''
  1011. if host_machine.cpu_family() == 'x86'
  1012. if system_has_kms_drm or host_machine.system() == 'gnu'
  1013. with_asm_arch = 'x86'
  1014. pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
  1015. '-DUSE_SSE_ASM']
  1016. if with_glx_read_only_text
  1017. pre_args += ['-DGLX_X86_READONLY_TEXT']
  1018. endif
  1019. endif
  1020. elif host_machine.cpu_family() == 'x86_64'
  1021. if system_has_kms_drm
  1022. with_asm_arch = 'x86_64'
  1023. pre_args += ['-DUSE_X86_64_ASM']
  1024. endif
  1025. elif host_machine.cpu_family() == 'arm'
  1026. if system_has_kms_drm
  1027. with_asm_arch = 'arm'
  1028. pre_args += ['-DUSE_ARM_ASM']
  1029. endif
  1030. elif host_machine.cpu_family() == 'aarch64'
  1031. if system_has_kms_drm
  1032. with_asm_arch = 'aarch64'
  1033. pre_args += ['-DUSE_AARCH64_ASM']
  1034. endif
  1035. elif host_machine.cpu_family() == 'sparc64'
  1036. if system_has_kms_drm
  1037. with_asm_arch = 'sparc'
  1038. pre_args += ['-DUSE_SPARC_ASM']
  1039. endif
  1040. elif host_machine.cpu_family().startswith('ppc64') and host_machine.endian() == 'little'
  1041. if system_has_kms_drm
  1042. with_asm_arch = 'ppc64le'
  1043. pre_args += ['-DUSE_PPC64LE_ASM']
  1044. endif
  1045. endif
  1046. # Check for standard headers and functions
  1047. if (cc.has_header_symbol('sys/sysmacros.h', 'major') and
  1048. cc.has_header_symbol('sys/sysmacros.h', 'minor') and
  1049. cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
  1050. pre_args += '-DMAJOR_IN_SYSMACROS'
  1051. endif
  1052. if (cc.has_header_symbol('sys/mkdev.h', 'major') and
  1053. cc.has_header_symbol('sys/mkdev.h', 'minor') and
  1054. cc.has_header_symbol('sys/mkdev.h', 'makedev'))
  1055. pre_args += '-DMAJOR_IN_MKDEV'
  1056. endif
  1057. foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'execinfo.h', 'sys/shm.h', 'cet.h']
  1058. if cc.compiles('#include <@0@>'.format(h), name : '@0@'.format(h))
  1059. pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
  1060. endif
  1061. endforeach
  1062. foreach f : ['strtof', 'mkostemp', 'timespec_get', 'memfd_create', 'random_r', 'flock', 'strtok_r']
  1063. if cc.has_function(f)
  1064. pre_args += '-DHAVE_@0@'.format(f.to_upper())
  1065. endif
  1066. endforeach
  1067. if cc.has_header_symbol('errno.h', 'program_invocation_name',
  1068. args : '-D_GNU_SOURCE')
  1069. pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME'
  1070. elif with_tools.contains('intel')
  1071. error('Intel tools require the program_invocation_name variable')
  1072. endif
  1073. # MinGW provides a __builtin_posix_memalign function, but not a posix_memalign.
  1074. # This means that this check will succeed, but then compilation will later
  1075. # fail. MSVC doesn't have this function at all, so only check for it on
  1076. # non-windows platforms.
  1077. if host_machine.system() != 'windows'
  1078. if cc.has_function('posix_memalign')
  1079. pre_args += '-DHAVE_POSIX_MEMALIGN'
  1080. endif
  1081. endif
  1082. # strtod locale support
  1083. if cc.links('''
  1084. #define _GNU_SOURCE
  1085. #include <stdlib.h>
  1086. #include <locale.h>
  1087. #ifdef HAVE_XLOCALE_H
  1088. #include <xlocale.h>
  1089. #endif
  1090. int main() {
  1091. locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
  1092. const char *s = "1.0";
  1093. char *end;
  1094. double d = strtod_l(s, end, loc);
  1095. float f = strtof_l(s, end, loc);
  1096. freelocale(loc);
  1097. return 0;
  1098. }''',
  1099. args : pre_args,
  1100. name : 'strtod has locale support')
  1101. pre_args += '-DHAVE_STRTOD_L'
  1102. endif
  1103. # Check for some linker flags
  1104. ld_args_bsymbolic = []
  1105. if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
  1106. ld_args_bsymbolic += '-Wl,-Bsymbolic'
  1107. endif
  1108. ld_args_gc_sections = []
  1109. if cc.links('static char unused() { return 5; } int main() { return 0; }',
  1110. args : '-Wl,--gc-sections', name : 'gc-sections')
  1111. ld_args_gc_sections += '-Wl,--gc-sections'
  1112. endif
  1113. with_ld_version_script = false
  1114. if cc.links('int main() { return 0; }',
  1115. args : '-Wl,--version-script=@0@'.format(
  1116. join_paths(meson.source_root(), 'build-support/conftest.map')),
  1117. name : 'version-script')
  1118. with_ld_version_script = true
  1119. endif
  1120. with_ld_dynamic_list = false
  1121. if cc.links('int main() { return 0; }',
  1122. args : '-Wl,--dynamic-list=@0@'.format(
  1123. join_paths(meson.source_root(), 'build-support/conftest.dyn')),
  1124. name : 'dynamic-list')
  1125. with_ld_dynamic_list = true
  1126. endif
  1127. ld_args_build_id = cc.get_supported_link_arguments('-Wl,--build-id=sha1')
  1128. # check for dl support
  1129. dep_dl = null_dep
  1130. if not cc.has_function('dlopen')
  1131. dep_dl = cc.find_library('dl', required : host_machine.system() != 'windows')
  1132. endif
  1133. if cc.has_function('dladdr', dependencies : dep_dl)
  1134. # This is really only required for megadrivers
  1135. pre_args += '-DHAVE_DLADDR'
  1136. endif
  1137. if cc.has_function('dl_iterate_phdr')
  1138. pre_args += '-DHAVE_DL_ITERATE_PHDR'
  1139. elif with_intel_vk
  1140. error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
  1141. elif with_dri_i965 and with_shader_cache
  1142. error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.')
  1143. endif
  1144. # Determine whether or not the rt library is needed for time functions
  1145. if host_machine.system() == 'windows' or cc.has_function('clock_gettime')
  1146. dep_clock = null_dep
  1147. else
  1148. dep_clock = cc.find_library('rt')
  1149. endif
  1150. # TODO: some of these may be conditional
  1151. dep_zlib = dependency('zlib', version : '>= 1.2.3', fallback : ['zlib', 'zlib_dep'])
  1152. pre_args += '-DHAVE_ZLIB'
  1153. _zstd = get_option('zstd')
  1154. if _zstd != 'false'
  1155. dep_zstd = dependency('libzstd', required : _zstd == 'true')
  1156. if dep_zstd.found()
  1157. pre_args += '-DHAVE_ZSTD'
  1158. endif
  1159. else
  1160. dep_zstd = null_dep
  1161. endif
  1162. dep_thread = dependency('threads')
  1163. if dep_thread.found() and host_machine.system() != 'windows'
  1164. pre_args += '-DHAVE_PTHREAD'
  1165. if cc.has_function(
  1166. 'pthread_setaffinity_np',
  1167. dependencies : dep_thread,
  1168. prefix : '#include <pthread.h>',
  1169. args : '-D_GNU_SOURCE')
  1170. pre_args += '-DHAVE_PTHREAD_SETAFFINITY'
  1171. endif
  1172. if cc.has_function(
  1173. 'pthread_setaffinity_np',
  1174. dependencies : dep_thread,
  1175. prefix : '#include <pthread_np.h>')
  1176. pre_args += '-DPTHREAD_SETAFFINITY_IN_NP_HEADER'
  1177. endif
  1178. endif
  1179. if host_machine.system() != 'windows'
  1180. dep_expat = dependency('expat', fallback : ['expat', 'expat_dep'])
  1181. else
  1182. dep_expat = null_dep
  1183. endif
  1184. # this only exists on linux so either this is linux and it will be found, or
  1185. # it's not linux and wont
  1186. dep_m = cc.find_library('m', required : false)
  1187. # Check for libdrm. Various drivers have different libdrm version requirements,
  1188. # but we always want to use the same version for all libdrm modules. That means
  1189. # even if driver foo requires 2.4.0 and driver bar requires 2.4.3, if foo and
  1190. # bar are both on use 2.4.3 for both of them
  1191. dep_libdrm_amdgpu = null_dep
  1192. dep_libdrm_radeon = null_dep
  1193. dep_libdrm_nouveau = null_dep
  1194. dep_libdrm_intel = null_dep
  1195. _drm_amdgpu_ver = '2.4.100'
  1196. _drm_radeon_ver = '2.4.71'
  1197. _drm_nouveau_ver = '2.4.66'
  1198. _drm_intel_ver = '2.4.75'
  1199. _drm_ver = '2.4.81'
  1200. _libdrm_checks = [
  1201. ['intel', with_dri_i915 or with_gallium_i915],
  1202. ['amdgpu', with_amd_vk or with_gallium_radeonsi],
  1203. ['radeon', (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or
  1204. with_gallium_r300 or with_gallium_r600)],
  1205. ['nouveau', (with_gallium_nouveau or with_dri_nouveau)],
  1206. ]
  1207. # VC4 only needs core libdrm support of this version, not a libdrm_vc4
  1208. # library.
  1209. if with_gallium_vc4
  1210. _drm_ver = '2.4.89'
  1211. endif
  1212. # etnaviv only needs core libdrm
  1213. if with_gallium_etnaviv
  1214. _drm_ver = '2.4.89'
  1215. endif
  1216. # Loop over the enables versions and get the highest libdrm requirement for all
  1217. # active drivers.
  1218. _drm_blame = ''
  1219. foreach d : _libdrm_checks
  1220. ver = get_variable('_drm_@0@_ver'.format(d[0]))
  1221. if d[1] and ver.version_compare('>' + _drm_ver)
  1222. _drm_ver = ver
  1223. _drm_blame = d[0]
  1224. endif
  1225. endforeach
  1226. if _drm_blame != ''
  1227. message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame))
  1228. endif
  1229. # Then get each libdrm module
  1230. foreach d : _libdrm_checks
  1231. if d[1]
  1232. set_variable(
  1233. 'dep_libdrm_' + d[0],
  1234. dependency('libdrm_' + d[0], version : '>=' + _drm_ver)
  1235. )
  1236. endif
  1237. endforeach
  1238. with_gallium_drisw_kms = false
  1239. dep_libdrm = dependency(
  1240. 'libdrm', version : '>=' + _drm_ver,
  1241. required : with_dri2 or with_dri3
  1242. )
  1243. if dep_libdrm.found()
  1244. pre_args += '-DHAVE_LIBDRM'
  1245. if with_dri_platform == 'drm' and with_dri
  1246. with_gallium_drisw_kms = true
  1247. endif
  1248. endif
  1249. llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit', 'core', 'executionengine', 'scalaropts', 'transformutils', 'instcombine']
  1250. llvm_optional_modules = ['coroutines']
  1251. if with_amd_vk or with_gallium_radeonsi or with_gallium_r600
  1252. llvm_modules += ['amdgpu', 'native', 'bitreader', 'ipo']
  1253. if with_gallium_r600
  1254. llvm_modules += 'asmparser'
  1255. endif
  1256. endif
  1257. if with_gallium_opencl
  1258. llvm_modules += [
  1259. 'all-targets', 'linker', 'coverage', 'instrumentation', 'ipo', 'irreader',
  1260. 'lto', 'option', 'objcarcopts', 'profiledata',
  1261. ]
  1262. endif
  1263. if with_amd_vk or with_gallium_radeonsi
  1264. _llvm_version = '>= 8.0.0'
  1265. elif with_gallium_swr
  1266. _llvm_version = '>= 6.0.0'
  1267. else
  1268. _llvm_version = '>= 3.9.0'
  1269. endif
  1270. _shared_llvm = get_option('shared-llvm')
  1271. _llvm = get_option('llvm')
  1272. # The cmake method will never find libllvm.so|dylib; this is fine for windows
  1273. # because llvm doesn't support libllvm.dll
  1274. _llvm_method = 'config-tool'
  1275. if (meson.version().version_compare('>= 0.51.0') and
  1276. host_machine.system() == 'windows')
  1277. _llvm_method = 'cmake'
  1278. endif
  1279. dep_llvm = null_dep
  1280. with_llvm = false
  1281. if _llvm != 'false'
  1282. dep_llvm = dependency(
  1283. 'llvm',
  1284. version : _llvm_version,
  1285. modules : llvm_modules,
  1286. optional_modules : llvm_optional_modules,
  1287. required : (
  1288. with_amd_vk or with_gallium_radeonsi or with_gallium_swr or
  1289. with_gallium_opencl or _llvm == 'true'
  1290. ),
  1291. static : not _shared_llvm,
  1292. method : _llvm_method,
  1293. fallback : ['llvm', 'dep_llvm'],
  1294. )
  1295. with_llvm = dep_llvm.found()
  1296. endif
  1297. if with_llvm
  1298. pre_args += '-DLLVM_AVAILABLE'
  1299. pre_args += '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version())
  1300. # LLVM can be built without rtti, turning off rtti changes the ABI of C++
  1301. # programs, so we need to build all C++ code in mesa without rtti as well to
  1302. # ensure that linking works.
  1303. #
  1304. # In meson 0.51.0 we can use cmake to find LLVM in addittion to meson's
  1305. # builtin llvm-config based finder. A new generic variable getter method
  1306. # has also been added, so we'll use that if we can, to cover the cmake case.
  1307. if dep_llvm.type_name() == 'internal'
  1308. _rtti = subproject('llvm').get_variable('has_rtti', true)
  1309. elif meson.version().version_compare('>=0.51')
  1310. # The CMake finder will return 'ON', the llvm-config will return 'YES'
  1311. _rtti = ['ON', 'YES'].contains(dep_llvm.get_variable(cmake : 'LLVM_ENABLE_RTTI', configtool: 'has-rtti'))
  1312. else
  1313. _rtti = dep_llvm.get_configtool_variable('has-rtti') == 'YES'
  1314. endif
  1315. if not _rtti
  1316. if with_gallium_nouveau
  1317. error('The Nouveau driver requires rtti. You either need to turn off nouveau or use an LLVM built with LLVM_ENABLE_RTTI.')
  1318. elif with_gallium_opencl
  1319. error('The Clover OpenCL state tracker requires rtti, you need to turn off clover or use an LLVM built with LLVM_ENABLE_RTTI.')
  1320. endif
  1321. if cc.get_id() == 'msvc'
  1322. cpp_args += '/GR-'
  1323. else
  1324. cpp_args += '-fno-rtti'
  1325. endif
  1326. endif
  1327. elif with_amd_vk or with_gallium_radeonsi or with_gallium_swr
  1328. error('The following drivers require LLVM: Radv, RadeonSI, SWR. One of these is enabled, but LLVM is disabled.')
  1329. elif with_gallium_opencl
  1330. error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.')
  1331. endif
  1332. if (with_amd_vk or with_gallium_radeonsi or with_gallium_opencl or
  1333. (with_gallium_r600 and with_llvm))
  1334. dep_elf = dependency('libelf', required : false)
  1335. if not dep_elf.found()
  1336. dep_elf = cc.find_library('elf')
  1337. endif
  1338. else
  1339. dep_elf = null_dep
  1340. endif
  1341. dep_glvnd = null_dep
  1342. if with_glvnd
  1343. dep_glvnd = dependency('libglvnd', version : '>= 1.2.0')
  1344. pre_args += '-DUSE_LIBGLVND=1'
  1345. endif
  1346. if with_valgrind != 'false'
  1347. dep_valgrind = dependency('valgrind', required : with_valgrind == 'true')
  1348. if dep_valgrind.found()
  1349. pre_args += '-DHAVE_VALGRIND'
  1350. endif
  1351. else
  1352. dep_valgrind = null_dep
  1353. endif
  1354. # pthread stubs. Lets not and say we didn't
  1355. if host_machine.system() == 'windows'
  1356. # Prefer the winflexbison versions, they're much easier to install and have
  1357. # better windows support.
  1358. prog_flex = find_program('win_flex', required : false)
  1359. if prog_flex.found()
  1360. # windows compatibility (uses <io.h> instead of <unistd.h> and _isatty,
  1361. # _fileno functions)
  1362. prog_flex = [prog_flex, '--wincompat']
  1363. else
  1364. prog_flex = [find_program('lex', 'flex', required : with_any_opengl)]
  1365. endif
  1366. # Force flex to use const keyword in prototypes, as relies on __cplusplus or
  1367. # __STDC__ macro to determine whether it's safe to use const keyword, but
  1368. # MSVC never defines __STDC__ unless we disable all MSVC extensions.
  1369. prog_flex += '-DYY_USE_CONST='
  1370. prog_bison = find_program('win_bison', required : false)
  1371. if not prog_bison.found()
  1372. prog_bison = find_program('yacc', 'bison', required : with_any_opengl)
  1373. endif
  1374. else
  1375. prog_bison = find_program('bison', required : with_any_opengl)
  1376. prog_flex = find_program('flex', required : with_any_opengl)
  1377. endif
  1378. dep_selinux = null_dep
  1379. if get_option('selinux')
  1380. dep_selinux = dependency('libselinux')
  1381. pre_args += '-DMESA_SELINUX'
  1382. endif
  1383. if with_libunwind != 'false'
  1384. dep_unwind = dependency('libunwind', required : with_libunwind == 'true')
  1385. if dep_unwind.found()
  1386. pre_args += '-DHAVE_LIBUNWIND'
  1387. endif
  1388. else
  1389. dep_unwind = null_dep
  1390. endif
  1391. if with_osmesa != 'none'
  1392. if with_osmesa == 'gallium' and not with_gallium_softpipe
  1393. error('OSMesa gallium requires gallium softpipe or llvmpipe.')
  1394. endif
  1395. if host_machine.system() == 'windows'
  1396. osmesa_lib_name = 'osmesa'
  1397. else
  1398. osmesa_lib_name = 'OSMesa'
  1399. endif
  1400. osmesa_bits = get_option('osmesa-bits')
  1401. if osmesa_bits != '8'
  1402. if with_dri or with_glx != 'disabled'
  1403. error('OSMesa bits must be 8 if building glx or dir based drivers')
  1404. endif
  1405. osmesa_lib_name = osmesa_lib_name + osmesa_bits
  1406. pre_args += [
  1407. '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31'
  1408. ]
  1409. endif
  1410. endif
  1411. # TODO: symbol mangling
  1412. if with_platform_wayland
  1413. dep_wl_scanner = dependency('wayland-scanner', native: true)
  1414. prog_wl_scanner = find_program(dep_wl_scanner.get_pkgconfig_variable('wayland_scanner'))
  1415. if dep_wl_scanner.version().version_compare('>= 1.15')
  1416. wl_scanner_arg = 'private-code'
  1417. else
  1418. wl_scanner_arg = 'code'
  1419. endif
  1420. dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
  1421. dep_wayland_client = dependency('wayland-client', version : '>=1.11')
  1422. dep_wayland_server = dependency('wayland-server', version : '>=1.11')
  1423. if with_egl
  1424. dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3')
  1425. dep_wayland_egl_headers = declare_dependency(
  1426. compile_args : run_command(prog_pkgconfig, ['wayland-egl-backend', '--cflags']).stdout().split())
  1427. endif
  1428. wayland_dmabuf_xml = join_paths(
  1429. dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
  1430. 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
  1431. )
  1432. pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED']
  1433. endif
  1434. dep_x11 = null_dep
  1435. dep_xext = null_dep
  1436. dep_xdamage = null_dep
  1437. dep_xfixes = null_dep
  1438. dep_x11_xcb = null_dep
  1439. dep_xcb = null_dep
  1440. dep_xcb_glx = null_dep
  1441. dep_xcb_dri2 = null_dep
  1442. dep_xcb_dri3 = null_dep
  1443. dep_dri2proto = null_dep
  1444. dep_glproto = null_dep
  1445. dep_xxf86vm = null_dep
  1446. dep_xcb_dri3 = null_dep
  1447. dep_xcb_present = null_dep
  1448. dep_xcb_sync = null_dep
  1449. dep_xcb_xfixes = null_dep
  1450. dep_xshmfence = null_dep
  1451. dep_xcb_xrandr = null_dep
  1452. dep_xlib_xrandr = null_dep
  1453. if with_platform_x11
  1454. if with_glx == 'xlib' or with_glx == 'gallium-xlib'
  1455. dep_x11 = dependency('x11')
  1456. dep_xext = dependency('xext')
  1457. dep_xcb = dependency('xcb')
  1458. elif with_glx == 'dri'
  1459. dep_x11 = dependency('x11')
  1460. dep_xext = dependency('xext')
  1461. dep_xdamage = dependency('xdamage', version : '>= 1.1')
  1462. dep_xfixes = dependency('xfixes')
  1463. dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
  1464. endif
  1465. if (with_any_vk or with_glx == 'dri' or with_egl or
  1466. (with_gallium_vdpau or with_gallium_xvmc or with_gallium_va or
  1467. with_gallium_omx != 'disabled'))
  1468. dep_xcb = dependency('xcb')
  1469. dep_x11_xcb = dependency('x11-xcb')
  1470. if with_dri_platform == 'drm' and not dep_libdrm.found()
  1471. error('libdrm required for gallium video statetrackers when using x11')
  1472. endif
  1473. endif
  1474. if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
  1475. dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
  1476. if with_dri3
  1477. pre_args += '-DHAVE_DRI3'
  1478. dep_xcb_dri3 = dependency('xcb-dri3')
  1479. dep_xcb_present = dependency('xcb-present')
  1480. # until xcb-dri3 has been around long enough to make a hard-dependency:
  1481. if (dep_xcb_dri3.version().version_compare('>= 1.13') and
  1482. dep_xcb_present.version().version_compare('>= 1.13'))
  1483. pre_args += '-DHAVE_DRI3_MODIFIERS'
  1484. endif
  1485. dep_xcb_sync = dependency('xcb-sync')
  1486. dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
  1487. endif
  1488. endif
  1489. if with_glx == 'dri' or with_glx == 'gallium-xlib'
  1490. dep_glproto = dependency('glproto', version : '>= 1.4.14')
  1491. endif
  1492. if with_glx == 'dri'
  1493. if with_dri_platform == 'drm'
  1494. dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
  1495. dep_xxf86vm = dependency('xxf86vm')
  1496. endif
  1497. endif
  1498. if (with_egl or (
  1499. with_gallium_vdpau or with_gallium_xvmc or with_gallium_xa or
  1500. with_gallium_omx != 'disabled'))
  1501. dep_xcb_xfixes = dependency('xcb-xfixes')
  1502. endif
  1503. if with_xlib_lease
  1504. dep_xcb_xrandr = dependency('xcb-randr')
  1505. dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
  1506. endif
  1507. endif
  1508. if get_option('gallium-extra-hud')
  1509. pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1'
  1510. endif
  1511. _sensors = get_option('lmsensors')
  1512. if _sensors != 'false'
  1513. dep_lmsensors = cc.find_library('sensors', required : _sensors == 'true')
  1514. if dep_lmsensors.found()
  1515. pre_args += '-DHAVE_LIBSENSORS=1'
  1516. endif
  1517. else
  1518. dep_lmsensors = null_dep
  1519. endif
  1520. foreach a : pre_args
  1521. add_project_arguments(a, language : ['c', 'cpp'])
  1522. endforeach
  1523. foreach a : c_args
  1524. add_project_arguments(a, language : ['c'])
  1525. endforeach
  1526. foreach a : cpp_args
  1527. add_project_arguments(a, language : ['cpp'])
  1528. endforeach
  1529. gl_priv_reqs = []
  1530. if with_glx == 'xlib' or with_glx == 'gallium-xlib'
  1531. gl_priv_reqs += ['x11', 'xext', 'xcb']
  1532. elif with_glx == 'dri'
  1533. gl_priv_reqs += [
  1534. 'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb',
  1535. 'xcb-glx >= 1.8.1']
  1536. if with_dri_platform == 'drm'
  1537. gl_priv_reqs += 'xcb-dri2 >= 1.8'
  1538. gl_priv_reqs += 'xxf86vm'
  1539. endif
  1540. endif
  1541. if dep_libdrm.found()
  1542. gl_priv_reqs += 'libdrm >= 2.4.75'
  1543. endif
  1544. gl_priv_libs = []
  1545. if dep_thread.found()
  1546. gl_priv_libs += ['-lpthread', '-pthread']
  1547. endif
  1548. if dep_m.found()
  1549. gl_priv_libs += '-lm'
  1550. endif
  1551. if dep_dl.found()
  1552. gl_priv_libs += '-ldl'
  1553. endif
  1554. pkg = import('pkgconfig')
  1555. if host_machine.system() == 'windows'
  1556. prog_dumpbin = find_program('dumpbin', required : false)
  1557. with_symbols_check = prog_dumpbin.found() and with_tests
  1558. symbols_check_args = ['--dumpbin', prog_dumpbin.path()]
  1559. else
  1560. prog_nm = find_program('nm')
  1561. with_symbols_check = with_tests
  1562. symbols_check_args = ['--nm', prog_nm.path()]
  1563. endif
  1564. # This quirk needs to be applied to sources with functions defined in assembly
  1565. # as GCC LTO drops them. See: https://bugs.freedesktop.org/show_bug.cgi?id=109391
  1566. gcc_lto_quirk = (cc.get_id() == 'gcc') ? ['-fno-lto'] : []
  1567. subdir('include')
  1568. subdir('bin')
  1569. subdir('src')
  1570. # Meson 0.49 and earlier seems to have a bug that fails to evaluate the string-
  1571. # formatting below unless the first argument is passed as a variable. This has
  1572. # been fixed in Meson 0.50 and beyond, but we need to keep it like this for now
  1573. # for backwards compatibility.
  1574. _with_opengl_string = with_opengl ? 'yes' : 'no'
  1575. lines = ['',
  1576. 'prefix: ' + get_option('prefix'),
  1577. 'libdir: ' + get_option('libdir'),
  1578. 'includedir: ' + get_option('includedir'),
  1579. '',
  1580. 'OpenGL: @0@ (ES1: @1@ ES2: @2@)'.format(_with_opengl_string,
  1581. with_gles1 ? 'yes' : 'no',
  1582. with_gles2 ? 'yes' : 'no'),
  1583. ]
  1584. if with_osmesa != 'none'
  1585. lines += ''
  1586. suffix = ''
  1587. if with_osmesa == 'gallium'
  1588. suffix = '(Gallium)'
  1589. endif
  1590. lines += 'OSMesa: lib' + osmesa_lib_name + suffix
  1591. else
  1592. lines += 'OSMesa: no'
  1593. endif
  1594. if with_dri
  1595. lines += ''
  1596. lines += 'DRI platform: ' + with_dri_platform
  1597. if dri_drivers.length() != 0 and dri_drivers != ['']
  1598. lines += 'DRI drivers: ' + ' '.join(dri_drivers)
  1599. else
  1600. lines += 'DRI drivers: no'
  1601. endif
  1602. lines += 'DRI driver dir: ' + dri_drivers_path
  1603. endif
  1604. if with_glx != 'disabled'
  1605. lines += ''
  1606. if with_glx == 'dri'
  1607. lines += 'GLX: DRI-based'
  1608. elif with_glx == 'xlib'
  1609. lines += 'GLX: Xlib-based'
  1610. elif with_glx == 'gallium-xlib'
  1611. lines += 'GLX: Xlib-based (Gallium)'
  1612. else
  1613. lines += 'GLX: ' + with_glx
  1614. endif
  1615. endif
  1616. lines += ''
  1617. lines += 'EGL: ' + (with_egl ? 'yes' : 'no')
  1618. if with_egl
  1619. egl_drivers = []
  1620. if with_dri
  1621. egl_drivers += 'builtin:egl_dri2'
  1622. endif
  1623. if with_dri3
  1624. egl_drivers += 'builtin:egl_dri3'
  1625. endif
  1626. lines += 'EGL drivers: ' + ' '.join(egl_drivers)
  1627. endif
  1628. lines += 'GBM: ' + (with_gbm ? 'yes' : 'no')
  1629. if with_platforms
  1630. lines += 'EGL/Vulkan/VL platforms: ' + ' '.join(_platforms)
  1631. endif
  1632. lines += ''
  1633. if with_any_vk
  1634. lines += 'Vulkan drivers: ' + ' '.join(_vulkan_drivers)
  1635. lines += 'Vulkan ICD dir: ' + with_vulkan_icd_dir
  1636. else
  1637. lines += 'Vulkan drivers: no'
  1638. endif
  1639. lines += ''
  1640. if with_llvm
  1641. lines += 'llvm: yes'
  1642. lines += 'llvm-version: ' + dep_llvm.version()
  1643. else
  1644. lines += 'llvm: no'
  1645. endif
  1646. lines += ''
  1647. if with_gallium
  1648. lines += 'Gallium drivers: ' + ' '.join(gallium_drivers)
  1649. gallium_st = ['mesa']
  1650. if with_gallium_xa
  1651. gallium_st += 'xa'
  1652. endif
  1653. if with_gallium_xvmc
  1654. gallium_st += 'xvmc'
  1655. endif
  1656. if with_gallium_xvmc
  1657. gallium_st += 'xvmc'
  1658. endif
  1659. if with_gallium_vdpau
  1660. gallium_st += 'vdpau'
  1661. endif
  1662. if with_gallium_omx != 'disabled'
  1663. gallium_st += 'omx' + with_gallium_omx
  1664. endif
  1665. if with_gallium_va
  1666. gallium_st += 'va'
  1667. endif
  1668. if with_gallium_st_nine
  1669. gallium_st += 'nine'
  1670. endif
  1671. if with_gallium_opencl
  1672. gallium_st += 'clover'
  1673. endif
  1674. lines += 'Gallium st: ' + ' '.join(gallium_st)
  1675. else
  1676. lines += 'Gallium: no'
  1677. endif
  1678. lines += 'HUD lmsensors: ' + (dep_lmsensors.found() ? 'yes' : 'no')
  1679. lines += ''
  1680. lines += 'Shared-glapi: ' + (with_shared_glapi ? 'yes' : 'no')
  1681. indent = ' '
  1682. summary = indent + ('\n' + indent).join(lines)
  1683. message('Configuration summary:\n@0@\n'.format(summary))