blob: 240c868675b10e815bf39aaaad1a27cefed9c97b [file] [log] [blame]
Dylan Bakerd1992252017-09-14 17:57:17 -07001# 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
21project('mesa', ['c', 'cpp'], version : '17.3.0-devel', license : 'MIT',
Dylan Baker052c0d52017-09-30 20:04:09 -070022 default_options : ['c_std=c99', 'cpp_std=c++11'])
Dylan Bakerd1992252017-09-14 17:57:17 -070023
Dylan Baker32180562017-09-20 20:11:32 -070024# 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++.
27pre_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"',
Dylan Baker601bd722017-10-09 14:22:07 -070034 '-D_GNU_SOURCE',
Dylan Baker32180562017-09-20 20:11:32 -070035]
36
Dylan Bakere915b8d2017-09-28 14:02:51 -070037with_vulkan_icd_dir = get_option('vulkan-icd-dir')
Dylan Bakerd1992252017-09-14 17:57:17 -070038with_tests = get_option('build-tests')
39with_valgrind = get_option('valgrind')
Dylan Baker32180562017-09-20 20:11:32 -070040with_asm = get_option('asm')
Dylan Baker02cf3a82017-10-12 09:47:30 -070041with_llvm = get_option('llvm')
Dylan Baker3b209e92017-10-10 15:25:07 -070042if 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.')
45endif
Dylan Baker32180562017-09-20 20:11:32 -070046
47# XXX: yeah, do these
48with_appledri = false
49with_windowsdri = false
50
Dylan Bakerdb978842017-09-28 13:59:04 -070051dri_drivers_path = get_option('dri-drivers-path')
52if dri_drivers_path == ''
53 dri_drivers_path = join_paths(get_option('libdir'), 'dri')
54endif
55
Dylan Baker32180562017-09-20 20:11:32 -070056with_gles1 = get_option('gles1')
57with_gles2 = get_option('gles2')
58with_opengl = get_option('opengl')
59with_any_opengl = with_opengl or with_gles1 or with_gles2
Dylan Bakera47c5252017-09-22 12:55:00 -070060# Only build shared_glapi if at least one OpenGL API is enabled
61with_shared_glapi = get_option('shared-glapi') and with_any_opengl
Dylan Baker32180562017-09-20 20:11:32 -070062
63# TODO: these will need options, but at the moment they just control header
64# installs
Dylan Baker32180562017-09-20 20:11:32 -070065with_osmesa = false
66
67# shared-glapi is required if at least two OpenGL APIs are being built
68if 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
73endif
74
75# We require OpenGL for OpenGL ES
76if (with_gles1 or with_gles2) and not with_opengl
77 error('building OpenGL ES without OpenGL is not supported.')
78endif
79
80with_dri = false
Ville Syrjälä22899642017-10-10 01:15:42 +030081with_dri_i915 = false
Dylan Baker32180562017-09-20 20:11:32 -070082with_dri_i965 = false
Dylan Bakerc2cd5802017-10-03 17:06:22 -070083with_dri_swrast = false
Dylan Baker32180562017-09-20 20:11:32 -070084_drivers = get_option('dri-drivers')
85if _drivers != ''
86 _split = _drivers.split(',')
Ville Syrjälä22899642017-10-10 01:15:42 +030087 with_dri_i915 = _split.contains('i915')
Dylan Baker32180562017-09-20 20:11:32 -070088 with_dri_i965 = _split.contains('i965')
Dylan Bakerc2cd5802017-10-03 17:06:22 -070089 with_dri_swrast = _split.contains('swrast')
Dylan Baker32180562017-09-20 20:11:32 -070090 with_dri = true
91endif
92
Dylan Bakeraf9d2762017-09-28 21:03:07 -070093with_gallium = false
94with_gallium_radeonsi = false
95_drivers = get_option('gallium-drivers')
96if _drivers != ''
97 _split = _drivers.split(',')
98 with_gallium_radeonsi = _split.contains('radeonsi')
99 with_gallium = true
100 with_dri = true
Ville Syrjälä22899642017-10-10 01:15:42 +0300101endif
102
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700103if not (with_dri or with_gallium)
Dylan Baker32180562017-09-20 20:11:32 -0700104 with_gles1 = false
105 with_gles2 = false
106 with_opengl = false
107 with_any_opengl = false
108 with_shared_glapi = false
109endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700110
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700111dep_libdrm_intel = []
112if with_dri_i915
113 dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
114endif
115
Dylan Bakera47c5252017-09-22 12:55:00 -0700116# TODO: other OSes
117with_dri_platform = 'drm'
118
Dylan Bakera47c5252017-09-22 12:55:00 -0700119# TODO: conditionalize libdrm requirement
120dep_libdrm = dependency('libdrm', version : '>= 2.4.75')
121pre_args += '-DHAVE_LIBDRM'
122
123with_dri2 = with_dri_platform == 'drm' and dep_libdrm.found()
124with_dri3 = get_option('dri3')
125if with_dri3 == 'auto'
Dylan Baker816bf7d12017-09-28 15:53:53 -0700126 if host_machine.system() == 'linux' and with_dri2
Dylan Bakera47c5252017-09-22 12:55:00 -0700127 with_dri3 = true
128 else
129 with_dri3 = false
130 endif
131elif with_dri3 == 'yes'
Dylan Baker816bf7d12017-09-28 15:53:53 -0700132 if not with_dri2
133 error('dri3 support requires libdrm')
134 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700135 with_dri3 = true
136else
137 with_dri3 = false
138endif
139
Dylan Bakerd1992252017-09-14 17:57:17 -0700140# TODO: there are more platforms required for non-vulkan drivers
141with_platform_wayland = false
142with_platform_x11 = false
Dylan Bakerb1b65392017-09-28 22:25:02 -0700143with_platform_drm = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700144_platforms = get_option('platforms')
145if _platforms != ''
146 _split = _platforms.split(',')
147 with_platform_x11 = _split.contains('x11')
148 with_platform_wayland = _split.contains('wayland')
Dylan Bakerb1b65392017-09-28 22:25:02 -0700149 with_platform_drm = _split.contains('drm')
Dylan Bakerd1992252017-09-14 17:57:17 -0700150endif
151
Dylan Baker816bf7d12017-09-28 15:53:53 -0700152with_gbm = get_option('gbm')
153if with_gbm == 'auto' and with_dri # TODO: or gallium
154 with_gbm = host_machine.system() == 'linux'
155elif with_gbm == 'yes'
156 if not ['linux', 'bsd'].contains(host_machine.system())
157 error('GBM only supports unix-like platforms')
158 endif
159 with_gbm = true
160else
161 with_gbm = false
162endif
163
Dylan Baker8e611872017-10-11 12:49:31 -0700164pre_args += '-DGLX_USE_TLS'
Dylan Bakera47c5252017-09-22 12:55:00 -0700165with_glx = get_option('glx')
166if with_glx != 'disabled'
Dylan Bakera47c5252017-09-22 12:55:00 -0700167 if not (with_platform_x11 and with_any_opengl) and with_glx != 'auto'
168 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
169 elif with_glx == 'gallium-xlib'
170 if not with_gallium
171 error('Gallium-xlib based GLX requires at least one gallium driver')
172 elif with_dri
173 error('gallium-xlib conflicts with any dri driver')
174 endif
175 elif with_glx == 'dri' and not with_dri
176 error('dri based GLX requires at least one DRI driver')
177 elif with_glx == 'auto'
178 if with_dri
179 with_glx = 'dri'
180 elif with_gallium
181 with_glx = 'gallium-xlib'
182 elif with_platform_x11 and with_any_opengl
183 with_glx = 'xlib'
184 else
185 with_glx = 'disabled'
186 endif
187 endif
188endif
189
190with_glvnd = get_option('glvnd')
191if with_glvnd and with_glx != 'dri'
192 message('glvnd requires dri based glx')
193endif
194
195# TODO: toggle for this
196with_glx_direct = true
197
Dylan Bakerd1992252017-09-14 17:57:17 -0700198if with_vulkan_icd_dir == ''
199 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
200endif
201
202with_intel_vk = false
203with_amd_vk = false
Dylan Bakera47c5252017-09-22 12:55:00 -0700204with_any_vk = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700205_vulkan_drivers = get_option('vulkan-drivers')
206if _vulkan_drivers != ''
207 _split = _vulkan_drivers.split(',')
208 with_intel_vk = _split.contains('intel')
209 with_amd_vk = _split.contains('amd')
Dylan Bakera47c5252017-09-22 12:55:00 -0700210 with_any_vk = with_amd_vk or with_intel_vk
Dylan Bakerd1992252017-09-14 17:57:17 -0700211 if not (with_platform_x11 or with_platform_wayland)
212 error('Vulkan requires at least one platform (x11, wayland)')
213 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700214 if with_platform_x11 and not with_dri3
215 error('Vulkan drivers require dri3 for X11 support')
216 endif
217endif
218
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700219if with_dri or with_gallium
Dylan Bakera47c5252017-09-22 12:55:00 -0700220 if with_glx == 'disabled' # TODO: or egl
221 error('building dri or gallium drivers require at least one window system')
222 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700223endif
224
225prog_python2 = find_program('python2')
Dylan Baker9342a7d2017-09-28 10:48:30 -0700226has_mako = run_command(prog_python2, '-c', 'import mako')
227if has_mako.returncode() != 0
228 error('Python (2.x) mako module required to build mesa.')
229endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700230
231cc = meson.get_compiler('c')
232if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
Eric Engestrom1262e822017-09-29 15:25:18 +0100233 error('When using GCC, version 4.4.6 or later is required.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700234endif
235
Dylan Bakerd1992252017-09-14 17:57:17 -0700236# Define DEBUG for debug and debugoptimized builds
237if get_option('buildtype').startswith('debug')
238 pre_args += '-DDEBUG'
239endif
240
Dylan Baker673dda82017-09-20 11:53:29 -0700241if get_option('shader-cache')
242 pre_args += '-DENABLE_SHADER_CACHE'
243elif with_amd_vk
244 error('Radv requires shader cache support')
245endif
246
Dylan Bakerd1992252017-09-14 17:57:17 -0700247# Check for GCC style builtins
248foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
249 'ffsll', 'popcount', 'popcountll', 'unreachable']
250 if cc.has_function(b)
251 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
252 endif
253endforeach
254
Dylan Baker673dda82017-09-20 11:53:29 -0700255# check for GCC __attribute__
Dylan Bakerd1992252017-09-14 17:57:17 -0700256foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
257 'warn_unused_result', 'weak',]
258 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
259 name : '__attribute__((@0@))'.format(a))
260 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
261 endif
262endforeach
263if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
264 name : '__attribute__((format(...)))')
265 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
266endif
267if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
268 name : '__attribute__((packed))')
269 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
270endif
271if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
272 name : '__attribute__((returns_nonnull))')
273 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
274endif
275if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
276 int foo_hid(void) __attribute__((visibility("hidden")));
277 int foo_int(void) __attribute__((visibility("internal")));
278 int foo_pro(void) __attribute__((visibility("protected")));''',
279 name : '__attribute__((visibility(...)))')
280 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
281endif
282if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
283 name : '__attribute__((alias(...)))')
284 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
285endif
286
287# TODO: this is very incomplete
288if host_machine.system() == 'linux'
289 pre_args += '-D_GNU_SOURCE'
290endif
291
292# Check for generic C arguments
293c_args = []
294foreach a : ['-Wall', '-Werror=implicit-function-declaration',
295 '-Werror=missing-prototypes', '-fno-math-errno',
296 '-fno-trapping-math', '-Qunused-arguments']
297 if cc.has_argument(a)
298 c_args += a
299 endif
300endforeach
301c_vis_args = []
302if cc.has_argument('-fvisibility=hidden')
303 c_vis_args += '-fvisibility=hidden'
304endif
305
306# Check for generic C++ arguments
307cpp = meson.get_compiler('cpp')
308cpp_args = []
309foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
310 '-Qunused-arguments', '-Wno-non-virtual-dtor']
311 if cpp.has_argument(a)
312 cpp_args += a
313 endif
314endforeach
315cpp_vis_args = []
316if cpp.has_argument('-fvisibility=hidden')
317 cpp_vis_args += '-fvisibility=hidden'
318endif
319
320# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
321# in parts of the mesa code base that need to compile with old versions of
322# MSVC, mainly common code
323c_msvc_compat_args = []
324cpp_msvc_compat_args = []
325foreach a : ['-Werror=pointer-arith', '-Werror=vla']
326 if cc.has_argument(a)
327 c_msvc_compat_args += a
328 endif
329 if cpp.has_argument(a)
330 cpp_msvc_compat_args += a
331 endif
332endforeach
333
334no_override_init_args = []
335foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
336 if cc.has_argument(a)
337 no_override_init_args += a
338 endif
339endforeach
340
341# TODO: SSE41 (which is only required for core mesa)
342
343# Check for GCC style atomics
344if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
345 name : 'GCC atomic builtins')
346 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
347endif
348if not cc.links('''#include <stdint.h>
349 uint64_t v;
350 int main() {
351 return __sync_add_and_fetch(&v, (uint64_t)1);
352 }''',
353 name : 'GCC 64bit atomics')
354 pre_args += '-DMISSING_64_BIT_ATOMICS'
355endif
356
357# TODO: endian
358# TODO: powr8
359# TODO: shared/static? Is this even worth doing?
360
361# I don't think that I need to set any of the debug stuff, I think meson
362# handles that for us
363
364# TODO: ldflags
365
366# TODO: texture-float (gallium/mesa only)
367
368# TODO: cross-compiling. I don't think this is relavent to meson
369
Dylan Baker32180562017-09-20 20:11:32 -0700370# FIXME: enable asm when cross compiler
371# This is doable (autotools does it), but it's not of immediate concern
372if meson.is_cross_build()
373 message('Cross compiling, disabling asm')
374 with_asm = false
375endif
376
377with_asm_arch = ''
378if with_asm
379 # TODO: SPARC and PPC
380 if host_machine.cpu_family() == 'x86'
381 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
382 with_asm_arch = 'x86'
383 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
384 '-DUSE_SSE_ASM']
385 endif
386 elif host_machine.cpu_family() == 'x86_64'
387 if host_machine.system() == 'linux'
388 with_asm_arch = 'x86_64'
389 pre_args += ['-DUSE_X86_64_ASM']
390 endif
391 elif host_machine.cpu_family() == 'arm'
392 if host_machine.system() == 'linux'
393 with_asm_arch = 'arm'
394 pre_args += ['-DUSE_ARM_ASM']
395 endif
396 elif host_machine.cpu_family() == 'aarch64'
397 if host_machine.system() == 'linux'
398 with_asm_arch = 'aarch64'
399 pre_args += ['-DUSE_AARCH64_ASM']
400 endif
401 endif
402endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700403
404# Check for standard headers and functions
405if cc.has_header_symbol('sys/sysmacros.h', 'major')
406 pre_args += '-DMAJOR_IN_SYSMACROS'
407elif cc.has_header_symbol('sys/mkdev.h', 'major')
408 pre_args += '-DMAJOR_IN_MKDEV'
409endif
410
411foreach h : ['xlocale.h', 'sys/sysctl.h']
412 if cc.has_header(h)
413 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
414 endif
415endforeach
416
417foreach f : ['strtof', 'mkostemp', 'posix_memalign']
418 if cc.has_function(f)
419 pre_args += '-DHAVE_@0@'.format(f.to_upper())
420 endif
421endforeach
422
423# strtod locale support
424if cc.links('''
425 #define _GNU_SOURCE
426 #include <stdlib.h>
427 #include <locale.h>
428 #ifdef HAVE_XLOCALE_H
429 #include <xlocale.h>
430 #endif
431 int main() {
432 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
433 const char *s = "1.0";
434 char *end;
435 double d = strtod_l(s, end, loc);
436 float f = strtod_l(s, end, loc);
437 freelocale(loc);
438 return 0;
439 }''',
440 extra_args : pre_args,
441 name : 'strtod has locale support')
442 pre_args += '-DHAVE_STRTOD_L'
443endif
444
445# Check for some linker flags
446ld_args_bsymbolic = []
Dylan Bakere21e0a62017-09-30 13:15:52 -0700447if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
Dylan Bakerd1992252017-09-14 17:57:17 -0700448 ld_args_bsymbolic += '-Wl,-Bsymbolic'
449endif
450ld_args_gc_sections = []
451if cc.links('static char unused() { return 5; } int main() { return 0; }',
Dylan Bakere21e0a62017-09-30 13:15:52 -0700452 args : '-Wl,--gc-sections', name : 'gc-sections')
Dylan Bakerd1992252017-09-14 17:57:17 -0700453 ld_args_gc_sections += '-Wl,--gc-sections'
454endif
Dylan Bakere21e0a62017-09-30 13:15:52 -0700455with_ld_version_script = false
456if cc.links('int main() { return 0; }',
457 args : '-Wl,--version-script=@0@'.format(
458 join_paths(meson.source_root(), 'build-support/conftest.map')),
459 name : 'version-script')
460 with_ld_version_script = true
461endif
462with_ld_dynamic_list = false
463if cc.links('int main() { return 0; }',
464 args : '-Wl,--dynamic-list=@0@'.format(
465 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
466 name : 'dynamic-list')
467 with_ld_dynamic_list = true
468endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700469
470# check for dl support
471if cc.has_function('dlopen')
472 dep_dl = []
473else
474 dep_dl = cc.find_library('dl')
475endif
Dylan Baker32180562017-09-20 20:11:32 -0700476if cc.has_function('dladdr', dependencies : dep_dl)
477 # This is really only required for megadrivers
478 pre_args += '-DHAVE_DLADDR'
Dylan Bakerd1992252017-09-14 17:57:17 -0700479endif
480
481if cc.has_function('dl_iterate_phdr')
482 pre_args += '-DHAVE_DL_ITERATE_PHDR'
483else
484 # TODO: this is required for vulkan
485endif
486
487# Determine whether or not the rt library is needed for time functions
488if cc.has_function('clock_gettime')
489 dep_clock = []
490else
491 dep_clock = cc.find_library('rt')
492endif
493
494# TODO: some of these may be conditional
495dep_zlib = dependency('zlib', version : '>= 1.2.3')
496dep_thread = dependency('threads')
497pre_args += '-DHAVE_PTHREAD'
Dylan Bakercc4f5872017-09-27 11:30:21 -0700498dep_elf = dependency('libelf', required : false)
499if not dep_elf.found()
Dylan Baker97aea7d2017-10-04 11:36:06 -0700500 dep_elf = cc.find_library('elf', required : with_amd_vk) # TODO: clover, r600, radeonsi
Dylan Bakercc4f5872017-09-27 11:30:21 -0700501endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700502dep_expat = dependency('expat')
503# this only exists on linux so either this is linux and it will be found, or
504# its not linux and and wont
505dep_m = cc.find_library('m', required : false)
506
Dylan Baker673dda82017-09-20 11:53:29 -0700507dep_libdrm_amdgpu = []
508if with_amd_vk
509 dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.82')
510endif
511
512llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
513if with_amd_vk
514 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
515endif
516dep_llvm = dependency(
517 'llvm', version : '>= 3.9.0', required : false, modules : llvm_modules,
518)
Dylan Baker02cf3a82017-10-12 09:47:30 -0700519if with_llvm
520 if dep_llvm.found()
521 _llvm_version = dep_llvm.version().split('.')
522 # Development versions of LLVM have an 'svn' suffix, we don't want that for
523 # our version checks.
524 _llvm_patch = _llvm_version[2]
525 if _llvm_patch.endswith('svn')
526 _llvm_patch = _llvm_patch.split('s')[0]
527 endif
528 pre_args += [
529 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
530 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
531 ]
532 else
533 if with_amd_vk
534 error('The following drivers requires LLVM: Radv. One of these is enabled, but LLVM was not found.')
535 endif
Dylan Baker673dda82017-09-20 11:53:29 -0700536 endif
Dylan Baker02cf3a82017-10-12 09:47:30 -0700537elif with_amd_vk
538 error('The following drivers requires LLVM: Radv. One of these is enabled, but LLVM is disabled.')
Dylan Baker673dda82017-09-20 11:53:29 -0700539endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700540
Dylan Bakera47c5252017-09-22 12:55:00 -0700541dep_glvnd = []
542if with_glvnd
543 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
544 pre_args += '-DUSE_LIBGLVND=1'
545endif
546
Dylan Bakerd1992252017-09-14 17:57:17 -0700547# TODO: make this conditional
548dep_valgrind = dependency('valgrind', required : false)
549if dep_valgrind.found() and with_valgrind
550 pre_args += '-DHAVE_VALGRIND'
551endif
552
553# pthread stubs. Lets not and say we didn't
554
Dylan Baker32180562017-09-20 20:11:32 -0700555prog_bison = find_program('bison', required : with_any_opengl)
556prog_flex = find_program('flex', required : with_any_opengl)
557
Dylan Bakerd1992252017-09-14 17:57:17 -0700558# TODO: selinux
Dylan Baker32180562017-09-20 20:11:32 -0700559dep_selinux = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700560
561# TODO: llvm-prefix and llvm-shared-libs
562
Dylan Bakerb1b65392017-09-28 22:25:02 -0700563dep_unwind = dependency('libunwind', required : false)
564if dep_unwind.found()
565 pre_args += '-DHAVE_LIBUNWIND'
566endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700567
568# TODO: flags for opengl, gles, dri
569
570# TODO: gallium-hud
571
572# TODO: glx provider
573
574# TODO: osmesa provider
575
Dylan Bakerd1992252017-09-14 17:57:17 -0700576# TODO: symbol mangling
577
Dylan Bakerd1992252017-09-14 17:57:17 -0700578# TODO: egl configuration
579
580if with_platform_wayland
581 prog_wl_scanner = find_program('wayland-scanner')
582 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
583 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
584 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
585else
586 prog_wl_scanner = []
587 dep_wl_protocols = []
588 dep_wayland_client = []
589 dep_wayland_server = []
590endif
591
592dep_xcb_dri2 = []
593dep_xcb_dri3 = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700594dep_dri2proto = []
595dep_glproto = []
596dep_x11 = []
597dep_xf86vm = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700598if with_platform_x11
Dylan Bakera47c5252017-09-22 12:55:00 -0700599 if with_glx == 'xlib'
600 # TODO
601 error('TODO')
602 elif with_glx == 'gallium-xlib'
603 # TODO
604 error('TODO')
Dylan Bakerd1992252017-09-14 17:57:17 -0700605 else
Dylan Bakera47c5252017-09-22 12:55:00 -0700606 pre_args += '-DGLX_INDIRECT_RENDERING'
607 if with_glx_direct
608 pre_args += '-DGLX_DIRECT_RENDERING'
609 endif
610 if with_dri_platform == 'drm'
611 pre_args += '-DGLX_USE_DRM'
612 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
613 dep_x11 = [
614 dependency('x11'),
615 dependency('xext'),
616 dependency('xdamage', version : '>= 1.1'),
617 dependency('xfixes'),
618 dependency('x11-xcb'),
619 dependency('xcb'),
620 dependency('xcb-glx', version : '>= 1.8.1'),
621 ]
622
Ville Syrjälä66b15972017-10-10 01:34:18 +0300623 dep_xf86vm = dependency('xxf86vm', required : false)
Dylan Bakera47c5252017-09-22 12:55:00 -0700624 endif
625 # TODO: XF86VIDMODE
626 endif
627 if with_glx != 'disabled'
628 dep_glproto = dependency('glproto', version : '>= 1.4.14')
629 endif
630 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
631 dep_xcb_dri2 = [
632 dependency('x11-xcb'),
633 dependency('xcb'),
634 dependency('xcb-dri2', version : '>= 1.8'),
635 dependency('xcb-xfixes'),
636 ]
637 pre_args += '-DHAVE_X11_PLATFORM'
638 if with_dri3
639 pre_args += '-DHAVE_DRI3'
640 dep_xcb_dri3 = [
641 dep_xcb_dri2,
642 dependency('xcb-dri3'),
643 dependency('xcb-present'),
644 dependency('xcb-sync'),
645 dependency('xshmfence', version : '>= 1.1'),
646 ]
647 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700648 endif
649endif
650
651# TODO: platforms for !vulkan
652
Dylan Bakerd1992252017-09-14 17:57:17 -0700653# TODO: osmesa
654
655# TODO: egl
656
Dylan Bakerd1992252017-09-14 17:57:17 -0700657# TODO: vallium G3DVL
658
659# TODO: nine
660
661# TODO: clover
662
663# TODO: egl sans x11
664
Dylan Bakerb1b65392017-09-28 22:25:02 -0700665with_gallium_xvmc = false
666with_gallium_vdpau = false
667with_gallium_omx = false # this is bellagio
668with_gallium_va = false
669with_gallium_media = false
670dep_va = []
671_drivers = get_option('gallium-media')
672if _drivers != ''
673 _split = _drivers.split(',')
674 with_gallium_xvmc = _split.contains('xvmc')
675 with_gallium_vdpau = _split.contains('vdpau')
676 with_gallium_omx = _split.contains('omx')
677 with_gallium_va = _split.contains('va')
678 with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or
679 with_gallium_omx or with_gallium_va)
680 if with_gallium_media
681 dep_va = [
682 dependency('x11-xcb'),
683 dependency('xcb'),
684 dependency('xcb-dri2', version : '>= 1.8'), # FIXME: dedup version
685 ]
686 endif
687endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700688
689# TODO: gallium tests
690
691# TODO: various libdirs
692
693# TODO: swr
694
695# TODO: gallium driver dirs
696
697# FIXME: this is a workaround for #2326
698prog_touch = find_program('touch')
699dummy_cpp = custom_target(
700 'dummy_cpp',
701 output : 'dummy.cpp',
702 command : [prog_touch, '@OUTPUT@'],
703)
704
705foreach a : pre_args
706 add_project_arguments(a, language : ['c', 'cpp'])
707endforeach
708foreach a : c_args
709 add_project_arguments(a, language : ['c'])
710endforeach
711foreach a : cpp_args
712 add_project_arguments(a, language : ['cpp'])
713endforeach
714
715inc_include = include_directories('include')
716
Dylan Baker32180562017-09-20 20:11:32 -0700717pkg = import('pkgconfig')
718
Dylan Bakerd1992252017-09-14 17:57:17 -0700719subdir('include')
720subdir('src')