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

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