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 38KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  1. # Copyright © 2017 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.42',
  25. default_options : ['buildtype=debugoptimized', 'c_std=c99', 'cpp_std=c++11']
  26. )
  27. # Arguments for the preprocessor, put these in a separate array from the C and
  28. # C++ (cpp in meson terminology) arguments since they need to be added to the
  29. # default arguments for both C and C++.
  30. pre_args = [
  31. '-D__STDC_CONSTANT_MACROS',
  32. '-D__STDC_FORMAT_MACROS',
  33. '-D__STDC_LIMIT_MACROS',
  34. '-DVERSION="@0@"'.format(meson.project_version()),
  35. '-DPACKAGE_VERSION=VERSION',
  36. '-DPACKAGE_BUGREPORT="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa"',
  37. ]
  38. with_vulkan_icd_dir = get_option('vulkan-icd-dir')
  39. with_tests = get_option('build-tests')
  40. with_valgrind = get_option('valgrind')
  41. with_libunwind = get_option('libunwind')
  42. with_asm = get_option('asm')
  43. with_osmesa = get_option('osmesa')
  44. with_swr_arches = get_option('swr-arches').split(',')
  45. with_tools = get_option('tools').split(',')
  46. if with_tools.contains('all')
  47. with_tools = ['freedreno', 'glsl', 'intel', 'nir', 'nouveau']
  48. endif
  49. if get_option('texture-float')
  50. pre_args += '-DTEXTURE_FLOAT_ENABLED'
  51. message('WARNING: Floating-point texture enabled. Please consult docs/patents.txt and your lawyer before building mesa.')
  52. endif
  53. dri_drivers_path = get_option('dri-drivers-path')
  54. if dri_drivers_path == ''
  55. dri_drivers_path = join_paths(get_option('libdir'), 'dri')
  56. endif
  57. dri_search_path = get_option('dri-search-path')
  58. if dri_search_path == ''
  59. dri_search_path = join_paths(get_option('prefix'), dri_drivers_path)
  60. endif
  61. with_gles1 = get_option('gles1')
  62. with_gles2 = get_option('gles2')
  63. with_opengl = get_option('opengl')
  64. with_any_opengl = with_opengl or with_gles1 or with_gles2
  65. # Only build shared_glapi if at least one OpenGL API is enabled
  66. with_shared_glapi = get_option('shared-glapi') and with_any_opengl
  67. # shared-glapi is required if at least two OpenGL APIs are being built
  68. if not with_shared_glapi
  69. if ((with_gles1 and with_gles2) or (with_gles1 and with_opengl)
  70. or (with_gles2 and with_opengl))
  71. error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x')
  72. endif
  73. endif
  74. # We require OpenGL for OpenGL ES
  75. if (with_gles1 or with_gles2) and not with_opengl
  76. error('building OpenGL ES without OpenGL is not supported.')
  77. endif
  78. with_dri = false
  79. with_dri_i915 = false
  80. with_dri_i965 = false
  81. with_dri_r100 = false
  82. with_dri_r200 = false
  83. with_dri_nouveau = false
  84. with_dri_swrast = false
  85. _drivers = get_option('dri-drivers')
  86. if _drivers == 'auto'
  87. if host_machine.system() == 'linux'
  88. # TODO: PPC, Sparc
  89. if ['x86', 'x86_64'].contains(host_machine.cpu_family())
  90. _drivers = 'i915,i965,r100,r200,nouveau'
  91. else
  92. error('Unknown architecture. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
  93. endif
  94. elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
  95. # only swrast would make sense here, but gallium swrast is a much better default
  96. _drivers = ''
  97. else
  98. error('Unknown OS. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
  99. endif
  100. endif
  101. if _drivers != ''
  102. _split = _drivers.split(',')
  103. with_dri_i915 = _split.contains('i915')
  104. with_dri_i965 = _split.contains('i965')
  105. with_dri_r100 = _split.contains('r100')
  106. with_dri_r200 = _split.contains('r200')
  107. with_dri_nouveau = _split.contains('nouveau')
  108. with_dri_swrast = _split.contains('swrast')
  109. with_dri = true
  110. endif
  111. with_gallium = false
  112. with_gallium_pl111 = false
  113. with_gallium_radeonsi = false
  114. with_gallium_r300 = false
  115. with_gallium_r600 = false
  116. with_gallium_nouveau = false
  117. with_gallium_freedreno = false
  118. with_gallium_softpipe = false
  119. with_gallium_vc4 = false
  120. with_gallium_vc5 = false
  121. with_gallium_etnaviv = false
  122. with_gallium_imx = false
  123. with_gallium_i915 = false
  124. with_gallium_svga = false
  125. with_gallium_virgl = false
  126. with_gallium_swr = false
  127. _drivers = get_option('gallium-drivers')
  128. if _drivers == 'auto'
  129. if host_machine.system() == 'linux'
  130. # TODO: PPC, Sparc
  131. if ['x86', 'x86_64'].contains(host_machine.cpu_family())
  132. _drivers = 'r300,r600,radeonsi,nouveau,virgl,svga,swrast'
  133. elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
  134. _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,virgl,svga,swrast'
  135. else
  136. error('Unknown architecture. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
  137. endif
  138. elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
  139. _drivers = 'swrast'
  140. else
  141. error('Unknown OS. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
  142. endif
  143. endif
  144. if _drivers != ''
  145. _split = _drivers.split(',')
  146. with_gallium_pl111 = _split.contains('pl111')
  147. with_gallium_radeonsi = _split.contains('radeonsi')
  148. with_gallium_r300 = _split.contains('r300')
  149. with_gallium_r600 = _split.contains('r600')
  150. with_gallium_nouveau = _split.contains('nouveau')
  151. with_gallium_freedreno = _split.contains('freedreno')
  152. with_gallium_softpipe = _split.contains('swrast')
  153. with_gallium_vc4 = _split.contains('vc4')
  154. with_gallium_vc5 = _split.contains('vc5')
  155. with_gallium_etnaviv = _split.contains('etnaviv')
  156. with_gallium_imx = _split.contains('imx')
  157. with_gallium_i915 = _split.contains('i915')
  158. with_gallium_svga = _split.contains('svga')
  159. with_gallium_virgl = _split.contains('virgl')
  160. with_gallium_swr = _split.contains('swr')
  161. with_gallium = true
  162. endif
  163. with_intel_vk = false
  164. with_amd_vk = false
  165. with_any_vk = false
  166. _vulkan_drivers = get_option('vulkan-drivers')
  167. if _vulkan_drivers == 'auto'
  168. if host_machine.system() == 'linux'
  169. if host_machine.cpu_family().startswith('x86')
  170. _vulkan_drivers = 'amd,intel'
  171. else
  172. error('Unknown architecture. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.')
  173. endif
  174. elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
  175. # No vulkan driver supports windows or macOS currently
  176. _vulkan_drivers = ''
  177. else
  178. error('Unknown OS. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.')
  179. endif
  180. endif
  181. if _vulkan_drivers != ''
  182. _split = _vulkan_drivers.split(',')
  183. with_intel_vk = _split.contains('intel')
  184. with_amd_vk = _split.contains('amd')
  185. with_any_vk = with_amd_vk or with_intel_vk
  186. endif
  187. if with_dri_swrast and (with_gallium_softpipe or with_gallium_swr)
  188. error('Only one swrast provider can be built')
  189. endif
  190. if with_dri_i915 and with_gallium_i915
  191. error('Only one i915 provider can be built')
  192. endif
  193. if with_gallium_imx and not with_gallium_etnaviv
  194. error('IMX driver requires etnaviv driver')
  195. endif
  196. if with_gallium_pl111 and not with_gallium_vc4
  197. error('pl111 driver requires vc4 driver')
  198. endif
  199. dep_libdrm_intel = []
  200. if with_dri_i915 or with_gallium_i915
  201. dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
  202. endif
  203. system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'dragonfly', 'linux'].contains(host_machine.system())
  204. if host_machine.system() == 'darwin'
  205. with_dri_platform = 'apple'
  206. elif ['windows', 'cygwin'].contains(host_machine.system())
  207. with_dri_platform = 'windows'
  208. elif system_has_kms_drm
  209. with_dri_platform = 'drm'
  210. else
  211. # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should
  212. # assert here that one of those cases has been met.
  213. # FIXME: GNU (hurd) ends up here as well, but meson doesn't officially
  214. # support Hurd at time of writing (2017/11)
  215. # FIXME: illumos ends up here as well
  216. with_dri_platform = 'none'
  217. endif
  218. with_platform_android = false
  219. with_platform_wayland = false
  220. with_platform_x11 = false
  221. with_platform_drm = false
  222. with_platform_surfaceless = false
  223. egl_native_platform = ''
  224. _platforms = get_option('platforms')
  225. if _platforms == 'auto'
  226. if system_has_kms_drm
  227. _platforms = 'x11,wayland,drm,surfaceless'
  228. elif ['darwin', 'windows', 'cygwin'].contains(host_machine.system())
  229. _platforms = 'x11,surfaceless'
  230. elif ['haiku'].contains(host_machine.system())
  231. _platforms = 'haiku'
  232. else
  233. error('Unknown OS. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.')
  234. endif
  235. endif
  236. if _platforms != ''
  237. _split = _platforms.split(',')
  238. with_platform_android = _split.contains('android')
  239. with_platform_x11 = _split.contains('x11')
  240. with_platform_wayland = _split.contains('wayland')
  241. with_platform_drm = _split.contains('drm')
  242. with_platform_haiku = _split.contains('haiku')
  243. with_platform_surfaceless = _split.contains('surfaceless')
  244. egl_native_platform = _split[0]
  245. endif
  246. with_glx = get_option('glx')
  247. if with_glx == 'auto'
  248. if with_dri
  249. with_glx = 'dri'
  250. elif with_platform_haiku
  251. with_glx = 'disabled'
  252. elif with_gallium
  253. # Even when building just gallium drivers the user probably wants dri
  254. with_glx = 'dri'
  255. elif with_platform_x11 and with_any_opengl and not with_any_vk
  256. # The automatic behavior should not be to turn on xlib based glx when
  257. # building only vulkan drivers
  258. with_glx = 'xlib'
  259. else
  260. with_glx = 'disabled'
  261. endif
  262. endif
  263. if with_glx == 'dri'
  264. if with_gallium
  265. with_dri = true
  266. endif
  267. endif
  268. if not (with_dri or with_gallium or with_glx == 'xlib' or with_glx == 'gallium-xlib')
  269. with_gles1 = false
  270. with_gles2 = false
  271. with_opengl = false
  272. with_any_opengl = false
  273. with_shared_glapi = false
  274. endif
  275. with_gbm = get_option('gbm')
  276. if with_gbm == 'auto' and with_dri # TODO: or gallium
  277. with_gbm = system_has_kms_drm
  278. elif with_gbm == 'true'
  279. if not system_has_kms_drm
  280. error('GBM only supports DRM/KMS platforms')
  281. endif
  282. with_gbm = true
  283. else
  284. with_gbm = false
  285. endif
  286. _egl = get_option('egl')
  287. if _egl == 'auto'
  288. with_egl = with_dri and with_shared_glapi and egl_native_platform != ''
  289. elif _egl == 'true'
  290. if not with_dri
  291. error('EGL requires dri')
  292. elif not with_shared_glapi
  293. error('EGL requires shared-glapi')
  294. elif egl_native_platform == ''
  295. error('No platforms specified, consider -Dplatforms=drm,x11 at least')
  296. endif
  297. with_egl = true
  298. else
  299. with_egl = false
  300. endif
  301. if with_egl and not (with_platform_drm or with_platform_surfaceless)
  302. if with_gallium_radeonsi
  303. error('RadeonSI requires drm or surfaceless platform when using EGL')
  304. endif
  305. if with_gallium_virgl
  306. error('Virgl requires drm or surfaceless platform when using EGL')
  307. endif
  308. endif
  309. pre_args += '-DGLX_USE_TLS'
  310. if with_glx != 'disabled'
  311. if not (with_platform_x11 and with_any_opengl)
  312. if with_glx == 'auto'
  313. with_glx = 'disabled'
  314. else
  315. error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
  316. endif
  317. elif with_glx == 'gallium-xlib'
  318. if not with_gallium
  319. error('Gallium-xlib based GLX requires at least one gallium driver')
  320. elif not with_gallium_softpipe
  321. error('Gallium-xlib based GLX requires softpipe or llvmpipe.')
  322. elif with_dri
  323. error('gallium-xlib conflicts with any dri driver')
  324. endif
  325. elif with_glx == 'xlib'
  326. if with_dri
  327. error('xlib conflicts with any dri driver')
  328. endif
  329. elif with_glx == 'dri' and not with_dri
  330. error('dri based GLX requires at least one DRI driver')
  331. endif
  332. endif
  333. with_glvnd = get_option('glvnd')
  334. if with_glvnd
  335. if with_glx == 'xlib' or with_glx == 'gallium-xlib'
  336. error('Cannot build glvnd support for GLX that is not DRI based.')
  337. elif with_glx == 'disabled' and not with_egl
  338. error('glvnd requires DRI based GLX and/or EGL')
  339. endif
  340. endif
  341. # TODO: toggle for this
  342. with_glx_direct = true
  343. if with_vulkan_icd_dir == ''
  344. with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
  345. endif
  346. with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
  347. with_dri3 = get_option('dri3')
  348. if with_dri3 == 'auto'
  349. with_dri3 = system_has_kms_drm and with_dri2
  350. else
  351. with_dri3 = with_dri3 == 'true'
  352. endif
  353. if with_any_vk and (with_platform_x11 and not with_dri3)
  354. error('Vulkan drivers require dri3 for X11 support')
  355. endif
  356. if with_dri or with_gallium
  357. if with_glx == 'disabled' and not with_egl and not with_platform_haiku
  358. error('building dri or gallium drivers require at least one window system')
  359. endif
  360. endif
  361. prog_pkgconfig = find_program('pkg-config')
  362. _vdpau = get_option('gallium-vdpau')
  363. if not system_has_kms_drm
  364. if _vdpau == 'true'
  365. error('VDPAU state tracker can only be build on unix-like OSes.')
  366. else
  367. _vdpau = 'false'
  368. endif
  369. elif not with_platform_x11
  370. if _vdpau == 'true'
  371. error('VDPAU state tracker requires X11 support.')
  372. else
  373. _vdpau = 'false'
  374. endif
  375. elif not (with_gallium_r300 or with_gallium_r600 or with_gallium_radeonsi or
  376. with_gallium_nouveau)
  377. if _vdpau == 'true'
  378. error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau.')
  379. else
  380. _vdpau = 'false'
  381. endif
  382. elif _vdpau == 'auto'
  383. _vdpau = 'true'
  384. endif
  385. with_gallium_vdpau = _vdpau == 'true'
  386. dep_vdpau = []
  387. if with_gallium_vdpau
  388. dep_vdpau = dependency('vdpau', version : '>= 1.1')
  389. dep_vdpau = declare_dependency(
  390. compile_args : run_command(prog_pkgconfig, ['vdpau', '--cflags']).stdout().split()
  391. )
  392. endif
  393. if with_gallium_vdpau
  394. pre_args += '-DHAVE_ST_VDPAU'
  395. endif
  396. vdpau_drivers_path = get_option('vdpau-libs-path')
  397. if vdpau_drivers_path == ''
  398. vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
  399. endif
  400. _xvmc = get_option('gallium-xvmc')
  401. if not system_has_kms_drm
  402. if _xvmc == 'true'
  403. error('XVMC state tracker can only be build on unix-like OSes.')
  404. else
  405. _xvmc = 'false'
  406. endif
  407. elif not with_platform_x11
  408. if _xvmc == 'true'
  409. error('XVMC state tracker requires X11 support.')
  410. else
  411. _xvmc = 'false'
  412. endif
  413. elif not (with_gallium_r600 or with_gallium_nouveau)
  414. if _xvmc == 'true'
  415. error('XVMC state tracker requires at least one of the following gallium drivers: r600, nouveau.')
  416. else
  417. _xvmc = 'false'
  418. endif
  419. elif _xvmc == 'auto'
  420. _xvmc = 'true'
  421. endif
  422. with_gallium_xvmc = _xvmc == 'true'
  423. dep_xvmc = []
  424. if with_gallium_xvmc
  425. dep_xvmc = dependency('xvmc', version : '>= 1.0.6')
  426. endif
  427. xvmc_drivers_path = get_option('xvmc-libs-path')
  428. if xvmc_drivers_path == ''
  429. xvmc_drivers_path = get_option('libdir')
  430. endif
  431. _omx = get_option('gallium-omx')
  432. if not system_has_kms_drm
  433. if _omx == 'true'
  434. error('OMX state tracker can only be built on unix-like OSes.')
  435. else
  436. _omx = 'false'
  437. endif
  438. elif not (with_platform_x11 or with_platform_drm)
  439. if _omx == 'true'
  440. error('OMX state tracker requires X11 or drm platform support.')
  441. else
  442. _omx = 'false'
  443. endif
  444. elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
  445. if _omx == 'true'
  446. error('OMX state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
  447. else
  448. _omx = 'false'
  449. endif
  450. elif _omx == 'auto'
  451. _omx = 'true'
  452. endif
  453. with_gallium_omx = _omx == 'true'
  454. dep_omx = []
  455. if with_gallium_omx
  456. dep_omx = dependency('libomxil-bellagio')
  457. endif
  458. omx_drivers_path = get_option('omx-libs-path')
  459. if with_gallium_omx
  460. # Figure out where to put the omx driver.
  461. # FIXME: this could all be vastly simplified by adding a 'defined_variable'
  462. # argument to meson's get_pkgconfig_variable method.
  463. if omx_drivers_path == ''
  464. _omx_libdir = dep_omx.get_pkgconfig_variable('libdir')
  465. _omx_drivers_dir = dep_omx.get_pkgconfig_variable('pluginsdir')
  466. if _omx_libdir == get_option('libdir')
  467. omx_drivers_path = _omx_drivers_dir
  468. else
  469. _omx_base_dir = []
  470. # This will fail on windows. Does OMX run on windows?
  471. _omx_libdir = _omx_libdir.split('/')
  472. _omx_drivers_dir = _omx_drivers_dir.split('/')
  473. foreach o : _omx_drivers_dir
  474. if not _omx_libdir.contains(o)
  475. _omx_base_dir += o
  476. endif
  477. endforeach
  478. omx_drivers_path = join_paths(get_option('libdir'), _omx_base_dir)
  479. endif
  480. endif
  481. endif
  482. _va = get_option('gallium-va')
  483. if not system_has_kms_drm
  484. if _va == 'true'
  485. error('VA state tracker can only be built on unix-like OSes.')
  486. else
  487. _va = 'false'
  488. endif
  489. elif not (with_platform_x11 or with_platform_drm)
  490. if _va == 'true'
  491. error('VA state tracker requires X11 or drm or wayland platform support.')
  492. else
  493. _va = 'false'
  494. endif
  495. elif not (with_gallium_r600 or with_gallium_radeonsi or with_gallium_nouveau)
  496. if _va == 'true'
  497. error('VA state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau.')
  498. else
  499. _va = 'false'
  500. endif
  501. elif _va == 'auto'
  502. _va = 'true'
  503. endif
  504. with_gallium_va = _va == 'true'
  505. dep_va = []
  506. if with_gallium_va
  507. dep_va = dependency('libva', version : '>= 0.38.0')
  508. dep_va_headers = declare_dependency(
  509. compile_args : run_command(prog_pkgconfig, ['libva', '--cflags']).stdout().split()
  510. )
  511. endif
  512. va_drivers_path = get_option('va-libs-path')
  513. if va_drivers_path == ''
  514. va_drivers_path = join_paths(get_option('libdir'), 'dri')
  515. endif
  516. _xa = get_option('gallium-xa')
  517. if not system_has_kms_drm
  518. if _xa == 'true'
  519. error('XA state tracker can only be built on unix-like OSes.')
  520. else
  521. _xa = 'false'
  522. endif
  523. elif not (with_gallium_nouveau or with_gallium_freedreno or with_gallium_i915
  524. or with_gallium_svga)
  525. if _xa == 'true'
  526. error('XA state tracker requires at least one of the following gallium drivers: nouveau, freedreno, i915, svga.')
  527. else
  528. _xa = 'false'
  529. endif
  530. endif
  531. with_gallium_xa = _xa != 'false'
  532. d3d_drivers_path = get_option('d3d-drivers-path')
  533. if d3d_drivers_path == ''
  534. d3d_drivers_path = join_paths(get_option('libdir'), 'd3d')
  535. endif
  536. with_gallium_st_nine = get_option('gallium-nine')
  537. if with_gallium_st_nine
  538. if not with_gallium_softpipe
  539. error('The nine state tracker requires gallium softpipe/llvmpipe.')
  540. elif not (with_gallium_radeonsi or with_gallium_nouveau or with_gallium_r600
  541. or with_gallium_r300 or with_gallium_svga or with_gallium_i915)
  542. error('The nine state tracker requires at least on non-swrast gallium driver.')
  543. endif
  544. if not with_dri3
  545. error('Using nine with wine requires dri3')
  546. endif
  547. endif
  548. _opencl = get_option('gallium-opencl')
  549. if _opencl != 'disabled'
  550. if not with_gallium
  551. error('OpenCL Clover implementation requires at least one gallium driver.')
  552. endif
  553. # TODO: alitvec?
  554. dep_clc = dependency('libclc')
  555. with_gallium_opencl = true
  556. with_opencl_icd = _opencl == 'icd'
  557. else
  558. dep_clc = []
  559. with_gallium_opencl = false
  560. with_gallium_icd = false
  561. endif
  562. gl_pkgconfig_c_flags = []
  563. if with_platform_x11
  564. if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
  565. pre_args += '-DHAVE_X11_PLATFORM'
  566. endif
  567. if with_glx == 'xlib' or with_glx == 'gallium-xlib'
  568. pre_args += '-DUSE_XSHM'
  569. else
  570. pre_args += '-DGLX_INDIRECT_RENDERING'
  571. if with_glx_direct
  572. pre_args += '-DGLX_DIRECT_RENDERING'
  573. endif
  574. if with_dri_platform == 'drm'
  575. pre_args += '-DGLX_USE_DRM'
  576. elif with_dri_platform == 'apple'
  577. pre_args += '-DGLX_USE_APPLEGL'
  578. elif with_dri_platform == 'windows'
  579. pre_args += '-DGLX_USE_WINDOWSGL'
  580. endif
  581. endif
  582. else
  583. pre_args += '-DMESA_EGL_NO_X11_HEADERS'
  584. gl_pkgconfig_c_flags += '-DMESA_EGL_NO_X11_HEADERS'
  585. endif
  586. if with_platform_drm
  587. if with_egl and not with_gbm
  588. error('EGL drm platform requires gbm')
  589. endif
  590. pre_args += '-DHAVE_DRM_PLATFORM'
  591. endif
  592. if with_platform_surfaceless
  593. pre_args += '-DHAVE_SURFACELESS_PLATFORM'
  594. endif
  595. if with_platform_android
  596. dep_android = [
  597. dependency('cutils'),
  598. dependency('hardware'),
  599. dependency('sync'),
  600. ]
  601. pre_args += '-DHAVE_ANDROID_PLATFORM'
  602. endif
  603. if with_platform_haiku
  604. pre_args += '-DHAVE_HAIKU_PLATFORM'
  605. endif
  606. prog_python2 = find_program('python2')
  607. has_mako = run_command(prog_python2, '-c', 'import mako')
  608. if has_mako.returncode() != 0
  609. error('Python (2.x) mako module required to build mesa.')
  610. endif
  611. cc = meson.get_compiler('c')
  612. if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
  613. error('When using GCC, version 4.4.6 or later is required.')
  614. endif
  615. # Define DEBUG for debug builds only (debugoptimized is not included on this one)
  616. if get_option('buildtype') == 'debug'
  617. pre_args += '-DDEBUG'
  618. endif
  619. if get_option('shader-cache')
  620. pre_args += '-DENABLE_SHADER_CACHE'
  621. elif with_amd_vk
  622. error('Radv requires shader cache support')
  623. endif
  624. # Check for GCC style builtins
  625. foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
  626. 'ffsll', 'popcount', 'popcountll', 'unreachable']
  627. if cc.has_function(b)
  628. pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
  629. endif
  630. endforeach
  631. # check for GCC __attribute__
  632. foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
  633. 'warn_unused_result', 'weak',]
  634. if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
  635. name : '__attribute__((@0@))'.format(a))
  636. pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
  637. endif
  638. endforeach
  639. if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
  640. name : '__attribute__((format(...)))')
  641. pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
  642. endif
  643. if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
  644. name : '__attribute__((packed))')
  645. pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
  646. endif
  647. if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
  648. name : '__attribute__((returns_nonnull))')
  649. pre_args += '-DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL'
  650. endif
  651. if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
  652. int foo_hid(void) __attribute__((visibility("hidden")));
  653. int foo_int(void) __attribute__((visibility("internal")));
  654. int foo_pro(void) __attribute__((visibility("protected")));''',
  655. name : '__attribute__((visibility(...)))')
  656. pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY'
  657. endif
  658. if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
  659. name : '__attribute__((alias(...)))')
  660. pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
  661. endif
  662. if cc.compiles('int foo(void) __attribute__((__noreturn__));',
  663. name : '__attribute__((__noreturn__))')
  664. pre_args += '-DHAVE_FUNC_ATTRIBUTE_NORETURN'
  665. endif
  666. # TODO: this is very incomplete
  667. if ['linux', 'cygwin'].contains(host_machine.system())
  668. pre_args += '-D_GNU_SOURCE'
  669. endif
  670. # Check for generic C arguments
  671. c_args = []
  672. foreach a : ['-Wall', '-Werror=implicit-function-declaration',
  673. '-Werror=missing-prototypes', '-fno-math-errno',
  674. '-fno-trapping-math', '-Qunused-arguments']
  675. if cc.has_argument(a)
  676. c_args += a
  677. endif
  678. endforeach
  679. c_vis_args = []
  680. if cc.has_argument('-fvisibility=hidden')
  681. c_vis_args += '-fvisibility=hidden'
  682. endif
  683. # Check for generic C++ arguments
  684. cpp = meson.get_compiler('cpp')
  685. cpp_args = []
  686. foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
  687. '-Qunused-arguments']
  688. if cpp.has_argument(a)
  689. cpp_args += a
  690. endif
  691. endforeach
  692. # For some reason, the test for -Wno-foo always succeeds with gcc, even if the
  693. # option is not supported. Hence, check for -Wfoo instead.
  694. if cpp.has_argument('-Wnon-virtual-dtor')
  695. cpp_args += '-Wno-non-virtual-dtor'
  696. endif
  697. no_override_init_args = []
  698. foreach a : ['override-init', 'initializer-overrides']
  699. if cc.has_argument('-W' + a)
  700. no_override_init_args += '-Wno-' + a
  701. endif
  702. endforeach
  703. cpp_vis_args = []
  704. if cpp.has_argument('-fvisibility=hidden')
  705. cpp_vis_args += '-fvisibility=hidden'
  706. endif
  707. # Check for C and C++ arguments for MSVC2013 compatibility. These are only used
  708. # in parts of the mesa code base that need to compile with old versions of
  709. # MSVC, mainly common code
  710. c_msvc_compat_args = []
  711. cpp_msvc_compat_args = []
  712. foreach a : ['-Werror=pointer-arith', '-Werror=vla']
  713. if cc.has_argument(a)
  714. c_msvc_compat_args += a
  715. endif
  716. if cpp.has_argument(a)
  717. cpp_msvc_compat_args += a
  718. endif
  719. endforeach
  720. if host_machine.cpu_family().startswith('x86')
  721. pre_args += '-DUSE_SSE41'
  722. with_sse41 = true
  723. sse41_args = ['-msse4.1']
  724. # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
  725. # that's not guaranteed
  726. if host_machine.cpu_family() == 'x86'
  727. sse41_args += '-mstackrealign'
  728. endif
  729. else
  730. with_sse41 = false
  731. sse41_args = []
  732. endif
  733. # Check for GCC style atomics
  734. if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
  735. name : 'GCC atomic builtins')
  736. pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
  737. endif
  738. if not cc.links('''#include <stdint.h>
  739. uint64_t v;
  740. int main() {
  741. return __sync_add_and_fetch(&v, (uint64_t)1);
  742. }''',
  743. name : 'GCC 64bit atomics')
  744. pre_args += '-DMISSING_64_BIT_ATOMICS'
  745. endif
  746. # TODO: endian
  747. # TODO: powr8
  748. # TODO: shared/static? Is this even worth doing?
  749. # Building x86 assembly code requires running x86 binaries. It is possible for
  750. # x86_64 OSes to run x86 binaries, so don't disable asm in those cases
  751. # TODO: it should be possible to use an exe_wrapper to run the binary during
  752. # the build.
  753. if meson.is_cross_build()
  754. if not (build_machine.cpu_family() == 'x86_64' and host_machine.cpu_family() == 'x86'
  755. and build_machine.system() == host_machine.system())
  756. message('Cross compiling to x86 from non-x86, disabling asm')
  757. with_asm = false
  758. endif
  759. endif
  760. with_asm_arch = ''
  761. if with_asm
  762. # TODO: SPARC and PPC
  763. if host_machine.cpu_family() == 'x86'
  764. if system_has_kms_drm
  765. with_asm_arch = 'x86'
  766. pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
  767. '-DUSE_SSE_ASM']
  768. endif
  769. elif host_machine.cpu_family() == 'x86_64'
  770. if system_has_kms_drm
  771. with_asm_arch = 'x86_64'
  772. pre_args += ['-DUSE_X86_64_ASM']
  773. endif
  774. elif host_machine.cpu_family() == 'arm'
  775. if system_has_kms_drm
  776. with_asm_arch = 'arm'
  777. pre_args += ['-DUSE_ARM_ASM']
  778. endif
  779. elif host_machine.cpu_family() == 'aarch64'
  780. if system_has_kms_drm
  781. with_asm_arch = 'aarch64'
  782. pre_args += ['-DUSE_AARCH64_ASM']
  783. endif
  784. endif
  785. endif
  786. # Check for standard headers and functions
  787. if cc.has_header_symbol('sys/sysmacros.h', 'major')
  788. pre_args += '-DMAJOR_IN_SYSMACROS'
  789. elif cc.has_header_symbol('sys/mkdev.h', 'major')
  790. pre_args += '-DMAJOR_IN_MKDEV'
  791. endif
  792. foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h']
  793. if cc.has_header(h)
  794. pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
  795. endif
  796. endforeach
  797. foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get', 'memfd_create']
  798. if cc.has_function(f)
  799. pre_args += '-DHAVE_@0@'.format(f.to_upper())
  800. endif
  801. endforeach
  802. # strtod locale support
  803. if cc.links('''
  804. #define _GNU_SOURCE
  805. #include <stdlib.h>
  806. #include <locale.h>
  807. #ifdef HAVE_XLOCALE_H
  808. #include <xlocale.h>
  809. #endif
  810. int main() {
  811. locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
  812. const char *s = "1.0";
  813. char *end;
  814. double d = strtod_l(s, end, loc);
  815. float f = strtof_l(s, end, loc);
  816. freelocale(loc);
  817. return 0;
  818. }''',
  819. extra_args : pre_args,
  820. name : 'strtod has locale support')
  821. pre_args += '-DHAVE_STRTOD_L'
  822. endif
  823. # Check for some linker flags
  824. ld_args_bsymbolic = []
  825. if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
  826. ld_args_bsymbolic += '-Wl,-Bsymbolic'
  827. endif
  828. ld_args_gc_sections = []
  829. if cc.links('static char unused() { return 5; } int main() { return 0; }',
  830. args : '-Wl,--gc-sections', name : 'gc-sections')
  831. ld_args_gc_sections += '-Wl,--gc-sections'
  832. endif
  833. with_ld_version_script = false
  834. if cc.links('int main() { return 0; }',
  835. args : '-Wl,--version-script=@0@'.format(
  836. join_paths(meson.source_root(), 'build-support/conftest.map')),
  837. name : 'version-script')
  838. with_ld_version_script = true
  839. endif
  840. with_ld_dynamic_list = false
  841. if cc.links('int main() { return 0; }',
  842. args : '-Wl,--dynamic-list=@0@'.format(
  843. join_paths(meson.source_root(), 'build-support/conftest.dyn')),
  844. name : 'dynamic-list')
  845. with_ld_dynamic_list = true
  846. endif
  847. ld_args_build_id = []
  848. if build_machine.system() != 'darwin'
  849. ld_args_build_id += '-Wl,--build-id=sha1'
  850. endif
  851. # check for dl support
  852. if cc.has_function('dlopen')
  853. dep_dl = []
  854. else
  855. dep_dl = cc.find_library('dl')
  856. endif
  857. if cc.has_function('dladdr', dependencies : dep_dl)
  858. # This is really only required for megadrivers
  859. pre_args += '-DHAVE_DLADDR'
  860. endif
  861. if cc.has_function('dl_iterate_phdr')
  862. pre_args += '-DHAVE_DL_ITERATE_PHDR'
  863. elif with_intel_vk
  864. error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
  865. elif with_dri_i965 and get_option('shader-cache')
  866. error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.')
  867. endif
  868. # Determine whether or not the rt library is needed for time functions
  869. if cc.has_function('clock_gettime')
  870. dep_clock = []
  871. else
  872. dep_clock = cc.find_library('rt')
  873. endif
  874. with_gallium_drisw_kms = false
  875. dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
  876. required : with_dri2 or with_dri3)
  877. if dep_libdrm.found()
  878. pre_args += '-DHAVE_LIBDRM'
  879. if with_dri_platform == 'drm' and with_dri
  880. with_gallium_drisw_kms = true
  881. endif
  882. endif
  883. # TODO: some of these may be conditional
  884. dep_zlib = dependency('zlib', version : '>= 1.2.3')
  885. pre_args += '-DHAVE_ZLIB'
  886. dep_thread = dependency('threads')
  887. if dep_thread.found() and host_machine.system() != 'windows'
  888. pre_args += '-DHAVE_PTHREAD'
  889. endif
  890. if with_amd_vk or with_gallium_radeonsi or with_gallium_r600 or with_gallium_opencl
  891. dep_elf = dependency('libelf', required : false)
  892. if not dep_elf.found()
  893. dep_elf = cc.find_library('elf')
  894. endif
  895. else
  896. dep_elf = []
  897. endif
  898. dep_expat = dependency('expat')
  899. # this only exists on linux so either this is linux and it will be found, or
  900. # its not linux and and wont
  901. dep_m = cc.find_library('m', required : false)
  902. dep_libdrm_amdgpu = []
  903. dep_libdrm_radeon = []
  904. dep_libdrm_nouveau = []
  905. dep_libdrm_etnaviv = []
  906. dep_libdrm_freedreno = []
  907. if with_amd_vk or with_gallium_radeonsi
  908. dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.90')
  909. endif
  910. if (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or
  911. with_gallium_r300 or with_gallium_r600)
  912. dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
  913. endif
  914. if with_gallium_nouveau or with_dri_nouveau
  915. dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
  916. endif
  917. if with_gallium_etnaviv
  918. dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
  919. endif
  920. if with_gallium_freedreno
  921. dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.89')
  922. endif
  923. llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
  924. if with_amd_vk or with_gallium_radeonsi or with_gallium_r600
  925. llvm_modules += ['amdgpu', 'bitreader', 'ipo']
  926. if with_gallium_r600
  927. llvm_modules += 'asmparser'
  928. endif
  929. endif
  930. if with_gallium_opencl
  931. llvm_modules += [
  932. 'all-targets', 'linker', 'coverage', 'instrumentation', 'ipo', 'irreader',
  933. 'lto', 'option', 'objcarcopts', 'profiledata',
  934. ]
  935. # TODO: optional modules
  936. endif
  937. if with_amd_vk or with_gallium_radeonsi
  938. _llvm_version = '>= 4.0.0'
  939. elif with_gallium_opencl or with_gallium_swr or with_gallium_r600
  940. _llvm_version = '>= 3.9.0'
  941. else
  942. _llvm_version = '>= 3.3.0'
  943. endif
  944. _llvm = get_option('llvm')
  945. if _llvm == 'auto'
  946. dep_llvm = dependency(
  947. 'llvm', version : _llvm_version, modules : llvm_modules,
  948. required : with_amd_vk or with_gallium_radeonsi or with_gallium_swr or with_gallium_opencl,
  949. )
  950. with_llvm = dep_llvm.found()
  951. elif _llvm == 'true'
  952. dep_llvm = dependency('llvm', version : _llvm_version, modules : llvm_modules)
  953. with_llvm = true
  954. else
  955. dep_llvm = []
  956. with_llvm = false
  957. endif
  958. if with_llvm
  959. _llvm_version = dep_llvm.version().split('.')
  960. # Development versions of LLVM have an 'svn' or 'git' suffix, we don't want
  961. # that for our version checks.
  962. # svn suffixes are stripped by meson as of 0.43, and git suffixes are
  963. # strippped as of 0.44, but we support older meson versions.
  964. _llvm_patch = _llvm_version[2]
  965. if _llvm_patch.endswith('svn')
  966. _llvm_patch = _llvm_patch.split('s')[0]
  967. elif _llvm_patch.contains('git')
  968. _llvm_patch = _llvm_patch.split('g')[0]
  969. endif
  970. pre_args += [
  971. '-DHAVE_LLVM=0x0@0@0@1@'.format(_llvm_version[0], _llvm_version[1]),
  972. '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
  973. ]
  974. elif with_amd_vk or with_gallium_radeonsi or with_gallium_swr
  975. error('The following drivers require LLVM: Radv, RadeonSI, SWR. One of these is enabled, but LLVM is disabled.')
  976. endif
  977. dep_glvnd = []
  978. if with_glvnd
  979. dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
  980. pre_args += '-DUSE_LIBGLVND=1'
  981. endif
  982. if with_valgrind != 'false'
  983. dep_valgrind = dependency('valgrind', required : with_valgrind == 'true')
  984. if dep_valgrind.found()
  985. pre_args += '-DHAVE_VALGRIND'
  986. endif
  987. else
  988. dep_valgrind = []
  989. endif
  990. # pthread stubs. Lets not and say we didn't
  991. prog_bison = find_program('bison', required : with_any_opengl)
  992. prog_flex = find_program('flex', required : with_any_opengl)
  993. dep_selinux = []
  994. if get_option('selinux')
  995. dep_selinux = dependency('libselinux')
  996. pre_args += '-DMESA_SELINUX'
  997. endif
  998. # TODO: llvm-prefix and llvm-shared-libs
  999. if with_libunwind != 'false'
  1000. dep_unwind = dependency('libunwind', required : with_libunwind == 'true')
  1001. if dep_unwind.found()
  1002. pre_args += '-DHAVE_LIBUNWIND'
  1003. endif
  1004. else
  1005. dep_unwind = []
  1006. endif
  1007. # TODO: gallium-hud
  1008. if with_osmesa != 'none'
  1009. if with_osmesa == 'classic' and not with_dri_swrast
  1010. error('OSMesa classic requires dri (classic) swrast.')
  1011. endif
  1012. if with_osmesa == 'gallium' and not with_gallium_softpipe
  1013. error('OSMesa gallium requires gallium softpipe or llvmpipe.')
  1014. endif
  1015. osmesa_lib_name = 'OSMesa'
  1016. osmesa_bits = get_option('osmesa-bits')
  1017. if osmesa_bits != '8'
  1018. if with_dri or with_glx != 'disabled'
  1019. error('OSMesa bits must be 8 if building glx or dir based drivers')
  1020. endif
  1021. osmesa_lib_name = osmesa_lib_name + osmesa_bits
  1022. pre_args += [
  1023. '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31'
  1024. ]
  1025. endif
  1026. endif
  1027. # TODO: symbol mangling
  1028. if with_platform_wayland
  1029. prog_wl_scanner = find_program('wayland-scanner')
  1030. dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
  1031. dep_wayland_client = dependency('wayland-client', version : '>=1.11')
  1032. dep_wayland_server = dependency('wayland-server', version : '>=1.11')
  1033. wayland_dmabuf_xml = join_paths(
  1034. dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
  1035. 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
  1036. )
  1037. pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED']
  1038. else
  1039. prog_wl_scanner = []
  1040. dep_wl_protocols = []
  1041. dep_wayland_client = []
  1042. dep_wayland_server = []
  1043. wayland_dmabuf_xml = ''
  1044. endif
  1045. dep_x11 = []
  1046. dep_xext = []
  1047. dep_xdamage = []
  1048. dep_xfixes = []
  1049. dep_x11_xcb = []
  1050. dep_xcb = []
  1051. dep_xcb_glx = []
  1052. dep_xcb_dri2 = []
  1053. dep_xcb_dri3 = []
  1054. dep_dri2proto = []
  1055. dep_glproto = []
  1056. dep_xxf86vm = []
  1057. dep_xcb_dri3 = []
  1058. dep_xcb_present = []
  1059. dep_xcb_sync = []
  1060. dep_xcb_xfixes = []
  1061. dep_xshmfence = []
  1062. if with_platform_x11
  1063. if with_glx == 'xlib' or with_glx == 'gallium-xlib'
  1064. dep_x11 = dependency('x11')
  1065. dep_xext = dependency('xext')
  1066. dep_xcb = dependency('xcb')
  1067. elif with_glx == 'dri'
  1068. dep_x11 = dependency('x11')
  1069. dep_xext = dependency('xext')
  1070. dep_xdamage = dependency('xdamage', version : '>= 1.1')
  1071. dep_xfixes = dependency('xfixes')
  1072. dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
  1073. dep_xxf86vm = dependency('xxf86vm', required : false)
  1074. endif
  1075. if (with_any_vk or with_glx == 'dri' or
  1076. (with_gallium_vdpau or with_gallium_xvmc or with_gallium_omx or
  1077. with_gallium_xa))
  1078. dep_xcb = dependency('xcb')
  1079. dep_x11_xcb = dependency('x11-xcb')
  1080. endif
  1081. if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
  1082. dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
  1083. if with_dri3
  1084. pre_args += '-DHAVE_DRI3'
  1085. dep_xcb_dri3 = dependency('xcb-dri3')
  1086. dep_xcb_present = dependency('xcb-present')
  1087. dep_xcb_sync = dependency('xcb-sync')
  1088. dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
  1089. endif
  1090. endif
  1091. if with_glx == 'dri'
  1092. if with_dri_platform == 'drm'
  1093. dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
  1094. endif
  1095. dep_glproto = dependency('glproto', version : '>= 1.4.14')
  1096. endif
  1097. if with_egl
  1098. dep_xcb_xfixes = dependency('xcb-xfixes')
  1099. endif
  1100. endif
  1101. if get_option('gallium-extra-hud')
  1102. pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1'
  1103. endif
  1104. _sensors = get_option('lmsensors')
  1105. if _sensors != 'false'
  1106. dep_lmsensors = cc.find_library('libsensors', required : _sensors == 'true')
  1107. if dep_lmsensors.found()
  1108. pre_args += '-DHAVE_LIBSENSORS=1'
  1109. endif
  1110. else
  1111. dep_lmsensors = []
  1112. endif
  1113. # TODO: gallium tests
  1114. # TODO: various libdirs
  1115. # TODO: gallium driver dirs
  1116. # FIXME: this is a workaround for #2326
  1117. prog_touch = find_program('touch')
  1118. dummy_cpp = custom_target(
  1119. 'dummy_cpp',
  1120. output : 'dummy.cpp',
  1121. command : [prog_touch, '@OUTPUT@'],
  1122. )
  1123. foreach a : pre_args
  1124. add_project_arguments(a, language : ['c', 'cpp'])
  1125. endforeach
  1126. foreach a : c_args
  1127. add_project_arguments(a, language : ['c'])
  1128. endforeach
  1129. foreach a : cpp_args
  1130. add_project_arguments(a, language : ['cpp'])
  1131. endforeach
  1132. inc_include = include_directories('include')
  1133. gl_priv_reqs = [
  1134. 'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb',
  1135. 'xcb-glx >= 1.8.1']
  1136. if dep_libdrm.found()
  1137. gl_priv_reqs += 'libdrm >= 2.4.75'
  1138. endif
  1139. if dep_xxf86vm != [] and dep_xxf86vm.found()
  1140. gl_priv_reqs += 'xxf86vm'
  1141. endif
  1142. if with_dri_platform == 'drm'
  1143. gl_priv_reqs += 'xcb-dri2 >= 1.8'
  1144. endif
  1145. gl_priv_libs = []
  1146. if dep_thread.found()
  1147. gl_priv_libs += ['-lpthread', '-pthread']
  1148. endif
  1149. if dep_m.found()
  1150. gl_priv_libs += '-lm'
  1151. endif
  1152. if dep_dl != [] and dep_dl.found()
  1153. gl_priv_libs += '-ldl'
  1154. endif
  1155. pkg = import('pkgconfig')
  1156. subdir('include')
  1157. subdir('bin')
  1158. subdir('src')