i965: Drop a bunch of downcasting and upcasting of gl_program pointers.
[mesa.git] / meson.build
1 # Copyright © 2017 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('mesa', ['c', 'cpp'], version : '17.3.0-devel', license : 'MIT',
22 default_options : ['c_std=c99', 'cpp_std=c++11'])
23
24 # Arguments for the preprocessor, put these in a separate array from the C and
25 # C++ (cpp in meson terminology) arguments since they need to be added to the
26 # default arguments for both C and C++.
27 pre_args = [
28 '-D__STDC_CONSTANT_MACROS',
29 '-D__STDC_FORMAT_MACROS',
30 '-D__STDC_LIMIT_MACROS',
31 '-DVERSION="@0@"'.format(meson.project_version()),
32 '-DPACKAGE_VERSION=VERSION',
33 '-DPACKAGE_BUGREPORT="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa"',
34 '-D_GNU_SOURCE',
35 ]
36
37 with_vulkan_icd_dir = get_option('vulkan-icd-dir')
38 with_tests = get_option('build-tests')
39 with_valgrind = get_option('valgrind')
40 with_asm = get_option('asm')
41 with_llvm = get_option('llvm')
42 if get_option('texture-float')
43 pre_args += '-DTEXTURE_FLOAT_ENABLED'
44 message('WARNING: Floating-point texture enabled. Please consult docs/patents.txt and your lawyer before building mesa.')
45 endif
46
47 # XXX: yeah, do these
48 with_appledri = false
49 with_windowsdri = false
50
51 dri_drivers_path = get_option('dri-drivers-path')
52 if dri_drivers_path == ''
53 dri_drivers_path = join_paths(get_option('libdir'), 'dri')
54 endif
55
56 with_gles1 = get_option('gles1')
57 with_gles2 = get_option('gles2')
58 with_opengl = get_option('opengl')
59 with_any_opengl = with_opengl or with_gles1 or with_gles2
60 # Only build shared_glapi if at least one OpenGL API is enabled
61 with_shared_glapi = get_option('shared-glapi') and with_any_opengl
62
63 # TODO: these will need options, but at the moment they just control header
64 # installs
65 with_osmesa = false
66
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
75 # We require OpenGL for OpenGL ES
76 if (with_gles1 or with_gles2) and not with_opengl
77 error('building OpenGL ES without OpenGL is not supported.')
78 endif
79
80 with_dri = false
81 with_dri_i915 = false
82 with_dri_i965 = false
83 with_dri_swrast = false
84 _drivers = get_option('dri-drivers')
85 if _drivers != ''
86 _split = _drivers.split(',')
87 with_dri_i915 = _split.contains('i915')
88 with_dri_i965 = _split.contains('i965')
89 with_dri_swrast = _split.contains('swrast')
90 with_dri = true
91 endif
92
93 with_gallium = false
94 with_gallium_pl111 = false
95 with_gallium_radeonsi = false
96 with_gallium_nouveau = false
97 with_gallium_freedreno = false
98 with_gallium_softpipe = false
99 with_gallium_vc4 = false
100 with_gallium_vc5 = false
101 with_gallium_etnaviv = false
102 with_gallium_imx = false
103 _drivers = get_option('gallium-drivers')
104 if _drivers != ''
105 _split = _drivers.split(',')
106 with_gallium_pl111 = _split.contains('pl111')
107 with_gallium_radeonsi = _split.contains('radeonsi')
108 with_gallium_nouveau = _split.contains('nouveau')
109 with_gallium_freedreno = _split.contains('freedreno')
110 with_gallium_softpipe = _split.contains('swrast')
111 with_gallium_vc4 = _split.contains('vc4')
112 with_gallium_vc5 = _split.contains('vc5')
113 with_gallium_etnaviv = _split.contains('etnaviv')
114 with_gallium_imx = _split.contains('imx')
115 with_gallium = true
116 with_dri = true
117 endif
118
119 if not (with_dri or with_gallium)
120 with_gles1 = false
121 with_gles2 = false
122 with_opengl = false
123 with_any_opengl = false
124 with_shared_glapi = false
125 endif
126
127 if with_dri_swrast and with_gallium_softpipe
128 error('Only one swrast provider can be built')
129 endif
130 if with_gallium_imx and not with_gallium_etnaviv
131 error('IMX driver requires etnaviv driver')
132 endif
133
134 dep_libdrm_intel = []
135 if with_dri_i915
136 dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
137 endif
138
139 # TODO: other OSes
140 with_dri_platform = 'drm'
141
142 # TODO: android platform
143 with_platform_wayland = false
144 with_platform_x11 = false
145 with_platform_drm = false
146 with_platform_surfaceless = false
147 egl_native_platform = ''
148 _platforms = get_option('platforms')
149 if _platforms != ''
150 _split = _platforms.split(',')
151 with_platform_x11 = _split.contains('x11')
152 with_platform_wayland = _split.contains('wayland')
153 with_platform_drm = _split.contains('drm')
154 with_platform_surfaceless = _split.contains('surfaceless')
155 egl_native_platform = _split[0]
156 endif
157
158 with_gbm = get_option('gbm')
159 if with_gbm == 'auto' and with_dri # TODO: or gallium
160 with_gbm = host_machine.system() == 'linux'
161 elif with_gbm == 'yes'
162 if not ['linux', 'bsd'].contains(host_machine.system())
163 error('GBM only supports unix-like platforms')
164 endif
165 with_gbm = true
166 else
167 with_gbm = false
168 endif
169
170 _egl = get_option('egl')
171 if _egl == 'auto'
172 with_egl = with_dri and with_shared_glapi and egl_native_platform != ''
173 elif _egl == 'yes'
174 if not with_dri
175 error('EGL requires dri')
176 elif not with_shared_glapi
177 error('EGL requires shared-glapi')
178 elif egl_native_platform == ''
179 error('No platforms specified, consider -Dplatforms=drm,x11 at least')
180 endif
181 with_egl = true
182 else
183 with_egl = false
184 endif
185
186 # TODO: or virgl
187 if with_egl and with_gallium_radeonsi and not (with_platform_drm or with_platform_surfaceless)
188 error('RadeonSI requires drm or surfaceless platform when using EGL')
189 endif
190
191 pre_args += '-DGLX_USE_TLS'
192 with_glx = get_option('glx')
193 if with_glx != 'disabled'
194 if not (with_platform_x11 and with_any_opengl)
195 if with_glx == 'auto'
196 with_glx = 'disabled'
197 else
198 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
199 endif
200 elif with_glx == 'gallium-xlib'
201 if not with_gallium
202 error('Gallium-xlib based GLX requires at least one gallium driver')
203 elif with_dri
204 error('gallium-xlib conflicts with any dri driver')
205 endif
206 elif with_glx == 'dri' and not with_dri
207 error('dri based GLX requires at least one DRI driver')
208 elif with_glx == 'auto'
209 if with_dri
210 with_glx = 'dri'
211 elif with_gallium
212 with_glx = 'gallium-xlib'
213 elif with_platform_x11 and with_any_opengl
214 with_glx = 'xlib'
215 else
216 with_glx = 'disabled'
217 endif
218 endif
219 endif
220
221 with_glvnd = get_option('glvnd')
222 if with_glvnd and with_glx != 'dri'
223 message('glvnd requires dri based glx')
224 endif
225
226 # TODO: toggle for this
227 with_glx_direct = true
228
229 if with_vulkan_icd_dir == ''
230 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
231 endif
232
233 with_intel_vk = false
234 with_amd_vk = false
235 with_any_vk = false
236 _vulkan_drivers = get_option('vulkan-drivers')
237 if _vulkan_drivers != ''
238 _split = _vulkan_drivers.split(',')
239 with_intel_vk = _split.contains('intel')
240 with_amd_vk = _split.contains('amd')
241 with_any_vk = with_amd_vk or with_intel_vk
242 if not (with_platform_x11 or with_platform_wayland)
243 error('Vulkan requires at least one platform (x11, wayland)')
244 endif
245 endif
246
247 with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
248 with_dri3 = get_option('dri3')
249 if with_dri3 == 'auto'
250 if host_machine.system() == 'linux' and with_dri2
251 with_dri3 = true
252 else
253 with_dri3 = false
254 endif
255 elif with_dri3 == 'yes'
256 with_dri3 = true
257 else
258 with_dri3 = false
259 endif
260
261 if with_any_vk and (with_platform_x11 and not with_dri3)
262 error('Vulkan drivers require dri3 for X11 support')
263 endif
264 if with_dri or with_gallium
265 if with_glx == 'disabled' and not with_egl
266 error('building dri or gallium drivers require at least one window system')
267 endif
268 endif
269
270 with_gallium_xvmc = false
271 with_gallium_vdpau = false
272 with_gallium_omx = false # this is bellagio
273 with_gallium_va = false
274 with_gallium_media = false
275 dep_va = []
276 _drivers = get_option('gallium-media')
277 if _drivers != ''
278 _split = _drivers.split(',')
279 with_gallium_xvmc = _split.contains('xvmc')
280 with_gallium_vdpau = _split.contains('vdpau')
281 with_gallium_omx = _split.contains('omx')
282 with_gallium_va = _split.contains('va')
283 with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or
284 with_gallium_omx or with_gallium_va)
285 endif
286
287 gl_pkgconfig_c_flags = []
288 if with_platform_x11
289 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
290 pre_args += '-DHAVE_X11_PLATFORM'
291 endif
292 if with_glx == 'xlib'
293 # TODO
294 error('TODO')
295 elif with_glx == 'gallium-xlib'
296 # TODO
297 error('TODO')
298 else
299 pre_args += '-DGLX_INDIRECT_RENDERING'
300 if with_glx_direct
301 pre_args += '-DGLX_DIRECT_RENDERING'
302 endif
303 if with_dri_platform == 'drm'
304 pre_args += '-DGLX_USE_DRM'
305 endif
306 endif
307 else
308 pre_args += '-DMESA_EGL_NO_X11_HEADERS'
309 gl_pkgconfig_c_flags += '-DMESA_EGL_NO_X11_HEADERS'
310 endif
311 if with_platform_drm
312 if with_egl and not with_gbm
313 error('EGL drm platform requires gbm')
314 endif
315 pre_args += '-DHAVE_DRM_PLATFORM'
316 endif
317 if with_platform_surfaceless
318 pre_args += '-DHAVE_SURFACELESS_PLATFORM'
319 endif
320
321 prog_python2 = find_program('python2')
322 has_mako = run_command(prog_python2, '-c', 'import mako')
323 if has_mako.returncode() != 0
324 error('Python (2.x) mako module required to build mesa.')
325 endif
326
327 cc = meson.get_compiler('c')
328 if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
329 error('When using GCC, version 4.4.6 or later is required.')
330 endif
331
332 # Define DEBUG for debug and debugoptimized builds
333 if get_option('buildtype').startswith('debug')
334 pre_args += '-DDEBUG'
335 endif
336
337 if get_option('shader-cache')
338 pre_args += '-DENABLE_SHADER_CACHE'
339 elif with_amd_vk
340 error('Radv requires shader cache support')
341 endif
342
343 # Check for GCC style builtins
344 foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
345 'ffsll', 'popcount', 'popcountll', 'unreachable']
346 if cc.has_function(b)
347 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
348 endif
349 endforeach
350
351 # check for GCC __attribute__
352 foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
353 'warn_unused_result', 'weak',]
354 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
355 name : '__attribute__((@0@))'.format(a))
356 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
357 endif
358 endforeach
359 if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
360 name : '__attribute__((format(...)))')
361 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
362 endif
363 if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
364 name : '__attribute__((packed))')
365 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
366 endif
367 if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
368 name : '__attribute__((returns_nonnull))')
369 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
370 endif
371 if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
372 int foo_hid(void) __attribute__((visibility("hidden")));
373 int foo_int(void) __attribute__((visibility("internal")));
374 int foo_pro(void) __attribute__((visibility("protected")));''',
375 name : '__attribute__((visibility(...)))')
376 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
377 endif
378 if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
379 name : '__attribute__((alias(...)))')
380 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
381 endif
382
383 # TODO: this is very incomplete
384 if host_machine.system() == 'linux'
385 pre_args += '-D_GNU_SOURCE'
386 endif
387
388 # Check for generic C arguments
389 c_args = []
390 foreach a : ['-Wall', '-Werror=implicit-function-declaration',
391 '-Werror=missing-prototypes', '-fno-math-errno',
392 '-fno-trapping-math', '-Qunused-arguments']
393 if cc.has_argument(a)
394 c_args += a
395 endif
396 endforeach
397 c_vis_args = []
398 if cc.has_argument('-fvisibility=hidden')
399 c_vis_args += '-fvisibility=hidden'
400 endif
401
402 # Check for generic C++ arguments
403 cpp = meson.get_compiler('cpp')
404 cpp_args = []
405 foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
406 '-Qunused-arguments', '-Wno-non-virtual-dtor']
407 if cpp.has_argument(a)
408 cpp_args += a
409 endif
410 endforeach
411 cpp_vis_args = []
412 if cpp.has_argument('-fvisibility=hidden')
413 cpp_vis_args += '-fvisibility=hidden'
414 endif
415
416 # Check for C and C++ arguments for MSVC2013 compatibility. These are only used
417 # in parts of the mesa code base that need to compile with old versions of
418 # MSVC, mainly common code
419 c_msvc_compat_args = []
420 cpp_msvc_compat_args = []
421 foreach a : ['-Werror=pointer-arith', '-Werror=vla']
422 if cc.has_argument(a)
423 c_msvc_compat_args += a
424 endif
425 if cpp.has_argument(a)
426 cpp_msvc_compat_args += a
427 endif
428 endforeach
429
430 no_override_init_args = []
431 foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
432 if cc.has_argument(a)
433 no_override_init_args += a
434 endif
435 endforeach
436
437 # TODO: SSE41 (which is only required for core mesa)
438
439 # Check for GCC style atomics
440 if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
441 name : 'GCC atomic builtins')
442 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
443 endif
444 if not cc.links('''#include <stdint.h>
445 uint64_t v;
446 int main() {
447 return __sync_add_and_fetch(&v, (uint64_t)1);
448 }''',
449 name : 'GCC 64bit atomics')
450 pre_args += '-DMISSING_64_BIT_ATOMICS'
451 endif
452
453 # TODO: endian
454 # TODO: powr8
455 # TODO: shared/static? Is this even worth doing?
456
457 # I don't think that I need to set any of the debug stuff, I think meson
458 # handles that for us
459
460 # TODO: ldflags
461
462 # TODO: texture-float (gallium/mesa only)
463
464 # TODO: cross-compiling. I don't think this is relavent to meson
465
466 # FIXME: enable asm when cross compiler
467 # This is doable (autotools does it), but it's not of immediate concern
468 if meson.is_cross_build()
469 message('Cross compiling, disabling asm')
470 with_asm = false
471 endif
472
473 with_asm_arch = ''
474 if with_asm
475 # TODO: SPARC and PPC
476 if host_machine.cpu_family() == 'x86'
477 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
478 with_asm_arch = 'x86'
479 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
480 '-DUSE_SSE_ASM']
481 endif
482 elif host_machine.cpu_family() == 'x86_64'
483 if host_machine.system() == 'linux'
484 with_asm_arch = 'x86_64'
485 pre_args += ['-DUSE_X86_64_ASM']
486 endif
487 elif host_machine.cpu_family() == 'arm'
488 if host_machine.system() == 'linux'
489 with_asm_arch = 'arm'
490 pre_args += ['-DUSE_ARM_ASM']
491 endif
492 elif host_machine.cpu_family() == 'aarch64'
493 if host_machine.system() == 'linux'
494 with_asm_arch = 'aarch64'
495 pre_args += ['-DUSE_AARCH64_ASM']
496 endif
497 endif
498 endif
499
500 # Check for standard headers and functions
501 if cc.has_header_symbol('sys/sysmacros.h', 'major')
502 pre_args += '-DMAJOR_IN_SYSMACROS'
503 elif cc.has_header_symbol('sys/mkdev.h', 'major')
504 pre_args += '-DMAJOR_IN_MKDEV'
505 endif
506
507 foreach h : ['xlocale.h', 'sys/sysctl.h']
508 if cc.has_header(h)
509 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
510 endif
511 endforeach
512
513 foreach f : ['strtof', 'mkostemp', 'posix_memalign']
514 if cc.has_function(f)
515 pre_args += '-DHAVE_@0@'.format(f.to_upper())
516 endif
517 endforeach
518
519 # strtod locale support
520 if cc.links('''
521 #define _GNU_SOURCE
522 #include <stdlib.h>
523 #include <locale.h>
524 #ifdef HAVE_XLOCALE_H
525 #include <xlocale.h>
526 #endif
527 int main() {
528 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
529 const char *s = "1.0";
530 char *end;
531 double d = strtod_l(s, end, loc);
532 float f = strtod_l(s, end, loc);
533 freelocale(loc);
534 return 0;
535 }''',
536 extra_args : pre_args,
537 name : 'strtod has locale support')
538 pre_args += '-DHAVE_STRTOD_L'
539 endif
540
541 # Check for some linker flags
542 ld_args_bsymbolic = []
543 if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
544 ld_args_bsymbolic += '-Wl,-Bsymbolic'
545 endif
546 ld_args_gc_sections = []
547 if cc.links('static char unused() { return 5; } int main() { return 0; }',
548 args : '-Wl,--gc-sections', name : 'gc-sections')
549 ld_args_gc_sections += '-Wl,--gc-sections'
550 endif
551 with_ld_version_script = false
552 if cc.links('int main() { return 0; }',
553 args : '-Wl,--version-script=@0@'.format(
554 join_paths(meson.source_root(), 'build-support/conftest.map')),
555 name : 'version-script')
556 with_ld_version_script = true
557 endif
558 with_ld_dynamic_list = false
559 if cc.links('int main() { return 0; }',
560 args : '-Wl,--dynamic-list=@0@'.format(
561 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
562 name : 'dynamic-list')
563 with_ld_dynamic_list = true
564 endif
565
566 # check for dl support
567 if cc.has_function('dlopen')
568 dep_dl = []
569 else
570 dep_dl = cc.find_library('dl')
571 endif
572 if cc.has_function('dladdr', dependencies : dep_dl)
573 # This is really only required for megadrivers
574 pre_args += '-DHAVE_DLADDR'
575 endif
576
577 if cc.has_function('dl_iterate_phdr')
578 pre_args += '-DHAVE_DL_ITERATE_PHDR'
579 else
580 # TODO: this is required for vulkan
581 endif
582
583 # Determine whether or not the rt library is needed for time functions
584 if cc.has_function('clock_gettime')
585 dep_clock = []
586 else
587 dep_clock = cc.find_library('rt')
588 endif
589
590 with_gallium_drisw_kms = false
591 dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
592 required : with_dri2 or with_dri3)
593 if dep_libdrm.found()
594 pre_args += '-DHAVE_LIBDRM'
595 if with_dri_platform == 'drm' and with_dri
596 with_gallium_drisw_kms = true
597 endif
598 endif
599
600 # TODO: some of these may be conditional
601 dep_zlib = dependency('zlib', version : '>= 1.2.3')
602 dep_thread = dependency('threads')
603 if dep_thread.found() and host_machine.system() == 'linux'
604 pre_args += '-DHAVE_PTHREAD'
605 endif
606 dep_elf = dependency('libelf', required : false)
607 if not dep_elf.found() and (with_amd_vk or with_gallium_radeonsi) # TODO: clover, r600
608 dep_elf = cc.find_library('elf')
609 endif
610 dep_expat = dependency('expat')
611 # this only exists on linux so either this is linux and it will be found, or
612 # its not linux and and wont
613 dep_m = cc.find_library('m', required : false)
614
615 dep_libdrm_amdgpu = []
616 dep_libdrm_radeon = []
617 dep_libdrm_nouveau = []
618 dep_libdrm_etnaviv = []
619 dep_libdrm_freedreno = []
620 if with_amd_vk or with_gallium_radeonsi
621 dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.85')
622 endif
623 if with_gallium_radeonsi # older radeon too
624 dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
625 endif
626 if with_gallium_nouveau
627 dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
628 endif
629 if with_gallium_etnaviv
630 dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
631 endif
632 if with_gallium_freedreno
633 dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.74')
634 endif
635
636 llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
637 if with_amd_vk
638 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
639 endif
640 dep_llvm = dependency(
641 'llvm', version : '>= 3.9.0', required : with_amd_vk, modules : llvm_modules,
642 )
643 if with_llvm
644 if dep_llvm.found()
645 _llvm_version = dep_llvm.version().split('.')
646 # Development versions of LLVM have an 'svn' suffix, we don't want that for
647 # our version checks.
648 _llvm_patch = _llvm_version[2]
649 if _llvm_patch.endswith('svn')
650 _llvm_patch = _llvm_patch.split('s')[0]
651 endif
652 pre_args += [
653 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
654 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
655 ]
656 else
657 if with_gallium_softpipe
658 error('Cannot find LLVM to build LLVMPipe. If you wanted softpipe pass -Dllvm=false to meson')
659 elif with_amd_vk or with_gallium_radeonsi # etc
660 error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM was not found.')
661 endif
662 endif
663 elif with_amd_vk or with_gallium_radeonsi
664 error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM is disabled.')
665 endif
666
667 dep_glvnd = []
668 if with_glvnd
669 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
670 pre_args += '-DUSE_LIBGLVND=1'
671 endif
672
673 # TODO: make this conditional
674 dep_valgrind = dependency('valgrind', required : false)
675 if dep_valgrind.found() and with_valgrind
676 pre_args += '-DHAVE_VALGRIND'
677 endif
678
679 # pthread stubs. Lets not and say we didn't
680
681 prog_bison = find_program('bison', required : with_any_opengl)
682 prog_flex = find_program('flex', required : with_any_opengl)
683
684 # TODO: selinux
685 dep_selinux = []
686
687 # TODO: llvm-prefix and llvm-shared-libs
688
689 dep_unwind = dependency('libunwind', required : false)
690 if dep_unwind.found()
691 pre_args += '-DHAVE_LIBUNWIND'
692 endif
693
694 # TODO: flags for opengl, gles, dri
695
696 # TODO: gallium-hud
697
698 # TODO: glx provider
699
700 # TODO: osmesa provider
701
702 # TODO: symbol mangling
703
704 if with_platform_wayland
705 prog_wl_scanner = find_program('wayland-scanner')
706 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
707 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
708 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
709 wayland_dmabuf_xml = join_paths(
710 dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
711 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
712 )
713 pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED']
714 else
715 prog_wl_scanner = []
716 dep_wl_protocols = []
717 dep_wayland_client = []
718 dep_wayland_server = []
719 wayland_dmabuf_xml = ''
720 endif
721
722 dep_x11 = []
723 dep_xext = []
724 dep_xdamage = []
725 dep_xfixes = []
726 dep_x11_xcb = []
727 dep_xcb_glx = []
728 dep_xcb_dri2 = []
729 dep_xcb_dri3 = []
730 dep_dri2proto = []
731 dep_glproto = []
732 dep_xf86vm = []
733 dep_xcb_dri3 = []
734 dep_xcb_present = []
735 dep_xcb_sync = []
736 dep_xcb_xfixes = []
737 dep_xshmfence = []
738 if with_platform_x11
739 if with_glx == 'dri' and with_dri_platform == 'drm'
740 dep_x11 = dependency('x11')
741 dep_xext = dependency('xext')
742 dep_xdamage = dependency('xdamage', version : '>= 1.1')
743 dep_xfixes = dependency('xfixes')
744 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
745 dep_xf86vm = dependency('xxf86vm', required : false)
746 endif
747 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
748 dep_xcb = dependency('xcb')
749 dep_x11_xcb = dependency('x11-xcb')
750 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
751
752 if with_dri3
753 pre_args += '-DHAVE_DRI3'
754 dep_xcb_dri3 = dependency('xcb-dri3')
755 dep_xcb_present = dependency('xcb-present')
756 dep_xcb_sync = dependency('xcb-sync')
757 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
758 endif
759 endif
760 if with_glx != 'disabled'
761 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
762 dep_glproto = dependency('glproto', version : '>= 1.4.14')
763 endif
764 if with_egl
765 dep_xcb_xfixes = dependency('xcb-xfixes')
766 endif
767 endif
768
769 # TODO: osmesa
770
771 # TODO: vallium G3DVL
772
773 # TODO: nine
774
775 # TODO: clover
776
777 # TODO: gallium tests
778
779 # TODO: various libdirs
780
781 # TODO: swr
782
783 # TODO: gallium driver dirs
784
785 # FIXME: this is a workaround for #2326
786 prog_touch = find_program('touch')
787 dummy_cpp = custom_target(
788 'dummy_cpp',
789 output : 'dummy.cpp',
790 command : [prog_touch, '@OUTPUT@'],
791 )
792
793 foreach a : pre_args
794 add_project_arguments(a, language : ['c', 'cpp'])
795 endforeach
796 foreach a : c_args
797 add_project_arguments(a, language : ['c'])
798 endforeach
799 foreach a : cpp_args
800 add_project_arguments(a, language : ['cpp'])
801 endforeach
802
803 inc_include = include_directories('include')
804
805 gl_priv_reqs = [
806 'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb',
807 'xcb-glx >= 1.8.1', 'libdrm >= 2.4.75',
808 ]
809 if dep_xf86vm != [] and dep_xf86vm.found()
810 gl_priv_reqs += 'xf86vm'
811 endif
812 if with_dri_platform == 'drm'
813 gl_priv_reqs += 'xcb-dri2 >= 1.8'
814 endif
815
816 gl_priv_libs = []
817 if dep_thread.found()
818 gl_priv_libs += ['-lpthread', '-pthread']
819 endif
820 if dep_m.found()
821 gl_priv_libs += '-lm'
822 endif
823 if dep_dl.found()
824 gl_priv_libs += '-ldl'
825 endif
826
827 pkg = import('pkgconfig')
828
829 subdir('include')
830 subdir('src')