blob: d5a7c62266117217a3b6651d15c3c17164b7b180 [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
Eric Engestrom7983adc2017-10-24 14:57:11 +010021project(
22 'mesa',
23 ['c', 'cpp'],
Dylan Baker3e9533d2017-11-01 11:54:10 -070024 version : run_command(
25 [find_program('python', 'python2', 'python3'), 'bin/meson_get_version.py']
26 ).stdout(),
Eric Engestrom7983adc2017-10-24 14:57:11 +010027 license : 'MIT',
28 meson_version : '>= 0.42',
Eric Engestromd5597f02017-11-06 16:49:27 +000029 default_options : ['buildtype=debugoptimized', 'c_std=c99', 'cpp_std=c++11']
Eric Engestrom7983adc2017-10-24 14:57:11 +010030)
Dylan Bakerd1992252017-09-14 17:57:17 -070031
Dylan Baker32180562017-09-20 20:11:32 -070032# Arguments for the preprocessor, put these in a separate array from the C and
33# C++ (cpp in meson terminology) arguments since they need to be added to the
34# default arguments for both C and C++.
35pre_args = [
36 '-D__STDC_CONSTANT_MACROS',
37 '-D__STDC_FORMAT_MACROS',
38 '-D__STDC_LIMIT_MACROS',
39 '-DVERSION="@0@"'.format(meson.project_version()),
40 '-DPACKAGE_VERSION=VERSION',
41 '-DPACKAGE_BUGREPORT="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa"',
42]
43
Dylan Bakere915b8d2017-09-28 14:02:51 -070044with_vulkan_icd_dir = get_option('vulkan-icd-dir')
Dylan Bakerd1992252017-09-14 17:57:17 -070045with_tests = get_option('build-tests')
46with_valgrind = get_option('valgrind')
Erik Faye-Lund9e5a5a12017-10-23 20:54:03 +020047with_libunwind = get_option('libunwind')
Dylan Baker32180562017-09-20 20:11:32 -070048with_asm = get_option('asm')
Dylan Bakercbbd5bb2017-10-20 21:48:18 -070049with_osmesa = get_option('osmesa')
Dylan Baker3b209e92017-10-10 15:25:07 -070050if get_option('texture-float')
51 pre_args += '-DTEXTURE_FLOAT_ENABLED'
52 message('WARNING: Floating-point texture enabled. Please consult docs/patents.txt and your lawyer before building mesa.')
53endif
Dylan Baker32180562017-09-20 20:11:32 -070054
55# XXX: yeah, do these
56with_appledri = false
57with_windowsdri = false
58
Dylan Bakerdb978842017-09-28 13:59:04 -070059dri_drivers_path = get_option('dri-drivers-path')
60if dri_drivers_path == ''
61 dri_drivers_path = join_paths(get_option('libdir'), 'dri')
62endif
63
Dylan Baker32180562017-09-20 20:11:32 -070064with_gles1 = get_option('gles1')
65with_gles2 = get_option('gles2')
66with_opengl = get_option('opengl')
67with_any_opengl = with_opengl or with_gles1 or with_gles2
Dylan Bakera47c5252017-09-22 12:55:00 -070068# Only build shared_glapi if at least one OpenGL API is enabled
69with_shared_glapi = get_option('shared-glapi') and with_any_opengl
Dylan Baker32180562017-09-20 20:11:32 -070070
Dylan Baker32180562017-09-20 20:11:32 -070071
72# shared-glapi is required if at least two OpenGL APIs are being built
73if not with_shared_glapi
74 if ((with_gles1 and with_gles2) or (with_gles1 and with_opengl)
75 or (with_gles2 and with_opengl))
76 error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x')
77 endif
78endif
79
80# We require OpenGL for OpenGL ES
81if (with_gles1 or with_gles2) and not with_opengl
82 error('building OpenGL ES without OpenGL is not supported.')
83endif
84
85with_dri = false
Ville Syrjälä22899642017-10-10 01:15:42 +030086with_dri_i915 = false
Dylan Baker32180562017-09-20 20:11:32 -070087with_dri_i965 = false
Dylan Baker191e7852017-10-16 17:12:52 -070088with_dri_r100 = false
Dylan Bakereecd2862017-10-16 17:24:56 -070089with_dri_r200 = false
Dylan Bakereb3bb032017-10-16 17:51:47 -070090with_dri_nouveau = false
Dylan Bakerc2cd5802017-10-03 17:06:22 -070091with_dri_swrast = false
Dylan Baker32180562017-09-20 20:11:32 -070092_drivers = get_option('dri-drivers')
Dylan Baker18733272017-10-30 10:17:22 -070093if _drivers == 'auto'
94 # TODO: PPC, Sparc
95 if not ['darwin', 'windows'].contains(host_machine.system())
96 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
97 _drivers = 'i915,i965,r100,r200,nouveau'
98 else
99 error('Unknown architecture. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
100 endif
101 else
102 error('Unknown OS. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
103 endif
104endif
Dylan Baker32180562017-09-20 20:11:32 -0700105if _drivers != ''
106 _split = _drivers.split(',')
Ville Syrjälä22899642017-10-10 01:15:42 +0300107 with_dri_i915 = _split.contains('i915')
Dylan Baker32180562017-09-20 20:11:32 -0700108 with_dri_i965 = _split.contains('i965')
Dylan Baker191e7852017-10-16 17:12:52 -0700109 with_dri_r100 = _split.contains('r100')
Dylan Bakereecd2862017-10-16 17:24:56 -0700110 with_dri_r200 = _split.contains('r200')
Dylan Bakereb3bb032017-10-16 17:51:47 -0700111 with_dri_nouveau = _split.contains('nouveau')
Dylan Bakerc2cd5802017-10-03 17:06:22 -0700112 with_dri_swrast = _split.contains('swrast')
Dylan Baker32180562017-09-20 20:11:32 -0700113 with_dri = true
114endif
115
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700116with_gallium = false
Eric Anholt1918c9b2017-10-12 18:39:08 -0700117with_gallium_pl111 = false
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700118with_gallium_radeonsi = false
Dylan Baker813b4b02017-10-09 14:59:35 -0700119with_gallium_nouveau = false
Rob Clark4aa69cc2017-10-14 10:08:50 -0400120with_gallium_freedreno = false
Dylan Bakerf3d03a22017-10-10 11:57:50 -0700121with_gallium_softpipe = false
Eric Anholt1ae80182017-10-12 13:53:12 -0700122with_gallium_vc4 = false
Eric Anholt4f3e3802017-10-12 18:40:16 -0700123with_gallium_vc5 = false
Dylan Baker51558a12017-10-20 15:45:22 -0700124with_gallium_etnaviv = false
Dylan Bakerd4567ef2017-10-20 15:57:15 -0700125with_gallium_imx = false
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700126_drivers = get_option('gallium-drivers')
Dylan Baker18733272017-10-30 10:17:22 -0700127if _drivers == 'auto'
128 if not ['darwin', 'windows'].contains(host_machine.system())
129 # TODO: PPC, Sparc
130 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
131 _drivers = 'radeonsi,nouveau,swrast'
132 elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
133 _drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,swrast'
134 else
135 error('Unknown architecture. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
136 endif
137 else
138 error('Unknown OS. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
139 endif
140endif
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700141if _drivers != ''
142 _split = _drivers.split(',')
Dylan Bakerfbf39fd2017-10-17 14:44:15 -0700143 with_gallium_pl111 = _split.contains('pl111')
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700144 with_gallium_radeonsi = _split.contains('radeonsi')
Dylan Baker813b4b02017-10-09 14:59:35 -0700145 with_gallium_nouveau = _split.contains('nouveau')
Rob Clark4aa69cc2017-10-14 10:08:50 -0400146 with_gallium_freedreno = _split.contains('freedreno')
Dylan Bakerde24d612017-10-10 14:27:19 -0700147 with_gallium_softpipe = _split.contains('swrast')
Eric Anholt1ae80182017-10-12 13:53:12 -0700148 with_gallium_vc4 = _split.contains('vc4')
Eric Anholt4f3e3802017-10-12 18:40:16 -0700149 with_gallium_vc5 = _split.contains('vc5')
Dylan Baker51558a12017-10-20 15:45:22 -0700150 with_gallium_etnaviv = _split.contains('etnaviv')
Dylan Bakerd4567ef2017-10-20 15:57:15 -0700151 with_gallium_imx = _split.contains('imx')
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700152 with_gallium = true
Ville Syrjälä22899642017-10-10 01:15:42 +0300153endif
154
Jason Ekstrand00fb21b2017-11-11 10:30:35 -0800155with_intel_vk = false
156with_amd_vk = false
157with_any_vk = false
158_vulkan_drivers = get_option('vulkan-drivers')
159if _vulkan_drivers == 'auto'
160 if not ['darwin', 'windows'].contains(host_machine.system())
161 if host_machine.cpu_family().startswith('x86')
162 _vulkan_drivers = 'amd,intel'
163 else
164 error('Unknown architecture. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.')
165 endif
166 else
167 # No vulkan driver supports windows or macOS currently
168 _vulkan_drivers = ''
169 endif
170endif
171if _vulkan_drivers != ''
172 _split = _vulkan_drivers.split(',')
173 with_intel_vk = _split.contains('intel')
174 with_amd_vk = _split.contains('amd')
175 with_any_vk = with_amd_vk or with_intel_vk
176endif
177
Dylan Bakerde24d612017-10-10 14:27:19 -0700178if with_dri_swrast and with_gallium_softpipe
179 error('Only one swrast provider can be built')
180endif
Dylan Bakerd4567ef2017-10-20 15:57:15 -0700181if with_gallium_imx and not with_gallium_etnaviv
182 error('IMX driver requires etnaviv driver')
183endif
Dylan Bakerde24d612017-10-10 14:27:19 -0700184
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700185dep_libdrm_intel = []
186if with_dri_i915
187 dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75')
188endif
189
Dylan Baker33627d22017-10-27 17:20:52 -0700190if host_machine.system() == 'darwin'
191 with_dri_platform = 'apple'
192elif ['windows', 'cygwin'].contains(host_machine.system())
193 with_dri_platform = 'windows'
194elif host_machine.system() == 'linux'
195 # FIXME: This should include BSD and possibly other systems
196 with_dri_platform = 'drm'
197else
198 # FIXME: haiku doesn't use dri, and xlib doesn't use dri, probably should
199 # assert here that one of those cases has been met.
200 # FIXME: GNU (hurd) ends up here as well, but meson doesn't officially
201 # support Hurd at time of writing (2017/11)
202 with_dri_platform = 'none'
203endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700204
Eric Engestromc5ec1552017-10-24 16:08:15 +0100205with_platform_android = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700206with_platform_wayland = false
207with_platform_x11 = false
Dylan Bakerb1b65392017-09-28 22:25:02 -0700208with_platform_drm = false
Dylan Baker108d2572017-10-18 12:20:43 -0700209with_platform_surfaceless = false
210egl_native_platform = ''
Dylan Bakerd1992252017-09-14 17:57:17 -0700211_platforms = get_option('platforms')
Dylan Baker4b61b072017-11-15 17:31:32 -0800212if _platforms == 'auto'
213 if ['linux'].contains(host_machine.system())
214 _platforms = 'x11,wayland,drm,surfaceless'
215 else
216 error('Unknown OS, no platforms enabled. Patches gladly accepted to fix this.')
217 endif
218endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700219if _platforms != ''
220 _split = _platforms.split(',')
Eric Engestromc5ec1552017-10-24 16:08:15 +0100221 with_platform_android = _split.contains('android')
Dylan Bakerd1992252017-09-14 17:57:17 -0700222 with_platform_x11 = _split.contains('x11')
223 with_platform_wayland = _split.contains('wayland')
Dylan Bakerb1b65392017-09-28 22:25:02 -0700224 with_platform_drm = _split.contains('drm')
Dylan Baker108d2572017-10-18 12:20:43 -0700225 with_platform_surfaceless = _split.contains('surfaceless')
226 egl_native_platform = _split[0]
Dylan Bakerd1992252017-09-14 17:57:17 -0700227endif
228
Dylan Baker118a7f02017-11-01 17:42:41 -0700229with_glx = get_option('glx')
230if with_glx == 'auto'
231 if with_dri
232 with_glx = 'dri'
233 elif with_gallium
Dylan Bakerad9c2f52017-11-02 13:36:44 -0700234 # Even when building just gallium drivers the user probably wants dri
235 with_glx = 'dri'
236 with_dri = true
Dylan Baker118a7f02017-11-01 17:42:41 -0700237 elif with_platform_x11 and with_any_opengl and not with_any_vk
238 # The automatic behavior should not be to turn on xlib based glx when
239 # building only vulkan drivers
240 with_glx = 'xlib'
241 else
242 with_glx = 'disabled'
243 endif
244endif
245
Dylan Bakerad9c2f52017-11-02 13:36:44 -0700246if not (with_dri or with_gallium or with_glx == 'xlib' or with_glx == 'gallium-xlib')
Dylan Baker118a7f02017-11-01 17:42:41 -0700247 with_gles1 = false
248 with_gles2 = false
249 with_opengl = false
250 with_any_opengl = false
251 with_shared_glapi = false
252endif
253
Dylan Baker816bf7d12017-09-28 15:53:53 -0700254with_gbm = get_option('gbm')
255if with_gbm == 'auto' and with_dri # TODO: or gallium
256 with_gbm = host_machine.system() == 'linux'
Dylan Baker05893312017-10-30 10:27:48 -0700257elif with_gbm == 'true'
Dylan Baker816bf7d12017-09-28 15:53:53 -0700258 if not ['linux', 'bsd'].contains(host_machine.system())
259 error('GBM only supports unix-like platforms')
260 endif
261 with_gbm = true
262else
263 with_gbm = false
264endif
265
Dylan Baker108d2572017-10-18 12:20:43 -0700266_egl = get_option('egl')
267if _egl == 'auto'
268 with_egl = with_dri and with_shared_glapi and egl_native_platform != ''
Dylan Baker05893312017-10-30 10:27:48 -0700269elif _egl == 'true'
Dylan Baker108d2572017-10-18 12:20:43 -0700270 if not with_dri
271 error('EGL requires dri')
272 elif not with_shared_glapi
273 error('EGL requires shared-glapi')
274 elif egl_native_platform == ''
275 error('No platforms specified, consider -Dplatforms=drm,x11 at least')
276 endif
277 with_egl = true
278else
279 with_egl = false
280endif
281
282# TODO: or virgl
283if with_egl and with_gallium_radeonsi and not (with_platform_drm or with_platform_surfaceless)
284 error('RadeonSI requires drm or surfaceless platform when using EGL')
285endif
286
Dylan Baker8e611872017-10-11 12:49:31 -0700287pre_args += '-DGLX_USE_TLS'
Dylan Bakera47c5252017-09-22 12:55:00 -0700288if with_glx != 'disabled'
Dylan Baker8d3b1212017-10-18 15:47:11 -0700289 if not (with_platform_x11 and with_any_opengl)
290 if with_glx == 'auto'
291 with_glx = 'disabled'
292 else
293 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
294 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700295 elif with_glx == 'gallium-xlib'
296 if not with_gallium
297 error('Gallium-xlib based GLX requires at least one gallium driver')
Dylan Bakerad9c2f52017-11-02 13:36:44 -0700298 elif not with_gallium_softpipe
299 error('Gallium-xlib based GLX requires softpipe or llvmpipe.')
Dylan Bakera47c5252017-09-22 12:55:00 -0700300 elif with_dri
301 error('gallium-xlib conflicts with any dri driver')
302 endif
Dylan Baker118a7f02017-11-01 17:42:41 -0700303 elif with_glx == 'xlib'
304 if with_dri
305 error('xlib conflicts with any dri driver')
306 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700307 elif with_glx == 'dri' and not with_dri
308 error('dri based GLX requires at least one DRI driver')
Dylan Bakera47c5252017-09-22 12:55:00 -0700309 endif
310endif
311
312with_glvnd = get_option('glvnd')
Dylan Baker8a36f022017-11-01 10:24:10 -0700313if with_glvnd
314 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
315 error('Cannot build glvnd support for GLX that is not DRI based.')
316 elif with_glx == 'disabled' and not with_egl
317 error('glvnd requires DRI based GLX and/or EGL')
318 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700319endif
320
321# TODO: toggle for this
322with_glx_direct = true
323
Dylan Bakerd1992252017-09-14 17:57:17 -0700324if with_vulkan_icd_dir == ''
325 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
326endif
327
Dylan Baker50c28df2017-09-29 17:53:01 -0700328with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
329with_dri3 = get_option('dri3')
330if with_dri3 == 'auto'
331 if host_machine.system() == 'linux' and with_dri2
332 with_dri3 = true
333 else
334 with_dri3 = false
335 endif
Dylan Baker05893312017-10-30 10:27:48 -0700336elif with_dri3 == 'true'
Dylan Baker50c28df2017-09-29 17:53:01 -0700337 with_dri3 = true
338else
339 with_dri3 = false
340endif
341
342if with_any_vk and (with_platform_x11 and not with_dri3)
343 error('Vulkan drivers require dri3 for X11 support')
344endif
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700345if with_dri or with_gallium
Dylan Baker108d2572017-10-18 12:20:43 -0700346 if with_glx == 'disabled' and not with_egl
Dylan Bakera47c5252017-09-22 12:55:00 -0700347 error('building dri or gallium drivers require at least one window system')
348 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700349endif
350
Dylan Baker50c28df2017-09-29 17:53:01 -0700351with_gallium_xvmc = false
352with_gallium_vdpau = false
353with_gallium_omx = false # this is bellagio
354with_gallium_va = false
355with_gallium_media = false
356dep_va = []
357_drivers = get_option('gallium-media')
358if _drivers != ''
359 _split = _drivers.split(',')
360 with_gallium_xvmc = _split.contains('xvmc')
361 with_gallium_vdpau = _split.contains('vdpau')
362 with_gallium_omx = _split.contains('omx')
363 with_gallium_va = _split.contains('va')
364 with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or
365 with_gallium_omx or with_gallium_va)
366endif
367
Dylan Baker108d2572017-10-18 12:20:43 -0700368gl_pkgconfig_c_flags = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700369if with_platform_x11
370 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
371 pre_args += '-DHAVE_X11_PLATFORM'
372 endif
Dylan Bakerad9c2f52017-11-02 13:36:44 -0700373 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
Dylan Baker118a7f02017-11-01 17:42:41 -0700374 pre_args += '-DUSE_XSHM'
Dylan Baker50c28df2017-09-29 17:53:01 -0700375 else
376 pre_args += '-DGLX_INDIRECT_RENDERING'
377 if with_glx_direct
378 pre_args += '-DGLX_DIRECT_RENDERING'
379 endif
380 if with_dri_platform == 'drm'
381 pre_args += '-DGLX_USE_DRM'
382 endif
383 endif
Dylan Baker108d2572017-10-18 12:20:43 -0700384else
385 pre_args += '-DMESA_EGL_NO_X11_HEADERS'
386 gl_pkgconfig_c_flags += '-DMESA_EGL_NO_X11_HEADERS'
387endif
388if with_platform_drm
389 if with_egl and not with_gbm
390 error('EGL drm platform requires gbm')
391 endif
392 pre_args += '-DHAVE_DRM_PLATFORM'
393endif
394if with_platform_surfaceless
395 pre_args += '-DHAVE_SURFACELESS_PLATFORM'
Dylan Baker50c28df2017-09-29 17:53:01 -0700396endif
Eric Engestromc5ec1552017-10-24 16:08:15 +0100397if with_platform_android
398 dep_android = [
399 dependency('cutils'),
400 dependency('hardware'),
401 dependency('sync'),
402 ]
403 pre_args += '-DHAVE_ANDROID_PLATFORM'
404endif
Dylan Baker50c28df2017-09-29 17:53:01 -0700405
Dylan Bakerd1992252017-09-14 17:57:17 -0700406prog_python2 = find_program('python2')
Dylan Baker9342a7d2017-09-28 10:48:30 -0700407has_mako = run_command(prog_python2, '-c', 'import mako')
408if has_mako.returncode() != 0
409 error('Python (2.x) mako module required to build mesa.')
410endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700411
412cc = meson.get_compiler('c')
413if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
Eric Engestrom1262e822017-09-29 15:25:18 +0100414 error('When using GCC, version 4.4.6 or later is required.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700415endif
416
Eric Engestrom1e6f9ea2017-11-06 17:18:06 +0000417# Define DEBUG for debug builds only (debugoptimized is not included on this one)
418if get_option('buildtype') == 'debug'
Dylan Bakerd1992252017-09-14 17:57:17 -0700419 pre_args += '-DDEBUG'
420endif
421
Dylan Baker673dda82017-09-20 11:53:29 -0700422if get_option('shader-cache')
423 pre_args += '-DENABLE_SHADER_CACHE'
424elif with_amd_vk
425 error('Radv requires shader cache support')
426endif
427
Dylan Bakerd1992252017-09-14 17:57:17 -0700428# Check for GCC style builtins
429foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
430 'ffsll', 'popcount', 'popcountll', 'unreachable']
431 if cc.has_function(b)
432 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
433 endif
434endforeach
435
Dylan Baker673dda82017-09-20 11:53:29 -0700436# check for GCC __attribute__
Dylan Bakerd1992252017-09-14 17:57:17 -0700437foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
438 'warn_unused_result', 'weak',]
439 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
440 name : '__attribute__((@0@))'.format(a))
441 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
442 endif
443endforeach
444if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
445 name : '__attribute__((format(...)))')
446 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
447endif
448if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
449 name : '__attribute__((packed))')
450 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
451endif
452if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
453 name : '__attribute__((returns_nonnull))')
454 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
455endif
456if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
457 int foo_hid(void) __attribute__((visibility("hidden")));
458 int foo_int(void) __attribute__((visibility("internal")));
459 int foo_pro(void) __attribute__((visibility("protected")));''',
460 name : '__attribute__((visibility(...)))')
461 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
462endif
463if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
464 name : '__attribute__((alias(...)))')
465 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
466endif
467
468# TODO: this is very incomplete
469if host_machine.system() == 'linux'
470 pre_args += '-D_GNU_SOURCE'
471endif
472
473# Check for generic C arguments
474c_args = []
475foreach a : ['-Wall', '-Werror=implicit-function-declaration',
476 '-Werror=missing-prototypes', '-fno-math-errno',
477 '-fno-trapping-math', '-Qunused-arguments']
478 if cc.has_argument(a)
479 c_args += a
480 endif
481endforeach
482c_vis_args = []
483if cc.has_argument('-fvisibility=hidden')
484 c_vis_args += '-fvisibility=hidden'
485endif
486
487# Check for generic C++ arguments
488cpp = meson.get_compiler('cpp')
489cpp_args = []
490foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
491 '-Qunused-arguments', '-Wno-non-virtual-dtor']
492 if cpp.has_argument(a)
493 cpp_args += a
494 endif
495endforeach
496cpp_vis_args = []
497if cpp.has_argument('-fvisibility=hidden')
498 cpp_vis_args += '-fvisibility=hidden'
499endif
500
501# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
502# in parts of the mesa code base that need to compile with old versions of
503# MSVC, mainly common code
504c_msvc_compat_args = []
505cpp_msvc_compat_args = []
506foreach a : ['-Werror=pointer-arith', '-Werror=vla']
507 if cc.has_argument(a)
508 c_msvc_compat_args += a
509 endif
510 if cpp.has_argument(a)
511 cpp_msvc_compat_args += a
512 endif
513endforeach
514
515no_override_init_args = []
516foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
517 if cc.has_argument(a)
518 no_override_init_args += a
519 endif
520endforeach
521
Dylan Baker84486f62017-11-15 16:09:22 -0800522if host_machine.cpu_family().startswith('x86')
523 pre_args += '-DHAVE_SSE41'
524 with_sse41 = true
525 sse41_args = ['-msse4.1']
526
527 # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
528 # that's not guaranteed
529 if host_machine.cpu_family() == 'x86'
530 sse41_args += '-mstackrealign'
531 endif
532else
533 with_sse41 = false
534 sse41_args = []
535endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700536
537# Check for GCC style atomics
538if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
539 name : 'GCC atomic builtins')
540 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
541endif
542if not cc.links('''#include <stdint.h>
543 uint64_t v;
544 int main() {
545 return __sync_add_and_fetch(&v, (uint64_t)1);
546 }''',
547 name : 'GCC 64bit atomics')
548 pre_args += '-DMISSING_64_BIT_ATOMICS'
549endif
550
551# TODO: endian
552# TODO: powr8
553# TODO: shared/static? Is this even worth doing?
554
Dylan Baker2d62fc02017-11-15 16:53:40 -0800555# Building x86 assembly code requires running x86 binaries. It is possible for
556# x86_64 OSes to run x86 binaries, so don't disable asm in those cases
557# TODO: it should be possible to use an exe_wrapper to run the binary during
558# the build.
559if meson.is_cross_build()
560 if not (build_machine.cpu_family() == 'x86_64' and host_machine.cpu_family() == 'x86'
561 and build_machine.system() == host_machine.system())
562 message('Cross compiling to x86 from non-x86, disabling asm')
563 with_asm = false
564 endif
Dylan Baker32180562017-09-20 20:11:32 -0700565endif
566
567with_asm_arch = ''
568if with_asm
569 # TODO: SPARC and PPC
570 if host_machine.cpu_family() == 'x86'
571 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
572 with_asm_arch = 'x86'
573 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
574 '-DUSE_SSE_ASM']
575 endif
576 elif host_machine.cpu_family() == 'x86_64'
577 if host_machine.system() == 'linux'
578 with_asm_arch = 'x86_64'
579 pre_args += ['-DUSE_X86_64_ASM']
580 endif
581 elif host_machine.cpu_family() == 'arm'
582 if host_machine.system() == 'linux'
583 with_asm_arch = 'arm'
584 pre_args += ['-DUSE_ARM_ASM']
585 endif
586 elif host_machine.cpu_family() == 'aarch64'
587 if host_machine.system() == 'linux'
588 with_asm_arch = 'aarch64'
589 pre_args += ['-DUSE_AARCH64_ASM']
590 endif
591 endif
592endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700593
594# Check for standard headers and functions
595if cc.has_header_symbol('sys/sysmacros.h', 'major')
596 pre_args += '-DMAJOR_IN_SYSMACROS'
597elif cc.has_header_symbol('sys/mkdev.h', 'major')
598 pre_args += '-DMAJOR_IN_MKDEV'
599endif
600
Timothy Arcerif98a2762017-10-16 18:06:49 +1100601foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h']
Dylan Bakerd1992252017-09-14 17:57:17 -0700602 if cc.has_header(h)
603 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
604 endif
605endforeach
606
Nicolai Hähnle2e3d0dd2017-11-15 12:41:58 +0100607foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get']
Dylan Bakerd1992252017-09-14 17:57:17 -0700608 if cc.has_function(f)
609 pre_args += '-DHAVE_@0@'.format(f.to_upper())
610 endif
611endforeach
612
613# strtod locale support
614if cc.links('''
615 #define _GNU_SOURCE
616 #include <stdlib.h>
617 #include <locale.h>
618 #ifdef HAVE_XLOCALE_H
619 #include <xlocale.h>
620 #endif
621 int main() {
622 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
623 const char *s = "1.0";
624 char *end;
625 double d = strtod_l(s, end, loc);
626 float f = strtod_l(s, end, loc);
627 freelocale(loc);
628 return 0;
629 }''',
630 extra_args : pre_args,
631 name : 'strtod has locale support')
632 pre_args += '-DHAVE_STRTOD_L'
633endif
634
635# Check for some linker flags
636ld_args_bsymbolic = []
Dylan Bakere21e0a62017-09-30 13:15:52 -0700637if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
Dylan Bakerd1992252017-09-14 17:57:17 -0700638 ld_args_bsymbolic += '-Wl,-Bsymbolic'
639endif
640ld_args_gc_sections = []
641if cc.links('static char unused() { return 5; } int main() { return 0; }',
Dylan Bakere21e0a62017-09-30 13:15:52 -0700642 args : '-Wl,--gc-sections', name : 'gc-sections')
Dylan Bakerd1992252017-09-14 17:57:17 -0700643 ld_args_gc_sections += '-Wl,--gc-sections'
644endif
Dylan Bakere21e0a62017-09-30 13:15:52 -0700645with_ld_version_script = false
646if cc.links('int main() { return 0; }',
647 args : '-Wl,--version-script=@0@'.format(
648 join_paths(meson.source_root(), 'build-support/conftest.map')),
649 name : 'version-script')
650 with_ld_version_script = true
651endif
652with_ld_dynamic_list = false
653if cc.links('int main() { return 0; }',
654 args : '-Wl,--dynamic-list=@0@'.format(
655 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
656 name : 'dynamic-list')
657 with_ld_dynamic_list = true
658endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700659
660# check for dl support
661if cc.has_function('dlopen')
662 dep_dl = []
663else
664 dep_dl = cc.find_library('dl')
665endif
Dylan Baker32180562017-09-20 20:11:32 -0700666if cc.has_function('dladdr', dependencies : dep_dl)
667 # This is really only required for megadrivers
668 pre_args += '-DHAVE_DLADDR'
Dylan Bakerd1992252017-09-14 17:57:17 -0700669endif
670
671if cc.has_function('dl_iterate_phdr')
672 pre_args += '-DHAVE_DL_ITERATE_PHDR'
Dylan Bakere89842e2017-11-15 17:07:37 -0800673elif with_intel_vk
674 error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
675elif with_dri_i965 and get_option('shader-cache')
676 error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700677endif
678
679# Determine whether or not the rt library is needed for time functions
680if cc.has_function('clock_gettime')
681 dep_clock = []
682else
683 dep_clock = cc.find_library('rt')
684endif
685
Dylan Baker66c94b92017-09-30 13:48:34 -0700686with_gallium_drisw_kms = false
Dylan Baker50c28df2017-09-29 17:53:01 -0700687dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
688 required : with_dri2 or with_dri3)
689if dep_libdrm.found()
690 pre_args += '-DHAVE_LIBDRM'
Dylan Baker66c94b92017-09-30 13:48:34 -0700691 if with_dri_platform == 'drm' and with_dri
692 with_gallium_drisw_kms = true
693 endif
Dylan Baker50c28df2017-09-29 17:53:01 -0700694endif
695
Dylan Bakerd1992252017-09-14 17:57:17 -0700696# TODO: some of these may be conditional
697dep_zlib = dependency('zlib', version : '>= 1.2.3')
698dep_thread = dependency('threads')
Jon Turney8ceccbf2017-11-13 10:13:39 +0000699if dep_thread.found() and host_machine.system() != 'windows'
Dylan Baker50c28df2017-09-29 17:53:01 -0700700 pre_args += '-DHAVE_PTHREAD'
701endif
Dylan Bakercc4f5872017-09-27 11:30:21 -0700702dep_elf = dependency('libelf', required : false)
Dylan Bakerb154b442017-09-30 14:04:28 -0700703if not dep_elf.found() and (with_amd_vk or with_gallium_radeonsi) # TODO: clover, r600
704 dep_elf = cc.find_library('elf')
Dylan Bakercc4f5872017-09-27 11:30:21 -0700705endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700706dep_expat = dependency('expat')
707# this only exists on linux so either this is linux and it will be found, or
708# its not linux and and wont
709dep_m = cc.find_library('m', required : false)
Dylan Baker66f97f62017-09-30 09:03:51 -0700710
711dep_libdrm_amdgpu = []
712dep_libdrm_radeon = []
Dylan Baker813b4b02017-10-09 14:59:35 -0700713dep_libdrm_nouveau = []
Dylan Baker51558a12017-10-20 15:45:22 -0700714dep_libdrm_etnaviv = []
Rob Clark4aa69cc2017-10-14 10:08:50 -0400715dep_libdrm_freedreno = []
Dylan Baker66f97f62017-09-30 09:03:51 -0700716if with_amd_vk or with_gallium_radeonsi
Andrey Grodzovsky19fc3cd2017-11-02 10:50:39 -0400717 dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.88')
Dylan Baker66f97f62017-09-30 09:03:51 -0700718endif
Dylan Bakereecd2862017-10-16 17:24:56 -0700719if with_gallium_radeonsi or with_dri_r100 or with_dri_r200
Dylan Baker66f97f62017-09-30 09:03:51 -0700720 dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
721endif
Dylan Bakereb3bb032017-10-16 17:51:47 -0700722if with_gallium_nouveau or with_dri_nouveau
Dylan Baker813b4b02017-10-09 14:59:35 -0700723 dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
724endif
Dylan Baker51558a12017-10-20 15:45:22 -0700725if with_gallium_etnaviv
726 dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
727endif
Rob Clark4aa69cc2017-10-14 10:08:50 -0400728if with_gallium_freedreno
729 dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.74')
730endif
Dylan Baker673dda82017-09-20 11:53:29 -0700731
732llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
Dylan Baker2d1a3bf2017-11-20 16:26:06 -0800733if with_amd_vk or with_gallium_radeonsi
Dylan Baker673dda82017-09-20 11:53:29 -0700734 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
735endif
Dylan Baker48f64e52017-11-17 16:37:50 -0800736
737_llvm = get_option('llvm')
738if _llvm == 'auto'
Eric Anholtd975e692017-11-08 11:52:09 -0800739 dep_llvm = dependency(
Dylan Baker48f64e52017-11-17 16:37:50 -0800740 'llvm', version : '>= 3.9.0', modules : llvm_modules,
Dylan Baker2d1a3bf2017-11-20 16:26:06 -0800741 required : with_amd_vk or with_gallium_radeonsi,
Eric Anholtd975e692017-11-08 11:52:09 -0800742 )
Dylan Baker48f64e52017-11-17 16:37:50 -0800743 with_llvm = dep_llvm.found()
744elif _llvm == 'true'
745 dep_llvm = dependency('llvm', version : '>= 3.9.0', modules : llvm_modules)
746 with_llvm = true
747else
748 dep_llvm = []
749 with_llvm = false
750endif
751if with_llvm
752 _llvm_version = dep_llvm.version().split('.')
753 # Development versions of LLVM have an 'svn' suffix, we don't want that for
754 # our version checks.
755 _llvm_patch = _llvm_version[2]
756 if _llvm_patch.endswith('svn')
757 _llvm_patch = _llvm_patch.split('s')[0]
Dylan Baker673dda82017-09-20 11:53:29 -0700758 endif
Dylan Baker48f64e52017-11-17 16:37:50 -0800759 pre_args += [
760 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
761 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
762 ]
Dylan Baker66f97f62017-09-30 09:03:51 -0700763elif with_amd_vk or with_gallium_radeonsi
764 error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM is disabled.')
Dylan Baker673dda82017-09-20 11:53:29 -0700765endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700766
Dylan Bakera47c5252017-09-22 12:55:00 -0700767dep_glvnd = []
768if with_glvnd
769 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
770 pre_args += '-DUSE_LIBGLVND=1'
771endif
772
Erik Faye-Lund5c2ff572017-10-25 10:02:38 +0200773if with_valgrind != 'false'
774 dep_valgrind = dependency('valgrind', required : with_valgrind == 'true')
775 if dep_valgrind.found()
776 pre_args += '-DHAVE_VALGRIND'
777 endif
778else
779 dep_valgrind = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700780endif
781
782# pthread stubs. Lets not and say we didn't
783
Dylan Baker32180562017-09-20 20:11:32 -0700784prog_bison = find_program('bison', required : with_any_opengl)
785prog_flex = find_program('flex', required : with_any_opengl)
786
Dylan Baker32180562017-09-20 20:11:32 -0700787dep_selinux = []
Eric Engestrom4b9421d2017-10-26 16:19:41 +0100788if get_option('selinux')
789 dep_selinux = dependency('libselinux')
790 pre_args += '-DMESA_SELINUX'
791endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700792
793# TODO: llvm-prefix and llvm-shared-libs
794
Erik Faye-Lund5c2ff572017-10-25 10:02:38 +0200795if with_libunwind != 'false'
796 dep_unwind = dependency('libunwind', required : with_libunwind == 'true')
797 if dep_unwind.found()
798 pre_args += '-DHAVE_LIBUNWIND'
799 endif
800else
801 dep_unwind = []
Dylan Bakerb1b65392017-09-28 22:25:02 -0700802endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700803
Dylan Bakerd1992252017-09-14 17:57:17 -0700804# TODO: gallium-hud
805
Dylan Bakercbbd5bb2017-10-20 21:48:18 -0700806if with_osmesa != 'none'
807 if with_osmesa == 'classic' and not with_dri_swrast
808 error('OSMesa classic requires dri (classic) swrast.')
809 endif
Dylan Bakerf121a662017-10-24 15:52:57 -0700810 if with_osmesa == 'gallium' and not with_gallium_softpipe
811 error('OSMesa gallium requires gallium softpipe or llvmpipe.')
812 endif
Dylan Bakercbbd5bb2017-10-20 21:48:18 -0700813 osmesa_lib_name = 'OSMesa'
814 osmesa_bits = get_option('osmesa-bits')
815 if osmesa_bits != '8'
816 if with_dri or with_glx != 'disabled'
817 error('OSMesa bits must be 8 if building glx or dir based drivers')
818 endif
819 osmesa_lib_name = osmesa_lib_name + osmesa_bits
820 pre_args += [
821 '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31'
822 ]
823 endif
824endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700825
Dylan Bakerd1992252017-09-14 17:57:17 -0700826# TODO: symbol mangling
827
Dylan Bakerd1992252017-09-14 17:57:17 -0700828if with_platform_wayland
829 prog_wl_scanner = find_program('wayland-scanner')
830 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
831 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
832 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
Dylan Baker108d2572017-10-18 12:20:43 -0700833 wayland_dmabuf_xml = join_paths(
834 dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
835 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
836 )
837 pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED']
Dylan Bakerd1992252017-09-14 17:57:17 -0700838else
839 prog_wl_scanner = []
840 dep_wl_protocols = []
841 dep_wayland_client = []
842 dep_wayland_server = []
Dylan Baker108d2572017-10-18 12:20:43 -0700843 wayland_dmabuf_xml = ''
Dylan Bakerd1992252017-09-14 17:57:17 -0700844endif
845
Dylan Baker50c28df2017-09-29 17:53:01 -0700846dep_x11 = []
847dep_xext = []
848dep_xdamage = []
849dep_xfixes = []
850dep_x11_xcb = []
Dylan Bakercbbd5bb2017-10-20 21:48:18 -0700851dep_xcb = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700852dep_xcb_glx = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700853dep_xcb_dri2 = []
854dep_xcb_dri3 = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700855dep_dri2proto = []
856dep_glproto = []
Dylan Baker1f11ac42017-10-24 11:34:04 -0700857dep_xxf86vm = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700858dep_xcb_dri3 = []
859dep_xcb_present = []
860dep_xcb_sync = []
Dylan Baker108d2572017-10-18 12:20:43 -0700861dep_xcb_xfixes = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700862dep_xshmfence = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700863if with_platform_x11
Dylan Bakerad9c2f52017-11-02 13:36:44 -0700864 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
Dylan Baker118a7f02017-11-01 17:42:41 -0700865 dep_x11 = dependency('x11')
866 dep_xext = dependency('xext')
867 dep_xcb = dependency('xcb')
868 elif with_glx == 'dri' and with_dri_platform == 'drm'
Dylan Baker50c28df2017-09-29 17:53:01 -0700869 dep_x11 = dependency('x11')
870 dep_xext = dependency('xext')
871 dep_xdamage = dependency('xdamage', version : '>= 1.1')
872 dep_xfixes = dependency('xfixes')
873 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
Dylan Baker1f11ac42017-10-24 11:34:04 -0700874 dep_xxf86vm = dependency('xxf86vm', required : false)
Dylan Bakera47c5252017-09-22 12:55:00 -0700875 endif
876 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
Dylan Baker50c28df2017-09-29 17:53:01 -0700877 dep_xcb = dependency('xcb')
878 dep_x11_xcb = dependency('x11-xcb')
879 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
880
Dylan Bakera47c5252017-09-22 12:55:00 -0700881 if with_dri3
882 pre_args += '-DHAVE_DRI3'
Dylan Baker50c28df2017-09-29 17:53:01 -0700883 dep_xcb_dri3 = dependency('xcb-dri3')
884 dep_xcb_present = dependency('xcb-present')
885 dep_xcb_sync = dependency('xcb-sync')
886 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
Dylan Bakera47c5252017-09-22 12:55:00 -0700887 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700888 endif
Dylan Baker118a7f02017-11-01 17:42:41 -0700889 if with_glx == 'dri'
Dylan Baker50c28df2017-09-29 17:53:01 -0700890 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
891 dep_glproto = dependency('glproto', version : '>= 1.4.14')
892 endif
Dylan Baker108d2572017-10-18 12:20:43 -0700893 if with_egl
894 dep_xcb_xfixes = dependency('xcb-xfixes')
895 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700896endif
897
Dylan Bakerd1992252017-09-14 17:57:17 -0700898# TODO: nine
899
900# TODO: clover
901
Dylan Bakerd1992252017-09-14 17:57:17 -0700902# TODO: gallium tests
903
904# TODO: various libdirs
905
906# TODO: swr
907
908# TODO: gallium driver dirs
909
910# FIXME: this is a workaround for #2326
911prog_touch = find_program('touch')
912dummy_cpp = custom_target(
913 'dummy_cpp',
914 output : 'dummy.cpp',
915 command : [prog_touch, '@OUTPUT@'],
916)
917
918foreach a : pre_args
919 add_project_arguments(a, language : ['c', 'cpp'])
920endforeach
921foreach a : c_args
922 add_project_arguments(a, language : ['c'])
923endforeach
924foreach a : cpp_args
925 add_project_arguments(a, language : ['cpp'])
926endforeach
927
928inc_include = include_directories('include')
929
Dylan Baker108d2572017-10-18 12:20:43 -0700930gl_priv_reqs = [
931 'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb',
932 'xcb-glx >= 1.8.1', 'libdrm >= 2.4.75',
933]
Dylan Baker1f11ac42017-10-24 11:34:04 -0700934if dep_xxf86vm != [] and dep_xxf86vm.found()
Dylan Bakerb92992e2017-10-24 11:28:42 -0700935 gl_priv_reqs += 'xxf86vm'
Dylan Baker108d2572017-10-18 12:20:43 -0700936endif
937if with_dri_platform == 'drm'
938 gl_priv_reqs += 'xcb-dri2 >= 1.8'
939endif
940
941gl_priv_libs = []
942if dep_thread.found()
943 gl_priv_libs += ['-lpthread', '-pthread']
944endif
945if dep_m.found()
946 gl_priv_libs += '-lm'
947endif
Jon Turney7df9a362017-11-13 10:13:54 +0000948if dep_dl != [] and dep_dl.found()
Dylan Baker108d2572017-10-18 12:20:43 -0700949 gl_priv_libs += '-ldl'
950endif
951
Dylan Baker32180562017-09-20 20:11:32 -0700952pkg = import('pkgconfig')
953
Dylan Bakerd1992252017-09-14 17:57:17 -0700954subdir('include')
Eric Engestrom05a94a42017-10-24 18:03:39 +0100955subdir('bin')
Dylan Bakerd1992252017-09-14 17:57:17 -0700956subdir('src')