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