blob: cfe4afa550ddca09740f9fe796462603751786c5 [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 Bakera47c5252017-09-22 12:55:00 -0700190# TODO: other OSes
191with_dri_platform = 'drm'
192
Eric Engestromc5ec1552017-10-24 16:08:15 +0100193with_platform_android = false
Dylan Bakerd1992252017-09-14 17:57:17 -0700194with_platform_wayland = false
195with_platform_x11 = false
Dylan Bakerb1b65392017-09-28 22:25:02 -0700196with_platform_drm = false
Dylan Baker108d2572017-10-18 12:20:43 -0700197with_platform_surfaceless = false
198egl_native_platform = ''
Dylan Bakerd1992252017-09-14 17:57:17 -0700199_platforms = get_option('platforms')
Dylan Baker4b61b072017-11-15 17:31:32 -0800200if _platforms == 'auto'
201 if ['linux'].contains(host_machine.system())
202 _platforms = 'x11,wayland,drm,surfaceless'
203 else
204 error('Unknown OS, no platforms enabled. Patches gladly accepted to fix this.')
205 endif
206endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700207if _platforms != ''
208 _split = _platforms.split(',')
Eric Engestromc5ec1552017-10-24 16:08:15 +0100209 with_platform_android = _split.contains('android')
Dylan Bakerd1992252017-09-14 17:57:17 -0700210 with_platform_x11 = _split.contains('x11')
211 with_platform_wayland = _split.contains('wayland')
Dylan Bakerb1b65392017-09-28 22:25:02 -0700212 with_platform_drm = _split.contains('drm')
Dylan Baker108d2572017-10-18 12:20:43 -0700213 with_platform_surfaceless = _split.contains('surfaceless')
214 egl_native_platform = _split[0]
Dylan Bakerd1992252017-09-14 17:57:17 -0700215endif
216
Dylan Baker118a7f02017-11-01 17:42:41 -0700217with_glx = get_option('glx')
218if with_glx == 'auto'
219 if with_dri
220 with_glx = 'dri'
221 elif with_gallium
Dylan Bakerad9c2f52017-11-02 13:36:44 -0700222 # Even when building just gallium drivers the user probably wants dri
223 with_glx = 'dri'
224 with_dri = true
Dylan Baker118a7f02017-11-01 17:42:41 -0700225 elif with_platform_x11 and with_any_opengl and not with_any_vk
226 # The automatic behavior should not be to turn on xlib based glx when
227 # building only vulkan drivers
228 with_glx = 'xlib'
229 else
230 with_glx = 'disabled'
231 endif
232endif
233
Dylan Bakerad9c2f52017-11-02 13:36:44 -0700234if not (with_dri or with_gallium or with_glx == 'xlib' or with_glx == 'gallium-xlib')
Dylan Baker118a7f02017-11-01 17:42:41 -0700235 with_gles1 = false
236 with_gles2 = false
237 with_opengl = false
238 with_any_opengl = false
239 with_shared_glapi = false
240endif
241
Dylan Baker816bf7d12017-09-28 15:53:53 -0700242with_gbm = get_option('gbm')
243if with_gbm == 'auto' and with_dri # TODO: or gallium
244 with_gbm = host_machine.system() == 'linux'
Dylan Baker05893312017-10-30 10:27:48 -0700245elif with_gbm == 'true'
Dylan Baker816bf7d12017-09-28 15:53:53 -0700246 if not ['linux', 'bsd'].contains(host_machine.system())
247 error('GBM only supports unix-like platforms')
248 endif
249 with_gbm = true
250else
251 with_gbm = false
252endif
253
Dylan Baker108d2572017-10-18 12:20:43 -0700254_egl = get_option('egl')
255if _egl == 'auto'
256 with_egl = with_dri and with_shared_glapi and egl_native_platform != ''
Dylan Baker05893312017-10-30 10:27:48 -0700257elif _egl == 'true'
Dylan Baker108d2572017-10-18 12:20:43 -0700258 if not with_dri
259 error('EGL requires dri')
260 elif not with_shared_glapi
261 error('EGL requires shared-glapi')
262 elif egl_native_platform == ''
263 error('No platforms specified, consider -Dplatforms=drm,x11 at least')
264 endif
265 with_egl = true
266else
267 with_egl = false
268endif
269
270# TODO: or virgl
271if with_egl and with_gallium_radeonsi and not (with_platform_drm or with_platform_surfaceless)
272 error('RadeonSI requires drm or surfaceless platform when using EGL')
273endif
274
Dylan Baker8e611872017-10-11 12:49:31 -0700275pre_args += '-DGLX_USE_TLS'
Dylan Bakera47c5252017-09-22 12:55:00 -0700276if with_glx != 'disabled'
Dylan Baker8d3b1212017-10-18 15:47:11 -0700277 if not (with_platform_x11 and with_any_opengl)
278 if with_glx == 'auto'
279 with_glx = 'disabled'
280 else
281 error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
282 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700283 elif with_glx == 'gallium-xlib'
284 if not with_gallium
285 error('Gallium-xlib based GLX requires at least one gallium driver')
Dylan Bakerad9c2f52017-11-02 13:36:44 -0700286 elif not with_gallium_softpipe
287 error('Gallium-xlib based GLX requires softpipe or llvmpipe.')
Dylan Bakera47c5252017-09-22 12:55:00 -0700288 elif with_dri
289 error('gallium-xlib conflicts with any dri driver')
290 endif
Dylan Baker118a7f02017-11-01 17:42:41 -0700291 elif with_glx == 'xlib'
292 if with_dri
293 error('xlib conflicts with any dri driver')
294 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700295 elif with_glx == 'dri' and not with_dri
296 error('dri based GLX requires at least one DRI driver')
Dylan Bakera47c5252017-09-22 12:55:00 -0700297 endif
298endif
299
300with_glvnd = get_option('glvnd')
Dylan Baker8a36f022017-11-01 10:24:10 -0700301if with_glvnd
302 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
303 error('Cannot build glvnd support for GLX that is not DRI based.')
304 elif with_glx == 'disabled' and not with_egl
305 error('glvnd requires DRI based GLX and/or EGL')
306 endif
Dylan Bakera47c5252017-09-22 12:55:00 -0700307endif
308
309# TODO: toggle for this
310with_glx_direct = true
311
Dylan Bakerd1992252017-09-14 17:57:17 -0700312if with_vulkan_icd_dir == ''
313 with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d')
314endif
315
Dylan Baker50c28df2017-09-29 17:53:01 -0700316with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm'
317with_dri3 = get_option('dri3')
318if with_dri3 == 'auto'
319 if host_machine.system() == 'linux' and with_dri2
320 with_dri3 = true
321 else
322 with_dri3 = false
323 endif
Dylan Baker05893312017-10-30 10:27:48 -0700324elif with_dri3 == 'true'
Dylan Baker50c28df2017-09-29 17:53:01 -0700325 with_dri3 = true
326else
327 with_dri3 = false
328endif
329
330if with_any_vk and (with_platform_x11 and not with_dri3)
331 error('Vulkan drivers require dri3 for X11 support')
332endif
Dylan Bakeraf9d2762017-09-28 21:03:07 -0700333if with_dri or with_gallium
Dylan Baker108d2572017-10-18 12:20:43 -0700334 if with_glx == 'disabled' and not with_egl
Dylan Bakera47c5252017-09-22 12:55:00 -0700335 error('building dri or gallium drivers require at least one window system')
336 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700337endif
338
Dylan Baker50c28df2017-09-29 17:53:01 -0700339with_gallium_xvmc = false
340with_gallium_vdpau = false
341with_gallium_omx = false # this is bellagio
342with_gallium_va = false
343with_gallium_media = false
344dep_va = []
345_drivers = get_option('gallium-media')
346if _drivers != ''
347 _split = _drivers.split(',')
348 with_gallium_xvmc = _split.contains('xvmc')
349 with_gallium_vdpau = _split.contains('vdpau')
350 with_gallium_omx = _split.contains('omx')
351 with_gallium_va = _split.contains('va')
352 with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or
353 with_gallium_omx or with_gallium_va)
354endif
355
Dylan Baker108d2572017-10-18 12:20:43 -0700356gl_pkgconfig_c_flags = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700357if with_platform_x11
358 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
359 pre_args += '-DHAVE_X11_PLATFORM'
360 endif
Dylan Bakerad9c2f52017-11-02 13:36:44 -0700361 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
Dylan Baker118a7f02017-11-01 17:42:41 -0700362 pre_args += '-DUSE_XSHM'
Dylan Baker50c28df2017-09-29 17:53:01 -0700363 else
364 pre_args += '-DGLX_INDIRECT_RENDERING'
365 if with_glx_direct
366 pre_args += '-DGLX_DIRECT_RENDERING'
367 endif
368 if with_dri_platform == 'drm'
369 pre_args += '-DGLX_USE_DRM'
370 endif
371 endif
Dylan Baker108d2572017-10-18 12:20:43 -0700372else
373 pre_args += '-DMESA_EGL_NO_X11_HEADERS'
374 gl_pkgconfig_c_flags += '-DMESA_EGL_NO_X11_HEADERS'
375endif
376if with_platform_drm
377 if with_egl and not with_gbm
378 error('EGL drm platform requires gbm')
379 endif
380 pre_args += '-DHAVE_DRM_PLATFORM'
381endif
382if with_platform_surfaceless
383 pre_args += '-DHAVE_SURFACELESS_PLATFORM'
Dylan Baker50c28df2017-09-29 17:53:01 -0700384endif
Eric Engestromc5ec1552017-10-24 16:08:15 +0100385if with_platform_android
386 dep_android = [
387 dependency('cutils'),
388 dependency('hardware'),
389 dependency('sync'),
390 ]
391 pre_args += '-DHAVE_ANDROID_PLATFORM'
392endif
Dylan Baker50c28df2017-09-29 17:53:01 -0700393
Dylan Bakerd1992252017-09-14 17:57:17 -0700394prog_python2 = find_program('python2')
Dylan Baker9342a7d2017-09-28 10:48:30 -0700395has_mako = run_command(prog_python2, '-c', 'import mako')
396if has_mako.returncode() != 0
397 error('Python (2.x) mako module required to build mesa.')
398endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700399
400cc = meson.get_compiler('c')
401if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
Eric Engestrom1262e822017-09-29 15:25:18 +0100402 error('When using GCC, version 4.4.6 or later is required.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700403endif
404
Eric Engestrom1e6f9ea2017-11-06 17:18:06 +0000405# Define DEBUG for debug builds only (debugoptimized is not included on this one)
406if get_option('buildtype') == 'debug'
Dylan Bakerd1992252017-09-14 17:57:17 -0700407 pre_args += '-DDEBUG'
408endif
409
Dylan Baker673dda82017-09-20 11:53:29 -0700410if get_option('shader-cache')
411 pre_args += '-DENABLE_SHADER_CACHE'
412elif with_amd_vk
413 error('Radv requires shader cache support')
414endif
415
Dylan Bakerd1992252017-09-14 17:57:17 -0700416# Check for GCC style builtins
417foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
418 'ffsll', 'popcount', 'popcountll', 'unreachable']
419 if cc.has_function(b)
420 pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
421 endif
422endforeach
423
Dylan Baker673dda82017-09-20 11:53:29 -0700424# check for GCC __attribute__
Dylan Bakerd1992252017-09-14 17:57:17 -0700425foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused',
426 'warn_unused_result', 'weak',]
427 if cc.compiles('int foo(void) __attribute__((@0@));'.format(a),
428 name : '__attribute__((@0@))'.format(a))
429 pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())
430 endif
431endforeach
432if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));',
433 name : '__attribute__((format(...)))')
434 pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT'
435endif
436if cc.compiles('struct __attribute__((packed)) foo { int bar; };',
437 name : '__attribute__((packed))')
438 pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED'
439endif
440if cc.compiles('int *foo(void) __attribute__((returns_nonnull));',
441 name : '__attribute__((returns_nonnull))')
442 pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL'
443endif
444if cc.compiles('''int foo_def(void) __attribute__((visibility("default")));
445 int foo_hid(void) __attribute__((visibility("hidden")));
446 int foo_int(void) __attribute__((visibility("internal")));
447 int foo_pro(void) __attribute__((visibility("protected")));''',
448 name : '__attribute__((visibility(...)))')
449 pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY'
450endif
451if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));',
452 name : '__attribute__((alias(...)))')
453 pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS'
454endif
455
456# TODO: this is very incomplete
457if host_machine.system() == 'linux'
458 pre_args += '-D_GNU_SOURCE'
459endif
460
461# Check for generic C arguments
462c_args = []
463foreach a : ['-Wall', '-Werror=implicit-function-declaration',
464 '-Werror=missing-prototypes', '-fno-math-errno',
465 '-fno-trapping-math', '-Qunused-arguments']
466 if cc.has_argument(a)
467 c_args += a
468 endif
469endforeach
470c_vis_args = []
471if cc.has_argument('-fvisibility=hidden')
472 c_vis_args += '-fvisibility=hidden'
473endif
474
475# Check for generic C++ arguments
476cpp = meson.get_compiler('cpp')
477cpp_args = []
478foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
479 '-Qunused-arguments', '-Wno-non-virtual-dtor']
480 if cpp.has_argument(a)
481 cpp_args += a
482 endif
483endforeach
484cpp_vis_args = []
485if cpp.has_argument('-fvisibility=hidden')
486 cpp_vis_args += '-fvisibility=hidden'
487endif
488
489# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
490# in parts of the mesa code base that need to compile with old versions of
491# MSVC, mainly common code
492c_msvc_compat_args = []
493cpp_msvc_compat_args = []
494foreach a : ['-Werror=pointer-arith', '-Werror=vla']
495 if cc.has_argument(a)
496 c_msvc_compat_args += a
497 endif
498 if cpp.has_argument(a)
499 cpp_msvc_compat_args += a
500 endif
501endforeach
502
503no_override_init_args = []
504foreach a : ['-Wno-override-init', '-Wno-initializer-overrides']
505 if cc.has_argument(a)
506 no_override_init_args += a
507 endif
508endforeach
509
Dylan Baker84486f62017-11-15 16:09:22 -0800510if host_machine.cpu_family().startswith('x86')
511 pre_args += '-DHAVE_SSE41'
512 with_sse41 = true
513 sse41_args = ['-msse4.1']
514
515 # GCC on x86 (not x86_64) with -msse* assumes a 16 byte aligned stack, but
516 # that's not guaranteed
517 if host_machine.cpu_family() == 'x86'
518 sse41_args += '-mstackrealign'
519 endif
520else
521 with_sse41 = false
522 sse41_args = []
523endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700524
525# Check for GCC style atomics
526if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }',
527 name : 'GCC atomic builtins')
528 pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
529endif
530if not cc.links('''#include <stdint.h>
531 uint64_t v;
532 int main() {
533 return __sync_add_and_fetch(&v, (uint64_t)1);
534 }''',
535 name : 'GCC 64bit atomics')
536 pre_args += '-DMISSING_64_BIT_ATOMICS'
537endif
538
539# TODO: endian
540# TODO: powr8
541# TODO: shared/static? Is this even worth doing?
542
Dylan Baker2d62fc02017-11-15 16:53:40 -0800543# Building x86 assembly code requires running x86 binaries. It is possible for
544# x86_64 OSes to run x86 binaries, so don't disable asm in those cases
545# TODO: it should be possible to use an exe_wrapper to run the binary during
546# the build.
547if meson.is_cross_build()
548 if not (build_machine.cpu_family() == 'x86_64' and host_machine.cpu_family() == 'x86'
549 and build_machine.system() == host_machine.system())
550 message('Cross compiling to x86 from non-x86, disabling asm')
551 with_asm = false
552 endif
Dylan Baker32180562017-09-20 20:11:32 -0700553endif
554
555with_asm_arch = ''
556if with_asm
557 # TODO: SPARC and PPC
558 if host_machine.cpu_family() == 'x86'
559 if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
560 with_asm_arch = 'x86'
561 pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
562 '-DUSE_SSE_ASM']
563 endif
564 elif host_machine.cpu_family() == 'x86_64'
565 if host_machine.system() == 'linux'
566 with_asm_arch = 'x86_64'
567 pre_args += ['-DUSE_X86_64_ASM']
568 endif
569 elif host_machine.cpu_family() == 'arm'
570 if host_machine.system() == 'linux'
571 with_asm_arch = 'arm'
572 pre_args += ['-DUSE_ARM_ASM']
573 endif
574 elif host_machine.cpu_family() == 'aarch64'
575 if host_machine.system() == 'linux'
576 with_asm_arch = 'aarch64'
577 pre_args += ['-DUSE_AARCH64_ASM']
578 endif
579 endif
580endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700581
582# Check for standard headers and functions
583if cc.has_header_symbol('sys/sysmacros.h', 'major')
584 pre_args += '-DMAJOR_IN_SYSMACROS'
585elif cc.has_header_symbol('sys/mkdev.h', 'major')
586 pre_args += '-DMAJOR_IN_MKDEV'
587endif
588
Timothy Arcerif98a2762017-10-16 18:06:49 +1100589foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h']
Dylan Bakerd1992252017-09-14 17:57:17 -0700590 if cc.has_header(h)
591 pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
592 endif
593endforeach
594
Nicolai Hähnle2e3d0dd2017-11-15 12:41:58 +0100595foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get']
Dylan Bakerd1992252017-09-14 17:57:17 -0700596 if cc.has_function(f)
597 pre_args += '-DHAVE_@0@'.format(f.to_upper())
598 endif
599endforeach
600
601# strtod locale support
602if cc.links('''
603 #define _GNU_SOURCE
604 #include <stdlib.h>
605 #include <locale.h>
606 #ifdef HAVE_XLOCALE_H
607 #include <xlocale.h>
608 #endif
609 int main() {
610 locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL);
611 const char *s = "1.0";
612 char *end;
613 double d = strtod_l(s, end, loc);
614 float f = strtod_l(s, end, loc);
615 freelocale(loc);
616 return 0;
617 }''',
618 extra_args : pre_args,
619 name : 'strtod has locale support')
620 pre_args += '-DHAVE_STRTOD_L'
621endif
622
623# Check for some linker flags
624ld_args_bsymbolic = []
Dylan Bakere21e0a62017-09-30 13:15:52 -0700625if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic')
Dylan Bakerd1992252017-09-14 17:57:17 -0700626 ld_args_bsymbolic += '-Wl,-Bsymbolic'
627endif
628ld_args_gc_sections = []
629if cc.links('static char unused() { return 5; } int main() { return 0; }',
Dylan Bakere21e0a62017-09-30 13:15:52 -0700630 args : '-Wl,--gc-sections', name : 'gc-sections')
Dylan Bakerd1992252017-09-14 17:57:17 -0700631 ld_args_gc_sections += '-Wl,--gc-sections'
632endif
Dylan Bakere21e0a62017-09-30 13:15:52 -0700633with_ld_version_script = false
634if cc.links('int main() { return 0; }',
635 args : '-Wl,--version-script=@0@'.format(
636 join_paths(meson.source_root(), 'build-support/conftest.map')),
637 name : 'version-script')
638 with_ld_version_script = true
639endif
640with_ld_dynamic_list = false
641if cc.links('int main() { return 0; }',
642 args : '-Wl,--dynamic-list=@0@'.format(
643 join_paths(meson.source_root(), 'build-support/conftest.dyn')),
644 name : 'dynamic-list')
645 with_ld_dynamic_list = true
646endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700647
648# check for dl support
649if cc.has_function('dlopen')
650 dep_dl = []
651else
652 dep_dl = cc.find_library('dl')
653endif
Dylan Baker32180562017-09-20 20:11:32 -0700654if cc.has_function('dladdr', dependencies : dep_dl)
655 # This is really only required for megadrivers
656 pre_args += '-DHAVE_DLADDR'
Dylan Bakerd1992252017-09-14 17:57:17 -0700657endif
658
659if cc.has_function('dl_iterate_phdr')
660 pre_args += '-DHAVE_DL_ITERATE_PHDR'
Dylan Bakere89842e2017-11-15 17:07:37 -0800661elif with_intel_vk
662 error('Intel "Anvil" Vulkan driver requires the dl_iterate_phdr function')
663elif with_dri_i965 and get_option('shader-cache')
664 error('Intel i965 GL driver requires dl_iterate_phdr when built with shader caching.')
Dylan Bakerd1992252017-09-14 17:57:17 -0700665endif
666
667# Determine whether or not the rt library is needed for time functions
668if cc.has_function('clock_gettime')
669 dep_clock = []
670else
671 dep_clock = cc.find_library('rt')
672endif
673
Dylan Baker66c94b92017-09-30 13:48:34 -0700674with_gallium_drisw_kms = false
Dylan Baker50c28df2017-09-29 17:53:01 -0700675dep_libdrm = dependency('libdrm', version : '>= 2.4.75',
676 required : with_dri2 or with_dri3)
677if dep_libdrm.found()
678 pre_args += '-DHAVE_LIBDRM'
Dylan Baker66c94b92017-09-30 13:48:34 -0700679 if with_dri_platform == 'drm' and with_dri
680 with_gallium_drisw_kms = true
681 endif
Dylan Baker50c28df2017-09-29 17:53:01 -0700682endif
683
Dylan Bakerd1992252017-09-14 17:57:17 -0700684# TODO: some of these may be conditional
685dep_zlib = dependency('zlib', version : '>= 1.2.3')
686dep_thread = dependency('threads')
Jon Turney8ceccbf2017-11-13 10:13:39 +0000687if dep_thread.found() and host_machine.system() != 'windows'
Dylan Baker50c28df2017-09-29 17:53:01 -0700688 pre_args += '-DHAVE_PTHREAD'
689endif
Dylan Bakercc4f5872017-09-27 11:30:21 -0700690dep_elf = dependency('libelf', required : false)
Dylan Bakerb154b442017-09-30 14:04:28 -0700691if not dep_elf.found() and (with_amd_vk or with_gallium_radeonsi) # TODO: clover, r600
692 dep_elf = cc.find_library('elf')
Dylan Bakercc4f5872017-09-27 11:30:21 -0700693endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700694dep_expat = dependency('expat')
695# this only exists on linux so either this is linux and it will be found, or
696# its not linux and and wont
697dep_m = cc.find_library('m', required : false)
Dylan Baker66f97f62017-09-30 09:03:51 -0700698
699dep_libdrm_amdgpu = []
700dep_libdrm_radeon = []
Dylan Baker813b4b02017-10-09 14:59:35 -0700701dep_libdrm_nouveau = []
Dylan Baker51558a12017-10-20 15:45:22 -0700702dep_libdrm_etnaviv = []
Rob Clark4aa69cc2017-10-14 10:08:50 -0400703dep_libdrm_freedreno = []
Dylan Baker66f97f62017-09-30 09:03:51 -0700704if with_amd_vk or with_gallium_radeonsi
Andrey Grodzovsky19fc3cd2017-11-02 10:50:39 -0400705 dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.88')
Dylan Baker66f97f62017-09-30 09:03:51 -0700706endif
Dylan Bakereecd2862017-10-16 17:24:56 -0700707if with_gallium_radeonsi or with_dri_r100 or with_dri_r200
Dylan Baker66f97f62017-09-30 09:03:51 -0700708 dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71')
709endif
Dylan Bakereb3bb032017-10-16 17:51:47 -0700710if with_gallium_nouveau or with_dri_nouveau
Dylan Baker813b4b02017-10-09 14:59:35 -0700711 dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
712endif
Dylan Baker51558a12017-10-20 15:45:22 -0700713if with_gallium_etnaviv
714 dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
715endif
Rob Clark4aa69cc2017-10-14 10:08:50 -0400716if with_gallium_freedreno
717 dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.74')
718endif
Dylan Baker673dda82017-09-20 11:53:29 -0700719
720llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit']
721if with_amd_vk
722 llvm_modules += ['amdgpu', 'bitreader', 'ipo']
723endif
Dylan Baker48f64e52017-11-17 16:37:50 -0800724
725_llvm = get_option('llvm')
726if _llvm == 'auto'
Eric Anholtd975e692017-11-08 11:52:09 -0800727 dep_llvm = dependency(
Dylan Baker48f64e52017-11-17 16:37:50 -0800728 'llvm', version : '>= 3.9.0', modules : llvm_modules,
729 required : with_amd_vk,
Eric Anholtd975e692017-11-08 11:52:09 -0800730 )
Dylan Baker48f64e52017-11-17 16:37:50 -0800731 with_llvm = dep_llvm.found()
732elif _llvm == 'true'
733 dep_llvm = dependency('llvm', version : '>= 3.9.0', modules : llvm_modules)
734 with_llvm = true
735else
736 dep_llvm = []
737 with_llvm = false
738endif
739if with_llvm
740 _llvm_version = dep_llvm.version().split('.')
741 # Development versions of LLVM have an 'svn' suffix, we don't want that for
742 # our version checks.
743 _llvm_patch = _llvm_version[2]
744 if _llvm_patch.endswith('svn')
745 _llvm_patch = _llvm_patch.split('s')[0]
Dylan Baker673dda82017-09-20 11:53:29 -0700746 endif
Dylan Baker48f64e52017-11-17 16:37:50 -0800747 pre_args += [
748 '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch),
749 '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch),
750 ]
Dylan Baker66f97f62017-09-30 09:03:51 -0700751elif with_amd_vk or with_gallium_radeonsi
752 error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM is disabled.')
Dylan Baker673dda82017-09-20 11:53:29 -0700753endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700754
Dylan Bakera47c5252017-09-22 12:55:00 -0700755dep_glvnd = []
756if with_glvnd
757 dep_glvnd = dependency('libglvnd', version : '>= 0.2.0')
758 pre_args += '-DUSE_LIBGLVND=1'
759endif
760
Erik Faye-Lund5c2ff572017-10-25 10:02:38 +0200761if with_valgrind != 'false'
762 dep_valgrind = dependency('valgrind', required : with_valgrind == 'true')
763 if dep_valgrind.found()
764 pre_args += '-DHAVE_VALGRIND'
765 endif
766else
767 dep_valgrind = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700768endif
769
770# pthread stubs. Lets not and say we didn't
771
Dylan Baker32180562017-09-20 20:11:32 -0700772prog_bison = find_program('bison', required : with_any_opengl)
773prog_flex = find_program('flex', required : with_any_opengl)
774
Dylan Baker32180562017-09-20 20:11:32 -0700775dep_selinux = []
Eric Engestrom4b9421d2017-10-26 16:19:41 +0100776if get_option('selinux')
777 dep_selinux = dependency('libselinux')
778 pre_args += '-DMESA_SELINUX'
779endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700780
781# TODO: llvm-prefix and llvm-shared-libs
782
Erik Faye-Lund5c2ff572017-10-25 10:02:38 +0200783if with_libunwind != 'false'
784 dep_unwind = dependency('libunwind', required : with_libunwind == 'true')
785 if dep_unwind.found()
786 pre_args += '-DHAVE_LIBUNWIND'
787 endif
788else
789 dep_unwind = []
Dylan Bakerb1b65392017-09-28 22:25:02 -0700790endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700791
Dylan Bakerd1992252017-09-14 17:57:17 -0700792# TODO: gallium-hud
793
Dylan Bakercbbd5bb2017-10-20 21:48:18 -0700794if with_osmesa != 'none'
795 if with_osmesa == 'classic' and not with_dri_swrast
796 error('OSMesa classic requires dri (classic) swrast.')
797 endif
Dylan Bakerf121a662017-10-24 15:52:57 -0700798 if with_osmesa == 'gallium' and not with_gallium_softpipe
799 error('OSMesa gallium requires gallium softpipe or llvmpipe.')
800 endif
Dylan Bakercbbd5bb2017-10-20 21:48:18 -0700801 osmesa_lib_name = 'OSMesa'
802 osmesa_bits = get_option('osmesa-bits')
803 if osmesa_bits != '8'
804 if with_dri or with_glx != 'disabled'
805 error('OSMesa bits must be 8 if building glx or dir based drivers')
806 endif
807 osmesa_lib_name = osmesa_lib_name + osmesa_bits
808 pre_args += [
809 '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31'
810 ]
811 endif
812endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700813
Dylan Bakerd1992252017-09-14 17:57:17 -0700814# TODO: symbol mangling
815
Dylan Bakerd1992252017-09-14 17:57:17 -0700816if with_platform_wayland
817 prog_wl_scanner = find_program('wayland-scanner')
818 dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
819 dep_wayland_client = dependency('wayland-client', version : '>=1.11')
820 dep_wayland_server = dependency('wayland-server', version : '>=1.11')
Dylan Baker108d2572017-10-18 12:20:43 -0700821 wayland_dmabuf_xml = join_paths(
822 dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
823 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
824 )
825 pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED']
Dylan Bakerd1992252017-09-14 17:57:17 -0700826else
827 prog_wl_scanner = []
828 dep_wl_protocols = []
829 dep_wayland_client = []
830 dep_wayland_server = []
Dylan Baker108d2572017-10-18 12:20:43 -0700831 wayland_dmabuf_xml = ''
Dylan Bakerd1992252017-09-14 17:57:17 -0700832endif
833
Dylan Baker50c28df2017-09-29 17:53:01 -0700834dep_x11 = []
835dep_xext = []
836dep_xdamage = []
837dep_xfixes = []
838dep_x11_xcb = []
Dylan Bakercbbd5bb2017-10-20 21:48:18 -0700839dep_xcb = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700840dep_xcb_glx = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700841dep_xcb_dri2 = []
842dep_xcb_dri3 = []
Dylan Bakera47c5252017-09-22 12:55:00 -0700843dep_dri2proto = []
844dep_glproto = []
Dylan Baker1f11ac42017-10-24 11:34:04 -0700845dep_xxf86vm = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700846dep_xcb_dri3 = []
847dep_xcb_present = []
848dep_xcb_sync = []
Dylan Baker108d2572017-10-18 12:20:43 -0700849dep_xcb_xfixes = []
Dylan Baker50c28df2017-09-29 17:53:01 -0700850dep_xshmfence = []
Dylan Bakerd1992252017-09-14 17:57:17 -0700851if with_platform_x11
Dylan Bakerad9c2f52017-11-02 13:36:44 -0700852 if with_glx == 'xlib' or with_glx == 'gallium-xlib'
Dylan Baker118a7f02017-11-01 17:42:41 -0700853 dep_x11 = dependency('x11')
854 dep_xext = dependency('xext')
855 dep_xcb = dependency('xcb')
856 elif with_glx == 'dri' and with_dri_platform == 'drm'
Dylan Baker50c28df2017-09-29 17:53:01 -0700857 dep_x11 = dependency('x11')
858 dep_xext = dependency('xext')
859 dep_xdamage = dependency('xdamage', version : '>= 1.1')
860 dep_xfixes = dependency('xfixes')
861 dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
Dylan Baker1f11ac42017-10-24 11:34:04 -0700862 dep_xxf86vm = dependency('xxf86vm', required : false)
Dylan Bakera47c5252017-09-22 12:55:00 -0700863 endif
864 if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm')
Dylan Baker50c28df2017-09-29 17:53:01 -0700865 dep_xcb = dependency('xcb')
866 dep_x11_xcb = dependency('x11-xcb')
867 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8')
868
Dylan Bakera47c5252017-09-22 12:55:00 -0700869 if with_dri3
870 pre_args += '-DHAVE_DRI3'
Dylan Baker50c28df2017-09-29 17:53:01 -0700871 dep_xcb_dri3 = dependency('xcb-dri3')
872 dep_xcb_present = dependency('xcb-present')
873 dep_xcb_sync = dependency('xcb-sync')
874 dep_xshmfence = dependency('xshmfence', version : '>= 1.1')
Dylan Bakera47c5252017-09-22 12:55:00 -0700875 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700876 endif
Dylan Baker118a7f02017-11-01 17:42:41 -0700877 if with_glx == 'dri'
Dylan Baker50c28df2017-09-29 17:53:01 -0700878 dep_dri2proto = dependency('dri2proto', version : '>= 2.8')
879 dep_glproto = dependency('glproto', version : '>= 1.4.14')
880 endif
Dylan Baker108d2572017-10-18 12:20:43 -0700881 if with_egl
882 dep_xcb_xfixes = dependency('xcb-xfixes')
883 endif
Dylan Bakerd1992252017-09-14 17:57:17 -0700884endif
885
Dylan Bakerd1992252017-09-14 17:57:17 -0700886# TODO: nine
887
888# TODO: clover
889
Dylan Bakerd1992252017-09-14 17:57:17 -0700890# TODO: gallium tests
891
892# TODO: various libdirs
893
894# TODO: swr
895
896# TODO: gallium driver dirs
897
898# FIXME: this is a workaround for #2326
899prog_touch = find_program('touch')
900dummy_cpp = custom_target(
901 'dummy_cpp',
902 output : 'dummy.cpp',
903 command : [prog_touch, '@OUTPUT@'],
904)
905
906foreach a : pre_args
907 add_project_arguments(a, language : ['c', 'cpp'])
908endforeach
909foreach a : c_args
910 add_project_arguments(a, language : ['c'])
911endforeach
912foreach a : cpp_args
913 add_project_arguments(a, language : ['cpp'])
914endforeach
915
916inc_include = include_directories('include')
917
Dylan Baker108d2572017-10-18 12:20:43 -0700918gl_priv_reqs = [
919 'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb',
920 'xcb-glx >= 1.8.1', 'libdrm >= 2.4.75',
921]
Dylan Baker1f11ac42017-10-24 11:34:04 -0700922if dep_xxf86vm != [] and dep_xxf86vm.found()
Dylan Bakerb92992e2017-10-24 11:28:42 -0700923 gl_priv_reqs += 'xxf86vm'
Dylan Baker108d2572017-10-18 12:20:43 -0700924endif
925if with_dri_platform == 'drm'
926 gl_priv_reqs += 'xcb-dri2 >= 1.8'
927endif
928
929gl_priv_libs = []
930if dep_thread.found()
931 gl_priv_libs += ['-lpthread', '-pthread']
932endif
933if dep_m.found()
934 gl_priv_libs += '-lm'
935endif
Jon Turney7df9a362017-11-13 10:13:54 +0000936if dep_dl != [] and dep_dl.found()
Dylan Baker108d2572017-10-18 12:20:43 -0700937 gl_priv_libs += '-ldl'
938endif
939
Dylan Baker32180562017-09-20 20:11:32 -0700940pkg = import('pkgconfig')
941
Dylan Bakerd1992252017-09-14 17:57:17 -0700942subdir('include')
Eric Engestrom05a94a42017-10-24 18:03:39 +0100943subdir('bin')
Dylan Bakerd1992252017-09-14 17:57:17 -0700944subdir('src')