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