1 # Copyright © 2017 Intel Corporation
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:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
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
24 version : run_command(
25 [find_program('python', 'python2', 'python3'), 'bin/meson_get_version.py']
28 meson_version : '>= 0.42',
29 default_options : ['buildtype=debugoptimized', 'c_std=c99', 'cpp_std=c++11']
32 # Arguments for the preprocessor, put these in a separate array from the C and
33 # C++ (cpp in meson terminology) arguments since they need to be added to the
34 # default arguments for both C and C++.
36 '-D__STDC_CONSTANT_MACROS',
37 '-D__STDC_FORMAT_MACROS',
38 '-D__STDC_LIMIT_MACROS',
39 '-DVERSION="@0@"'.format(meson.project_version()),
40 '-DPACKAGE_VERSION=VERSION',
41 '-DPACKAGE_BUGREPORT="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa"',
44 with_vulkan_icd_dir = get_option('vulkan-icd-dir')
45 with_tests = get_option('build-tests')
46 with_valgrind = get_option('valgrind')
47 with_libunwind = get_option('libunwind')
48 with_asm = get_option('asm')
49 with_osmesa = get_option('osmesa')
50 if get_option('texture-float')
51 pre_args += '-DTEXTURE_FLOAT_ENABLED'
52 message('WARNING: Floating-point texture enabled. Please consult docs/patents.txt and your lawyer before building mesa.')
57 with_windowsdri = false
59 dri_drivers_path = get_option('dri-drivers-path')
60 if dri_drivers_path == ''
61 dri_drivers_path = join_paths(get_option('libdir'), 'dri')
64 with_gles1 = get_option('gles1')
65 with_gles2 = get_option('gles2')
66 with_opengl = get_option('opengl')
67 with_any_opengl = with_opengl or with_gles1 or with_gles2
68 # Only build shared_glapi if at least one OpenGL API is enabled
69 with_shared_glapi = get_option('shared-glapi') and with_any_opengl
72 # shared-glapi is required if at least two OpenGL APIs are being built
73 if not with_shared_glapi
74 if ((with_gles1 and with_gles2) or (with_gles1 and with_opengl)
75 or (with_gles2 and with_opengl))
76 error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x')
80 # We require OpenGL for OpenGL ES
81 if (with_gles1 or with_gles2) and not with_opengl
82 error('building OpenGL ES without OpenGL is not supported.')
90 with_dri_nouveau = false
91 with_dri_swrast = false
92 _drivers = get_option('dri-drivers')
95 if not ['darwin', 'windows'].contains(host_machine.system())
96 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
97 _drivers = 'i915,i965,r100,r200,nouveau'
99 error('Unknown architecture. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
102 error('Unknown OS. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
106 _split = _drivers.split(',')
107 with_dri_i915 = _split.contains('i915')
108 with_dri_i965 = _split.contains('i965')
109 with_dri_r100 = _split.contains('r100')
110 with_dri_r200 = _split.contains('r200')
111 with_dri_nouveau = _split.contains('nouveau')
112 with_dri_swrast = _split.contains('swrast')
117 with_gallium_pl111 = false
118 with_gallium_radeonsi = false
119 with_gallium_nouveau = false
120 with_gallium_freedreno = false
121 with_gallium_softpipe = false
122 with_gallium_vc4 = false
123 with_gallium_vc5 = false
124 with_gallium_etnaviv = false
125 with_gallium_imx = false
126 _drivers = get_option('gallium-drivers')
127 if _drivers == 'auto'
128 if not ['darwin', 'windows'].contains(host_machine.system())
130 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
131 _drivers = 'radeonsi,nouveau,swrast'
132 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
133 _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,swrast'
135 error('Unknown architecture. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
138 error('Unknown OS. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
142 _split = _drivers.split(',')
143 with_gallium_pl111 = _split.contains('pl111')
144 with_gallium_radeonsi = _split.contains('radeonsi')
145 with_gallium_nouveau = _split.contains('nouveau')
146 with_gallium_freedreno = _split.contains('freedreno')
147 with_gallium_softpipe = _split.contains('swrast')
148 with_gallium_vc4 = _split.contains('vc4')
149 with_gallium_vc5 = _split.contains('vc5')
150 with_gallium_etnaviv = _split.contains('etnaviv')
151 with_gallium_imx = _split.contains('imx')
155 with_intel_vk = false
158 _vulkan_drivers = get_option('vulkan-drivers')
159 if _vulkan_drivers == 'auto'
160 if not ['darwin', 'windows'].contains(host_machine.system())
161 if host_machine.cpu_family().startswith('x86')
162 _vulkan_drivers = 'amd,intel'
164 error('Unknown architecture. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.')
167 # No vulkan driver supports windows or macOS currently
171 if _vulkan_drivers != ''
172 _split = _vulkan_drivers.split(',')
173 with_intel_vk = _split.contains('intel')
174 with_amd_vk = _split.contains('amd')
175 with_any_vk = with_amd_vk or with_intel_vk
178 if with_dri_swrast and with_gallium_softpipe
179 error('Only one swrast provider can be built')
181 if with_gallium_imx and not with_gallium_etnaviv
182 error('IMX driver requires etnaviv driver')
185 dep_libdrm_intel = []
187 dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
191 with_dri_platform = 'drm'
193 with_platform_android = false
194 with_platform_wayland = false
195 with_platform_x11 = false
196 with_platform_drm = false
197 with_platform_surfaceless = false
198 egl_native_platform = ''
199 _platforms = get_option('platforms')
200 if _platforms == 'auto'
201 if ['linux'].contains(host_machine.system())
202 _platforms = 'x11,wayland,drm,surfaceless'
204 error('Unknown OS, no platforms enabled. Patches gladly accepted to fix this.')
208 _split = _platforms.split(',')
209 with_platform_android = _split.contains('android')
210 with_platform_x11 = _split.contains('x11')
211 with_platform_wayland = _split.contains('wayland')
212 with_platform_drm = _split.contains('drm')
213 with_platform_surfaceless = _split.contains('surfaceless')
214 egl_native_platform = _split[0]
217 with_glx = get_option('glx')
218 if with_glx == 'auto'
222 # Even when building just gallium drivers the user probably wants dri
225 elif with_platform_x11 and with_any_opengl and not with_any_vk
226 # The automatic behavior should not be to turn on xlib based glx when
227 # building only vulkan drivers
230 with_glx = 'disabled'
234 if not (with_dri or with_gallium or with_glx == 'xlib' or with_glx == 'gallium-xlib')
238 with_any_opengl = false
239 with_shared_glapi = false
242 with_gbm = get_option('gbm')
243 if with_gbm == 'auto' and with_dri # TODO: or gallium
244 with_gbm = host_machine.system() == 'linux'
245 elif with_gbm == 'true'
246 if not ['linux', 'bsd'].contains(host_machine.system())
247 error('GBM only supports unix-like platforms')
254 _egl = get_option('egl')
256 with_egl = with_dri and with_shared_glapi and egl_native_platform != ''
259 error('EGL requires dri')
260 elif not with_shared_glapi
261 error('EGL requires shared-glapi')
262 elif egl_native_platform == ''
263 error('No platforms specified, consider -Dplatforms=drm,x11 at least')
271 if with_egl and with_gallium_radeonsi and not (with_platform_drm or with_platform_surfaceless)
272 error('RadeonSI requires drm or surfaceless platform when using EGL')
275 pre_args += '-DGLX_USE_TLS'
276 if with_glx != 'disabled'
277 if not (with_platform_x11 and with_any_opengl)
278 if with_glx == 'auto'
279 with_glx = 'disabled'
281 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
283 elif with_glx == 'gallium-xlib'
285 error('Gallium-xlib based GLX requires at least one gallium driver')
286 elif not with_gallium_softpipe
287 error('Gallium-xlib based GLX requires softpipe or llvmpipe.')
289 error('gallium-xlib conflicts with any dri driver')
291 elif with_glx == 'xlib'
293 error('xlib conflicts with any dri driver')
295 elif with_glx == 'dri' and not with_dri
296 error('dri based GLX requires at least one DRI driver')
300 with_glvnd = get_option('glvnd')
302 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
303 error('Cannot build glvnd support for GLX that is not DRI based.')
304 elif with_glx == 'disabled' and not with_egl
305 error('glvnd requires DRI based GLX and/or EGL')
309 # TODO: toggle for this
310 with_glx_direct = true
312 if with_vulkan_icd_dir == ''
313 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
316 with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
317 with_dri3 = get_option('dri3')
318 if with_dri3 == 'auto'
319 if host_machine.system() == 'linux' and with_dri2
324 elif with_dri3 == 'true'
330 if with_any_vk and (with_platform_x11 and not with_dri3)
331 error('Vulkan drivers require dri3 for X11 support')
333 if with_dri or with_gallium
334 if with_glx == 'disabled' and not with_egl
335 error('building dri or gallium drivers require at least one window system')
339 with_gallium_xvmc = false
340 with_gallium_vdpau = false
341 with_gallium_omx = false # this is bellagio
342 with_gallium_va = false
343 with_gallium_media = false
345 _drivers = get_option('gallium-media')
347 _split = _drivers.split(',')
348 with_gallium_xvmc = _split.contains('xvmc')
349 with_gallium_vdpau = _split.contains('vdpau')
350 with_gallium_omx = _split.contains('omx')
351 with_gallium_va = _split.contains('va')
352 with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or
353 with_gallium_omx or with_gallium_va)
356 gl_pkgconfig_c_flags = []
358 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
359 pre_args += '-DHAVE_X11_PLATFORM'
361 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
362 pre_args += '-DUSE_XSHM'
364 pre_args += '-DGLX_INDIRECT_RENDERING'
366 pre_args += '-DGLX_DIRECT_RENDERING'
368 if with_dri_platform == 'drm'
369 pre_args += '-DGLX_USE_DRM'
373 pre_args += '-DMESA_EGL_NO_X11_HEADERS'
374 gl_pkgconfig_c_flags += '-DMESA_EGL_NO_X11_HEADERS'
377 if with_egl and not with_gbm
378 error('EGL drm platform requires gbm')
380 pre_args += '-DHAVE_DRM_PLATFORM'
382 if with_platform_surfaceless
383 pre_args += '-DHAVE_SURFACELESS_PLATFORM'
385 if with_platform_android
387 dependency('cutils'),
388 dependency('hardware'),
391 pre_args += '-DHAVE_ANDROID_PLATFORM'
394 prog_python2 = find_program('python2')
395 has_mako = run_command(prog_python2, '-c', 'import mako')
396 if has_mako.returncode() != 0
397 error('Python (2.x) mako module required to build mesa.')
400 cc = meson.get_compiler('c')
401 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
402 error('When using GCC, version 4.4.6 or later is required.')
405 # Define DEBUG for debug builds only (debugoptimized is not included on this one)
406 if get_option('buildtype') == 'debug'
407 pre_args += '-DDEBUG'
410 if get_option('shader-cache')
411 pre_args += '-DENABLE_SHADER_CACHE'
413 error('Radv requires shader cache support')
416 # Check for GCC style builtins
417 foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
418 'ffsll', 'popcount', 'popcountll', 'unreachable']
419 if cc.has_function(b)
420 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
424 # check for GCC __attribute__
425 foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
426 'warn_unused_result', 'weak',]
427 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
428 name : '__attribute__((@0@))'.format(a))
429 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
432 if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
433 name : '__attribute__((format(...)))')
434 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
436 if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
437 name : '__attribute__((packed))')
438 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
440 if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
441 name : '__attribute__((returns_nonnull))')
442 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
444 if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
445 int foo_hid(void) __attribute__((visibility("hidden")));
446 int foo_int(void) __attribute__((visibility("internal")));
447 int foo_pro(void) __attribute__((visibility("protected")));''',
448 name : '__attribute__((visibility(...)))')
449 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
451 if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
452 name : '__attribute__((alias(...)))')
453 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
456 # TODO: this is very incomplete
457 if host_machine.system() == 'linux'
458 pre_args += '-D_GNU_SOURCE'
461 # Check for generic C arguments
463 foreach a : ['-Wall', '-Werror=implicit-function-declaration',
464 '-Werror=missing-prototypes', '-fno-math-errno',
465 '-fno-trapping-math', '-Qunused-arguments']
466 if cc.has_argument(a)
471 if cc.has_argument('-fvisibility=hidden')
472 c_vis_args += '-fvisibility=hidden'
475 # Check for generic C++ arguments
476 cpp = meson.get_compiler('cpp')
478 foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
479 '-Qunused-arguments', '-Wno-non-virtual-dtor']
480 if cpp.has_argument(a)
485 if cpp.has_argument('-fvisibility=hidden')
486 cpp_vis_args += '-fvisibility=hidden'
489 # Check for C and C++ arguments for MSVC2013 compatibility. These are only used
490 # in parts of the mesa code base that need to compile with old versions of
491 # MSVC, mainly common code
492 c_msvc_compat_args = []
493 cpp_msvc_compat_args = []
494 foreach a : ['-Werror=pointer-arith', '-Werror=vla']
495 if cc.has_argument(a)
496 c_msvc_compat_args += a
498 if cpp.has_argument(a)
499 cpp_msvc_compat_args += a
503 no_override_init_args = []
504 foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
505 if cc.has_argument(a)
506 no_override_init_args += a
510 if host_machine.cpu_family().startswith('x86')
511 pre_args += '-DHAVE_SSE41'
513 sse41_args = ['-msse4.1']
515 # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
516 # that's not guaranteed
517 if host_machine.cpu_family() == 'x86'
518 sse41_args += '-mstackrealign'
525 # Check for GCC style atomics
526 if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
527 name : 'GCC atomic builtins')
528 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
530 if not cc.links('''#include <stdint.h>
533 return __sync_add_and_fetch(&v, (uint64_t)1);
535 name : 'GCC 64bit atomics')
536 pre_args += '-DMISSING_64_BIT_ATOMICS'
541 # TODO: shared/static? Is this even worth doing?
543 # Building x86 assembly code requires running x86 binaries. It is possible for
544 # x86_64 OSes to run x86 binaries, so don't disable asm in those cases
545 # TODO: it should be possible to use an exe_wrapper to run the binary during
547 if meson.is_cross_build()
548 if not (build_machine.cpu_family() == 'x86_64' and host_machine.cpu_family() == 'x86'
549 and build_machine.system() == host_machine.system())
550 message('Cross compiling to x86 from non-x86, disabling asm')
557 # TODO: SPARC and PPC
558 if host_machine.cpu_family() == 'x86'
559 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
560 with_asm_arch = 'x86'
561 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
564 elif host_machine.cpu_family() == 'x86_64'
565 if host_machine.system() == 'linux'
566 with_asm_arch = 'x86_64'
567 pre_args += ['-DUSE_X86_64_ASM']
569 elif host_machine.cpu_family() == 'arm'
570 if host_machine.system() == 'linux'
571 with_asm_arch = 'arm'
572 pre_args += ['-DUSE_ARM_ASM']
574 elif host_machine.cpu_family() == 'aarch64'
575 if host_machine.system() == 'linux'
576 with_asm_arch = 'aarch64'
577 pre_args += ['-DUSE_AARCH64_ASM']
582 # Check for standard headers and functions
583 if cc.has_header_symbol('sys/sysmacros.h', 'major')
584 pre_args += '-DMAJOR_IN_SYSMACROS'
585 elif cc.has_header_symbol('sys/mkdev.h', 'major')
586 pre_args += '-DMAJOR_IN_MKDEV'
589 foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h']
591 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
595 foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get']
596 if cc.has_function(f)
597 pre_args += '-DHAVE_@0@'.format(f.to_upper())
601 # strtod locale support
606 #ifdef HAVE_XLOCALE_H
610 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
611 const char *s = "1.0";
613 double d = strtod_l(s, end, loc);
614 float f = strtod_l(s, end, loc);
618 extra_args : pre_args,
619 name : 'strtod has locale support')
620 pre_args += '-DHAVE_STRTOD_L'
623 # Check for some linker flags
624 ld_args_bsymbolic = []
625 if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
626 ld_args_bsymbolic += '-Wl,-Bsymbolic'
628 ld_args_gc_sections = []
629 if cc.links('static char unused() { return 5; } int main() { return 0; }',
630 args : '-Wl,--gc-sections', name : 'gc-sections')
631 ld_args_gc_sections += '-Wl,--gc-sections'
633 with_ld_version_script = false
634 if cc.links('int main() { return 0; }',
635 args : '-Wl,--version-script=@0@'.format(
636 join_paths(meson.source_root(), 'build-support/conftest.map')),
637 name : 'version-script')
638 with_ld_version_script = true
640 with_ld_dynamic_list = false
641 if cc.links('int main() { return 0; }',
642 args : '-Wl,--dynamic-list=@0@'.format(
643 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
644 name : 'dynamic-list')
645 with_ld_dynamic_list = true
648 # check for dl support
649 if cc.has_function('dlopen')
652 dep_dl = cc.find_library('dl')
654 if cc.has_function('dladdr', dependencies : dep_dl)
655 # This is really only required for megadrivers
656 pre_args += '-DHAVE_DLADDR'
659 if cc.has_function('dl_iterate_phdr')
660 pre_args += '-DHAVE_DL_ITERATE_PHDR'
662 error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
663 elif with_dri_i965 and get_option('shader-cache')
664 error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.')
667 # Determine whether or not the rt library is needed for time functions
668 if cc.has_function('clock_gettime')
671 dep_clock = cc.find_library('rt')
674 with_gallium_drisw_kms = false
675 dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
676 required : with_dri2 or with_dri3)
677 if dep_libdrm.found()
678 pre_args += '-DHAVE_LIBDRM'
679 if with_dri_platform == 'drm' and with_dri
680 with_gallium_drisw_kms = true
684 # TODO: some of these may be conditional
685 dep_zlib = dependency('zlib', version : '>= 1.2.3')
686 dep_thread = dependency('threads')
687 if dep_thread.found() and host_machine.system() != 'windows'
688 pre_args += '-DHAVE_PTHREAD'
690 dep_elf = dependency('libelf', required : false)
691 if not dep_elf.found() and (with_amd_vk or with_gallium_radeonsi) # TODO: clover, r600
692 dep_elf = cc.find_library('elf')
694 dep_expat = dependency('expat')
695 # this only exists on linux so either this is linux and it will be found, or
696 # its not linux and and wont
697 dep_m = cc.find_library('m', required : false)
699 dep_libdrm_amdgpu = []
700 dep_libdrm_radeon = []
701 dep_libdrm_nouveau = []
702 dep_libdrm_etnaviv = []
703 dep_libdrm_freedreno = []
704 if with_amd_vk or with_gallium_radeonsi
705 dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.88')
707 if with_gallium_radeonsi or with_dri_r100 or with_dri_r200
708 dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
710 if with_gallium_nouveau or with_dri_nouveau
711 dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
713 if with_gallium_etnaviv
714 dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
716 if with_gallium_freedreno
717 dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.74')
720 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
721 if with_amd_vk or with_gallium_radeonsi
722 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
725 _llvm = get_option('llvm')
727 dep_llvm = dependency(
728 'llvm', version : '>= 3.9.0', modules : llvm_modules,
729 required : with_amd_vk or with_gallium_radeonsi,
731 with_llvm = dep_llvm.found()
733 dep_llvm = dependency('llvm', version : '>= 3.9.0', modules : llvm_modules)
740 _llvm_version = dep_llvm.version().split('.')
741 # Development versions of LLVM have an 'svn' suffix, we don't want that for
742 # our version checks.
743 _llvm_patch = _llvm_version[2]
744 if _llvm_patch.endswith('svn')
745 _llvm_patch = _llvm_patch.split('s')[0]
748 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
749 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
751 elif with_amd_vk or with_gallium_radeonsi
752 error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM is disabled.')
757 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
758 pre_args += '-DUSE_LIBGLVND=1'
761 if with_valgrind != 'false'
762 dep_valgrind = dependency('valgrind', required : with_valgrind == 'true')
763 if dep_valgrind.found()
764 pre_args += '-DHAVE_VALGRIND'
770 # pthread stubs. Lets not and say we didn't
772 prog_bison = find_program('bison', required : with_any_opengl)
773 prog_flex = find_program('flex', required : with_any_opengl)
776 if get_option('selinux')
777 dep_selinux = dependency('libselinux')
778 pre_args += '-DMESA_SELINUX'
781 # TODO: llvm-prefix and llvm-shared-libs
783 if with_libunwind != 'false'
784 dep_unwind = dependency('libunwind', required : with_libunwind == 'true')
785 if dep_unwind.found()
786 pre_args += '-DHAVE_LIBUNWIND'
794 if with_osmesa != 'none'
795 if with_osmesa == 'classic' and not with_dri_swrast
796 error('OSMesa classic requires dri (classic) swrast.')
798 if with_osmesa == 'gallium' and not with_gallium_softpipe
799 error('OSMesa gallium requires gallium softpipe or llvmpipe.')
801 osmesa_lib_name = 'OSMesa'
802 osmesa_bits = get_option('osmesa-bits')
803 if osmesa_bits != '8'
804 if with_dri or with_glx != 'disabled'
805 error('OSMesa bits must be 8 if building glx or dir based drivers')
807 osmesa_lib_name = osmesa_lib_name + osmesa_bits
809 '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31'
814 # TODO: symbol mangling
816 if with_platform_wayland
817 prog_wl_scanner = find_program('wayland-scanner')
818 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
819 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
820 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
821 wayland_dmabuf_xml = join_paths(
822 dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
823 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
825 pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED']
828 dep_wl_protocols = []
829 dep_wayland_client = []
830 dep_wayland_server = []
831 wayland_dmabuf_xml = ''
852 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
853 dep_x11 = dependency('x11')
854 dep_xext = dependency('xext')
855 dep_xcb = dependency('xcb')
856 elif with_glx == 'dri' and with_dri_platform == 'drm'
857 dep_x11 = dependency('x11')
858 dep_xext = dependency('xext')
859 dep_xdamage = dependency('xdamage', version : '>= 1.1')
860 dep_xfixes = dependency('xfixes')
861 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
862 dep_xxf86vm = dependency('xxf86vm', required : false)
864 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
865 dep_xcb = dependency('xcb')
866 dep_x11_xcb = dependency('x11-xcb')
867 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
870 pre_args += '-DHAVE_DRI3'
871 dep_xcb_dri3 = dependency('xcb-dri3')
872 dep_xcb_present = dependency('xcb-present')
873 dep_xcb_sync = dependency('xcb-sync')
874 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
878 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
879 dep_glproto = dependency('glproto', version : '>= 1.4.14')
882 dep_xcb_xfixes = dependency('xcb-xfixes')
890 # TODO: gallium tests
892 # TODO: various libdirs
896 # TODO: gallium driver dirs
898 # FIXME: this is a workaround for #2326
899 prog_touch = find_program('touch')
900 dummy_cpp = custom_target(
902 output : 'dummy.cpp',
903 command : [prog_touch, '@OUTPUT@'],
907 add_project_arguments(a, language : ['c', 'cpp'])
910 add_project_arguments(a, language : ['c'])
913 add_project_arguments(a, language : ['cpp'])
916 inc_include = include_directories('include')
919 'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb',
920 'xcb-glx >= 1.8.1', 'libdrm >= 2.4.75',
922 if dep_xxf86vm != [] and dep_xxf86vm.found()
923 gl_priv_reqs += 'xxf86vm'
925 if with_dri_platform == 'drm'
926 gl_priv_reqs += 'xcb-dri2 >= 1.8'
930 if dep_thread.found()
931 gl_priv_libs += ['-lpthread', '-pthread']
934 gl_priv_libs += '-lm'
936 if dep_dl != [] and dep_dl.found()
937 gl_priv_libs += '-ldl'
940 pkg = import('pkgconfig')