blob: 0ffa280b7e41c2ecb7f6bb4c35a53d400fd0ebcc [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
143_platforms = get_option('platforms')
144if _platforms != ''
145 _split = _platforms.split(',')
146 with_platform_x11 = _split.contains('x11')
147 with_platform_wayland = _split.contains('wayland')
148endif
149
Dylan Baker816bf7d12017-09-28 15:53:53 -0700150with_gbm = get_option('gbm')
151if with_gbm == 'auto' and with_dri # TODO: or gallium
152 with_gbm = host_machine.system() == 'linux'
153elif with_gbm == 'yes'
154 if not ['linux', 'bsd'].contains(host_machine.system())
155 error('GBM only supports unix-like platforms')
156 endif
157 with_gbm = true
158else
159 with_gbm = false
160endif
161
Dylan Baker8e611872017-10-11 12:49:31 -0700162pre_args += '-DGLX_USE_TLS'
Dylan Bakera47c5252017-09-22 12:55:00 -0700163with_glx = get_option('glx')
164if with_glx != 'disabled'
Dylan Bakera47c5252017-09-22 12:55:00 -0700165 if not (with_platform_x11 and with_any_opengl) and with_glx != 'auto'
166 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
167 elif with_glx == 'gallium-xlib'
168 if not with_gallium
169 error('Gallium-xlib based GLX requires at least one gallium driver')
170 elif with_dri
171 error('gallium-xlib conflicts with any dri driver')
172 endif
173 elif with_glx == 'dri' and not with_dri
174 error('dri based GLX requires at least one DRI driver')
175 elif with_glx == 'auto'
176 if with_dri
177 with_glx = 'dri'
178 elif with_gallium
179 with_glx = 'gallium-xlib'
180 elif with_platform_x11 and with_any_opengl
181 with_glx = 'xlib'
182 else
183 with_glx = 'disabled'
184 endif
185 endif
186endif
187
188with_glvnd = get_option('glvnd')
189if with_glvnd and with_glx != 'dri'
190 message('glvnd requires dri based glx')
191endif
192
193# TODO: toggle for this
194with_glx_direct = true
195
Dylan Bakerd1992252017-09-14 17:57:17 -0700196if with_vulkan_icd_dir == ''
197 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
198endif
199
200with_intel_vk = false
201with_amd_vk = false
Dylan Bakera47c5252017-09-22 12:55:00 -0700202with_any_vk = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700203_vulkan_drivers = get_option('vulkan-drivers')
204if _vulkan_drivers != ''
205 _split = _vulkan_drivers.split(',')
206 with_intel_vk = _split.contains('intel')
207 with_amd_vk = _split.contains('amd')
Dylan Bakera47c5252017-09-22 12:55:00 -0700208 with_any_vk = with_amd_vk or with_intel_vk
Dylan Bakerd1992252017-09-14 17:57:17 -0700209 if not (with_platform_x11 or with_platform_wayland)
210 error('Vulkan requires at least one platform (x11, wayland)')
211 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700212 if with_platform_x11 and not with_dri3
213 error('Vulkan drivers require dri3 for X11 support')
214 endif
215endif
216
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700217if with_dri or with_gallium
Dylan Bakera47c5252017-09-22 12:55:00 -0700218 if with_glx == 'disabled' # TODO: or egl
219 error('building dri or gallium drivers require at least one window system')
220 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700221endif
222
223prog_python2 = find_program('python2')
Dylan Baker9342a7d2017-09-28 10:48:30 -0700224has_mako = run_command(prog_python2, '-c', 'import mako')
225if has_mako.returncode() != 0
226 error('Python (2.x) mako module required to build mesa.')
227endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700228
229cc = meson.get_compiler('c')
230if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
Eric Engestrom1262e822017-09-29 15:25:18 +0100231 error('When using GCC, version 4.4.6 or later is required.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700232endif
233
Dylan Bakerd1992252017-09-14 17:57:17 -0700234# Define DEBUG for debug and debugoptimized builds
235if get_option('buildtype').startswith('debug')
236 pre_args += '-DDEBUG'
237endif
238
Dylan Baker673dda82017-09-20 11:53:29 -0700239if get_option('shader-cache')
240 pre_args += '-DENABLE_SHADER_CACHE'
241elif with_amd_vk
242 error('Radv requires shader cache support')
243endif
244
Dylan Bakerd1992252017-09-14 17:57:17 -0700245# Check for GCC style builtins
246foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
247 'ffsll', 'popcount', 'popcountll', 'unreachable']
248 if cc.has_function(b)
249 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
250 endif
251endforeach
252
Dylan Baker673dda82017-09-20 11:53:29 -0700253# check for GCC __attribute__
Dylan Bakerd1992252017-09-14 17:57:17 -0700254foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
255 'warn_unused_result', 'weak',]
256 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
257 name : '__attribute__((@0@))'.format(a))
258 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
259 endif
260endforeach
261if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
262 name : '__attribute__((format(...)))')
263 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
264endif
265if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
266 name : '__attribute__((packed))')
267 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
268endif
269if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
270 name : '__attribute__((returns_nonnull))')
271 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
272endif
273if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
274 int foo_hid(void) __attribute__((visibility("hidden")));
275 int foo_int(void) __attribute__((visibility("internal")));
276 int foo_pro(void) __attribute__((visibility("protected")));''',
277 name : '__attribute__((visibility(...)))')
278 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
279endif
280if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
281 name : '__attribute__((alias(...)))')
282 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
283endif
284
285# TODO: this is very incomplete
286if host_machine.system() == 'linux'
287 pre_args += '-D_GNU_SOURCE'
288endif
289
290# Check for generic C arguments
291c_args = []
292foreach a : ['-Wall', '-Werror=implicit-function-declaration',
293 '-Werror=missing-prototypes', '-fno-math-errno',
294 '-fno-trapping-math', '-Qunused-arguments']
295 if cc.has_argument(a)
296 c_args += a
297 endif
298endforeach
299c_vis_args = []
300if cc.has_argument('-fvisibility=hidden')
301 c_vis_args += '-fvisibility=hidden'
302endif
303
304# Check for generic C++ arguments
305cpp = meson.get_compiler('cpp')
306cpp_args = []
307foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
308 '-Qunused-arguments', '-Wno-non-virtual-dtor']
309 if cpp.has_argument(a)
310 cpp_args += a
311 endif
312endforeach
313cpp_vis_args = []
314if cpp.has_argument('-fvisibility=hidden')
315 cpp_vis_args += '-fvisibility=hidden'
316endif
317
318# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
319# in parts of the mesa code base that need to compile with old versions of
320# MSVC, mainly common code
321c_msvc_compat_args = []
322cpp_msvc_compat_args = []
323foreach a : ['-Werror=pointer-arith', '-Werror=vla']
324 if cc.has_argument(a)
325 c_msvc_compat_args += a
326 endif
327 if cpp.has_argument(a)
328 cpp_msvc_compat_args += a
329 endif
330endforeach
331
332no_override_init_args = []
333foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
334 if cc.has_argument(a)
335 no_override_init_args += a
336 endif
337endforeach
338
339# TODO: SSE41 (which is only required for core mesa)
340
341# Check for GCC style atomics
342if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
343 name : 'GCC atomic builtins')
344 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
345endif
346if not cc.links('''#include <stdint.h>
347 uint64_t v;
348 int main() {
349 return __sync_add_and_fetch(&v, (uint64_t)1);
350 }''',
351 name : 'GCC 64bit atomics')
352 pre_args += '-DMISSING_64_BIT_ATOMICS'
353endif
354
355# TODO: endian
356# TODO: powr8
357# TODO: shared/static? Is this even worth doing?
358
359# I don't think that I need to set any of the debug stuff, I think meson
360# handles that for us
361
362# TODO: ldflags
363
364# TODO: texture-float (gallium/mesa only)
365
366# TODO: cross-compiling. I don't think this is relavent to meson
367
Dylan Baker32180562017-09-20 20:11:32 -0700368# FIXME: enable asm when cross compiler
369# This is doable (autotools does it), but it's not of immediate concern
370if meson.is_cross_build()
371 message('Cross compiling, disabling asm')
372 with_asm = false
373endif
374
375with_asm_arch = ''
376if with_asm
377 # TODO: SPARC and PPC
378 if host_machine.cpu_family() == 'x86'
379 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
380 with_asm_arch = 'x86'
381 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
382 '-DUSE_SSE_ASM']
383 endif
384 elif host_machine.cpu_family() == 'x86_64'
385 if host_machine.system() == 'linux'
386 with_asm_arch = 'x86_64'
387 pre_args += ['-DUSE_X86_64_ASM']
388 endif
389 elif host_machine.cpu_family() == 'arm'
390 if host_machine.system() == 'linux'
391 with_asm_arch = 'arm'
392 pre_args += ['-DUSE_ARM_ASM']
393 endif
394 elif host_machine.cpu_family() == 'aarch64'
395 if host_machine.system() == 'linux'
396 with_asm_arch = 'aarch64'
397 pre_args += ['-DUSE_AARCH64_ASM']
398 endif
399 endif
400endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700401
402# Check for standard headers and functions
403if cc.has_header_symbol('sys/sysmacros.h', 'major')
404 pre_args += '-DMAJOR_IN_SYSMACROS'
405elif cc.has_header_symbol('sys/mkdev.h', 'major')
406 pre_args += '-DMAJOR_IN_MKDEV'
407endif
408
409foreach h : ['xlocale.h', 'sys/sysctl.h']
410 if cc.has_header(h)
411 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
412 endif
413endforeach
414
415foreach f : ['strtof', 'mkostemp', 'posix_memalign']
416 if cc.has_function(f)
417 pre_args += '-DHAVE_@0@'.format(f.to_upper())
418 endif
419endforeach
420
421# strtod locale support
422if cc.links('''
423 #define _GNU_SOURCE
424 #include <stdlib.h>
425 #include <locale.h>
426 #ifdef HAVE_XLOCALE_H
427 #include <xlocale.h>
428 #endif
429 int main() {
430 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
431 const char *s = "1.0";
432 char *end;
433 double d = strtod_l(s, end, loc);
434 float f = strtod_l(s, end, loc);
435 freelocale(loc);
436 return 0;
437 }''',
438 extra_args : pre_args,
439 name : 'strtod has locale support')
440 pre_args += '-DHAVE_STRTOD_L'
441endif
442
443# Check for some linker flags
444ld_args_bsymbolic = []
Dylan Bakere21e0a62017-09-30 13:15:52 -0700445if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
Dylan Bakerd1992252017-09-14 17:57:17 -0700446 ld_args_bsymbolic += '-Wl,-Bsymbolic'
447endif
448ld_args_gc_sections = []
449if cc.links('static char unused() { return 5; } int main() { return 0; }',
Dylan Bakere21e0a62017-09-30 13:15:52 -0700450 args : '-Wl,--gc-sections', name : 'gc-sections')
Dylan Bakerd1992252017-09-14 17:57:17 -0700451 ld_args_gc_sections += '-Wl,--gc-sections'
452endif
Dylan Bakere21e0a62017-09-30 13:15:52 -0700453with_ld_version_script = false
454if cc.links('int main() { return 0; }',
455 args : '-Wl,--version-script=@0@'.format(
456 join_paths(meson.source_root(), 'build-support/conftest.map')),
457 name : 'version-script')
458 with_ld_version_script = true
459endif
460with_ld_dynamic_list = false
461if cc.links('int main() { return 0; }',
462 args : '-Wl,--dynamic-list=@0@'.format(
463 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
464 name : 'dynamic-list')
465 with_ld_dynamic_list = true
466endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700467
468# check for dl support
469if cc.has_function('dlopen')
470 dep_dl = []
471else
472 dep_dl = cc.find_library('dl')
473endif
Dylan Baker32180562017-09-20 20:11:32 -0700474if cc.has_function('dladdr', dependencies : dep_dl)
475 # This is really only required for megadrivers
476 pre_args += '-DHAVE_DLADDR'
Dylan Bakerd1992252017-09-14 17:57:17 -0700477endif
478
479if cc.has_function('dl_iterate_phdr')
480 pre_args += '-DHAVE_DL_ITERATE_PHDR'
481else
482 # TODO: this is required for vulkan
483endif
484
485# Determine whether or not the rt library is needed for time functions
486if cc.has_function('clock_gettime')
487 dep_clock = []
488else
489 dep_clock = cc.find_library('rt')
490endif
491
492# TODO: some of these may be conditional
493dep_zlib = dependency('zlib', version : '>= 1.2.3')
494dep_thread = dependency('threads')
495pre_args += '-DHAVE_PTHREAD'
Dylan Bakercc4f5872017-09-27 11:30:21 -0700496dep_elf = dependency('libelf', required : false)
497if not dep_elf.found()
Dylan Baker97aea7d2017-10-04 11:36:06 -0700498 dep_elf = cc.find_library('elf', required : with_amd_vk) # TODO: clover, r600, radeonsi
Dylan Bakercc4f5872017-09-27 11:30:21 -0700499endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700500dep_expat = dependency('expat')
501# this only exists on linux so either this is linux and it will be found, or
502# its not linux and and wont
503dep_m = cc.find_library('m', required : false)
504
Dylan Baker673dda82017-09-20 11:53:29 -0700505dep_libdrm_amdgpu = []
506if with_amd_vk
507 dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.82')
508endif
509
510llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
511if with_amd_vk
512 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
513endif
514dep_llvm = dependency(
515 'llvm', version : '>= 3.9.0', required : false, modules : llvm_modules,
516)
Dylan Baker02cf3a82017-10-12 09:47:30 -0700517if with_llvm
518 if dep_llvm.found()
519 _llvm_version = dep_llvm.version().split('.')
520 # Development versions of LLVM have an 'svn' suffix, we don't want that for
521 # our version checks.
522 _llvm_patch = _llvm_version[2]
523 if _llvm_patch.endswith('svn')
524 _llvm_patch = _llvm_patch.split('s')[0]
525 endif
526 pre_args += [
527 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
528 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
529 ]
530 else
531 if with_amd_vk
532 error('The following drivers requires LLVM: Radv. One of these is enabled, but LLVM was not found.')
533 endif
Dylan Baker673dda82017-09-20 11:53:29 -0700534 endif
Dylan Baker02cf3a82017-10-12 09:47:30 -0700535elif with_amd_vk
536 error('The following drivers requires LLVM: Radv. One of these is enabled, but LLVM is disabled.')
Dylan Baker673dda82017-09-20 11:53:29 -0700537endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700538
Dylan Bakera47c5252017-09-22 12:55:00 -0700539dep_glvnd = []
540if with_glvnd
541 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
542 pre_args += '-DUSE_LIBGLVND=1'
543endif
544
Dylan Bakerd1992252017-09-14 17:57:17 -0700545# TODO: make this conditional
546dep_valgrind = dependency('valgrind', required : false)
547if dep_valgrind.found() and with_valgrind
548 pre_args += '-DHAVE_VALGRIND'
549endif
550
551# pthread stubs. Lets not and say we didn't
552
Dylan Baker32180562017-09-20 20:11:32 -0700553prog_bison = find_program('bison', required : with_any_opengl)
554prog_flex = find_program('flex', required : with_any_opengl)
555
Dylan Bakerd1992252017-09-14 17:57:17 -0700556# TODO: selinux
Dylan Baker32180562017-09-20 20:11:32 -0700557dep_selinux = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700558
559# TODO: llvm-prefix and llvm-shared-libs
560
Dylan Bakerd1992252017-09-14 17:57:17 -0700561# TODO: unwind (llvm [radeon, gallivm] and gallium)
562
563# TODO: flags for opengl, gles, dri
564
565# TODO: gallium-hud
566
567# TODO: glx provider
568
569# TODO: osmesa provider
570
571# TODO: flags for xa, egl, gbm, nin, xvmc, vdpau, omx, va, opencl,
572# gallium-tests,
573
Dylan Bakerd1992252017-09-14 17:57:17 -0700574# TODO: symbol mangling
575
Dylan Bakerd1992252017-09-14 17:57:17 -0700576# TODO: egl configuration
577
578if with_platform_wayland
579 prog_wl_scanner = find_program('wayland-scanner')
580 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
581 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
582 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
583else
584 prog_wl_scanner = []
585 dep_wl_protocols = []
586 dep_wayland_client = []
587 dep_wayland_server = []
588endif
589
590dep_xcb_dri2 = []
591dep_xcb_dri3 = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700592dep_dri2proto = []
593dep_glproto = []
594dep_x11 = []
595dep_xf86vm = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700596if with_platform_x11
Dylan Bakera47c5252017-09-22 12:55:00 -0700597 if with_glx == 'xlib'
598 # TODO
599 error('TODO')
600 elif with_glx == 'gallium-xlib'
601 # TODO
602 error('TODO')
Dylan Bakerd1992252017-09-14 17:57:17 -0700603 else
Dylan Bakera47c5252017-09-22 12:55:00 -0700604 pre_args += '-DGLX_INDIRECT_RENDERING'
605 if with_glx_direct
606 pre_args += '-DGLX_DIRECT_RENDERING'
607 endif
608 if with_dri_platform == 'drm'
609 pre_args += '-DGLX_USE_DRM'
610 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
611 dep_x11 = [
612 dependency('x11'),
613 dependency('xext'),
614 dependency('xdamage', version : '>= 1.1'),
615 dependency('xfixes'),
616 dependency('x11-xcb'),
617 dependency('xcb'),
618 dependency('xcb-glx', version : '>= 1.8.1'),
619 ]
620
Ville Syrjälä66b15972017-10-10 01:34:18 +0300621 dep_xf86vm = dependency('xxf86vm', required : false)
Dylan Bakera47c5252017-09-22 12:55:00 -0700622 endif
623 # TODO: XF86VIDMODE
624 endif
625 if with_glx != 'disabled'
626 dep_glproto = dependency('glproto', version : '>= 1.4.14')
627 endif
628 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
629 dep_xcb_dri2 = [
630 dependency('x11-xcb'),
631 dependency('xcb'),
632 dependency('xcb-dri2', version : '>= 1.8'),
633 dependency('xcb-xfixes'),
634 ]
635 pre_args += '-DHAVE_X11_PLATFORM'
636 if with_dri3
637 pre_args += '-DHAVE_DRI3'
638 dep_xcb_dri3 = [
639 dep_xcb_dri2,
640 dependency('xcb-dri3'),
641 dependency('xcb-present'),
642 dependency('xcb-sync'),
643 dependency('xshmfence', version : '>= 1.1'),
644 ]
645 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700646 endif
647endif
648
649# TODO: platforms for !vulkan
650
Dylan Bakerd1992252017-09-14 17:57:17 -0700651# TODO: osmesa
652
653# TODO: egl
654
655# TODO: xa
656
657# TODO: vallium G3DVL
658
659# TODO: nine
660
661# TODO: clover
662
663# TODO: egl sans x11
664
665# TODO: xvmc
666
667# TODO: gallium tests
668
669# TODO: various libdirs
670
671# TODO: swr
672
673# TODO: gallium driver dirs
674
675# FIXME: this is a workaround for #2326
676prog_touch = find_program('touch')
677dummy_cpp = custom_target(
678 'dummy_cpp',
679 output : 'dummy.cpp',
680 command : [prog_touch, '@OUTPUT@'],
681)
682
683foreach a : pre_args
684 add_project_arguments(a, language : ['c', 'cpp'])
685endforeach
686foreach a : c_args
687 add_project_arguments(a, language : ['c'])
688endforeach
689foreach a : cpp_args
690 add_project_arguments(a, language : ['cpp'])
691endforeach
692
693inc_include = include_directories('include')
694
Dylan Baker32180562017-09-20 20:11:32 -0700695pkg = import('pkgconfig')
696
Dylan Bakerd1992252017-09-14 17:57:17 -0700697subdir('include')
698subdir('src')