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