Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 1 | # 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 Engestrom | 7983adc | 2017-10-24 14:57:11 +0100 | [diff] [blame] | 21 | project( |
| 22 | 'mesa', |
| 23 | ['c', 'cpp'], |
Dylan Baker | 3e9533d | 2017-11-01 11:54:10 -0700 | [diff] [blame^] | 24 | version : run_command( |
| 25 | [find_program('python', 'python2', 'python3'), 'bin/meson_get_version.py'] |
| 26 | ).stdout(), |
Eric Engestrom | 7983adc | 2017-10-24 14:57:11 +0100 | [diff] [blame] | 27 | license : 'MIT', |
| 28 | meson_version : '>= 0.42', |
Eric Engestrom | d5597f0 | 2017-11-06 16:49:27 +0000 | [diff] [blame] | 29 | default_options : ['buildtype=debugoptimized', 'c_std=c99', 'cpp_std=c++11'] |
Eric Engestrom | 7983adc | 2017-10-24 14:57:11 +0100 | [diff] [blame] | 30 | ) |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 31 | |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 32 | # 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++. |
| 35 | pre_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"', |
Dylan Baker | 601bd72 | 2017-10-09 14:22:07 -0700 | [diff] [blame] | 42 | '-D_GNU_SOURCE', |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 43 | ] |
| 44 | |
Dylan Baker | e915b8d | 2017-09-28 14:02:51 -0700 | [diff] [blame] | 45 | with_vulkan_icd_dir = get_option('vulkan-icd-dir') |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 46 | with_tests = get_option('build-tests') |
| 47 | with_valgrind = get_option('valgrind') |
Erik Faye-Lund | 9e5a5a1 | 2017-10-23 20:54:03 +0200 | [diff] [blame] | 48 | with_libunwind = get_option('libunwind') |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 49 | with_asm = get_option('asm') |
Dylan Baker | 02cf3a8 | 2017-10-12 09:47:30 -0700 | [diff] [blame] | 50 | with_llvm = get_option('llvm') |
Dylan Baker | cbbd5bb | 2017-10-20 21:48:18 -0700 | [diff] [blame] | 51 | with_osmesa = get_option('osmesa') |
Dylan Baker | 3b209e9 | 2017-10-10 15:25:07 -0700 | [diff] [blame] | 52 | if get_option('texture-float') |
| 53 | pre_args += '-DTEXTURE_FLOAT_ENABLED' |
| 54 | message('WARNING: Floating-point texture enabled. Please consult docs/patents.txt and your lawyer before building mesa.') |
| 55 | endif |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 56 | |
| 57 | # XXX: yeah, do these |
| 58 | with_appledri = false |
| 59 | with_windowsdri = false |
| 60 | |
Dylan Baker | db97884 | 2017-09-28 13:59:04 -0700 | [diff] [blame] | 61 | dri_drivers_path = get_option('dri-drivers-path') |
| 62 | if dri_drivers_path == '' |
| 63 | dri_drivers_path = join_paths(get_option('libdir'), 'dri') |
| 64 | endif |
| 65 | |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 66 | with_gles1 = get_option('gles1') |
| 67 | with_gles2 = get_option('gles2') |
| 68 | with_opengl = get_option('opengl') |
| 69 | with_any_opengl = with_opengl or with_gles1 or with_gles2 |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 70 | # Only build shared_glapi if at least one OpenGL API is enabled |
| 71 | with_shared_glapi = get_option('shared-glapi') and with_any_opengl |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 72 | |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 73 | |
| 74 | # shared-glapi is required if at least two OpenGL APIs are being built |
| 75 | if not with_shared_glapi |
| 76 | if ((with_gles1 and with_gles2) or (with_gles1 and with_opengl) |
| 77 | or (with_gles2 and with_opengl)) |
| 78 | error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x') |
| 79 | endif |
| 80 | endif |
| 81 | |
| 82 | # We require OpenGL for OpenGL ES |
| 83 | if (with_gles1 or with_gles2) and not with_opengl |
| 84 | error('building OpenGL ES without OpenGL is not supported.') |
| 85 | endif |
| 86 | |
| 87 | with_dri = false |
Ville Syrjälä | 2289964 | 2017-10-10 01:15:42 +0300 | [diff] [blame] | 88 | with_dri_i915 = false |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 89 | with_dri_i965 = false |
Dylan Baker | 191e785 | 2017-10-16 17:12:52 -0700 | [diff] [blame] | 90 | with_dri_r100 = false |
Dylan Baker | eecd286 | 2017-10-16 17:24:56 -0700 | [diff] [blame] | 91 | with_dri_r200 = false |
Dylan Baker | eb3bb03 | 2017-10-16 17:51:47 -0700 | [diff] [blame] | 92 | with_dri_nouveau = false |
Dylan Baker | c2cd580 | 2017-10-03 17:06:22 -0700 | [diff] [blame] | 93 | with_dri_swrast = false |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 94 | _drivers = get_option('dri-drivers') |
| 95 | if _drivers != '' |
| 96 | _split = _drivers.split(',') |
Ville Syrjälä | 2289964 | 2017-10-10 01:15:42 +0300 | [diff] [blame] | 97 | with_dri_i915 = _split.contains('i915') |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 98 | with_dri_i965 = _split.contains('i965') |
Dylan Baker | 191e785 | 2017-10-16 17:12:52 -0700 | [diff] [blame] | 99 | with_dri_r100 = _split.contains('r100') |
Dylan Baker | eecd286 | 2017-10-16 17:24:56 -0700 | [diff] [blame] | 100 | with_dri_r200 = _split.contains('r200') |
Dylan Baker | eb3bb03 | 2017-10-16 17:51:47 -0700 | [diff] [blame] | 101 | with_dri_nouveau = _split.contains('nouveau') |
Dylan Baker | c2cd580 | 2017-10-03 17:06:22 -0700 | [diff] [blame] | 102 | with_dri_swrast = _split.contains('swrast') |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 103 | with_dri = true |
| 104 | endif |
| 105 | |
Dylan Baker | af9d276 | 2017-09-28 21:03:07 -0700 | [diff] [blame] | 106 | with_gallium = false |
Eric Anholt | 1918c9b | 2017-10-12 18:39:08 -0700 | [diff] [blame] | 107 | with_gallium_pl111 = false |
Dylan Baker | af9d276 | 2017-09-28 21:03:07 -0700 | [diff] [blame] | 108 | with_gallium_radeonsi = false |
Dylan Baker | 813b4b0 | 2017-10-09 14:59:35 -0700 | [diff] [blame] | 109 | with_gallium_nouveau = false |
Rob Clark | 4aa69cc | 2017-10-14 10:08:50 -0400 | [diff] [blame] | 110 | with_gallium_freedreno = false |
Dylan Baker | f3d03a2 | 2017-10-10 11:57:50 -0700 | [diff] [blame] | 111 | with_gallium_softpipe = false |
Eric Anholt | 1ae8018 | 2017-10-12 13:53:12 -0700 | [diff] [blame] | 112 | with_gallium_vc4 = false |
Eric Anholt | 4f3e380 | 2017-10-12 18:40:16 -0700 | [diff] [blame] | 113 | with_gallium_vc5 = false |
Dylan Baker | 51558a1 | 2017-10-20 15:45:22 -0700 | [diff] [blame] | 114 | with_gallium_etnaviv = false |
Dylan Baker | d4567ef | 2017-10-20 15:57:15 -0700 | [diff] [blame] | 115 | with_gallium_imx = false |
Dylan Baker | af9d276 | 2017-09-28 21:03:07 -0700 | [diff] [blame] | 116 | _drivers = get_option('gallium-drivers') |
| 117 | if _drivers != '' |
| 118 | _split = _drivers.split(',') |
Dylan Baker | fbf39fd | 2017-10-17 14:44:15 -0700 | [diff] [blame] | 119 | with_gallium_pl111 = _split.contains('pl111') |
Dylan Baker | af9d276 | 2017-09-28 21:03:07 -0700 | [diff] [blame] | 120 | with_gallium_radeonsi = _split.contains('radeonsi') |
Dylan Baker | 813b4b0 | 2017-10-09 14:59:35 -0700 | [diff] [blame] | 121 | with_gallium_nouveau = _split.contains('nouveau') |
Rob Clark | 4aa69cc | 2017-10-14 10:08:50 -0400 | [diff] [blame] | 122 | with_gallium_freedreno = _split.contains('freedreno') |
Dylan Baker | de24d61 | 2017-10-10 14:27:19 -0700 | [diff] [blame] | 123 | with_gallium_softpipe = _split.contains('swrast') |
Eric Anholt | 1ae8018 | 2017-10-12 13:53:12 -0700 | [diff] [blame] | 124 | with_gallium_vc4 = _split.contains('vc4') |
Eric Anholt | 4f3e380 | 2017-10-12 18:40:16 -0700 | [diff] [blame] | 125 | with_gallium_vc5 = _split.contains('vc5') |
Dylan Baker | 51558a1 | 2017-10-20 15:45:22 -0700 | [diff] [blame] | 126 | with_gallium_etnaviv = _split.contains('etnaviv') |
Dylan Baker | d4567ef | 2017-10-20 15:57:15 -0700 | [diff] [blame] | 127 | with_gallium_imx = _split.contains('imx') |
Dylan Baker | af9d276 | 2017-09-28 21:03:07 -0700 | [diff] [blame] | 128 | with_gallium = true |
| 129 | with_dri = true |
Ville Syrjälä | 2289964 | 2017-10-10 01:15:42 +0300 | [diff] [blame] | 130 | endif |
| 131 | |
Dylan Baker | af9d276 | 2017-09-28 21:03:07 -0700 | [diff] [blame] | 132 | if not (with_dri or with_gallium) |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 133 | with_gles1 = false |
| 134 | with_gles2 = false |
| 135 | with_opengl = false |
| 136 | with_any_opengl = false |
| 137 | with_shared_glapi = false |
| 138 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 139 | |
Dylan Baker | de24d61 | 2017-10-10 14:27:19 -0700 | [diff] [blame] | 140 | if with_dri_swrast and with_gallium_softpipe |
| 141 | error('Only one swrast provider can be built') |
| 142 | endif |
Dylan Baker | d4567ef | 2017-10-20 15:57:15 -0700 | [diff] [blame] | 143 | if with_gallium_imx and not with_gallium_etnaviv |
| 144 | error('IMX driver requires etnaviv driver') |
| 145 | endif |
Dylan Baker | de24d61 | 2017-10-10 14:27:19 -0700 | [diff] [blame] | 146 | |
Dylan Baker | af9d276 | 2017-09-28 21:03:07 -0700 | [diff] [blame] | 147 | dep_libdrm_intel = [] |
| 148 | if with_dri_i915 |
| 149 | dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75') |
| 150 | endif |
| 151 | |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 152 | # TODO: other OSes |
| 153 | with_dri_platform = 'drm' |
| 154 | |
Eric Engestrom | c5ec155 | 2017-10-24 16:08:15 +0100 | [diff] [blame] | 155 | with_platform_android = false |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 156 | with_platform_wayland = false |
| 157 | with_platform_x11 = false |
Dylan Baker | b1b6539 | 2017-09-28 22:25:02 -0700 | [diff] [blame] | 158 | with_platform_drm = false |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 159 | with_platform_surfaceless = false |
| 160 | egl_native_platform = '' |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 161 | _platforms = get_option('platforms') |
| 162 | if _platforms != '' |
| 163 | _split = _platforms.split(',') |
Eric Engestrom | c5ec155 | 2017-10-24 16:08:15 +0100 | [diff] [blame] | 164 | with_platform_android = _split.contains('android') |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 165 | with_platform_x11 = _split.contains('x11') |
| 166 | with_platform_wayland = _split.contains('wayland') |
Dylan Baker | b1b6539 | 2017-09-28 22:25:02 -0700 | [diff] [blame] | 167 | with_platform_drm = _split.contains('drm') |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 168 | with_platform_surfaceless = _split.contains('surfaceless') |
| 169 | egl_native_platform = _split[0] |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 170 | endif |
| 171 | |
Dylan Baker | 816bf7d1 | 2017-09-28 15:53:53 -0700 | [diff] [blame] | 172 | with_gbm = get_option('gbm') |
| 173 | if with_gbm == 'auto' and with_dri # TODO: or gallium |
| 174 | with_gbm = host_machine.system() == 'linux' |
Dylan Baker | 0589331 | 2017-10-30 10:27:48 -0700 | [diff] [blame] | 175 | elif with_gbm == 'true' |
Dylan Baker | 816bf7d1 | 2017-09-28 15:53:53 -0700 | [diff] [blame] | 176 | if not ['linux', 'bsd'].contains(host_machine.system()) |
| 177 | error('GBM only supports unix-like platforms') |
| 178 | endif |
| 179 | with_gbm = true |
| 180 | else |
| 181 | with_gbm = false |
| 182 | endif |
| 183 | |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 184 | _egl = get_option('egl') |
| 185 | if _egl == 'auto' |
| 186 | with_egl = with_dri and with_shared_glapi and egl_native_platform != '' |
Dylan Baker | 0589331 | 2017-10-30 10:27:48 -0700 | [diff] [blame] | 187 | elif _egl == 'true' |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 188 | if not with_dri |
| 189 | error('EGL requires dri') |
| 190 | elif not with_shared_glapi |
| 191 | error('EGL requires shared-glapi') |
| 192 | elif egl_native_platform == '' |
| 193 | error('No platforms specified, consider -Dplatforms=drm,x11 at least') |
| 194 | endif |
| 195 | with_egl = true |
| 196 | else |
| 197 | with_egl = false |
| 198 | endif |
| 199 | |
| 200 | # TODO: or virgl |
| 201 | if with_egl and with_gallium_radeonsi and not (with_platform_drm or with_platform_surfaceless) |
| 202 | error('RadeonSI requires drm or surfaceless platform when using EGL') |
| 203 | endif |
| 204 | |
Dylan Baker | 8e61187 | 2017-10-11 12:49:31 -0700 | [diff] [blame] | 205 | pre_args += '-DGLX_USE_TLS' |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 206 | with_glx = get_option('glx') |
| 207 | if with_glx != 'disabled' |
Dylan Baker | 8d3b121 | 2017-10-18 15:47:11 -0700 | [diff] [blame] | 208 | if not (with_platform_x11 and with_any_opengl) |
| 209 | if with_glx == 'auto' |
| 210 | with_glx = 'disabled' |
| 211 | else |
| 212 | error('Cannot build GLX support without X11 platform support and at least one OpenGL API') |
| 213 | endif |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 214 | elif with_glx == 'gallium-xlib' |
| 215 | if not with_gallium |
| 216 | error('Gallium-xlib based GLX requires at least one gallium driver') |
| 217 | elif with_dri |
| 218 | error('gallium-xlib conflicts with any dri driver') |
| 219 | endif |
| 220 | elif with_glx == 'dri' and not with_dri |
| 221 | error('dri based GLX requires at least one DRI driver') |
| 222 | elif with_glx == 'auto' |
| 223 | if with_dri |
| 224 | with_glx = 'dri' |
| 225 | elif with_gallium |
| 226 | with_glx = 'gallium-xlib' |
| 227 | elif with_platform_x11 and with_any_opengl |
| 228 | with_glx = 'xlib' |
| 229 | else |
| 230 | with_glx = 'disabled' |
| 231 | endif |
| 232 | endif |
| 233 | endif |
| 234 | |
| 235 | with_glvnd = get_option('glvnd') |
Dylan Baker | 8a36f02 | 2017-11-01 10:24:10 -0700 | [diff] [blame] | 236 | if with_glvnd |
| 237 | if with_glx == 'xlib' or with_glx == 'gallium-xlib' |
| 238 | error('Cannot build glvnd support for GLX that is not DRI based.') |
| 239 | elif with_glx == 'disabled' and not with_egl |
| 240 | error('glvnd requires DRI based GLX and/or EGL') |
| 241 | endif |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 242 | endif |
| 243 | |
| 244 | # TODO: toggle for this |
| 245 | with_glx_direct = true |
| 246 | |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 247 | if with_vulkan_icd_dir == '' |
| 248 | with_vulkan_icd_dir = join_paths(get_option('datadir'), 'vulkan/icd.d') |
| 249 | endif |
| 250 | |
| 251 | with_intel_vk = false |
| 252 | with_amd_vk = false |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 253 | with_any_vk = false |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 254 | _vulkan_drivers = get_option('vulkan-drivers') |
| 255 | if _vulkan_drivers != '' |
| 256 | _split = _vulkan_drivers.split(',') |
| 257 | with_intel_vk = _split.contains('intel') |
| 258 | with_amd_vk = _split.contains('amd') |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 259 | with_any_vk = with_amd_vk or with_intel_vk |
Eric Engestrom | c5ec155 | 2017-10-24 16:08:15 +0100 | [diff] [blame] | 260 | if not (with_platform_x11 or with_platform_wayland or with_platform_android) |
| 261 | error('Vulkan requires at least one platform (x11, wayland, android)') |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 262 | endif |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 263 | endif |
| 264 | |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 265 | with_dri2 = (with_dri or with_any_vk) and with_dri_platform == 'drm' |
| 266 | with_dri3 = get_option('dri3') |
| 267 | if with_dri3 == 'auto' |
| 268 | if host_machine.system() == 'linux' and with_dri2 |
| 269 | with_dri3 = true |
| 270 | else |
| 271 | with_dri3 = false |
| 272 | endif |
Dylan Baker | 0589331 | 2017-10-30 10:27:48 -0700 | [diff] [blame] | 273 | elif with_dri3 == 'true' |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 274 | with_dri3 = true |
| 275 | else |
| 276 | with_dri3 = false |
| 277 | endif |
| 278 | |
| 279 | if with_any_vk and (with_platform_x11 and not with_dri3) |
| 280 | error('Vulkan drivers require dri3 for X11 support') |
| 281 | endif |
Dylan Baker | af9d276 | 2017-09-28 21:03:07 -0700 | [diff] [blame] | 282 | if with_dri or with_gallium |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 283 | if with_glx == 'disabled' and not with_egl |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 284 | error('building dri or gallium drivers require at least one window system') |
| 285 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 286 | endif |
| 287 | |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 288 | with_gallium_xvmc = false |
| 289 | with_gallium_vdpau = false |
| 290 | with_gallium_omx = false # this is bellagio |
| 291 | with_gallium_va = false |
| 292 | with_gallium_media = false |
| 293 | dep_va = [] |
| 294 | _drivers = get_option('gallium-media') |
| 295 | if _drivers != '' |
| 296 | _split = _drivers.split(',') |
| 297 | with_gallium_xvmc = _split.contains('xvmc') |
| 298 | with_gallium_vdpau = _split.contains('vdpau') |
| 299 | with_gallium_omx = _split.contains('omx') |
| 300 | with_gallium_va = _split.contains('va') |
| 301 | with_gallium_media = (with_gallium_xvmc or with_gallium_vdpau or |
| 302 | with_gallium_omx or with_gallium_va) |
| 303 | endif |
| 304 | |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 305 | gl_pkgconfig_c_flags = [] |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 306 | if with_platform_x11 |
| 307 | if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm') |
| 308 | pre_args += '-DHAVE_X11_PLATFORM' |
| 309 | endif |
| 310 | if with_glx == 'xlib' |
| 311 | # TODO |
| 312 | error('TODO') |
| 313 | elif with_glx == 'gallium-xlib' |
| 314 | # TODO |
| 315 | error('TODO') |
| 316 | else |
| 317 | pre_args += '-DGLX_INDIRECT_RENDERING' |
| 318 | if with_glx_direct |
| 319 | pre_args += '-DGLX_DIRECT_RENDERING' |
| 320 | endif |
| 321 | if with_dri_platform == 'drm' |
| 322 | pre_args += '-DGLX_USE_DRM' |
| 323 | endif |
| 324 | endif |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 325 | else |
| 326 | pre_args += '-DMESA_EGL_NO_X11_HEADERS' |
| 327 | gl_pkgconfig_c_flags += '-DMESA_EGL_NO_X11_HEADERS' |
| 328 | endif |
| 329 | if with_platform_drm |
| 330 | if with_egl and not with_gbm |
| 331 | error('EGL drm platform requires gbm') |
| 332 | endif |
| 333 | pre_args += '-DHAVE_DRM_PLATFORM' |
| 334 | endif |
| 335 | if with_platform_surfaceless |
| 336 | pre_args += '-DHAVE_SURFACELESS_PLATFORM' |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 337 | endif |
Eric Engestrom | c5ec155 | 2017-10-24 16:08:15 +0100 | [diff] [blame] | 338 | if with_platform_android |
| 339 | dep_android = [ |
| 340 | dependency('cutils'), |
| 341 | dependency('hardware'), |
| 342 | dependency('sync'), |
| 343 | ] |
| 344 | pre_args += '-DHAVE_ANDROID_PLATFORM' |
| 345 | endif |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 346 | |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 347 | prog_python2 = find_program('python2') |
Dylan Baker | 9342a7d | 2017-09-28 10:48:30 -0700 | [diff] [blame] | 348 | has_mako = run_command(prog_python2, '-c', 'import mako') |
| 349 | if has_mako.returncode() != 0 |
| 350 | error('Python (2.x) mako module required to build mesa.') |
| 351 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 352 | |
| 353 | cc = meson.get_compiler('c') |
| 354 | if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6') |
Eric Engestrom | 1262e82 | 2017-09-29 15:25:18 +0100 | [diff] [blame] | 355 | error('When using GCC, version 4.4.6 or later is required.') |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 356 | endif |
| 357 | |
Eric Engestrom | 1e6f9ea | 2017-11-06 17:18:06 +0000 | [diff] [blame] | 358 | # Define DEBUG for debug builds only (debugoptimized is not included on this one) |
| 359 | if get_option('buildtype') == 'debug' |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 360 | pre_args += '-DDEBUG' |
| 361 | endif |
| 362 | |
Dylan Baker | 673dda8 | 2017-09-20 11:53:29 -0700 | [diff] [blame] | 363 | if get_option('shader-cache') |
| 364 | pre_args += '-DENABLE_SHADER_CACHE' |
| 365 | elif with_amd_vk |
| 366 | error('Radv requires shader cache support') |
| 367 | endif |
| 368 | |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 369 | # Check for GCC style builtins |
| 370 | foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs', |
| 371 | 'ffsll', 'popcount', 'popcountll', 'unreachable'] |
| 372 | if cc.has_function(b) |
| 373 | pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper()) |
| 374 | endif |
| 375 | endforeach |
| 376 | |
Dylan Baker | 673dda8 | 2017-09-20 11:53:29 -0700 | [diff] [blame] | 377 | # check for GCC __attribute__ |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 378 | foreach a : ['const', 'flatten', 'malloc', 'pure', 'unused', |
| 379 | 'warn_unused_result', 'weak',] |
| 380 | if cc.compiles('int foo(void) __attribute__((@0@));'.format(a), |
| 381 | name : '__attribute__((@0@))'.format(a)) |
| 382 | pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper()) |
| 383 | endif |
| 384 | endforeach |
| 385 | if cc.compiles('int foo(const char *p, ...) __attribute__((format(printf, 1, 2)));', |
| 386 | name : '__attribute__((format(...)))') |
| 387 | pre_args += '-DHAVE_FUNC_ATTRIBUTE_FORMAT' |
| 388 | endif |
| 389 | if cc.compiles('struct __attribute__((packed)) foo { int bar; };', |
| 390 | name : '__attribute__((packed))') |
| 391 | pre_args += '-DHAVE_FUNC_ATTRIBUTE_PACKED' |
| 392 | endif |
| 393 | if cc.compiles('int *foo(void) __attribute__((returns_nonnull));', |
| 394 | name : '__attribute__((returns_nonnull))') |
| 395 | pre_args += '-DHAVE_FUNC_ATTRIBUTE_NONNULL' |
| 396 | endif |
| 397 | if cc.compiles('''int foo_def(void) __attribute__((visibility("default"))); |
| 398 | int foo_hid(void) __attribute__((visibility("hidden"))); |
| 399 | int foo_int(void) __attribute__((visibility("internal"))); |
| 400 | int foo_pro(void) __attribute__((visibility("protected")));''', |
| 401 | name : '__attribute__((visibility(...)))') |
| 402 | pre_args += '-DHAVE_FUNC_ATTRIBUTE_VISBILITY' |
| 403 | endif |
| 404 | if cc.compiles('int foo(void) { return 0; } int bar(void) __attribute__((alias("foo")));', |
| 405 | name : '__attribute__((alias(...)))') |
| 406 | pre_args += '-DHAVE_FUNC_ATTRIBUTE_ALIAS' |
| 407 | endif |
| 408 | |
| 409 | # TODO: this is very incomplete |
| 410 | if host_machine.system() == 'linux' |
| 411 | pre_args += '-D_GNU_SOURCE' |
| 412 | endif |
| 413 | |
| 414 | # Check for generic C arguments |
| 415 | c_args = [] |
| 416 | foreach a : ['-Wall', '-Werror=implicit-function-declaration', |
| 417 | '-Werror=missing-prototypes', '-fno-math-errno', |
| 418 | '-fno-trapping-math', '-Qunused-arguments'] |
| 419 | if cc.has_argument(a) |
| 420 | c_args += a |
| 421 | endif |
| 422 | endforeach |
| 423 | c_vis_args = [] |
| 424 | if cc.has_argument('-fvisibility=hidden') |
| 425 | c_vis_args += '-fvisibility=hidden' |
| 426 | endif |
| 427 | |
| 428 | # Check for generic C++ arguments |
| 429 | cpp = meson.get_compiler('cpp') |
| 430 | cpp_args = [] |
| 431 | foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math', |
| 432 | '-Qunused-arguments', '-Wno-non-virtual-dtor'] |
| 433 | if cpp.has_argument(a) |
| 434 | cpp_args += a |
| 435 | endif |
| 436 | endforeach |
| 437 | cpp_vis_args = [] |
| 438 | if cpp.has_argument('-fvisibility=hidden') |
| 439 | cpp_vis_args += '-fvisibility=hidden' |
| 440 | endif |
| 441 | |
| 442 | # Check for C and C++ arguments for MSVC2013 compatibility. These are only used |
| 443 | # in parts of the mesa code base that need to compile with old versions of |
| 444 | # MSVC, mainly common code |
| 445 | c_msvc_compat_args = [] |
| 446 | cpp_msvc_compat_args = [] |
| 447 | foreach a : ['-Werror=pointer-arith', '-Werror=vla'] |
| 448 | if cc.has_argument(a) |
| 449 | c_msvc_compat_args += a |
| 450 | endif |
| 451 | if cpp.has_argument(a) |
| 452 | cpp_msvc_compat_args += a |
| 453 | endif |
| 454 | endforeach |
| 455 | |
| 456 | no_override_init_args = [] |
| 457 | foreach a : ['-Wno-override-init', '-Wno-initializer-overrides'] |
| 458 | if cc.has_argument(a) |
| 459 | no_override_init_args += a |
| 460 | endif |
| 461 | endforeach |
| 462 | |
| 463 | # TODO: SSE41 (which is only required for core mesa) |
| 464 | |
| 465 | # Check for GCC style atomics |
| 466 | if cc.compiles('int main() { int n; return __atomic_load_n(&n, __ATOMIC_ACQUIRE); }', |
| 467 | name : 'GCC atomic builtins') |
| 468 | pre_args += '-DUSE_GCC_ATOMIC_BUILTINS' |
| 469 | endif |
| 470 | if not cc.links('''#include <stdint.h> |
| 471 | uint64_t v; |
| 472 | int main() { |
| 473 | return __sync_add_and_fetch(&v, (uint64_t)1); |
| 474 | }''', |
| 475 | name : 'GCC 64bit atomics') |
| 476 | pre_args += '-DMISSING_64_BIT_ATOMICS' |
| 477 | endif |
| 478 | |
| 479 | # TODO: endian |
| 480 | # TODO: powr8 |
| 481 | # TODO: shared/static? Is this even worth doing? |
| 482 | |
| 483 | # I don't think that I need to set any of the debug stuff, I think meson |
| 484 | # handles that for us |
| 485 | |
| 486 | # TODO: ldflags |
| 487 | |
| 488 | # TODO: texture-float (gallium/mesa only) |
| 489 | |
| 490 | # TODO: cross-compiling. I don't think this is relavent to meson |
| 491 | |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 492 | # FIXME: enable asm when cross compiler |
| 493 | # This is doable (autotools does it), but it's not of immediate concern |
Eric Anholt | ebcb4c2 | 2017-11-08 14:07:38 -0800 | [diff] [blame] | 494 | if meson.is_cross_build() and host_machine.cpu_family().startswith('x86') |
| 495 | message('Cross compiling, disabling x86/x86_64 asm') |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 496 | with_asm = false |
| 497 | endif |
| 498 | |
| 499 | with_asm_arch = '' |
| 500 | if with_asm |
| 501 | # TODO: SPARC and PPC |
| 502 | if host_machine.cpu_family() == 'x86' |
| 503 | if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd? |
| 504 | with_asm_arch = 'x86' |
| 505 | pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM', |
| 506 | '-DUSE_SSE_ASM'] |
| 507 | endif |
| 508 | elif host_machine.cpu_family() == 'x86_64' |
| 509 | if host_machine.system() == 'linux' |
| 510 | with_asm_arch = 'x86_64' |
| 511 | pre_args += ['-DUSE_X86_64_ASM'] |
| 512 | endif |
| 513 | elif host_machine.cpu_family() == 'arm' |
| 514 | if host_machine.system() == 'linux' |
| 515 | with_asm_arch = 'arm' |
| 516 | pre_args += ['-DUSE_ARM_ASM'] |
| 517 | endif |
| 518 | elif host_machine.cpu_family() == 'aarch64' |
| 519 | if host_machine.system() == 'linux' |
| 520 | with_asm_arch = 'aarch64' |
| 521 | pre_args += ['-DUSE_AARCH64_ASM'] |
| 522 | endif |
| 523 | endif |
| 524 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 525 | |
| 526 | # Check for standard headers and functions |
| 527 | if cc.has_header_symbol('sys/sysmacros.h', 'major') |
| 528 | pre_args += '-DMAJOR_IN_SYSMACROS' |
| 529 | elif cc.has_header_symbol('sys/mkdev.h', 'major') |
| 530 | pre_args += '-DMAJOR_IN_MKDEV' |
| 531 | endif |
| 532 | |
Timothy Arceri | f98a276 | 2017-10-16 18:06:49 +1100 | [diff] [blame] | 533 | foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h'] |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 534 | if cc.has_header(h) |
| 535 | pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify()) |
| 536 | endif |
| 537 | endforeach |
| 538 | |
| 539 | foreach f : ['strtof', 'mkostemp', 'posix_memalign'] |
| 540 | if cc.has_function(f) |
| 541 | pre_args += '-DHAVE_@0@'.format(f.to_upper()) |
| 542 | endif |
| 543 | endforeach |
| 544 | |
| 545 | # strtod locale support |
| 546 | if cc.links(''' |
| 547 | #define _GNU_SOURCE |
| 548 | #include <stdlib.h> |
| 549 | #include <locale.h> |
| 550 | #ifdef HAVE_XLOCALE_H |
| 551 | #include <xlocale.h> |
| 552 | #endif |
| 553 | int main() { |
| 554 | locale_t loc = newlocale(LC_CTYPE_MASK, "C", NULL); |
| 555 | const char *s = "1.0"; |
| 556 | char *end; |
| 557 | double d = strtod_l(s, end, loc); |
| 558 | float f = strtod_l(s, end, loc); |
| 559 | freelocale(loc); |
| 560 | return 0; |
| 561 | }''', |
| 562 | extra_args : pre_args, |
| 563 | name : 'strtod has locale support') |
| 564 | pre_args += '-DHAVE_STRTOD_L' |
| 565 | endif |
| 566 | |
| 567 | # Check for some linker flags |
| 568 | ld_args_bsymbolic = [] |
Dylan Baker | e21e0a6 | 2017-09-30 13:15:52 -0700 | [diff] [blame] | 569 | if cc.links('int main() { return 0; }', args : '-Wl,-Bsymbolic', name : 'Bsymbolic') |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 570 | ld_args_bsymbolic += '-Wl,-Bsymbolic' |
| 571 | endif |
| 572 | ld_args_gc_sections = [] |
| 573 | if cc.links('static char unused() { return 5; } int main() { return 0; }', |
Dylan Baker | e21e0a6 | 2017-09-30 13:15:52 -0700 | [diff] [blame] | 574 | args : '-Wl,--gc-sections', name : 'gc-sections') |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 575 | ld_args_gc_sections += '-Wl,--gc-sections' |
| 576 | endif |
Dylan Baker | e21e0a6 | 2017-09-30 13:15:52 -0700 | [diff] [blame] | 577 | with_ld_version_script = false |
| 578 | if cc.links('int main() { return 0; }', |
| 579 | args : '-Wl,--version-script=@0@'.format( |
| 580 | join_paths(meson.source_root(), 'build-support/conftest.map')), |
| 581 | name : 'version-script') |
| 582 | with_ld_version_script = true |
| 583 | endif |
| 584 | with_ld_dynamic_list = false |
| 585 | if cc.links('int main() { return 0; }', |
| 586 | args : '-Wl,--dynamic-list=@0@'.format( |
| 587 | join_paths(meson.source_root(), 'build-support/conftest.dyn')), |
| 588 | name : 'dynamic-list') |
| 589 | with_ld_dynamic_list = true |
| 590 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 591 | |
| 592 | # check for dl support |
| 593 | if cc.has_function('dlopen') |
| 594 | dep_dl = [] |
| 595 | else |
| 596 | dep_dl = cc.find_library('dl') |
| 597 | endif |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 598 | if cc.has_function('dladdr', dependencies : dep_dl) |
| 599 | # This is really only required for megadrivers |
| 600 | pre_args += '-DHAVE_DLADDR' |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 601 | endif |
| 602 | |
| 603 | if cc.has_function('dl_iterate_phdr') |
| 604 | pre_args += '-DHAVE_DL_ITERATE_PHDR' |
| 605 | else |
| 606 | # TODO: this is required for vulkan |
| 607 | endif |
| 608 | |
| 609 | # Determine whether or not the rt library is needed for time functions |
| 610 | if cc.has_function('clock_gettime') |
| 611 | dep_clock = [] |
| 612 | else |
| 613 | dep_clock = cc.find_library('rt') |
| 614 | endif |
| 615 | |
Dylan Baker | 66c94b9 | 2017-09-30 13:48:34 -0700 | [diff] [blame] | 616 | with_gallium_drisw_kms = false |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 617 | dep_libdrm = dependency('libdrm', version : '>= 2.4.75', |
| 618 | required : with_dri2 or with_dri3) |
| 619 | if dep_libdrm.found() |
| 620 | pre_args += '-DHAVE_LIBDRM' |
Dylan Baker | 66c94b9 | 2017-09-30 13:48:34 -0700 | [diff] [blame] | 621 | if with_dri_platform == 'drm' and with_dri |
| 622 | with_gallium_drisw_kms = true |
| 623 | endif |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 624 | endif |
| 625 | |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 626 | # TODO: some of these may be conditional |
| 627 | dep_zlib = dependency('zlib', version : '>= 1.2.3') |
| 628 | dep_thread = dependency('threads') |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 629 | if dep_thread.found() and host_machine.system() == 'linux' |
| 630 | pre_args += '-DHAVE_PTHREAD' |
| 631 | endif |
Dylan Baker | cc4f587 | 2017-09-27 11:30:21 -0700 | [diff] [blame] | 632 | dep_elf = dependency('libelf', required : false) |
Dylan Baker | b154b44 | 2017-09-30 14:04:28 -0700 | [diff] [blame] | 633 | if not dep_elf.found() and (with_amd_vk or with_gallium_radeonsi) # TODO: clover, r600 |
| 634 | dep_elf = cc.find_library('elf') |
Dylan Baker | cc4f587 | 2017-09-27 11:30:21 -0700 | [diff] [blame] | 635 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 636 | dep_expat = dependency('expat') |
| 637 | # this only exists on linux so either this is linux and it will be found, or |
| 638 | # its not linux and and wont |
| 639 | dep_m = cc.find_library('m', required : false) |
Dylan Baker | 66f97f6 | 2017-09-30 09:03:51 -0700 | [diff] [blame] | 640 | |
| 641 | dep_libdrm_amdgpu = [] |
| 642 | dep_libdrm_radeon = [] |
Dylan Baker | 813b4b0 | 2017-10-09 14:59:35 -0700 | [diff] [blame] | 643 | dep_libdrm_nouveau = [] |
Dylan Baker | 51558a1 | 2017-10-20 15:45:22 -0700 | [diff] [blame] | 644 | dep_libdrm_etnaviv = [] |
Rob Clark | 4aa69cc | 2017-10-14 10:08:50 -0400 | [diff] [blame] | 645 | dep_libdrm_freedreno = [] |
Dylan Baker | 66f97f6 | 2017-09-30 09:03:51 -0700 | [diff] [blame] | 646 | if with_amd_vk or with_gallium_radeonsi |
Andrey Grodzovsky | 19fc3cd | 2017-11-02 10:50:39 -0400 | [diff] [blame] | 647 | dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.88') |
Dylan Baker | 66f97f6 | 2017-09-30 09:03:51 -0700 | [diff] [blame] | 648 | endif |
Dylan Baker | eecd286 | 2017-10-16 17:24:56 -0700 | [diff] [blame] | 649 | if with_gallium_radeonsi or with_dri_r100 or with_dri_r200 |
Dylan Baker | 66f97f6 | 2017-09-30 09:03:51 -0700 | [diff] [blame] | 650 | dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71') |
| 651 | endif |
Dylan Baker | eb3bb03 | 2017-10-16 17:51:47 -0700 | [diff] [blame] | 652 | if with_gallium_nouveau or with_dri_nouveau |
Dylan Baker | 813b4b0 | 2017-10-09 14:59:35 -0700 | [diff] [blame] | 653 | dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66') |
| 654 | endif |
Dylan Baker | 51558a1 | 2017-10-20 15:45:22 -0700 | [diff] [blame] | 655 | if with_gallium_etnaviv |
| 656 | dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82') |
| 657 | endif |
Rob Clark | 4aa69cc | 2017-10-14 10:08:50 -0400 | [diff] [blame] | 658 | if with_gallium_freedreno |
| 659 | dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.74') |
| 660 | endif |
Dylan Baker | 673dda8 | 2017-09-20 11:53:29 -0700 | [diff] [blame] | 661 | |
| 662 | llvm_modules = ['bitwriter', 'engine', 'mcdisassembler', 'mcjit'] |
| 663 | if with_amd_vk |
| 664 | llvm_modules += ['amdgpu', 'bitreader', 'ipo'] |
| 665 | endif |
Eric Anholt | d975e69 | 2017-11-08 11:52:09 -0800 | [diff] [blame] | 666 | dep_llvm = [] |
Dylan Baker | 02cf3a8 | 2017-10-12 09:47:30 -0700 | [diff] [blame] | 667 | if with_llvm |
Eric Anholt | d975e69 | 2017-11-08 11:52:09 -0800 | [diff] [blame] | 668 | dep_llvm = dependency( |
| 669 | 'llvm', version : '>= 3.9.0', required : with_amd_vk, modules : llvm_modules, |
| 670 | ) |
Dylan Baker | 02cf3a8 | 2017-10-12 09:47:30 -0700 | [diff] [blame] | 671 | if dep_llvm.found() |
| 672 | _llvm_version = dep_llvm.version().split('.') |
| 673 | # Development versions of LLVM have an 'svn' suffix, we don't want that for |
| 674 | # our version checks. |
| 675 | _llvm_patch = _llvm_version[2] |
| 676 | if _llvm_patch.endswith('svn') |
| 677 | _llvm_patch = _llvm_patch.split('s')[0] |
| 678 | endif |
| 679 | pre_args += [ |
| 680 | '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch), |
| 681 | '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch), |
| 682 | ] |
| 683 | else |
Dylan Baker | 6a9ad20 | 2017-10-10 14:56:39 -0700 | [diff] [blame] | 684 | if with_gallium_softpipe |
| 685 | error('Cannot find LLVM to build LLVMPipe. If you wanted softpipe pass -Dllvm=false to meson') |
| 686 | elif with_amd_vk or with_gallium_radeonsi # etc |
Dylan Baker | 66f97f6 | 2017-09-30 09:03:51 -0700 | [diff] [blame] | 687 | error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM was not found.') |
Dylan Baker | 02cf3a8 | 2017-10-12 09:47:30 -0700 | [diff] [blame] | 688 | endif |
Dylan Baker | 673dda8 | 2017-09-20 11:53:29 -0700 | [diff] [blame] | 689 | endif |
Dylan Baker | 66f97f6 | 2017-09-30 09:03:51 -0700 | [diff] [blame] | 690 | elif with_amd_vk or with_gallium_radeonsi |
| 691 | error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM is disabled.') |
Dylan Baker | 673dda8 | 2017-09-20 11:53:29 -0700 | [diff] [blame] | 692 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 693 | |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 694 | dep_glvnd = [] |
| 695 | if with_glvnd |
| 696 | dep_glvnd = dependency('libglvnd', version : '>= 0.2.0') |
| 697 | pre_args += '-DUSE_LIBGLVND=1' |
| 698 | endif |
| 699 | |
Erik Faye-Lund | 5c2ff57 | 2017-10-25 10:02:38 +0200 | [diff] [blame] | 700 | if with_valgrind != 'false' |
| 701 | dep_valgrind = dependency('valgrind', required : with_valgrind == 'true') |
| 702 | if dep_valgrind.found() |
| 703 | pre_args += '-DHAVE_VALGRIND' |
| 704 | endif |
| 705 | else |
| 706 | dep_valgrind = [] |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 707 | endif |
| 708 | |
| 709 | # pthread stubs. Lets not and say we didn't |
| 710 | |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 711 | prog_bison = find_program('bison', required : with_any_opengl) |
| 712 | prog_flex = find_program('flex', required : with_any_opengl) |
| 713 | |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 714 | dep_selinux = [] |
Eric Engestrom | 4b9421d | 2017-10-26 16:19:41 +0100 | [diff] [blame] | 715 | if get_option('selinux') |
| 716 | dep_selinux = dependency('libselinux') |
| 717 | pre_args += '-DMESA_SELINUX' |
| 718 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 719 | |
| 720 | # TODO: llvm-prefix and llvm-shared-libs |
| 721 | |
Erik Faye-Lund | 5c2ff57 | 2017-10-25 10:02:38 +0200 | [diff] [blame] | 722 | if with_libunwind != 'false' |
| 723 | dep_unwind = dependency('libunwind', required : with_libunwind == 'true') |
| 724 | if dep_unwind.found() |
| 725 | pre_args += '-DHAVE_LIBUNWIND' |
| 726 | endif |
| 727 | else |
| 728 | dep_unwind = [] |
Dylan Baker | b1b6539 | 2017-09-28 22:25:02 -0700 | [diff] [blame] | 729 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 730 | |
| 731 | # TODO: flags for opengl, gles, dri |
| 732 | |
| 733 | # TODO: gallium-hud |
| 734 | |
| 735 | # TODO: glx provider |
| 736 | |
Dylan Baker | cbbd5bb | 2017-10-20 21:48:18 -0700 | [diff] [blame] | 737 | if with_osmesa != 'none' |
| 738 | if with_osmesa == 'classic' and not with_dri_swrast |
| 739 | error('OSMesa classic requires dri (classic) swrast.') |
| 740 | endif |
Dylan Baker | f121a66 | 2017-10-24 15:52:57 -0700 | [diff] [blame] | 741 | if with_osmesa == 'gallium' and not with_gallium_softpipe |
| 742 | error('OSMesa gallium requires gallium softpipe or llvmpipe.') |
| 743 | endif |
Dylan Baker | cbbd5bb | 2017-10-20 21:48:18 -0700 | [diff] [blame] | 744 | osmesa_lib_name = 'OSMesa' |
| 745 | osmesa_bits = get_option('osmesa-bits') |
| 746 | if osmesa_bits != '8' |
| 747 | if with_dri or with_glx != 'disabled' |
| 748 | error('OSMesa bits must be 8 if building glx or dir based drivers') |
| 749 | endif |
| 750 | osmesa_lib_name = osmesa_lib_name + osmesa_bits |
| 751 | pre_args += [ |
| 752 | '-DCHAN_BITS=@0@'.format(osmesa_bits), '-DDEFAULT_SOFTWARE_DEPTH_BITS=31' |
| 753 | ] |
| 754 | endif |
| 755 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 756 | |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 757 | # TODO: symbol mangling |
| 758 | |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 759 | if with_platform_wayland |
| 760 | prog_wl_scanner = find_program('wayland-scanner') |
| 761 | dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8') |
| 762 | dep_wayland_client = dependency('wayland-client', version : '>=1.11') |
| 763 | dep_wayland_server = dependency('wayland-server', version : '>=1.11') |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 764 | wayland_dmabuf_xml = join_paths( |
| 765 | dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable', |
| 766 | 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml' |
| 767 | ) |
| 768 | pre_args += ['-DHAVE_WAYLAND_PLATFORM', '-DWL_HIDE_DEPRECATED'] |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 769 | else |
| 770 | prog_wl_scanner = [] |
| 771 | dep_wl_protocols = [] |
| 772 | dep_wayland_client = [] |
| 773 | dep_wayland_server = [] |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 774 | wayland_dmabuf_xml = '' |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 775 | endif |
| 776 | |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 777 | dep_x11 = [] |
| 778 | dep_xext = [] |
| 779 | dep_xdamage = [] |
| 780 | dep_xfixes = [] |
| 781 | dep_x11_xcb = [] |
Dylan Baker | cbbd5bb | 2017-10-20 21:48:18 -0700 | [diff] [blame] | 782 | dep_xcb = [] |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 783 | dep_xcb_glx = [] |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 784 | dep_xcb_dri2 = [] |
| 785 | dep_xcb_dri3 = [] |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 786 | dep_dri2proto = [] |
| 787 | dep_glproto = [] |
Dylan Baker | 1f11ac4 | 2017-10-24 11:34:04 -0700 | [diff] [blame] | 788 | dep_xxf86vm = [] |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 789 | dep_xcb_dri3 = [] |
| 790 | dep_xcb_present = [] |
| 791 | dep_xcb_sync = [] |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 792 | dep_xcb_xfixes = [] |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 793 | dep_xshmfence = [] |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 794 | if with_platform_x11 |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 795 | if with_glx == 'dri' and with_dri_platform == 'drm' |
| 796 | dep_x11 = dependency('x11') |
| 797 | dep_xext = dependency('xext') |
| 798 | dep_xdamage = dependency('xdamage', version : '>= 1.1') |
| 799 | dep_xfixes = dependency('xfixes') |
| 800 | dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1') |
Dylan Baker | 1f11ac4 | 2017-10-24 11:34:04 -0700 | [diff] [blame] | 801 | dep_xxf86vm = dependency('xxf86vm', required : false) |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 802 | endif |
| 803 | if with_any_vk or (with_glx == 'dri' and with_dri_platform == 'drm') |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 804 | dep_xcb = dependency('xcb') |
| 805 | dep_x11_xcb = dependency('x11-xcb') |
| 806 | dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8') |
| 807 | |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 808 | if with_dri3 |
| 809 | pre_args += '-DHAVE_DRI3' |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 810 | dep_xcb_dri3 = dependency('xcb-dri3') |
| 811 | dep_xcb_present = dependency('xcb-present') |
| 812 | dep_xcb_sync = dependency('xcb-sync') |
| 813 | dep_xshmfence = dependency('xshmfence', version : '>= 1.1') |
Dylan Baker | a47c525 | 2017-09-22 12:55:00 -0700 | [diff] [blame] | 814 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 815 | endif |
Dylan Baker | 50c28df | 2017-09-29 17:53:01 -0700 | [diff] [blame] | 816 | if with_glx != 'disabled' |
| 817 | dep_dri2proto = dependency('dri2proto', version : '>= 2.8') |
| 818 | dep_glproto = dependency('glproto', version : '>= 1.4.14') |
| 819 | endif |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 820 | if with_egl |
| 821 | dep_xcb_xfixes = dependency('xcb-xfixes') |
| 822 | endif |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 823 | endif |
| 824 | |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 825 | # TODO: osmesa |
| 826 | |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 827 | # TODO: vallium G3DVL |
| 828 | |
| 829 | # TODO: nine |
| 830 | |
| 831 | # TODO: clover |
| 832 | |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 833 | # TODO: gallium tests |
| 834 | |
| 835 | # TODO: various libdirs |
| 836 | |
| 837 | # TODO: swr |
| 838 | |
| 839 | # TODO: gallium driver dirs |
| 840 | |
| 841 | # FIXME: this is a workaround for #2326 |
| 842 | prog_touch = find_program('touch') |
| 843 | dummy_cpp = custom_target( |
| 844 | 'dummy_cpp', |
| 845 | output : 'dummy.cpp', |
| 846 | command : [prog_touch, '@OUTPUT@'], |
| 847 | ) |
| 848 | |
| 849 | foreach a : pre_args |
| 850 | add_project_arguments(a, language : ['c', 'cpp']) |
| 851 | endforeach |
| 852 | foreach a : c_args |
| 853 | add_project_arguments(a, language : ['c']) |
| 854 | endforeach |
| 855 | foreach a : cpp_args |
| 856 | add_project_arguments(a, language : ['cpp']) |
| 857 | endforeach |
| 858 | |
| 859 | inc_include = include_directories('include') |
| 860 | |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 861 | gl_priv_reqs = [ |
| 862 | 'x11', 'xext', 'xdamage >= 1.1', 'xfixes', 'x11-xcb', 'xcb', |
| 863 | 'xcb-glx >= 1.8.1', 'libdrm >= 2.4.75', |
| 864 | ] |
Dylan Baker | 1f11ac4 | 2017-10-24 11:34:04 -0700 | [diff] [blame] | 865 | if dep_xxf86vm != [] and dep_xxf86vm.found() |
Dylan Baker | b92992e | 2017-10-24 11:28:42 -0700 | [diff] [blame] | 866 | gl_priv_reqs += 'xxf86vm' |
Dylan Baker | 108d257 | 2017-10-18 12:20:43 -0700 | [diff] [blame] | 867 | endif |
| 868 | if with_dri_platform == 'drm' |
| 869 | gl_priv_reqs += 'xcb-dri2 >= 1.8' |
| 870 | endif |
| 871 | |
| 872 | gl_priv_libs = [] |
| 873 | if dep_thread.found() |
| 874 | gl_priv_libs += ['-lpthread', '-pthread'] |
| 875 | endif |
| 876 | if dep_m.found() |
| 877 | gl_priv_libs += '-lm' |
| 878 | endif |
| 879 | if dep_dl.found() |
| 880 | gl_priv_libs += '-ldl' |
| 881 | endif |
| 882 | |
Dylan Baker | 3218056 | 2017-09-20 20:11:32 -0700 | [diff] [blame] | 883 | pkg = import('pkgconfig') |
| 884 | |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 885 | subdir('include') |
Eric Engestrom | 05a94a4 | 2017-10-24 18:03:39 +0100 | [diff] [blame] | 886 | subdir('bin') |
Dylan Baker | d199225 | 2017-09-14 17:57:17 -0700 | [diff] [blame] | 887 | subdir('src') |