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