Clone of mesa.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

meson.build 57KB

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