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