blob: e96dc864986348a8971afcd666ec93e3149257c1 [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
Dylan Baker813b4b02017-10-09 14:59:35 -070095with_gallium_nouveau = false
Dylan Bakerf3d03a22017-10-10 11:57:50 -070096with_gallium_softpipe = false
Dylan Bakeraf9d2762017-09-28 21:03:07 -070097_drivers = get_option('gallium-drivers')
98if _drivers != ''
99 _split = _drivers.split(',')
100 with_gallium_radeonsi = _split.contains('radeonsi')
Dylan Baker813b4b02017-10-09 14:59:35 -0700101 with_gallium_nouveau = _split.contains('nouveau')
Dylan Bakerde24d612017-10-10 14:27:19 -0700102 with_gallium_softpipe = _split.contains('swrast')
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700103 with_gallium = true
104 with_dri = true
Ville Syrjälä22899642017-10-10 01:15:42 +0300105endif
106
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700107if not (with_dri or with_gallium)
Dylan Baker32180562017-09-20 20:11:32 -0700108 with_gles1 = false
109 with_gles2 = false
110 with_opengl = false
111 with_any_opengl = false
112 with_shared_glapi = false
113endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700114
Dylan Bakerde24d612017-10-10 14:27:19 -0700115if with_dri_swrast and with_gallium_softpipe
116 error('Only one swrast provider can be built')
117endif
118
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700119dep_libdrm_intel = []
120if with_dri_i915
121 dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
122endif
123
Dylan Bakera47c5252017-09-22 12:55:00 -0700124# TODO: other OSes
125with_dri_platform = 'drm'
126
Dylan Bakerd1992252017-09-14 17:57:17 -0700127# TODO: there are more platforms required for non-vulkan drivers
128with_platform_wayland = false
129with_platform_x11 = false
Dylan Bakerb1b65392017-09-28 22:25:02 -0700130with_platform_drm = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700131_platforms = get_option('platforms')
132if _platforms != ''
133 _split = _platforms.split(',')
134 with_platform_x11 = _split.contains('x11')
135 with_platform_wayland = _split.contains('wayland')
Dylan Bakerb1b65392017-09-28 22:25:02 -0700136 with_platform_drm = _split.contains('drm')
Dylan Bakerd1992252017-09-14 17:57:17 -0700137endif
138
Dylan Baker816bf7d12017-09-28 15:53:53 -0700139with_gbm = get_option('gbm')
140if with_gbm == 'auto' and with_dri # TODO: or gallium
141 with_gbm = host_machine.system() == 'linux'
142elif with_gbm == 'yes'
143 if not ['linux', 'bsd'].contains(host_machine.system())
144 error('GBM only supports unix-like platforms')
145 endif
146 with_gbm = true
147else
148 with_gbm = false
149endif
150
Dylan Baker8e611872017-10-11 12:49:31 -0700151pre_args += '-DGLX_USE_TLS'
Dylan Bakera47c5252017-09-22 12:55:00 -0700152with_glx = get_option('glx')
153if with_glx != 'disabled'
Dylan Bakera47c5252017-09-22 12:55:00 -0700154 if not (with_platform_x11 and with_any_opengl) and with_glx != 'auto'
155 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
156 elif with_glx == 'gallium-xlib'
157 if not with_gallium
158 error('Gallium-xlib based GLX requires at least one gallium driver')
159 elif with_dri
160 error('gallium-xlib conflicts with any dri driver')
161 endif
162 elif with_glx == 'dri' and not with_dri
163 error('dri based GLX requires at least one DRI driver')
164 elif with_glx == 'auto'
165 if with_dri
166 with_glx = 'dri'
167 elif with_gallium
168 with_glx = 'gallium-xlib'
169 elif with_platform_x11 and with_any_opengl
170 with_glx = 'xlib'
171 else
172 with_glx = 'disabled'
173 endif
174 endif
175endif
176
177with_glvnd = get_option('glvnd')
178if with_glvnd and with_glx != 'dri'
179 message('glvnd requires dri based glx')
180endif
181
182# TODO: toggle for this
183with_glx_direct = true
184
Dylan Bakerd1992252017-09-14 17:57:17 -0700185if with_vulkan_icd_dir == ''
186 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
187endif
188
189with_intel_vk = false
190with_amd_vk = false
Dylan Bakera47c5252017-09-22 12:55:00 -0700191with_any_vk = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700192_vulkan_drivers = get_option('vulkan-drivers')
193if _vulkan_drivers != ''
194 _split = _vulkan_drivers.split(',')
195 with_intel_vk = _split.contains('intel')
196 with_amd_vk = _split.contains('amd')
Dylan Bakera47c5252017-09-22 12:55:00 -0700197 with_any_vk = with_amd_vk or with_intel_vk
Dylan Bakerd1992252017-09-14 17:57:17 -0700198 if not (with_platform_x11 or with_platform_wayland)
199 error('Vulkan requires at least one platform (x11, wayland)')
200 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700201endif
202
Dylan Baker50c28df2017-09-29 17:53:01 -0700203with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
204with_dri3 = get_option('dri3')
205if with_dri3 == 'auto'
206 if host_machine.system() == 'linux' and with_dri2
207 with_dri3 = true
208 else
209 with_dri3 = false
210 endif
211elif with_dri3 == 'yes'
212 with_dri3 = true
213else
214 with_dri3 = false
215endif
216
217if with_any_vk and (with_platform_x11 and not with_dri3)
218 error('Vulkan drivers require dri3 for X11 support')
219endif
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700220if with_dri or with_gallium
Dylan Bakera47c5252017-09-22 12:55:00 -0700221 if with_glx == 'disabled' # TODO: or egl
222 error('building dri or gallium drivers require at least one window system')
223 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700224endif
225
Dylan Baker50c28df2017-09-29 17:53:01 -0700226with_gallium_xvmc = false
227with_gallium_vdpau = false
228with_gallium_omx = false # this is bellagio
229with_gallium_va = false
230with_gallium_media = false
231dep_va = []
232_drivers = get_option('gallium-media')
233if _drivers != ''
234 _split = _drivers.split(',')
235 with_gallium_xvmc = _split.contains('xvmc')
236 with_gallium_vdpau = _split.contains('vdpau')
237 with_gallium_omx = _split.contains('omx')
238 with_gallium_va = _split.contains('va')
239 with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or
240 with_gallium_omx or with_gallium_va)
241endif
242
243if with_platform_x11
244 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
245 pre_args += '-DHAVE_X11_PLATFORM'
246 endif
247 if with_glx == 'xlib'
248 # TODO
249 error('TODO')
250 elif with_glx == 'gallium-xlib'
251 # TODO
252 error('TODO')
253 else
254 pre_args += '-DGLX_INDIRECT_RENDERING'
255 if with_glx_direct
256 pre_args += '-DGLX_DIRECT_RENDERING'
257 endif
258 if with_dri_platform == 'drm'
259 pre_args += '-DGLX_USE_DRM'
260 endif
261 endif
262endif
263
Dylan Bakerd1992252017-09-14 17:57:17 -0700264prog_python2 = find_program('python2')
Dylan Baker9342a7d2017-09-28 10:48:30 -0700265has_mako = run_command(prog_python2, '-c', 'import mako')
266if has_mako.returncode() != 0
267 error('Python (2.x) mako module required to build mesa.')
268endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700269
270cc = meson.get_compiler('c')
271if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
Eric Engestrom1262e822017-09-29 15:25:18 +0100272 error('When using GCC, version 4.4.6 or later is required.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700273endif
274
Dylan Bakerd1992252017-09-14 17:57:17 -0700275# Define DEBUG for debug and debugoptimized builds
276if get_option('buildtype').startswith('debug')
277 pre_args += '-DDEBUG'
278endif
279
Dylan Baker673dda82017-09-20 11:53:29 -0700280if get_option('shader-cache')
281 pre_args += '-DENABLE_SHADER_CACHE'
282elif with_amd_vk
283 error('Radv requires shader cache support')
284endif
285
Dylan Bakerd1992252017-09-14 17:57:17 -0700286# Check for GCC style builtins
287foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
288 'ffsll', 'popcount', 'popcountll', 'unreachable']
289 if cc.has_function(b)
290 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
291 endif
292endforeach
293
Dylan Baker673dda82017-09-20 11:53:29 -0700294# check for GCC __attribute__
Dylan Bakerd1992252017-09-14 17:57:17 -0700295foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
296 'warn_unused_result', 'weak',]
297 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
298 name : '__attribute__((@0@))'.format(a))
299 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
300 endif
301endforeach
302if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
303 name : '__attribute__((format(...)))')
304 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
305endif
306if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
307 name : '__attribute__((packed))')
308 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
309endif
310if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
311 name : '__attribute__((returns_nonnull))')
312 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
313endif
314if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
315 int foo_hid(void) __attribute__((visibility("hidden")));
316 int foo_int(void) __attribute__((visibility("internal")));
317 int foo_pro(void) __attribute__((visibility("protected")));''',
318 name : '__attribute__((visibility(...)))')
319 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
320endif
321if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
322 name : '__attribute__((alias(...)))')
323 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
324endif
325
326# TODO: this is very incomplete
327if host_machine.system() == 'linux'
328 pre_args += '-D_GNU_SOURCE'
329endif
330
331# Check for generic C arguments
332c_args = []
333foreach a : ['-Wall', '-Werror=implicit-function-declaration',
334 '-Werror=missing-prototypes', '-fno-math-errno',
335 '-fno-trapping-math', '-Qunused-arguments']
336 if cc.has_argument(a)
337 c_args += a
338 endif
339endforeach
340c_vis_args = []
341if cc.has_argument('-fvisibility=hidden')
342 c_vis_args += '-fvisibility=hidden'
343endif
344
345# Check for generic C++ arguments
346cpp = meson.get_compiler('cpp')
347cpp_args = []
348foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
349 '-Qunused-arguments', '-Wno-non-virtual-dtor']
350 if cpp.has_argument(a)
351 cpp_args += a
352 endif
353endforeach
354cpp_vis_args = []
355if cpp.has_argument('-fvisibility=hidden')
356 cpp_vis_args += '-fvisibility=hidden'
357endif
358
359# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
360# in parts of the mesa code base that need to compile with old versions of
361# MSVC, mainly common code
362c_msvc_compat_args = []
363cpp_msvc_compat_args = []
364foreach a : ['-Werror=pointer-arith', '-Werror=vla']
365 if cc.has_argument(a)
366 c_msvc_compat_args += a
367 endif
368 if cpp.has_argument(a)
369 cpp_msvc_compat_args += a
370 endif
371endforeach
372
373no_override_init_args = []
374foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
375 if cc.has_argument(a)
376 no_override_init_args += a
377 endif
378endforeach
379
380# TODO: SSE41 (which is only required for core mesa)
381
382# Check for GCC style atomics
383if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
384 name : 'GCC atomic builtins')
385 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
386endif
387if not cc.links('''#include <stdint.h>
388 uint64_t v;
389 int main() {
390 return __sync_add_and_fetch(&v, (uint64_t)1);
391 }''',
392 name : 'GCC 64bit atomics')
393 pre_args += '-DMISSING_64_BIT_ATOMICS'
394endif
395
396# TODO: endian
397# TODO: powr8
398# TODO: shared/static? Is this even worth doing?
399
400# I don't think that I need to set any of the debug stuff, I think meson
401# handles that for us
402
403# TODO: ldflags
404
405# TODO: texture-float (gallium/mesa only)
406
407# TODO: cross-compiling. I don't think this is relavent to meson
408
Dylan Baker32180562017-09-20 20:11:32 -0700409# FIXME: enable asm when cross compiler
410# This is doable (autotools does it), but it's not of immediate concern
411if meson.is_cross_build()
412 message('Cross compiling, disabling asm')
413 with_asm = false
414endif
415
416with_asm_arch = ''
417if with_asm
418 # TODO: SPARC and PPC
419 if host_machine.cpu_family() == 'x86'
420 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
421 with_asm_arch = 'x86'
422 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
423 '-DUSE_SSE_ASM']
424 endif
425 elif host_machine.cpu_family() == 'x86_64'
426 if host_machine.system() == 'linux'
427 with_asm_arch = 'x86_64'
428 pre_args += ['-DUSE_X86_64_ASM']
429 endif
430 elif host_machine.cpu_family() == 'arm'
431 if host_machine.system() == 'linux'
432 with_asm_arch = 'arm'
433 pre_args += ['-DUSE_ARM_ASM']
434 endif
435 elif host_machine.cpu_family() == 'aarch64'
436 if host_machine.system() == 'linux'
437 with_asm_arch = 'aarch64'
438 pre_args += ['-DUSE_AARCH64_ASM']
439 endif
440 endif
441endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700442
443# Check for standard headers and functions
444if cc.has_header_symbol('sys/sysmacros.h', 'major')
445 pre_args += '-DMAJOR_IN_SYSMACROS'
446elif cc.has_header_symbol('sys/mkdev.h', 'major')
447 pre_args += '-DMAJOR_IN_MKDEV'
448endif
449
450foreach h : ['xlocale.h', 'sys/sysctl.h']
451 if cc.has_header(h)
452 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
453 endif
454endforeach
455
456foreach f : ['strtof', 'mkostemp', 'posix_memalign']
457 if cc.has_function(f)
458 pre_args += '-DHAVE_@0@'.format(f.to_upper())
459 endif
460endforeach
461
462# strtod locale support
463if cc.links('''
464 #define _GNU_SOURCE
465 #include <stdlib.h>
466 #include <locale.h>
467 #ifdef HAVE_XLOCALE_H
468 #include <xlocale.h>
469 #endif
470 int main() {
471 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
472 const char *s = "1.0";
473 char *end;
474 double d = strtod_l(s, end, loc);
475 float f = strtod_l(s, end, loc);
476 freelocale(loc);
477 return 0;
478 }''',
479 extra_args : pre_args,
480 name : 'strtod has locale support')
481 pre_args += '-DHAVE_STRTOD_L'
482endif
483
484# Check for some linker flags
485ld_args_bsymbolic = []
Dylan Bakere21e0a62017-09-30 13:15:52 -0700486if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
Dylan Bakerd1992252017-09-14 17:57:17 -0700487 ld_args_bsymbolic += '-Wl,-Bsymbolic'
488endif
489ld_args_gc_sections = []
490if cc.links('static char unused() { return 5; } int main() { return 0; }',
Dylan Bakere21e0a62017-09-30 13:15:52 -0700491 args : '-Wl,--gc-sections', name : 'gc-sections')
Dylan Bakerd1992252017-09-14 17:57:17 -0700492 ld_args_gc_sections += '-Wl,--gc-sections'
493endif
Dylan Bakere21e0a62017-09-30 13:15:52 -0700494with_ld_version_script = false
495if cc.links('int main() { return 0; }',
496 args : '-Wl,--version-script=@0@'.format(
497 join_paths(meson.source_root(), 'build-support/conftest.map')),
498 name : 'version-script')
499 with_ld_version_script = true
500endif
501with_ld_dynamic_list = false
502if cc.links('int main() { return 0; }',
503 args : '-Wl,--dynamic-list=@0@'.format(
504 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
505 name : 'dynamic-list')
506 with_ld_dynamic_list = true
507endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700508
509# check for dl support
510if cc.has_function('dlopen')
511 dep_dl = []
512else
513 dep_dl = cc.find_library('dl')
514endif
Dylan Baker32180562017-09-20 20:11:32 -0700515if cc.has_function('dladdr', dependencies : dep_dl)
516 # This is really only required for megadrivers
517 pre_args += '-DHAVE_DLADDR'
Dylan Bakerd1992252017-09-14 17:57:17 -0700518endif
519
520if cc.has_function('dl_iterate_phdr')
521 pre_args += '-DHAVE_DL_ITERATE_PHDR'
522else
523 # TODO: this is required for vulkan
524endif
525
526# Determine whether or not the rt library is needed for time functions
527if cc.has_function('clock_gettime')
528 dep_clock = []
529else
530 dep_clock = cc.find_library('rt')
531endif
532
Dylan Baker66c94b92017-09-30 13:48:34 -0700533with_gallium_drisw_kms = false
Dylan Baker50c28df2017-09-29 17:53:01 -0700534dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
535 required : with_dri2 or with_dri3)
536if dep_libdrm.found()
537 pre_args += '-DHAVE_LIBDRM'
Dylan Baker66c94b92017-09-30 13:48:34 -0700538 if with_dri_platform == 'drm' and with_dri
539 with_gallium_drisw_kms = true
540 endif
Dylan Baker50c28df2017-09-29 17:53:01 -0700541endif
542
Dylan Bakerd1992252017-09-14 17:57:17 -0700543# TODO: some of these may be conditional
544dep_zlib = dependency('zlib', version : '>= 1.2.3')
545dep_thread = dependency('threads')
Dylan Baker50c28df2017-09-29 17:53:01 -0700546if dep_thread.found() and host_machine.system() == 'linux'
547 pre_args += '-DHAVE_PTHREAD'
548endif
Dylan Bakercc4f5872017-09-27 11:30:21 -0700549dep_elf = dependency('libelf', required : false)
Dylan Bakerb154b442017-09-30 14:04:28 -0700550if not dep_elf.found() and (with_amd_vk or with_gallium_radeonsi) # TODO: clover, r600
551 dep_elf = cc.find_library('elf')
Dylan Bakercc4f5872017-09-27 11:30:21 -0700552endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700553dep_expat = dependency('expat')
554# this only exists on linux so either this is linux and it will be found, or
555# its not linux and and wont
556dep_m = cc.find_library('m', required : false)
Dylan Baker66f97f62017-09-30 09:03:51 -0700557
558dep_libdrm_amdgpu = []
559dep_libdrm_radeon = []
Dylan Baker813b4b02017-10-09 14:59:35 -0700560dep_libdrm_nouveau = []
Dylan Baker66f97f62017-09-30 09:03:51 -0700561if with_amd_vk or with_gallium_radeonsi
562 dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.84')
563endif
564if with_gallium_radeonsi # older radeon too
565 dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
566endif
Dylan Baker813b4b02017-10-09 14:59:35 -0700567if with_gallium_nouveau
568 dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
569endif
Dylan Baker673dda82017-09-20 11:53:29 -0700570
571llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
572if with_amd_vk
573 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
574endif
575dep_llvm = dependency(
Dylan Baker50c28df2017-09-29 17:53:01 -0700576 'llvm', version : '>= 3.9.0', required : with_amd_vk, modules : llvm_modules,
Dylan Baker673dda82017-09-20 11:53:29 -0700577)
Dylan Baker02cf3a82017-10-12 09:47:30 -0700578if with_llvm
579 if dep_llvm.found()
580 _llvm_version = dep_llvm.version().split('.')
581 # Development versions of LLVM have an 'svn' suffix, we don't want that for
582 # our version checks.
583 _llvm_patch = _llvm_version[2]
584 if _llvm_patch.endswith('svn')
585 _llvm_patch = _llvm_patch.split('s')[0]
586 endif
587 pre_args += [
588 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
589 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
590 ]
591 else
Dylan Baker66f97f62017-09-30 09:03:51 -0700592 if with_amd_vk or with_gallium_radeonsi
593 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 -0700594 endif
Dylan Baker673dda82017-09-20 11:53:29 -0700595 endif
Dylan Baker66f97f62017-09-30 09:03:51 -0700596elif with_amd_vk or with_gallium_radeonsi
597 error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM is disabled.')
Dylan Baker673dda82017-09-20 11:53:29 -0700598endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700599
Dylan Bakera47c5252017-09-22 12:55:00 -0700600dep_glvnd = []
601if with_glvnd
602 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
603 pre_args += '-DUSE_LIBGLVND=1'
604endif
605
Dylan Bakerd1992252017-09-14 17:57:17 -0700606# TODO: make this conditional
607dep_valgrind = dependency('valgrind', required : false)
608if dep_valgrind.found() and with_valgrind
609 pre_args += '-DHAVE_VALGRIND'
610endif
611
612# pthread stubs. Lets not and say we didn't
613
Dylan Baker32180562017-09-20 20:11:32 -0700614prog_bison = find_program('bison', required : with_any_opengl)
615prog_flex = find_program('flex', required : with_any_opengl)
616
Dylan Bakerd1992252017-09-14 17:57:17 -0700617# TODO: selinux
Dylan Baker32180562017-09-20 20:11:32 -0700618dep_selinux = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700619
620# TODO: llvm-prefix and llvm-shared-libs
621
Dylan Bakerb1b65392017-09-28 22:25:02 -0700622dep_unwind = dependency('libunwind', required : false)
623if dep_unwind.found()
624 pre_args += '-DHAVE_LIBUNWIND'
625endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700626
627# TODO: flags for opengl, gles, dri
628
629# TODO: gallium-hud
630
631# TODO: glx provider
632
633# TODO: osmesa provider
634
Dylan Bakerd1992252017-09-14 17:57:17 -0700635# TODO: symbol mangling
636
Dylan Bakerd1992252017-09-14 17:57:17 -0700637# TODO: egl configuration
638
639if with_platform_wayland
640 prog_wl_scanner = find_program('wayland-scanner')
641 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
642 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
643 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
644else
645 prog_wl_scanner = []
646 dep_wl_protocols = []
647 dep_wayland_client = []
648 dep_wayland_server = []
649endif
650
Dylan Baker50c28df2017-09-29 17:53:01 -0700651dep_x11 = []
652dep_xext = []
653dep_xdamage = []
654dep_xfixes = []
655dep_x11_xcb = []
656dep_xcb_glx = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700657dep_xcb_dri2 = []
658dep_xcb_dri3 = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700659dep_dri2proto = []
660dep_glproto = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700661dep_xf86vm = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700662dep_xcb_dri3 = []
663dep_xcb_present = []
664dep_xcb_sync = []
665dep_xshmfence = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700666if with_platform_x11
Dylan Baker50c28df2017-09-29 17:53:01 -0700667 if with_glx == 'dri' and with_dri_platform == 'drm'
668 dep_x11 = dependency('x11')
669 dep_xext = dependency('xext')
670 dep_xdamage = dependency('xdamage', version : '>= 1.1')
671 dep_xfixes = dependency('xfixes')
672 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
673 dep_xf86vm = dependency('xf86vm', required : false)
Dylan Bakera47c5252017-09-22 12:55:00 -0700674 endif
675 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
Dylan Baker50c28df2017-09-29 17:53:01 -0700676 dep_xcb = dependency('xcb')
677 dep_x11_xcb = dependency('x11-xcb')
678 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
679
Dylan Bakera47c5252017-09-22 12:55:00 -0700680 if with_dri3
681 pre_args += '-DHAVE_DRI3'
Dylan Baker50c28df2017-09-29 17:53:01 -0700682 dep_xcb_dri3 = dependency('xcb-dri3')
683 dep_xcb_present = dependency('xcb-present')
684 dep_xcb_sync = dependency('xcb-sync')
685 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
Dylan Bakera47c5252017-09-22 12:55:00 -0700686 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700687 endif
Dylan Baker50c28df2017-09-29 17:53:01 -0700688 if with_glx != 'disabled'
689 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
690 dep_glproto = dependency('glproto', version : '>= 1.4.14')
691 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700692endif
693
694# TODO: platforms for !vulkan
695
Dylan Bakerd1992252017-09-14 17:57:17 -0700696# TODO: osmesa
697
698# TODO: egl
699
Dylan Bakerd1992252017-09-14 17:57:17 -0700700# TODO: vallium G3DVL
701
702# TODO: nine
703
704# TODO: clover
705
706# TODO: egl sans x11
Dylan Bakerd1992252017-09-14 17:57:17 -0700707# TODO: gallium tests
708
709# TODO: various libdirs
710
711# TODO: swr
712
713# TODO: gallium driver dirs
714
715# FIXME: this is a workaround for #2326
716prog_touch = find_program('touch')
717dummy_cpp = custom_target(
718 'dummy_cpp',
719 output : 'dummy.cpp',
720 command : [prog_touch, '@OUTPUT@'],
721)
722
723foreach a : pre_args
724 add_project_arguments(a, language : ['c', 'cpp'])
725endforeach
726foreach a : c_args
727 add_project_arguments(a, language : ['c'])
728endforeach
729foreach a : cpp_args
730 add_project_arguments(a, language : ['cpp'])
731endforeach
732
733inc_include = include_directories('include')
734
Dylan Baker32180562017-09-20 20:11:32 -0700735pkg = import('pkgconfig')
736
Dylan Bakerd1992252017-09-14 17:57:17 -0700737subdir('include')
738subdir('src')