blob: fecb5dbac814275d26d3a4f3e93ef9680662c0d9 [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 Bakerd1992252017-09-14 17:57:17 -0700119# TODO: there are more platforms required for non-vulkan drivers
120with_platform_wayland = false
121with_platform_x11 = false
Dylan Bakerb1b65392017-09-28 22:25:02 -0700122with_platform_drm = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700123_platforms = get_option('platforms')
124if _platforms != ''
125 _split = _platforms.split(',')
126 with_platform_x11 = _split.contains('x11')
127 with_platform_wayland = _split.contains('wayland')
Dylan Bakerb1b65392017-09-28 22:25:02 -0700128 with_platform_drm = _split.contains('drm')
Dylan Bakerd1992252017-09-14 17:57:17 -0700129endif
130
Dylan Baker816bf7d12017-09-28 15:53:53 -0700131with_gbm = get_option('gbm')
132if with_gbm == 'auto' and with_dri # TODO: or gallium
133 with_gbm = host_machine.system() == 'linux'
134elif with_gbm == 'yes'
135 if not ['linux', 'bsd'].contains(host_machine.system())
136 error('GBM only supports unix-like platforms')
137 endif
138 with_gbm = true
139else
140 with_gbm = false
141endif
142
Dylan Baker8e611872017-10-11 12:49:31 -0700143pre_args += '-DGLX_USE_TLS'
Dylan Bakera47c5252017-09-22 12:55:00 -0700144with_glx = get_option('glx')
145if with_glx != 'disabled'
Dylan Bakera47c5252017-09-22 12:55:00 -0700146 if not (with_platform_x11 and with_any_opengl) and with_glx != 'auto'
147 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
148 elif with_glx == 'gallium-xlib'
149 if not with_gallium
150 error('Gallium-xlib based GLX requires at least one gallium driver')
151 elif with_dri
152 error('gallium-xlib conflicts with any dri driver')
153 endif
154 elif with_glx == 'dri' and not with_dri
155 error('dri based GLX requires at least one DRI driver')
156 elif with_glx == 'auto'
157 if with_dri
158 with_glx = 'dri'
159 elif with_gallium
160 with_glx = 'gallium-xlib'
161 elif with_platform_x11 and with_any_opengl
162 with_glx = 'xlib'
163 else
164 with_glx = 'disabled'
165 endif
166 endif
167endif
168
169with_glvnd = get_option('glvnd')
170if with_glvnd and with_glx != 'dri'
171 message('glvnd requires dri based glx')
172endif
173
174# TODO: toggle for this
175with_glx_direct = true
176
Dylan Bakerd1992252017-09-14 17:57:17 -0700177if with_vulkan_icd_dir == ''
178 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
179endif
180
181with_intel_vk = false
182with_amd_vk = false
Dylan Bakera47c5252017-09-22 12:55:00 -0700183with_any_vk = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700184_vulkan_drivers = get_option('vulkan-drivers')
185if _vulkan_drivers != ''
186 _split = _vulkan_drivers.split(',')
187 with_intel_vk = _split.contains('intel')
188 with_amd_vk = _split.contains('amd')
Dylan Bakera47c5252017-09-22 12:55:00 -0700189 with_any_vk = with_amd_vk or with_intel_vk
Dylan Bakerd1992252017-09-14 17:57:17 -0700190 if not (with_platform_x11 or with_platform_wayland)
191 error('Vulkan requires at least one platform (x11, wayland)')
192 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700193endif
194
Dylan Baker50c28df2017-09-29 17:53:01 -0700195with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
196with_dri3 = get_option('dri3')
197if with_dri3 == 'auto'
198 if host_machine.system() == 'linux' and with_dri2
199 with_dri3 = true
200 else
201 with_dri3 = false
202 endif
203elif with_dri3 == 'yes'
204 with_dri3 = true
205else
206 with_dri3 = false
207endif
208
209if with_any_vk and (with_platform_x11 and not with_dri3)
210 error('Vulkan drivers require dri3 for X11 support')
211endif
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700212if with_dri or with_gallium
Dylan Bakera47c5252017-09-22 12:55:00 -0700213 if with_glx == 'disabled' # TODO: or egl
214 error('building dri or gallium drivers require at least one window system')
215 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700216endif
217
Dylan Baker50c28df2017-09-29 17:53:01 -0700218with_gallium_xvmc = false
219with_gallium_vdpau = false
220with_gallium_omx = false # this is bellagio
221with_gallium_va = false
222with_gallium_media = false
223dep_va = []
224_drivers = get_option('gallium-media')
225if _drivers != ''
226 _split = _drivers.split(',')
227 with_gallium_xvmc = _split.contains('xvmc')
228 with_gallium_vdpau = _split.contains('vdpau')
229 with_gallium_omx = _split.contains('omx')
230 with_gallium_va = _split.contains('va')
231 with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or
232 with_gallium_omx or with_gallium_va)
233endif
234
235if with_platform_x11
236 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
237 pre_args += '-DHAVE_X11_PLATFORM'
238 endif
239 if with_glx == 'xlib'
240 # TODO
241 error('TODO')
242 elif with_glx == 'gallium-xlib'
243 # TODO
244 error('TODO')
245 else
246 pre_args += '-DGLX_INDIRECT_RENDERING'
247 if with_glx_direct
248 pre_args += '-DGLX_DIRECT_RENDERING'
249 endif
250 if with_dri_platform == 'drm'
251 pre_args += '-DGLX_USE_DRM'
252 endif
253 endif
254endif
255
Dylan Bakerd1992252017-09-14 17:57:17 -0700256prog_python2 = find_program('python2')
Dylan Baker9342a7d2017-09-28 10:48:30 -0700257has_mako = run_command(prog_python2, '-c', 'import mako')
258if has_mako.returncode() != 0
259 error('Python (2.x) mako module required to build mesa.')
260endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700261
262cc = meson.get_compiler('c')
263if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
Eric Engestrom1262e822017-09-29 15:25:18 +0100264 error('When using GCC, version 4.4.6 or later is required.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700265endif
266
Dylan Bakerd1992252017-09-14 17:57:17 -0700267# Define DEBUG for debug and debugoptimized builds
268if get_option('buildtype').startswith('debug')
269 pre_args += '-DDEBUG'
270endif
271
Dylan Baker673dda82017-09-20 11:53:29 -0700272if get_option('shader-cache')
273 pre_args += '-DENABLE_SHADER_CACHE'
274elif with_amd_vk
275 error('Radv requires shader cache support')
276endif
277
Dylan Bakerd1992252017-09-14 17:57:17 -0700278# Check for GCC style builtins
279foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
280 'ffsll', 'popcount', 'popcountll', 'unreachable']
281 if cc.has_function(b)
282 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
283 endif
284endforeach
285
Dylan Baker673dda82017-09-20 11:53:29 -0700286# check for GCC __attribute__
Dylan Bakerd1992252017-09-14 17:57:17 -0700287foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
288 'warn_unused_result', 'weak',]
289 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
290 name : '__attribute__((@0@))'.format(a))
291 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
292 endif
293endforeach
294if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
295 name : '__attribute__((format(...)))')
296 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
297endif
298if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
299 name : '__attribute__((packed))')
300 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
301endif
302if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
303 name : '__attribute__((returns_nonnull))')
304 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
305endif
306if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
307 int foo_hid(void) __attribute__((visibility("hidden")));
308 int foo_int(void) __attribute__((visibility("internal")));
309 int foo_pro(void) __attribute__((visibility("protected")));''',
310 name : '__attribute__((visibility(...)))')
311 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
312endif
313if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
314 name : '__attribute__((alias(...)))')
315 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
316endif
317
318# TODO: this is very incomplete
319if host_machine.system() == 'linux'
320 pre_args += '-D_GNU_SOURCE'
321endif
322
323# Check for generic C arguments
324c_args = []
325foreach a : ['-Wall', '-Werror=implicit-function-declaration',
326 '-Werror=missing-prototypes', '-fno-math-errno',
327 '-fno-trapping-math', '-Qunused-arguments']
328 if cc.has_argument(a)
329 c_args += a
330 endif
331endforeach
332c_vis_args = []
333if cc.has_argument('-fvisibility=hidden')
334 c_vis_args += '-fvisibility=hidden'
335endif
336
337# Check for generic C++ arguments
338cpp = meson.get_compiler('cpp')
339cpp_args = []
340foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
341 '-Qunused-arguments', '-Wno-non-virtual-dtor']
342 if cpp.has_argument(a)
343 cpp_args += a
344 endif
345endforeach
346cpp_vis_args = []
347if cpp.has_argument('-fvisibility=hidden')
348 cpp_vis_args += '-fvisibility=hidden'
349endif
350
351# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
352# in parts of the mesa code base that need to compile with old versions of
353# MSVC, mainly common code
354c_msvc_compat_args = []
355cpp_msvc_compat_args = []
356foreach a : ['-Werror=pointer-arith', '-Werror=vla']
357 if cc.has_argument(a)
358 c_msvc_compat_args += a
359 endif
360 if cpp.has_argument(a)
361 cpp_msvc_compat_args += a
362 endif
363endforeach
364
365no_override_init_args = []
366foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
367 if cc.has_argument(a)
368 no_override_init_args += a
369 endif
370endforeach
371
372# TODO: SSE41 (which is only required for core mesa)
373
374# Check for GCC style atomics
375if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
376 name : 'GCC atomic builtins')
377 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
378endif
379if not cc.links('''#include <stdint.h>
380 uint64_t v;
381 int main() {
382 return __sync_add_and_fetch(&v, (uint64_t)1);
383 }''',
384 name : 'GCC 64bit atomics')
385 pre_args += '-DMISSING_64_BIT_ATOMICS'
386endif
387
388# TODO: endian
389# TODO: powr8
390# TODO: shared/static? Is this even worth doing?
391
392# I don't think that I need to set any of the debug stuff, I think meson
393# handles that for us
394
395# TODO: ldflags
396
397# TODO: texture-float (gallium/mesa only)
398
399# TODO: cross-compiling. I don't think this is relavent to meson
400
Dylan Baker32180562017-09-20 20:11:32 -0700401# FIXME: enable asm when cross compiler
402# This is doable (autotools does it), but it's not of immediate concern
403if meson.is_cross_build()
404 message('Cross compiling, disabling asm')
405 with_asm = false
406endif
407
408with_asm_arch = ''
409if with_asm
410 # TODO: SPARC and PPC
411 if host_machine.cpu_family() == 'x86'
412 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
413 with_asm_arch = 'x86'
414 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
415 '-DUSE_SSE_ASM']
416 endif
417 elif host_machine.cpu_family() == 'x86_64'
418 if host_machine.system() == 'linux'
419 with_asm_arch = 'x86_64'
420 pre_args += ['-DUSE_X86_64_ASM']
421 endif
422 elif host_machine.cpu_family() == 'arm'
423 if host_machine.system() == 'linux'
424 with_asm_arch = 'arm'
425 pre_args += ['-DUSE_ARM_ASM']
426 endif
427 elif host_machine.cpu_family() == 'aarch64'
428 if host_machine.system() == 'linux'
429 with_asm_arch = 'aarch64'
430 pre_args += ['-DUSE_AARCH64_ASM']
431 endif
432 endif
433endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700434
435# Check for standard headers and functions
436if cc.has_header_symbol('sys/sysmacros.h', 'major')
437 pre_args += '-DMAJOR_IN_SYSMACROS'
438elif cc.has_header_symbol('sys/mkdev.h', 'major')
439 pre_args += '-DMAJOR_IN_MKDEV'
440endif
441
442foreach h : ['xlocale.h', 'sys/sysctl.h']
443 if cc.has_header(h)
444 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
445 endif
446endforeach
447
448foreach f : ['strtof', 'mkostemp', 'posix_memalign']
449 if cc.has_function(f)
450 pre_args += '-DHAVE_@0@'.format(f.to_upper())
451 endif
452endforeach
453
454# strtod locale support
455if cc.links('''
456 #define _GNU_SOURCE
457 #include <stdlib.h>
458 #include <locale.h>
459 #ifdef HAVE_XLOCALE_H
460 #include <xlocale.h>
461 #endif
462 int main() {
463 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
464 const char *s = "1.0";
465 char *end;
466 double d = strtod_l(s, end, loc);
467 float f = strtod_l(s, end, loc);
468 freelocale(loc);
469 return 0;
470 }''',
471 extra_args : pre_args,
472 name : 'strtod has locale support')
473 pre_args += '-DHAVE_STRTOD_L'
474endif
475
476# Check for some linker flags
477ld_args_bsymbolic = []
Dylan Bakere21e0a62017-09-30 13:15:52 -0700478if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
Dylan Bakerd1992252017-09-14 17:57:17 -0700479 ld_args_bsymbolic += '-Wl,-Bsymbolic'
480endif
481ld_args_gc_sections = []
482if cc.links('static char unused() { return 5; } int main() { return 0; }',
Dylan Bakere21e0a62017-09-30 13:15:52 -0700483 args : '-Wl,--gc-sections', name : 'gc-sections')
Dylan Bakerd1992252017-09-14 17:57:17 -0700484 ld_args_gc_sections += '-Wl,--gc-sections'
485endif
Dylan Bakere21e0a62017-09-30 13:15:52 -0700486with_ld_version_script = false
487if cc.links('int main() { return 0; }',
488 args : '-Wl,--version-script=@0@'.format(
489 join_paths(meson.source_root(), 'build-support/conftest.map')),
490 name : 'version-script')
491 with_ld_version_script = true
492endif
493with_ld_dynamic_list = false
494if cc.links('int main() { return 0; }',
495 args : '-Wl,--dynamic-list=@0@'.format(
496 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
497 name : 'dynamic-list')
498 with_ld_dynamic_list = true
499endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700500
501# check for dl support
502if cc.has_function('dlopen')
503 dep_dl = []
504else
505 dep_dl = cc.find_library('dl')
506endif
Dylan Baker32180562017-09-20 20:11:32 -0700507if cc.has_function('dladdr', dependencies : dep_dl)
508 # This is really only required for megadrivers
509 pre_args += '-DHAVE_DLADDR'
Dylan Bakerd1992252017-09-14 17:57:17 -0700510endif
511
512if cc.has_function('dl_iterate_phdr')
513 pre_args += '-DHAVE_DL_ITERATE_PHDR'
514else
515 # TODO: this is required for vulkan
516endif
517
518# Determine whether or not the rt library is needed for time functions
519if cc.has_function('clock_gettime')
520 dep_clock = []
521else
522 dep_clock = cc.find_library('rt')
523endif
524
Dylan Baker50c28df2017-09-29 17:53:01 -0700525dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
526 required : with_dri2 or with_dri3)
527if dep_libdrm.found()
528 pre_args += '-DHAVE_LIBDRM'
529endif
530
Dylan Bakerd1992252017-09-14 17:57:17 -0700531# TODO: some of these may be conditional
532dep_zlib = dependency('zlib', version : '>= 1.2.3')
533dep_thread = dependency('threads')
Dylan Baker50c28df2017-09-29 17:53:01 -0700534if dep_thread.found() and host_machine.system() == 'linux'
535 pre_args += '-DHAVE_PTHREAD'
536endif
Dylan Bakercc4f5872017-09-27 11:30:21 -0700537dep_elf = dependency('libelf', required : false)
538if not dep_elf.found()
Dylan Baker97aea7d2017-10-04 11:36:06 -0700539 dep_elf = cc.find_library('elf', required : with_amd_vk) # TODO: clover, r600, radeonsi
Dylan Bakercc4f5872017-09-27 11:30:21 -0700540endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700541dep_expat = dependency('expat')
542# this only exists on linux so either this is linux and it will be found, or
543# its not linux and and wont
544dep_m = cc.find_library('m', required : false)
Dylan Baker50c28df2017-09-29 17:53:01 -0700545dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.82', required : with_amd_vk)
Dylan Baker673dda82017-09-20 11:53:29 -0700546
547llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
548if with_amd_vk
549 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
550endif
551dep_llvm = dependency(
Dylan Baker50c28df2017-09-29 17:53:01 -0700552 'llvm', version : '>= 3.9.0', required : with_amd_vk, modules : llvm_modules,
Dylan Baker673dda82017-09-20 11:53:29 -0700553)
Dylan Baker02cf3a82017-10-12 09:47:30 -0700554if with_llvm
555 if dep_llvm.found()
556 _llvm_version = dep_llvm.version().split('.')
557 # Development versions of LLVM have an 'svn' suffix, we don't want that for
558 # our version checks.
559 _llvm_patch = _llvm_version[2]
560 if _llvm_patch.endswith('svn')
561 _llvm_patch = _llvm_patch.split('s')[0]
562 endif
563 pre_args += [
564 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
565 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
566 ]
567 else
568 if with_amd_vk
569 error('The following drivers requires LLVM: Radv. One of these is enabled, but LLVM was not found.')
570 endif
Dylan Baker673dda82017-09-20 11:53:29 -0700571 endif
Dylan Baker02cf3a82017-10-12 09:47:30 -0700572elif with_amd_vk
573 error('The following drivers requires LLVM: Radv. One of these is enabled, but LLVM is disabled.')
Dylan Baker673dda82017-09-20 11:53:29 -0700574endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700575
Dylan Bakera47c5252017-09-22 12:55:00 -0700576dep_glvnd = []
577if with_glvnd
578 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
579 pre_args += '-DUSE_LIBGLVND=1'
580endif
581
Dylan Bakerd1992252017-09-14 17:57:17 -0700582# TODO: make this conditional
583dep_valgrind = dependency('valgrind', required : false)
584if dep_valgrind.found() and with_valgrind
585 pre_args += '-DHAVE_VALGRIND'
586endif
587
588# pthread stubs. Lets not and say we didn't
589
Dylan Baker32180562017-09-20 20:11:32 -0700590prog_bison = find_program('bison', required : with_any_opengl)
591prog_flex = find_program('flex', required : with_any_opengl)
592
Dylan Bakerd1992252017-09-14 17:57:17 -0700593# TODO: selinux
Dylan Baker32180562017-09-20 20:11:32 -0700594dep_selinux = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700595
596# TODO: llvm-prefix and llvm-shared-libs
597
Dylan Bakerb1b65392017-09-28 22:25:02 -0700598dep_unwind = dependency('libunwind', required : false)
599if dep_unwind.found()
600 pre_args += '-DHAVE_LIBUNWIND'
601endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700602
603# TODO: flags for opengl, gles, dri
604
605# TODO: gallium-hud
606
607# TODO: glx provider
608
609# TODO: osmesa provider
610
Dylan Bakerd1992252017-09-14 17:57:17 -0700611# TODO: symbol mangling
612
Dylan Bakerd1992252017-09-14 17:57:17 -0700613# TODO: egl configuration
614
615if with_platform_wayland
616 prog_wl_scanner = find_program('wayland-scanner')
617 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
618 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
619 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
620else
621 prog_wl_scanner = []
622 dep_wl_protocols = []
623 dep_wayland_client = []
624 dep_wayland_server = []
625endif
626
Dylan Baker50c28df2017-09-29 17:53:01 -0700627dep_x11 = []
628dep_xext = []
629dep_xdamage = []
630dep_xfixes = []
631dep_x11_xcb = []
632dep_xcb_glx = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700633dep_xcb_dri2 = []
634dep_xcb_dri3 = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700635dep_dri2proto = []
636dep_glproto = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700637dep_xf86vm = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700638dep_xcb_dri3 = []
639dep_xcb_present = []
640dep_xcb_sync = []
641dep_xshmfence = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700642if with_platform_x11
Dylan Baker50c28df2017-09-29 17:53:01 -0700643 if with_glx == 'dri' and with_dri_platform == 'drm'
644 dep_x11 = dependency('x11')
645 dep_xext = dependency('xext')
646 dep_xdamage = dependency('xdamage', version : '>= 1.1')
647 dep_xfixes = dependency('xfixes')
648 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
649 dep_xf86vm = dependency('xf86vm', required : false)
Dylan Bakera47c5252017-09-22 12:55:00 -0700650 endif
651 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
Dylan Baker50c28df2017-09-29 17:53:01 -0700652 dep_xcb = dependency('xcb')
653 dep_x11_xcb = dependency('x11-xcb')
654 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
655
Dylan Bakera47c5252017-09-22 12:55:00 -0700656 if with_dri3
657 pre_args += '-DHAVE_DRI3'
Dylan Baker50c28df2017-09-29 17:53:01 -0700658 dep_xcb_dri3 = dependency('xcb-dri3')
659 dep_xcb_present = dependency('xcb-present')
660 dep_xcb_sync = dependency('xcb-sync')
661 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
Dylan Bakera47c5252017-09-22 12:55:00 -0700662 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700663 endif
Dylan Baker50c28df2017-09-29 17:53:01 -0700664 if with_glx != 'disabled'
665 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
666 dep_glproto = dependency('glproto', version : '>= 1.4.14')
667 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700668endif
669
670# TODO: platforms for !vulkan
671
Dylan Bakerd1992252017-09-14 17:57:17 -0700672# TODO: osmesa
673
674# TODO: egl
675
Dylan Bakerd1992252017-09-14 17:57:17 -0700676# TODO: vallium G3DVL
677
678# TODO: nine
679
680# TODO: clover
681
682# TODO: egl sans x11
Dylan Bakerd1992252017-09-14 17:57:17 -0700683# TODO: gallium tests
684
685# TODO: various libdirs
686
687# TODO: swr
688
689# TODO: gallium driver dirs
690
691# FIXME: this is a workaround for #2326
692prog_touch = find_program('touch')
693dummy_cpp = custom_target(
694 'dummy_cpp',
695 output : 'dummy.cpp',
696 command : [prog_touch, '@OUTPUT@'],
697)
698
699foreach a : pre_args
700 add_project_arguments(a, language : ['c', 'cpp'])
701endforeach
702foreach a : c_args
703 add_project_arguments(a, language : ['c'])
704endforeach
705foreach a : cpp_args
706 add_project_arguments(a, language : ['cpp'])
707endforeach
708
709inc_include = include_directories('include')
710
Dylan Baker32180562017-09-20 20:11:32 -0700711pkg = import('pkgconfig')
712
Dylan Bakerd1992252017-09-14 17:57:17 -0700713subdir('include')
714subdir('src')