blob: ebaf2d957fd925b024badffdd0ff51e9d9795d7a [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 Bakerf3d03a22017-10-10 11:57:50 -070095with_gallium_softpipe = false
Dylan Bakeraf9d2762017-09-28 21:03:07 -070096_drivers = get_option('gallium-drivers')
97if _drivers != ''
98 _split = _drivers.split(',')
99 with_gallium_radeonsi = _split.contains('radeonsi')
100 with_gallium = true
101 with_dri = true
Ville Syrjälä22899642017-10-10 01:15:42 +0300102endif
103
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700104if not (with_dri or with_gallium)
Dylan Baker32180562017-09-20 20:11:32 -0700105 with_gles1 = false
106 with_gles2 = false
107 with_opengl = false
108 with_any_opengl = false
109 with_shared_glapi = false
110endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700111
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700112dep_libdrm_intel = []
113if with_dri_i915
114 dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
115endif
116
Dylan Bakera47c5252017-09-22 12:55:00 -0700117# TODO: other OSes
118with_dri_platform = 'drm'
119
Dylan Bakerd1992252017-09-14 17:57:17 -0700120# TODO: there are more platforms required for non-vulkan drivers
121with_platform_wayland = false
122with_platform_x11 = false
Dylan Bakerb1b65392017-09-28 22:25:02 -0700123with_platform_drm = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700124_platforms = get_option('platforms')
125if _platforms != ''
126 _split = _platforms.split(',')
127 with_platform_x11 = _split.contains('x11')
128 with_platform_wayland = _split.contains('wayland')
Dylan Bakerb1b65392017-09-28 22:25:02 -0700129 with_platform_drm = _split.contains('drm')
Dylan Bakerd1992252017-09-14 17:57:17 -0700130endif
131
Dylan Baker816bf7d12017-09-28 15:53:53 -0700132with_gbm = get_option('gbm')
133if with_gbm == 'auto' and with_dri # TODO: or gallium
134 with_gbm = host_machine.system() == 'linux'
135elif with_gbm == 'yes'
136 if not ['linux', 'bsd'].contains(host_machine.system())
137 error('GBM only supports unix-like platforms')
138 endif
139 with_gbm = true
140else
141 with_gbm = false
142endif
143
Dylan Baker8e611872017-10-11 12:49:31 -0700144pre_args += '-DGLX_USE_TLS'
Dylan Bakera47c5252017-09-22 12:55:00 -0700145with_glx = get_option('glx')
146if with_glx != 'disabled'
Dylan Bakera47c5252017-09-22 12:55:00 -0700147 if not (with_platform_x11 and with_any_opengl) and with_glx != 'auto'
148 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
149 elif with_glx == 'gallium-xlib'
150 if not with_gallium
151 error('Gallium-xlib based GLX requires at least one gallium driver')
152 elif with_dri
153 error('gallium-xlib conflicts with any dri driver')
154 endif
155 elif with_glx == 'dri' and not with_dri
156 error('dri based GLX requires at least one DRI driver')
157 elif with_glx == 'auto'
158 if with_dri
159 with_glx = 'dri'
160 elif with_gallium
161 with_glx = 'gallium-xlib'
162 elif with_platform_x11 and with_any_opengl
163 with_glx = 'xlib'
164 else
165 with_glx = 'disabled'
166 endif
167 endif
168endif
169
170with_glvnd = get_option('glvnd')
171if with_glvnd and with_glx != 'dri'
172 message('glvnd requires dri based glx')
173endif
174
175# TODO: toggle for this
176with_glx_direct = true
177
Dylan Bakerd1992252017-09-14 17:57:17 -0700178if with_vulkan_icd_dir == ''
179 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
180endif
181
182with_intel_vk = false
183with_amd_vk = false
Dylan Bakera47c5252017-09-22 12:55:00 -0700184with_any_vk = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700185_vulkan_drivers = get_option('vulkan-drivers')
186if _vulkan_drivers != ''
187 _split = _vulkan_drivers.split(',')
188 with_intel_vk = _split.contains('intel')
189 with_amd_vk = _split.contains('amd')
Dylan Bakera47c5252017-09-22 12:55:00 -0700190 with_any_vk = with_amd_vk or with_intel_vk
Dylan Bakerd1992252017-09-14 17:57:17 -0700191 if not (with_platform_x11 or with_platform_wayland)
192 error('Vulkan requires at least one platform (x11, wayland)')
193 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700194endif
195
Dylan Baker50c28df2017-09-29 17:53:01 -0700196with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
197with_dri3 = get_option('dri3')
198if with_dri3 == 'auto'
199 if host_machine.system() == 'linux' and with_dri2
200 with_dri3 = true
201 else
202 with_dri3 = false
203 endif
204elif with_dri3 == 'yes'
205 with_dri3 = true
206else
207 with_dri3 = false
208endif
209
210if with_any_vk and (with_platform_x11 and not with_dri3)
211 error('Vulkan drivers require dri3 for X11 support')
212endif
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700213if with_dri or with_gallium
Dylan Bakera47c5252017-09-22 12:55:00 -0700214 if with_glx == 'disabled' # TODO: or egl
215 error('building dri or gallium drivers require at least one window system')
216 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700217endif
218
Dylan Baker50c28df2017-09-29 17:53:01 -0700219with_gallium_xvmc = false
220with_gallium_vdpau = false
221with_gallium_omx = false # this is bellagio
222with_gallium_va = false
223with_gallium_media = false
224dep_va = []
225_drivers = get_option('gallium-media')
226if _drivers != ''
227 _split = _drivers.split(',')
228 with_gallium_xvmc = _split.contains('xvmc')
229 with_gallium_vdpau = _split.contains('vdpau')
230 with_gallium_omx = _split.contains('omx')
231 with_gallium_va = _split.contains('va')
232 with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or
233 with_gallium_omx or with_gallium_va)
234endif
235
236if with_platform_x11
237 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
238 pre_args += '-DHAVE_X11_PLATFORM'
239 endif
240 if with_glx == 'xlib'
241 # TODO
242 error('TODO')
243 elif with_glx == 'gallium-xlib'
244 # TODO
245 error('TODO')
246 else
247 pre_args += '-DGLX_INDIRECT_RENDERING'
248 if with_glx_direct
249 pre_args += '-DGLX_DIRECT_RENDERING'
250 endif
251 if with_dri_platform == 'drm'
252 pre_args += '-DGLX_USE_DRM'
253 endif
254 endif
255endif
256
Dylan Bakerd1992252017-09-14 17:57:17 -0700257prog_python2 = find_program('python2')
Dylan Baker9342a7d2017-09-28 10:48:30 -0700258has_mako = run_command(prog_python2, '-c', 'import mako')
259if has_mako.returncode() != 0
260 error('Python (2.x) mako module required to build mesa.')
261endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700262
263cc = meson.get_compiler('c')
264if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
Eric Engestrom1262e822017-09-29 15:25:18 +0100265 error('When using GCC, version 4.4.6 or later is required.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700266endif
267
Dylan Bakerd1992252017-09-14 17:57:17 -0700268# Define DEBUG for debug and debugoptimized builds
269if get_option('buildtype').startswith('debug')
270 pre_args += '-DDEBUG'
271endif
272
Dylan Baker673dda82017-09-20 11:53:29 -0700273if get_option('shader-cache')
274 pre_args += '-DENABLE_SHADER_CACHE'
275elif with_amd_vk
276 error('Radv requires shader cache support')
277endif
278
Dylan Bakerd1992252017-09-14 17:57:17 -0700279# Check for GCC style builtins
280foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
281 'ffsll', 'popcount', 'popcountll', 'unreachable']
282 if cc.has_function(b)
283 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
284 endif
285endforeach
286
Dylan Baker673dda82017-09-20 11:53:29 -0700287# check for GCC __attribute__
Dylan Bakerd1992252017-09-14 17:57:17 -0700288foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
289 'warn_unused_result', 'weak',]
290 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
291 name : '__attribute__((@0@))'.format(a))
292 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
293 endif
294endforeach
295if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
296 name : '__attribute__((format(...)))')
297 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
298endif
299if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
300 name : '__attribute__((packed))')
301 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
302endif
303if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
304 name : '__attribute__((returns_nonnull))')
305 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
306endif
307if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
308 int foo_hid(void) __attribute__((visibility("hidden")));
309 int foo_int(void) __attribute__((visibility("internal")));
310 int foo_pro(void) __attribute__((visibility("protected")));''',
311 name : '__attribute__((visibility(...)))')
312 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
313endif
314if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
315 name : '__attribute__((alias(...)))')
316 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
317endif
318
319# TODO: this is very incomplete
320if host_machine.system() == 'linux'
321 pre_args += '-D_GNU_SOURCE'
322endif
323
324# Check for generic C arguments
325c_args = []
326foreach a : ['-Wall', '-Werror=implicit-function-declaration',
327 '-Werror=missing-prototypes', '-fno-math-errno',
328 '-fno-trapping-math', '-Qunused-arguments']
329 if cc.has_argument(a)
330 c_args += a
331 endif
332endforeach
333c_vis_args = []
334if cc.has_argument('-fvisibility=hidden')
335 c_vis_args += '-fvisibility=hidden'
336endif
337
338# Check for generic C++ arguments
339cpp = meson.get_compiler('cpp')
340cpp_args = []
341foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
342 '-Qunused-arguments', '-Wno-non-virtual-dtor']
343 if cpp.has_argument(a)
344 cpp_args += a
345 endif
346endforeach
347cpp_vis_args = []
348if cpp.has_argument('-fvisibility=hidden')
349 cpp_vis_args += '-fvisibility=hidden'
350endif
351
352# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
353# in parts of the mesa code base that need to compile with old versions of
354# MSVC, mainly common code
355c_msvc_compat_args = []
356cpp_msvc_compat_args = []
357foreach a : ['-Werror=pointer-arith', '-Werror=vla']
358 if cc.has_argument(a)
359 c_msvc_compat_args += a
360 endif
361 if cpp.has_argument(a)
362 cpp_msvc_compat_args += a
363 endif
364endforeach
365
366no_override_init_args = []
367foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
368 if cc.has_argument(a)
369 no_override_init_args += a
370 endif
371endforeach
372
373# TODO: SSE41 (which is only required for core mesa)
374
375# Check for GCC style atomics
376if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
377 name : 'GCC atomic builtins')
378 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
379endif
380if not cc.links('''#include <stdint.h>
381 uint64_t v;
382 int main() {
383 return __sync_add_and_fetch(&v, (uint64_t)1);
384 }''',
385 name : 'GCC 64bit atomics')
386 pre_args += '-DMISSING_64_BIT_ATOMICS'
387endif
388
389# TODO: endian
390# TODO: powr8
391# TODO: shared/static? Is this even worth doing?
392
393# I don't think that I need to set any of the debug stuff, I think meson
394# handles that for us
395
396# TODO: ldflags
397
398# TODO: texture-float (gallium/mesa only)
399
400# TODO: cross-compiling. I don't think this is relavent to meson
401
Dylan Baker32180562017-09-20 20:11:32 -0700402# FIXME: enable asm when cross compiler
403# This is doable (autotools does it), but it's not of immediate concern
404if meson.is_cross_build()
405 message('Cross compiling, disabling asm')
406 with_asm = false
407endif
408
409with_asm_arch = ''
410if with_asm
411 # TODO: SPARC and PPC
412 if host_machine.cpu_family() == 'x86'
413 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
414 with_asm_arch = 'x86'
415 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
416 '-DUSE_SSE_ASM']
417 endif
418 elif host_machine.cpu_family() == 'x86_64'
419 if host_machine.system() == 'linux'
420 with_asm_arch = 'x86_64'
421 pre_args += ['-DUSE_X86_64_ASM']
422 endif
423 elif host_machine.cpu_family() == 'arm'
424 if host_machine.system() == 'linux'
425 with_asm_arch = 'arm'
426 pre_args += ['-DUSE_ARM_ASM']
427 endif
428 elif host_machine.cpu_family() == 'aarch64'
429 if host_machine.system() == 'linux'
430 with_asm_arch = 'aarch64'
431 pre_args += ['-DUSE_AARCH64_ASM']
432 endif
433 endif
434endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700435
436# Check for standard headers and functions
437if cc.has_header_symbol('sys/sysmacros.h', 'major')
438 pre_args += '-DMAJOR_IN_SYSMACROS'
439elif cc.has_header_symbol('sys/mkdev.h', 'major')
440 pre_args += '-DMAJOR_IN_MKDEV'
441endif
442
443foreach h : ['xlocale.h', 'sys/sysctl.h']
444 if cc.has_header(h)
445 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
446 endif
447endforeach
448
449foreach f : ['strtof', 'mkostemp', 'posix_memalign']
450 if cc.has_function(f)
451 pre_args += '-DHAVE_@0@'.format(f.to_upper())
452 endif
453endforeach
454
455# strtod locale support
456if cc.links('''
457 #define _GNU_SOURCE
458 #include <stdlib.h>
459 #include <locale.h>
460 #ifdef HAVE_XLOCALE_H
461 #include <xlocale.h>
462 #endif
463 int main() {
464 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
465 const char *s = "1.0";
466 char *end;
467 double d = strtod_l(s, end, loc);
468 float f = strtod_l(s, end, loc);
469 freelocale(loc);
470 return 0;
471 }''',
472 extra_args : pre_args,
473 name : 'strtod has locale support')
474 pre_args += '-DHAVE_STRTOD_L'
475endif
476
477# Check for some linker flags
478ld_args_bsymbolic = []
Dylan Bakere21e0a62017-09-30 13:15:52 -0700479if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
Dylan Bakerd1992252017-09-14 17:57:17 -0700480 ld_args_bsymbolic += '-Wl,-Bsymbolic'
481endif
482ld_args_gc_sections = []
483if cc.links('static char unused() { return 5; } int main() { return 0; }',
Dylan Bakere21e0a62017-09-30 13:15:52 -0700484 args : '-Wl,--gc-sections', name : 'gc-sections')
Dylan Bakerd1992252017-09-14 17:57:17 -0700485 ld_args_gc_sections += '-Wl,--gc-sections'
486endif
Dylan Bakere21e0a62017-09-30 13:15:52 -0700487with_ld_version_script = false
488if cc.links('int main() { return 0; }',
489 args : '-Wl,--version-script=@0@'.format(
490 join_paths(meson.source_root(), 'build-support/conftest.map')),
491 name : 'version-script')
492 with_ld_version_script = true
493endif
494with_ld_dynamic_list = false
495if cc.links('int main() { return 0; }',
496 args : '-Wl,--dynamic-list=@0@'.format(
497 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
498 name : 'dynamic-list')
499 with_ld_dynamic_list = true
500endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700501
502# check for dl support
503if cc.has_function('dlopen')
504 dep_dl = []
505else
506 dep_dl = cc.find_library('dl')
507endif
Dylan Baker32180562017-09-20 20:11:32 -0700508if cc.has_function('dladdr', dependencies : dep_dl)
509 # This is really only required for megadrivers
510 pre_args += '-DHAVE_DLADDR'
Dylan Bakerd1992252017-09-14 17:57:17 -0700511endif
512
513if cc.has_function('dl_iterate_phdr')
514 pre_args += '-DHAVE_DL_ITERATE_PHDR'
515else
516 # TODO: this is required for vulkan
517endif
518
519# Determine whether or not the rt library is needed for time functions
520if cc.has_function('clock_gettime')
521 dep_clock = []
522else
523 dep_clock = cc.find_library('rt')
524endif
525
Dylan Baker50c28df2017-09-29 17:53:01 -0700526dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
527 required : with_dri2 or with_dri3)
528if dep_libdrm.found()
529 pre_args += '-DHAVE_LIBDRM'
530endif
531
Dylan Bakerd1992252017-09-14 17:57:17 -0700532# TODO: some of these may be conditional
533dep_zlib = dependency('zlib', version : '>= 1.2.3')
534dep_thread = dependency('threads')
Dylan Baker50c28df2017-09-29 17:53:01 -0700535if dep_thread.found() and host_machine.system() == 'linux'
536 pre_args += '-DHAVE_PTHREAD'
537endif
Dylan Bakercc4f5872017-09-27 11:30:21 -0700538dep_elf = dependency('libelf', required : false)
539if not dep_elf.found()
Dylan Baker97aea7d2017-10-04 11:36:06 -0700540 dep_elf = cc.find_library('elf', required : with_amd_vk) # TODO: clover, r600, radeonsi
Dylan Bakercc4f5872017-09-27 11:30:21 -0700541endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700542dep_expat = dependency('expat')
543# this only exists on linux so either this is linux and it will be found, or
544# its not linux and and wont
545dep_m = cc.find_library('m', required : false)
Dylan Baker66f97f62017-09-30 09:03:51 -0700546
547dep_libdrm_amdgpu = []
548dep_libdrm_radeon = []
549if with_amd_vk or with_gallium_radeonsi
550 dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.84')
551endif
552if with_gallium_radeonsi # older radeon too
553 dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
554endif
Dylan Baker673dda82017-09-20 11:53:29 -0700555
556llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
557if with_amd_vk
558 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
559endif
560dep_llvm = dependency(
Dylan Baker50c28df2017-09-29 17:53:01 -0700561 'llvm', version : '>= 3.9.0', required : with_amd_vk, modules : llvm_modules,
Dylan Baker673dda82017-09-20 11:53:29 -0700562)
Dylan Baker02cf3a82017-10-12 09:47:30 -0700563if with_llvm
564 if dep_llvm.found()
565 _llvm_version = dep_llvm.version().split('.')
566 # Development versions of LLVM have an 'svn' suffix, we don't want that for
567 # our version checks.
568 _llvm_patch = _llvm_version[2]
569 if _llvm_patch.endswith('svn')
570 _llvm_patch = _llvm_patch.split('s')[0]
571 endif
572 pre_args += [
573 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
574 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
575 ]
576 else
Dylan Baker66f97f62017-09-30 09:03:51 -0700577 if with_amd_vk or with_gallium_radeonsi
578 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 -0700579 endif
Dylan Baker673dda82017-09-20 11:53:29 -0700580 endif
Dylan Baker66f97f62017-09-30 09:03:51 -0700581elif with_amd_vk or with_gallium_radeonsi
582 error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM is disabled.')
Dylan Baker673dda82017-09-20 11:53:29 -0700583endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700584
Dylan Bakera47c5252017-09-22 12:55:00 -0700585dep_glvnd = []
586if with_glvnd
587 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
588 pre_args += '-DUSE_LIBGLVND=1'
589endif
590
Dylan Bakerd1992252017-09-14 17:57:17 -0700591# TODO: make this conditional
592dep_valgrind = dependency('valgrind', required : false)
593if dep_valgrind.found() and with_valgrind
594 pre_args += '-DHAVE_VALGRIND'
595endif
596
597# pthread stubs. Lets not and say we didn't
598
Dylan Baker32180562017-09-20 20:11:32 -0700599prog_bison = find_program('bison', required : with_any_opengl)
600prog_flex = find_program('flex', required : with_any_opengl)
601
Dylan Bakerd1992252017-09-14 17:57:17 -0700602# TODO: selinux
Dylan Baker32180562017-09-20 20:11:32 -0700603dep_selinux = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700604
605# TODO: llvm-prefix and llvm-shared-libs
606
Dylan Bakerb1b65392017-09-28 22:25:02 -0700607dep_unwind = dependency('libunwind', required : false)
608if dep_unwind.found()
609 pre_args += '-DHAVE_LIBUNWIND'
610endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700611
612# TODO: flags for opengl, gles, dri
613
614# TODO: gallium-hud
615
616# TODO: glx provider
617
618# TODO: osmesa provider
619
Dylan Bakerd1992252017-09-14 17:57:17 -0700620# TODO: symbol mangling
621
Dylan Bakerd1992252017-09-14 17:57:17 -0700622# TODO: egl configuration
623
624if with_platform_wayland
625 prog_wl_scanner = find_program('wayland-scanner')
626 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
627 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
628 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
629else
630 prog_wl_scanner = []
631 dep_wl_protocols = []
632 dep_wayland_client = []
633 dep_wayland_server = []
634endif
635
Dylan Baker50c28df2017-09-29 17:53:01 -0700636dep_x11 = []
637dep_xext = []
638dep_xdamage = []
639dep_xfixes = []
640dep_x11_xcb = []
641dep_xcb_glx = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700642dep_xcb_dri2 = []
643dep_xcb_dri3 = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700644dep_dri2proto = []
645dep_glproto = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700646dep_xf86vm = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700647dep_xcb_dri3 = []
648dep_xcb_present = []
649dep_xcb_sync = []
650dep_xshmfence = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700651if with_platform_x11
Dylan Baker50c28df2017-09-29 17:53:01 -0700652 if with_glx == 'dri' and with_dri_platform == 'drm'
653 dep_x11 = dependency('x11')
654 dep_xext = dependency('xext')
655 dep_xdamage = dependency('xdamage', version : '>= 1.1')
656 dep_xfixes = dependency('xfixes')
657 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
658 dep_xf86vm = dependency('xf86vm', required : false)
Dylan Bakera47c5252017-09-22 12:55:00 -0700659 endif
660 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
Dylan Baker50c28df2017-09-29 17:53:01 -0700661 dep_xcb = dependency('xcb')
662 dep_x11_xcb = dependency('x11-xcb')
663 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
664
Dylan Bakera47c5252017-09-22 12:55:00 -0700665 if with_dri3
666 pre_args += '-DHAVE_DRI3'
Dylan Baker50c28df2017-09-29 17:53:01 -0700667 dep_xcb_dri3 = dependency('xcb-dri3')
668 dep_xcb_present = dependency('xcb-present')
669 dep_xcb_sync = dependency('xcb-sync')
670 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
Dylan Bakera47c5252017-09-22 12:55:00 -0700671 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700672 endif
Dylan Baker50c28df2017-09-29 17:53:01 -0700673 if with_glx != 'disabled'
674 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
675 dep_glproto = dependency('glproto', version : '>= 1.4.14')
676 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700677endif
678
679# TODO: platforms for !vulkan
680
Dylan Bakerd1992252017-09-14 17:57:17 -0700681# TODO: osmesa
682
683# TODO: egl
684
Dylan Bakerd1992252017-09-14 17:57:17 -0700685# TODO: vallium G3DVL
686
687# TODO: nine
688
689# TODO: clover
690
691# TODO: egl sans x11
Dylan Bakerd1992252017-09-14 17:57:17 -0700692# TODO: gallium tests
693
694# TODO: various libdirs
695
696# TODO: swr
697
698# TODO: gallium driver dirs
699
700# FIXME: this is a workaround for #2326
701prog_touch = find_program('touch')
702dummy_cpp = custom_target(
703 'dummy_cpp',
704 output : 'dummy.cpp',
705 command : [prog_touch, '@OUTPUT@'],
706)
707
708foreach a : pre_args
709 add_project_arguments(a, language : ['c', 'cpp'])
710endforeach
711foreach a : c_args
712 add_project_arguments(a, language : ['c'])
713endforeach
714foreach a : cpp_args
715 add_project_arguments(a, language : ['cpp'])
716endforeach
717
718inc_include = include_directories('include')
719
Dylan Baker32180562017-09-20 20:11:32 -0700720pkg = import('pkgconfig')
721
Dylan Bakerd1992252017-09-14 17:57:17 -0700722subdir('include')
723subdir('src')