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