blob: 9967df08e0173cbd5e35285531851a519ed30dae [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
Eric Anholt1918c9b2017-10-12 18:39:08 -070094with_gallium_pl111 = false
Dylan Bakeraf9d2762017-09-28 21:03:07 -070095with_gallium_radeonsi = false
Dylan Baker813b4b02017-10-09 14:59:35 -070096with_gallium_nouveau = false
Dylan Bakerf3d03a22017-10-10 11:57:50 -070097with_gallium_softpipe = false
Eric Anholt1ae80182017-10-12 13:53:12 -070098with_gallium_vc4 = false
Dylan Bakeraf9d2762017-09-28 21:03:07 -070099_drivers = get_option('gallium-drivers')
100if _drivers != ''
101 _split = _drivers.split(',')
Eric Anholt1918c9b2017-10-12 18:39:08 -0700102 with_gallium_vc4 = _split.contains('pl111')
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700103 with_gallium_radeonsi = _split.contains('radeonsi')
Dylan Baker813b4b02017-10-09 14:59:35 -0700104 with_gallium_nouveau = _split.contains('nouveau')
Dylan Bakerde24d612017-10-10 14:27:19 -0700105 with_gallium_softpipe = _split.contains('swrast')
Eric Anholt1ae80182017-10-12 13:53:12 -0700106 with_gallium_vc4 = _split.contains('vc4')
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700107 with_gallium = true
108 with_dri = true
Ville Syrjälä22899642017-10-10 01:15:42 +0300109endif
110
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700111if not (with_dri or with_gallium)
Dylan Baker32180562017-09-20 20:11:32 -0700112 with_gles1 = false
113 with_gles2 = false
114 with_opengl = false
115 with_any_opengl = false
116 with_shared_glapi = false
117endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700118
Dylan Bakerde24d612017-10-10 14:27:19 -0700119if with_dri_swrast and with_gallium_softpipe
120 error('Only one swrast provider can be built')
121endif
122
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700123dep_libdrm_intel = []
124if with_dri_i915
125 dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
126endif
127
Dylan Bakera47c5252017-09-22 12:55:00 -0700128# TODO: other OSes
129with_dri_platform = 'drm'
130
Dylan Bakerd1992252017-09-14 17:57:17 -0700131# TODO: there are more platforms required for non-vulkan drivers
132with_platform_wayland = false
133with_platform_x11 = false
Dylan Bakerb1b65392017-09-28 22:25:02 -0700134with_platform_drm = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700135_platforms = get_option('platforms')
136if _platforms != ''
137 _split = _platforms.split(',')
138 with_platform_x11 = _split.contains('x11')
139 with_platform_wayland = _split.contains('wayland')
Dylan Bakerb1b65392017-09-28 22:25:02 -0700140 with_platform_drm = _split.contains('drm')
Dylan Bakerd1992252017-09-14 17:57:17 -0700141endif
142
Dylan Baker816bf7d12017-09-28 15:53:53 -0700143with_gbm = get_option('gbm')
144if with_gbm == 'auto' and with_dri # TODO: or gallium
145 with_gbm = host_machine.system() == 'linux'
146elif with_gbm == 'yes'
147 if not ['linux', 'bsd'].contains(host_machine.system())
148 error('GBM only supports unix-like platforms')
149 endif
150 with_gbm = true
151else
152 with_gbm = false
153endif
154
Dylan Baker8e611872017-10-11 12:49:31 -0700155pre_args += '-DGLX_USE_TLS'
Dylan Bakera47c5252017-09-22 12:55:00 -0700156with_glx = get_option('glx')
157if with_glx != 'disabled'
Dylan Bakera47c5252017-09-22 12:55:00 -0700158 if not (with_platform_x11 and with_any_opengl) and with_glx != 'auto'
159 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
160 elif with_glx == 'gallium-xlib'
161 if not with_gallium
162 error('Gallium-xlib based GLX requires at least one gallium driver')
163 elif with_dri
164 error('gallium-xlib conflicts with any dri driver')
165 endif
166 elif with_glx == 'dri' and not with_dri
167 error('dri based GLX requires at least one DRI driver')
168 elif with_glx == 'auto'
169 if with_dri
170 with_glx = 'dri'
171 elif with_gallium
172 with_glx = 'gallium-xlib'
173 elif with_platform_x11 and with_any_opengl
174 with_glx = 'xlib'
175 else
176 with_glx = 'disabled'
177 endif
178 endif
179endif
180
181with_glvnd = get_option('glvnd')
182if with_glvnd and with_glx != 'dri'
183 message('glvnd requires dri based glx')
184endif
185
186# TODO: toggle for this
187with_glx_direct = true
188
Dylan Bakerd1992252017-09-14 17:57:17 -0700189if with_vulkan_icd_dir == ''
190 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
191endif
192
193with_intel_vk = false
194with_amd_vk = false
Dylan Bakera47c5252017-09-22 12:55:00 -0700195with_any_vk = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700196_vulkan_drivers = get_option('vulkan-drivers')
197if _vulkan_drivers != ''
198 _split = _vulkan_drivers.split(',')
199 with_intel_vk = _split.contains('intel')
200 with_amd_vk = _split.contains('amd')
Dylan Bakera47c5252017-09-22 12:55:00 -0700201 with_any_vk = with_amd_vk or with_intel_vk
Dylan Bakerd1992252017-09-14 17:57:17 -0700202 if not (with_platform_x11 or with_platform_wayland)
203 error('Vulkan requires at least one platform (x11, wayland)')
204 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700205endif
206
Dylan Baker50c28df2017-09-29 17:53:01 -0700207with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
208with_dri3 = get_option('dri3')
209if with_dri3 == 'auto'
210 if host_machine.system() == 'linux' and with_dri2
211 with_dri3 = true
212 else
213 with_dri3 = false
214 endif
215elif with_dri3 == 'yes'
216 with_dri3 = true
217else
218 with_dri3 = false
219endif
220
221if with_any_vk and (with_platform_x11 and not with_dri3)
222 error('Vulkan drivers require dri3 for X11 support')
223endif
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700224if with_dri or with_gallium
Dylan Bakera47c5252017-09-22 12:55:00 -0700225 if with_glx == 'disabled' # TODO: or egl
226 error('building dri or gallium drivers require at least one window system')
227 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700228endif
229
Dylan Baker50c28df2017-09-29 17:53:01 -0700230with_gallium_xvmc = false
231with_gallium_vdpau = false
232with_gallium_omx = false # this is bellagio
233with_gallium_va = false
234with_gallium_media = false
235dep_va = []
236_drivers = get_option('gallium-media')
237if _drivers != ''
238 _split = _drivers.split(',')
239 with_gallium_xvmc = _split.contains('xvmc')
240 with_gallium_vdpau = _split.contains('vdpau')
241 with_gallium_omx = _split.contains('omx')
242 with_gallium_va = _split.contains('va')
243 with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or
244 with_gallium_omx or with_gallium_va)
245endif
246
247if with_platform_x11
248 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
249 pre_args += '-DHAVE_X11_PLATFORM'
250 endif
251 if with_glx == 'xlib'
252 # TODO
253 error('TODO')
254 elif with_glx == 'gallium-xlib'
255 # TODO
256 error('TODO')
257 else
258 pre_args += '-DGLX_INDIRECT_RENDERING'
259 if with_glx_direct
260 pre_args += '-DGLX_DIRECT_RENDERING'
261 endif
262 if with_dri_platform == 'drm'
263 pre_args += '-DGLX_USE_DRM'
264 endif
265 endif
266endif
267
Dylan Bakerd1992252017-09-14 17:57:17 -0700268prog_python2 = find_program('python2')
Dylan Baker9342a7d2017-09-28 10:48:30 -0700269has_mako = run_command(prog_python2, '-c', 'import mako')
270if has_mako.returncode() != 0
271 error('Python (2.x) mako module required to build mesa.')
272endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700273
274cc = meson.get_compiler('c')
275if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
Eric Engestrom1262e822017-09-29 15:25:18 +0100276 error('When using GCC, version 4.4.6 or later is required.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700277endif
278
Dylan Bakerd1992252017-09-14 17:57:17 -0700279# Define DEBUG for debug and debugoptimized builds
280if get_option('buildtype').startswith('debug')
281 pre_args += '-DDEBUG'
282endif
283
Dylan Baker673dda82017-09-20 11:53:29 -0700284if get_option('shader-cache')
285 pre_args += '-DENABLE_SHADER_CACHE'
286elif with_amd_vk
287 error('Radv requires shader cache support')
288endif
289
Dylan Bakerd1992252017-09-14 17:57:17 -0700290# Check for GCC style builtins
291foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
292 'ffsll', 'popcount', 'popcountll', 'unreachable']
293 if cc.has_function(b)
294 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
295 endif
296endforeach
297
Dylan Baker673dda82017-09-20 11:53:29 -0700298# check for GCC __attribute__
Dylan Bakerd1992252017-09-14 17:57:17 -0700299foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
300 'warn_unused_result', 'weak',]
301 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
302 name : '__attribute__((@0@))'.format(a))
303 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
304 endif
305endforeach
306if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
307 name : '__attribute__((format(...)))')
308 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
309endif
310if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
311 name : '__attribute__((packed))')
312 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
313endif
314if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
315 name : '__attribute__((returns_nonnull))')
316 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
317endif
318if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
319 int foo_hid(void) __attribute__((visibility("hidden")));
320 int foo_int(void) __attribute__((visibility("internal")));
321 int foo_pro(void) __attribute__((visibility("protected")));''',
322 name : '__attribute__((visibility(...)))')
323 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
324endif
325if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
326 name : '__attribute__((alias(...)))')
327 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
328endif
329
330# TODO: this is very incomplete
331if host_machine.system() == 'linux'
332 pre_args += '-D_GNU_SOURCE'
333endif
334
335# Check for generic C arguments
336c_args = []
337foreach a : ['-Wall', '-Werror=implicit-function-declaration',
338 '-Werror=missing-prototypes', '-fno-math-errno',
339 '-fno-trapping-math', '-Qunused-arguments']
340 if cc.has_argument(a)
341 c_args += a
342 endif
343endforeach
344c_vis_args = []
345if cc.has_argument('-fvisibility=hidden')
346 c_vis_args += '-fvisibility=hidden'
347endif
348
349# Check for generic C++ arguments
350cpp = meson.get_compiler('cpp')
351cpp_args = []
352foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
353 '-Qunused-arguments', '-Wno-non-virtual-dtor']
354 if cpp.has_argument(a)
355 cpp_args += a
356 endif
357endforeach
358cpp_vis_args = []
359if cpp.has_argument('-fvisibility=hidden')
360 cpp_vis_args += '-fvisibility=hidden'
361endif
362
363# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
364# in parts of the mesa code base that need to compile with old versions of
365# MSVC, mainly common code
366c_msvc_compat_args = []
367cpp_msvc_compat_args = []
368foreach a : ['-Werror=pointer-arith', '-Werror=vla']
369 if cc.has_argument(a)
370 c_msvc_compat_args += a
371 endif
372 if cpp.has_argument(a)
373 cpp_msvc_compat_args += a
374 endif
375endforeach
376
377no_override_init_args = []
378foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
379 if cc.has_argument(a)
380 no_override_init_args += a
381 endif
382endforeach
383
384# TODO: SSE41 (which is only required for core mesa)
385
386# Check for GCC style atomics
387if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
388 name : 'GCC atomic builtins')
389 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
390endif
391if not cc.links('''#include <stdint.h>
392 uint64_t v;
393 int main() {
394 return __sync_add_and_fetch(&v, (uint64_t)1);
395 }''',
396 name : 'GCC 64bit atomics')
397 pre_args += '-DMISSING_64_BIT_ATOMICS'
398endif
399
400# TODO: endian
401# TODO: powr8
402# TODO: shared/static? Is this even worth doing?
403
404# I don't think that I need to set any of the debug stuff, I think meson
405# handles that for us
406
407# TODO: ldflags
408
409# TODO: texture-float (gallium/mesa only)
410
411# TODO: cross-compiling. I don't think this is relavent to meson
412
Dylan Baker32180562017-09-20 20:11:32 -0700413# FIXME: enable asm when cross compiler
414# This is doable (autotools does it), but it's not of immediate concern
415if meson.is_cross_build()
416 message('Cross compiling, disabling asm')
417 with_asm = false
418endif
419
420with_asm_arch = ''
421if with_asm
422 # TODO: SPARC and PPC
423 if host_machine.cpu_family() == 'x86'
424 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
425 with_asm_arch = 'x86'
426 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
427 '-DUSE_SSE_ASM']
428 endif
429 elif host_machine.cpu_family() == 'x86_64'
430 if host_machine.system() == 'linux'
431 with_asm_arch = 'x86_64'
432 pre_args += ['-DUSE_X86_64_ASM']
433 endif
434 elif host_machine.cpu_family() == 'arm'
435 if host_machine.system() == 'linux'
436 with_asm_arch = 'arm'
437 pre_args += ['-DUSE_ARM_ASM']
438 endif
439 elif host_machine.cpu_family() == 'aarch64'
440 if host_machine.system() == 'linux'
441 with_asm_arch = 'aarch64'
442 pre_args += ['-DUSE_AARCH64_ASM']
443 endif
444 endif
445endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700446
447# Check for standard headers and functions
448if cc.has_header_symbol('sys/sysmacros.h', 'major')
449 pre_args += '-DMAJOR_IN_SYSMACROS'
450elif cc.has_header_symbol('sys/mkdev.h', 'major')
451 pre_args += '-DMAJOR_IN_MKDEV'
452endif
453
454foreach h : ['xlocale.h', 'sys/sysctl.h']
455 if cc.has_header(h)
456 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
457 endif
458endforeach
459
460foreach f : ['strtof', 'mkostemp', 'posix_memalign']
461 if cc.has_function(f)
462 pre_args += '-DHAVE_@0@'.format(f.to_upper())
463 endif
464endforeach
465
466# strtod locale support
467if cc.links('''
468 #define _GNU_SOURCE
469 #include <stdlib.h>
470 #include <locale.h>
471 #ifdef HAVE_XLOCALE_H
472 #include <xlocale.h>
473 #endif
474 int main() {
475 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
476 const char *s = "1.0";
477 char *end;
478 double d = strtod_l(s, end, loc);
479 float f = strtod_l(s, end, loc);
480 freelocale(loc);
481 return 0;
482 }''',
483 extra_args : pre_args,
484 name : 'strtod has locale support')
485 pre_args += '-DHAVE_STRTOD_L'
486endif
487
488# Check for some linker flags
489ld_args_bsymbolic = []
Dylan Bakere21e0a62017-09-30 13:15:52 -0700490if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
Dylan Bakerd1992252017-09-14 17:57:17 -0700491 ld_args_bsymbolic += '-Wl,-Bsymbolic'
492endif
493ld_args_gc_sections = []
494if cc.links('static char unused() { return 5; } int main() { return 0; }',
Dylan Bakere21e0a62017-09-30 13:15:52 -0700495 args : '-Wl,--gc-sections', name : 'gc-sections')
Dylan Bakerd1992252017-09-14 17:57:17 -0700496 ld_args_gc_sections += '-Wl,--gc-sections'
497endif
Dylan Bakere21e0a62017-09-30 13:15:52 -0700498with_ld_version_script = false
499if cc.links('int main() { return 0; }',
500 args : '-Wl,--version-script=@0@'.format(
501 join_paths(meson.source_root(), 'build-support/conftest.map')),
502 name : 'version-script')
503 with_ld_version_script = true
504endif
505with_ld_dynamic_list = false
506if cc.links('int main() { return 0; }',
507 args : '-Wl,--dynamic-list=@0@'.format(
508 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
509 name : 'dynamic-list')
510 with_ld_dynamic_list = true
511endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700512
513# check for dl support
514if cc.has_function('dlopen')
515 dep_dl = []
516else
517 dep_dl = cc.find_library('dl')
518endif
Dylan Baker32180562017-09-20 20:11:32 -0700519if cc.has_function('dladdr', dependencies : dep_dl)
520 # This is really only required for megadrivers
521 pre_args += '-DHAVE_DLADDR'
Dylan Bakerd1992252017-09-14 17:57:17 -0700522endif
523
524if cc.has_function('dl_iterate_phdr')
525 pre_args += '-DHAVE_DL_ITERATE_PHDR'
526else
527 # TODO: this is required for vulkan
528endif
529
530# Determine whether or not the rt library is needed for time functions
531if cc.has_function('clock_gettime')
532 dep_clock = []
533else
534 dep_clock = cc.find_library('rt')
535endif
536
Dylan Baker66c94b92017-09-30 13:48:34 -0700537with_gallium_drisw_kms = false
Dylan Baker50c28df2017-09-29 17:53:01 -0700538dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
539 required : with_dri2 or with_dri3)
540if dep_libdrm.found()
541 pre_args += '-DHAVE_LIBDRM'
Dylan Baker66c94b92017-09-30 13:48:34 -0700542 if with_dri_platform == 'drm' and with_dri
543 with_gallium_drisw_kms = true
544 endif
Dylan Baker50c28df2017-09-29 17:53:01 -0700545endif
546
Dylan Bakerd1992252017-09-14 17:57:17 -0700547# TODO: some of these may be conditional
548dep_zlib = dependency('zlib', version : '>= 1.2.3')
549dep_thread = dependency('threads')
Dylan Baker50c28df2017-09-29 17:53:01 -0700550if dep_thread.found() and host_machine.system() == 'linux'
551 pre_args += '-DHAVE_PTHREAD'
552endif
Dylan Bakercc4f5872017-09-27 11:30:21 -0700553dep_elf = dependency('libelf', required : false)
Dylan Bakerb154b442017-09-30 14:04:28 -0700554if not dep_elf.found() and (with_amd_vk or with_gallium_radeonsi) # TODO: clover, r600
555 dep_elf = cc.find_library('elf')
Dylan Bakercc4f5872017-09-27 11:30:21 -0700556endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700557dep_expat = dependency('expat')
558# this only exists on linux so either this is linux and it will be found, or
559# its not linux and and wont
560dep_m = cc.find_library('m', required : false)
Dylan Baker66f97f62017-09-30 09:03:51 -0700561
562dep_libdrm_amdgpu = []
563dep_libdrm_radeon = []
Dylan Baker813b4b02017-10-09 14:59:35 -0700564dep_libdrm_nouveau = []
Dylan Baker66f97f62017-09-30 09:03:51 -0700565if with_amd_vk or with_gallium_radeonsi
566 dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.84')
567endif
568if with_gallium_radeonsi # older radeon too
569 dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
570endif
Dylan Baker813b4b02017-10-09 14:59:35 -0700571if with_gallium_nouveau
572 dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
573endif
Dylan Baker673dda82017-09-20 11:53:29 -0700574
575llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
576if with_amd_vk
577 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
578endif
579dep_llvm = dependency(
Dylan Baker50c28df2017-09-29 17:53:01 -0700580 'llvm', version : '>= 3.9.0', required : with_amd_vk, modules : llvm_modules,
Dylan Baker673dda82017-09-20 11:53:29 -0700581)
Dylan Baker02cf3a82017-10-12 09:47:30 -0700582if with_llvm
583 if dep_llvm.found()
584 _llvm_version = dep_llvm.version().split('.')
585 # Development versions of LLVM have an 'svn' suffix, we don't want that for
586 # our version checks.
587 _llvm_patch = _llvm_version[2]
588 if _llvm_patch.endswith('svn')
589 _llvm_patch = _llvm_patch.split('s')[0]
590 endif
591 pre_args += [
592 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
593 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
594 ]
595 else
Dylan Baker6a9ad202017-10-10 14:56:39 -0700596 if with_gallium_softpipe
597 error('Cannot find LLVM to build LLVMPipe. If you wanted softpipe pass -Dllvm=false to meson')
598 elif with_amd_vk or with_gallium_radeonsi # etc
Dylan Baker66f97f62017-09-30 09:03:51 -0700599 error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM was not found.')
Dylan Baker02cf3a82017-10-12 09:47:30 -0700600 endif
Dylan Baker673dda82017-09-20 11:53:29 -0700601 endif
Dylan Baker66f97f62017-09-30 09:03:51 -0700602elif with_amd_vk or with_gallium_radeonsi
603 error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM is disabled.')
Dylan Baker673dda82017-09-20 11:53:29 -0700604endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700605
Dylan Bakera47c5252017-09-22 12:55:00 -0700606dep_glvnd = []
607if with_glvnd
608 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
609 pre_args += '-DUSE_LIBGLVND=1'
610endif
611
Dylan Bakerd1992252017-09-14 17:57:17 -0700612# TODO: make this conditional
613dep_valgrind = dependency('valgrind', required : false)
614if dep_valgrind.found() and with_valgrind
615 pre_args += '-DHAVE_VALGRIND'
616endif
617
618# pthread stubs. Lets not and say we didn't
619
Dylan Baker32180562017-09-20 20:11:32 -0700620prog_bison = find_program('bison', required : with_any_opengl)
621prog_flex = find_program('flex', required : with_any_opengl)
622
Dylan Bakerd1992252017-09-14 17:57:17 -0700623# TODO: selinux
Dylan Baker32180562017-09-20 20:11:32 -0700624dep_selinux = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700625
626# TODO: llvm-prefix and llvm-shared-libs
627
Dylan Bakerb1b65392017-09-28 22:25:02 -0700628dep_unwind = dependency('libunwind', required : false)
629if dep_unwind.found()
630 pre_args += '-DHAVE_LIBUNWIND'
631endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700632
633# TODO: flags for opengl, gles, dri
634
635# TODO: gallium-hud
636
637# TODO: glx provider
638
639# TODO: osmesa provider
640
Dylan Bakerd1992252017-09-14 17:57:17 -0700641# TODO: symbol mangling
642
Dylan Bakerd1992252017-09-14 17:57:17 -0700643# TODO: egl configuration
644
645if with_platform_wayland
646 prog_wl_scanner = find_program('wayland-scanner')
647 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
648 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
649 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
650else
651 prog_wl_scanner = []
652 dep_wl_protocols = []
653 dep_wayland_client = []
654 dep_wayland_server = []
655endif
656
Dylan Baker50c28df2017-09-29 17:53:01 -0700657dep_x11 = []
658dep_xext = []
659dep_xdamage = []
660dep_xfixes = []
661dep_x11_xcb = []
662dep_xcb_glx = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700663dep_xcb_dri2 = []
664dep_xcb_dri3 = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700665dep_dri2proto = []
666dep_glproto = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700667dep_xf86vm = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700668dep_xcb_dri3 = []
669dep_xcb_present = []
670dep_xcb_sync = []
671dep_xshmfence = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700672if with_platform_x11
Dylan Baker50c28df2017-09-29 17:53:01 -0700673 if with_glx == 'dri' and with_dri_platform == 'drm'
674 dep_x11 = dependency('x11')
675 dep_xext = dependency('xext')
676 dep_xdamage = dependency('xdamage', version : '>= 1.1')
677 dep_xfixes = dependency('xfixes')
678 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
679 dep_xf86vm = dependency('xf86vm', required : false)
Dylan Bakera47c5252017-09-22 12:55:00 -0700680 endif
681 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
Dylan Baker50c28df2017-09-29 17:53:01 -0700682 dep_xcb = dependency('xcb')
683 dep_x11_xcb = dependency('x11-xcb')
684 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
685
Dylan Bakera47c5252017-09-22 12:55:00 -0700686 if with_dri3
687 pre_args += '-DHAVE_DRI3'
Dylan Baker50c28df2017-09-29 17:53:01 -0700688 dep_xcb_dri3 = dependency('xcb-dri3')
689 dep_xcb_present = dependency('xcb-present')
690 dep_xcb_sync = dependency('xcb-sync')
691 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
Dylan Bakera47c5252017-09-22 12:55:00 -0700692 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700693 endif
Dylan Baker50c28df2017-09-29 17:53:01 -0700694 if with_glx != 'disabled'
695 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
696 dep_glproto = dependency('glproto', version : '>= 1.4.14')
697 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700698endif
699
700# TODO: platforms for !vulkan
701
Dylan Bakerd1992252017-09-14 17:57:17 -0700702# TODO: osmesa
703
704# TODO: egl
705
Dylan Bakerd1992252017-09-14 17:57:17 -0700706# TODO: vallium G3DVL
707
708# TODO: nine
709
710# TODO: clover
711
712# TODO: egl sans x11
Dylan Bakerd1992252017-09-14 17:57:17 -0700713# TODO: gallium tests
714
715# TODO: various libdirs
716
717# TODO: swr
718
719# TODO: gallium driver dirs
720
721# FIXME: this is a workaround for #2326
722prog_touch = find_program('touch')
723dummy_cpp = custom_target(
724 'dummy_cpp',
725 output : 'dummy.cpp',
726 command : [prog_touch, '@OUTPUT@'],
727)
728
729foreach a : pre_args
730 add_project_arguments(a, language : ['c', 'cpp'])
731endforeach
732foreach a : c_args
733 add_project_arguments(a, language : ['c'])
734endforeach
735foreach a : cpp_args
736 add_project_arguments(a, language : ['cpp'])
737endforeach
738
739inc_include = include_directories('include')
740
Dylan Baker32180562017-09-20 20:11:32 -0700741pkg = import('pkgconfig')
742
Dylan Bakerd1992252017-09-14 17:57:17 -0700743subdir('include')
744subdir('src')