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