From c445b1d56f47922206de55e557444aadb62e11f6 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 12 Mar 2018 16:32:59 -0700 Subject: [PATCH] meson: Use the same version for all libdrm checks Currently each driver specifies it's own version, and core libdrm specifies a version. In the most common case this is fine, since there will be exactly one libdrm installed on a system, but if there are more than one it's possible that mesa will be linked against different versions of libdrm. There is also the possibility that the current approach makes the pkg-config files we generate incorrect, since there could be #defines that use newer features if they're available. This patch corrects all of that. All of the versions are still set by driver (along with a default core version). Then all of the drivers that are enabled have their versions compared and the highest version is selected, then all libdrm checks are made with that version. v2: - Reorder the list to have the name first and whether the dependency is needed second (Eric) Signed-off-by: Dylan Baker Reviewed-by: Eric Engestrom --- meson.build | 66 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/meson.build b/meson.build index cfb40deaafe..ee2b4151e2f 100644 --- a/meson.build +++ b/meson.build @@ -1020,35 +1020,59 @@ dep_expat = dependency('expat') # its not linux and and wont dep_m = cc.find_library('m', required : false) +# Check for libdrm. various drivers have different libdrm version requirements, +# but we always want to use the same version for all libdrm modules. That means +# even if driver foo requires 2.4.0 and driver bar requires 2.4.3, if foo and +# bar are both on use 2.4.3 for both of them dep_libdrm_amdgpu = [] dep_libdrm_radeon = [] dep_libdrm_nouveau = [] dep_libdrm_etnaviv = [] dep_libdrm_freedreno = [] dep_libdrm_intel = [] -if with_dri_i915 or with_gallium_i915 - dep_libdrm_intel = dependency('libdrm_intel', version : '>= 2.4.75') -endif -if with_amd_vk or with_gallium_radeonsi - dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.91') -endif -if (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or - with_gallium_r300 or with_gallium_r600) - dep_libdrm_radeon = dependency('libdrm_radeon', version : '>= 2.4.71') -endif -if with_gallium_nouveau or with_dri_nouveau - dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66') -endif -if with_gallium_etnaviv - dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82') -endif -if with_gallium_freedreno - dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.91') -endif + +_drm_amdgpu_ver = '2.4.91' +_drm_radeon_ver = '2.4.71' +_drm_nouveau_ver = '2.4.66' +_drm_etnaviv_ver = '2.4.82' +_drm_freedreno_ver = '2.4.91' +_drm_intel_ver = '2.4.75' +_drm_ver = '2.4.75' + +_libdrm_checks = [ + ['intel', with_dri_i915 or with_gallium_i915], + ['amdgpu', with_amd_vk or with_gallium_radeonsi], + ['radeon', (with_gallium_radeonsi or with_dri_r100 or with_dri_r200 or + with_gallium_r300 or with_gallium_r600)], + ['nouveau', (with_gallium_nouveau or with_dri_nouveau)], + ['etnaviv', with_gallium_etnaviv], + ['freedreno', with_gallium_freedreno], +] + +# Loop over the enables versions and get the highest libdrm requirement for all +# active drivers. +foreach d : _libdrm_checks + ver = get_variable('_drm_@0@_ver'.format(d[0])) + if d[1] and ver.version_compare('>' + _drm_ver) + _drm_ver = ver + endif +endforeach + +# Then get each libdrm module +foreach d : _libdrm_checks + if d[1] + set_variable( + 'dep_libdrm_' + d[0], + dependency('libdrm_' + d[0], version : '>=' + _drm_ver) + ) + endif +endforeach with_gallium_drisw_kms = false -dep_libdrm = dependency('libdrm', version : '>= 2.4.75', - required : with_dri2 or with_dri3) +dep_libdrm = dependency( + 'libdrm', version : '>=' + _drm_ver, + required : with_dri2 or with_dri3 +) if dep_libdrm.found() pre_args += '-DHAVE_LIBDRM' if with_dri_platform == 'drm' and with_dri -- 2.30.2