blob: ff2ce55e9241684811109775cfb98a37627adda1 [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
Ville Syrjälä22899642017-10-10 01:15:42 +030093dep_libdrm_intel = []
94if with_dri_i915
95 dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
96endif
97
Dylan Baker32180562017-09-20 20:11:32 -070098if not with_dri
99 with_gles1 = false
100 with_gles2 = false
101 with_opengl = false
102 with_any_opengl = false
103 with_shared_glapi = false
104endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700105
Dylan Bakera47c5252017-09-22 12:55:00 -0700106# TODO: other OSes
107with_dri_platform = 'drm'
108
109with_gallium = false
110# TODO: gallium drivers
111
112# TODO: conditionalize libdrm requirement
113dep_libdrm = dependency('libdrm', version : '>= 2.4.75')
114pre_args += '-DHAVE_LIBDRM'
115
116with_dri2 = with_dri_platform == 'drm' and dep_libdrm.found()
117with_dri3 = get_option('dri3')
118if with_dri3 == 'auto'
Dylan Baker816bf7d12017-09-28 15:53:53 -0700119 if host_machine.system() == 'linux' and with_dri2
Dylan Bakera47c5252017-09-22 12:55:00 -0700120 with_dri3 = true
121 else
122 with_dri3 = false
123 endif
124elif with_dri3 == 'yes'
Dylan Baker816bf7d12017-09-28 15:53:53 -0700125 if not with_dri2
126 error('dri3 support requires libdrm')
127 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700128 with_dri3 = true
129else
130 with_dri3 = false
131endif
132
Dylan Bakerd1992252017-09-14 17:57:17 -0700133# TODO: there are more platforms required for non-vulkan drivers
134with_platform_wayland = false
135with_platform_x11 = false
136_platforms = get_option('platforms')
137if _platforms != ''
138 _split = _platforms.split(',')
139 with_platform_x11 = _split.contains('x11')
140 with_platform_wayland = _split.contains('wayland')
141endif
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 -0700205 if with_platform_x11 and not with_dri3
206 error('Vulkan drivers require dri3 for X11 support')
207 endif
208endif
209
210if with_dri # TODO: or gallium
211 if with_glx == 'disabled' # TODO: or egl
212 error('building dri or gallium drivers require at least one window system')
213 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700214endif
215
216prog_python2 = find_program('python2')
Dylan Baker9342a7d2017-09-28 10:48:30 -0700217has_mako = run_command(prog_python2, '-c', 'import mako')
218if has_mako.returncode() != 0
219 error('Python (2.x) mako module required to build mesa.')
220endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700221
222cc = meson.get_compiler('c')
223if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
Eric Engestrom1262e822017-09-29 15:25:18 +0100224 error('When using GCC, version 4.4.6 or later is required.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700225endif
226
Dylan Bakerd1992252017-09-14 17:57:17 -0700227# Define DEBUG for debug and debugoptimized builds
228if get_option('buildtype').startswith('debug')
229 pre_args += '-DDEBUG'
230endif
231
Dylan Baker673dda82017-09-20 11:53:29 -0700232if get_option('shader-cache')
233 pre_args += '-DENABLE_SHADER_CACHE'
234elif with_amd_vk
235 error('Radv requires shader cache support')
236endif
237
Dylan Bakerd1992252017-09-14 17:57:17 -0700238# Check for GCC style builtins
239foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
240 'ffsll', 'popcount', 'popcountll', 'unreachable']
241 if cc.has_function(b)
242 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
243 endif
244endforeach
245
Dylan Baker673dda82017-09-20 11:53:29 -0700246# check for GCC __attribute__
Dylan Bakerd1992252017-09-14 17:57:17 -0700247foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
248 'warn_unused_result', 'weak',]
249 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
250 name : '__attribute__((@0@))'.format(a))
251 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
252 endif
253endforeach
254if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
255 name : '__attribute__((format(...)))')
256 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
257endif
258if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
259 name : '__attribute__((packed))')
260 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
261endif
262if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
263 name : '__attribute__((returns_nonnull))')
264 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
265endif
266if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
267 int foo_hid(void) __attribute__((visibility("hidden")));
268 int foo_int(void) __attribute__((visibility("internal")));
269 int foo_pro(void) __attribute__((visibility("protected")));''',
270 name : '__attribute__((visibility(...)))')
271 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
272endif
273if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
274 name : '__attribute__((alias(...)))')
275 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
276endif
277
278# TODO: this is very incomplete
279if host_machine.system() == 'linux'
280 pre_args += '-D_GNU_SOURCE'
281endif
282
283# Check for generic C arguments
284c_args = []
285foreach a : ['-Wall', '-Werror=implicit-function-declaration',
286 '-Werror=missing-prototypes', '-fno-math-errno',
287 '-fno-trapping-math', '-Qunused-arguments']
288 if cc.has_argument(a)
289 c_args += a
290 endif
291endforeach
292c_vis_args = []
293if cc.has_argument('-fvisibility=hidden')
294 c_vis_args += '-fvisibility=hidden'
295endif
296
297# Check for generic C++ arguments
298cpp = meson.get_compiler('cpp')
299cpp_args = []
300foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
301 '-Qunused-arguments', '-Wno-non-virtual-dtor']
302 if cpp.has_argument(a)
303 cpp_args += a
304 endif
305endforeach
306cpp_vis_args = []
307if cpp.has_argument('-fvisibility=hidden')
308 cpp_vis_args += '-fvisibility=hidden'
309endif
310
311# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
312# in parts of the mesa code base that need to compile with old versions of
313# MSVC, mainly common code
314c_msvc_compat_args = []
315cpp_msvc_compat_args = []
316foreach a : ['-Werror=pointer-arith', '-Werror=vla']
317 if cc.has_argument(a)
318 c_msvc_compat_args += a
319 endif
320 if cpp.has_argument(a)
321 cpp_msvc_compat_args += a
322 endif
323endforeach
324
325no_override_init_args = []
326foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
327 if cc.has_argument(a)
328 no_override_init_args += a
329 endif
330endforeach
331
332# TODO: SSE41 (which is only required for core mesa)
333
334# Check for GCC style atomics
335if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
336 name : 'GCC atomic builtins')
337 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
338endif
339if not cc.links('''#include <stdint.h>
340 uint64_t v;
341 int main() {
342 return __sync_add_and_fetch(&v, (uint64_t)1);
343 }''',
344 name : 'GCC 64bit atomics')
345 pre_args += '-DMISSING_64_BIT_ATOMICS'
346endif
347
348# TODO: endian
349# TODO: powr8
350# TODO: shared/static? Is this even worth doing?
351
352# I don't think that I need to set any of the debug stuff, I think meson
353# handles that for us
354
355# TODO: ldflags
356
357# TODO: texture-float (gallium/mesa only)
358
359# TODO: cross-compiling. I don't think this is relavent to meson
360
Dylan Baker32180562017-09-20 20:11:32 -0700361# FIXME: enable asm when cross compiler
362# This is doable (autotools does it), but it's not of immediate concern
363if meson.is_cross_build()
364 message('Cross compiling, disabling asm')
365 with_asm = false
366endif
367
368with_asm_arch = ''
369if with_asm
370 # TODO: SPARC and PPC
371 if host_machine.cpu_family() == 'x86'
372 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
373 with_asm_arch = 'x86'
374 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
375 '-DUSE_SSE_ASM']
376 endif
377 elif host_machine.cpu_family() == 'x86_64'
378 if host_machine.system() == 'linux'
379 with_asm_arch = 'x86_64'
380 pre_args += ['-DUSE_X86_64_ASM']
381 endif
382 elif host_machine.cpu_family() == 'arm'
383 if host_machine.system() == 'linux'
384 with_asm_arch = 'arm'
385 pre_args += ['-DUSE_ARM_ASM']
386 endif
387 elif host_machine.cpu_family() == 'aarch64'
388 if host_machine.system() == 'linux'
389 with_asm_arch = 'aarch64'
390 pre_args += ['-DUSE_AARCH64_ASM']
391 endif
392 endif
393endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700394
395# Check for standard headers and functions
396if cc.has_header_symbol('sys/sysmacros.h', 'major')
397 pre_args += '-DMAJOR_IN_SYSMACROS'
398elif cc.has_header_symbol('sys/mkdev.h', 'major')
399 pre_args += '-DMAJOR_IN_MKDEV'
400endif
401
402foreach h : ['xlocale.h', 'sys/sysctl.h']
403 if cc.has_header(h)
404 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
405 endif
406endforeach
407
408foreach f : ['strtof', 'mkostemp', 'posix_memalign']
409 if cc.has_function(f)
410 pre_args += '-DHAVE_@0@'.format(f.to_upper())
411 endif
412endforeach
413
414# strtod locale support
415if cc.links('''
416 #define _GNU_SOURCE
417 #include <stdlib.h>
418 #include <locale.h>
419 #ifdef HAVE_XLOCALE_H
420 #include <xlocale.h>
421 #endif
422 int main() {
423 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
424 const char *s = "1.0";
425 char *end;
426 double d = strtod_l(s, end, loc);
427 float f = strtod_l(s, end, loc);
428 freelocale(loc);
429 return 0;
430 }''',
431 extra_args : pre_args,
432 name : 'strtod has locale support')
433 pre_args += '-DHAVE_STRTOD_L'
434endif
435
436# Check for some linker flags
437ld_args_bsymbolic = []
Dylan Bakere21e0a62017-09-30 13:15:52 -0700438if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
Dylan Bakerd1992252017-09-14 17:57:17 -0700439 ld_args_bsymbolic += '-Wl,-Bsymbolic'
440endif
441ld_args_gc_sections = []
442if cc.links('static char unused() { return 5; } int main() { return 0; }',
Dylan Bakere21e0a62017-09-30 13:15:52 -0700443 args : '-Wl,--gc-sections', name : 'gc-sections')
Dylan Bakerd1992252017-09-14 17:57:17 -0700444 ld_args_gc_sections += '-Wl,--gc-sections'
445endif
Dylan Bakere21e0a62017-09-30 13:15:52 -0700446with_ld_version_script = false
447if cc.links('int main() { return 0; }',
448 args : '-Wl,--version-script=@0@'.format(
449 join_paths(meson.source_root(), 'build-support/conftest.map')),
450 name : 'version-script')
451 with_ld_version_script = true
452endif
453with_ld_dynamic_list = false
454if cc.links('int main() { return 0; }',
455 args : '-Wl,--dynamic-list=@0@'.format(
456 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
457 name : 'dynamic-list')
458 with_ld_dynamic_list = true
459endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700460
461# check for dl support
462if cc.has_function('dlopen')
463 dep_dl = []
464else
465 dep_dl = cc.find_library('dl')
466endif
Dylan Baker32180562017-09-20 20:11:32 -0700467if cc.has_function('dladdr', dependencies : dep_dl)
468 # This is really only required for megadrivers
469 pre_args += '-DHAVE_DLADDR'
Dylan Bakerd1992252017-09-14 17:57:17 -0700470endif
471
472if cc.has_function('dl_iterate_phdr')
473 pre_args += '-DHAVE_DL_ITERATE_PHDR'
474else
475 # TODO: this is required for vulkan
476endif
477
478# Determine whether or not the rt library is needed for time functions
479if cc.has_function('clock_gettime')
480 dep_clock = []
481else
482 dep_clock = cc.find_library('rt')
483endif
484
485# TODO: some of these may be conditional
486dep_zlib = dependency('zlib', version : '>= 1.2.3')
487dep_thread = dependency('threads')
488pre_args += '-DHAVE_PTHREAD'
Dylan Bakercc4f5872017-09-27 11:30:21 -0700489dep_elf = dependency('libelf', required : false)
490if not dep_elf.found()
Dylan Baker97aea7d2017-10-04 11:36:06 -0700491 dep_elf = cc.find_library('elf', required : with_amd_vk) # TODO: clover, r600, radeonsi
Dylan Bakercc4f5872017-09-27 11:30:21 -0700492endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700493dep_expat = dependency('expat')
494# this only exists on linux so either this is linux and it will be found, or
495# its not linux and and wont
496dep_m = cc.find_library('m', required : false)
497
Dylan Baker673dda82017-09-20 11:53:29 -0700498dep_libdrm_amdgpu = []
499if with_amd_vk
500 dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.82')
501endif
502
503llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
504if with_amd_vk
505 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
506endif
507dep_llvm = dependency(
508 'llvm', version : '>= 3.9.0', required : false, modules : llvm_modules,
509)
Dylan Baker02cf3a82017-10-12 09:47:30 -0700510if with_llvm
511 if dep_llvm.found()
512 _llvm_version = dep_llvm.version().split('.')
513 # Development versions of LLVM have an 'svn' suffix, we don't want that for
514 # our version checks.
515 _llvm_patch = _llvm_version[2]
516 if _llvm_patch.endswith('svn')
517 _llvm_patch = _llvm_patch.split('s')[0]
518 endif
519 pre_args += [
520 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
521 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
522 ]
523 else
524 if with_amd_vk
525 error('The following drivers requires LLVM: Radv. One of these is enabled, but LLVM was not found.')
526 endif
Dylan Baker673dda82017-09-20 11:53:29 -0700527 endif
Dylan Baker02cf3a82017-10-12 09:47:30 -0700528elif with_amd_vk
529 error('The following drivers requires LLVM: Radv. One of these is enabled, but LLVM is disabled.')
Dylan Baker673dda82017-09-20 11:53:29 -0700530endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700531
Dylan Bakera47c5252017-09-22 12:55:00 -0700532dep_glvnd = []
533if with_glvnd
534 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
535 pre_args += '-DUSE_LIBGLVND=1'
536endif
537
Dylan Bakerd1992252017-09-14 17:57:17 -0700538# TODO: make this conditional
539dep_valgrind = dependency('valgrind', required : false)
540if dep_valgrind.found() and with_valgrind
541 pre_args += '-DHAVE_VALGRIND'
542endif
543
544# pthread stubs. Lets not and say we didn't
545
Dylan Baker32180562017-09-20 20:11:32 -0700546prog_bison = find_program('bison', required : with_any_opengl)
547prog_flex = find_program('flex', required : with_any_opengl)
548
Dylan Bakerd1992252017-09-14 17:57:17 -0700549# TODO: selinux
Dylan Baker32180562017-09-20 20:11:32 -0700550dep_selinux = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700551
552# TODO: llvm-prefix and llvm-shared-libs
553
Dylan Bakerd1992252017-09-14 17:57:17 -0700554# TODO: unwind (llvm [radeon, gallivm] and gallium)
555
556# TODO: flags for opengl, gles, dri
557
558# TODO: gallium-hud
559
560# TODO: glx provider
561
562# TODO: osmesa provider
563
564# TODO: flags for xa, egl, gbm, nin, xvmc, vdpau, omx, va, opencl,
565# gallium-tests,
566
567# TODO: gallium drivers
568
Dylan Bakerd1992252017-09-14 17:57:17 -0700569# TODO: symbol mangling
570
Dylan Bakerd1992252017-09-14 17:57:17 -0700571# TODO: egl configuration
572
573if with_platform_wayland
574 prog_wl_scanner = find_program('wayland-scanner')
575 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
576 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
577 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
578else
579 prog_wl_scanner = []
580 dep_wl_protocols = []
581 dep_wayland_client = []
582 dep_wayland_server = []
583endif
584
585dep_xcb_dri2 = []
586dep_xcb_dri3 = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700587dep_dri2proto = []
588dep_glproto = []
589dep_x11 = []
590dep_xf86vm = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700591if with_platform_x11
Dylan Bakera47c5252017-09-22 12:55:00 -0700592 if with_glx == 'xlib'
593 # TODO
594 error('TODO')
595 elif with_glx == 'gallium-xlib'
596 # TODO
597 error('TODO')
Dylan Bakerd1992252017-09-14 17:57:17 -0700598 else
Dylan Bakera47c5252017-09-22 12:55:00 -0700599 pre_args += '-DGLX_INDIRECT_RENDERING'
600 if with_glx_direct
601 pre_args += '-DGLX_DIRECT_RENDERING'
602 endif
603 if with_dri_platform == 'drm'
604 pre_args += '-DGLX_USE_DRM'
605 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
606 dep_x11 = [
607 dependency('x11'),
608 dependency('xext'),
609 dependency('xdamage', version : '>= 1.1'),
610 dependency('xfixes'),
611 dependency('x11-xcb'),
612 dependency('xcb'),
613 dependency('xcb-glx', version : '>= 1.8.1'),
614 ]
615
Ville Syrjälä66b15972017-10-10 01:34:18 +0300616 dep_xf86vm = dependency('xxf86vm', required : false)
Dylan Bakera47c5252017-09-22 12:55:00 -0700617 endif
618 # TODO: XF86VIDMODE
619 endif
620 if with_glx != 'disabled'
621 dep_glproto = dependency('glproto', version : '>= 1.4.14')
622 endif
623 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
624 dep_xcb_dri2 = [
625 dependency('x11-xcb'),
626 dependency('xcb'),
627 dependency('xcb-dri2', version : '>= 1.8'),
628 dependency('xcb-xfixes'),
629 ]
630 pre_args += '-DHAVE_X11_PLATFORM'
631 if with_dri3
632 pre_args += '-DHAVE_DRI3'
633 dep_xcb_dri3 = [
634 dep_xcb_dri2,
635 dependency('xcb-dri3'),
636 dependency('xcb-present'),
637 dependency('xcb-sync'),
638 dependency('xshmfence', version : '>= 1.1'),
639 ]
640 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700641 endif
642endif
643
644# TODO: platforms for !vulkan
645
Dylan Bakerd1992252017-09-14 17:57:17 -0700646# TODO: osmesa
647
648# TODO: egl
649
650# TODO: xa
651
652# TODO: vallium G3DVL
653
654# TODO: nine
655
656# TODO: clover
657
658# TODO: egl sans x11
659
660# TODO: xvmc
661
662# TODO: gallium tests
663
664# TODO: various libdirs
665
666# TODO: swr
667
668# TODO: gallium driver dirs
669
670# FIXME: this is a workaround for #2326
671prog_touch = find_program('touch')
672dummy_cpp = custom_target(
673 'dummy_cpp',
674 output : 'dummy.cpp',
675 command : [prog_touch, '@OUTPUT@'],
676)
677
678foreach a : pre_args
679 add_project_arguments(a, language : ['c', 'cpp'])
680endforeach
681foreach a : c_args
682 add_project_arguments(a, language : ['c'])
683endforeach
684foreach a : cpp_args
685 add_project_arguments(a, language : ['cpp'])
686endforeach
687
688inc_include = include_directories('include')
689
Dylan Baker32180562017-09-20 20:11:32 -0700690pkg = import('pkgconfig')
691
Dylan Bakerd1992252017-09-14 17:57:17 -0700692subdir('include')
693subdir('src')