[PATCH xserver 4/7] meson: Make driprotos and libdrm optional

Jon Turney jon.turney at dronecode.org.uk
Tue May 9 11:23:48 UTC 2017


On 08/05/2017 21:28, Jon Turney wrote:
> On 08/05/2017 18:12, Eric Anholt wrote:
>> Jon Turney writes:
>>> +libxserver_dri3 = ''
>>
>> Pretty sure this should be = []
>
> Yeah, me too.  But when I try it:
>
>> Meson encountered an error in file hw/kdrive/ephyr/meson.build, line
>> 40, column 0:
>> Link target [] is not library.
>
> Hmmm..  if I add it with libxserver += libxserver_dri3, it works, so it
> seems there is some kind of list flattening failure somewhere...

Yes, it seems link_with: doesn't get flattened.

https://github.com/mesonbuild/meson/issues/1764

Attached is a revised patch, which does the flattening by hand.


-------------- next part --------------
From 5a0e35a7e32b1a40a8d453e7e297722e2474a955 Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney at dronecode.org.uk>
Date: Sun, 16 Apr 2017 13:14:28 +0100
Subject: [PATCH xserver 4/7] meson: Make driprotos and libdrm optional

Add options for DRI{1,2,3}
shmfence is required for DRI3
libdrm is required for any DRI{1,2,3}
Consolidate calls to dependency('libdrm')
Set WITH_LIBDRM when building with libdrm

(configure.ac had LIBDRM as independently disableable even if DRI{1,2,3} was
enabled, but does that make sense?)

v2:
Initialize libxserver_dri3 to []
Manually flatten libxserver, since meson doesn't (currently)
Use version_compare rather than circumloctions with dependency()

Signed-off-by: Jon Turney <jon.turney at dronecode.org.uk>
---
 dri3/meson.build                           | 15 +++++----
 hw/xfree86/dri/meson.build                 |  2 +-
 hw/xfree86/dri2/meson.build                |  2 +-
 hw/xfree86/drivers/modesetting/meson.build |  2 +-
 hw/xfree86/meson.build                     |  6 ++--
 hw/xfree86/os-support/meson.build          |  2 +-
 include/meson.build                        |  4 +--
 meson.build                                | 49 +++++++++++++++++++++++++-----
 meson_options.txt                          |  4 +++
 9 files changed, 64 insertions(+), 22 deletions(-)

diff --git a/dri3/meson.build b/dri3/meson.build
index abb13c63a..3d05020e6 100644
--- a/dri3/meson.build
+++ b/dri3/meson.build
@@ -4,9 +4,12 @@ srcs_dri3 = [
 	'dri3_screen.c',
 ]
 
-libxserver_dri3 = static_library('libxserver_dri3',
-	srcs_dri3,
-	include_directories: inc,
-	dependencies: common_dep,
-	c_args: '-DHAVE_XORG_CONFIG_H'
-)
+libxserver_dri3 = []
+if build_dri3
+    libxserver_dri3 = static_library('libxserver_dri3',
+        srcs_dri3,
+        include_directories: inc,
+        dependencies: common_dep,
+        c_args: '-DHAVE_XORG_CONFIG_H'
+        )
+endif
diff --git a/hw/xfree86/dri/meson.build b/hw/xfree86/dri/meson.build
index 9baae100c..53d1e4f26 100644
--- a/hw/xfree86/dri/meson.build
+++ b/hw/xfree86/dri/meson.build
@@ -8,7 +8,7 @@ xorg_dri = static_library('xorg_dri',
     include_directories: [inc, xorg_inc],
     dependencies: [
         common_dep,
-        dependency('libdrm'),
+        libdrm_dep,
     ],
     c_args: xorg_c_args,
 )
diff --git a/hw/xfree86/dri2/meson.build b/hw/xfree86/dri2/meson.build
index 9e997d2f7..087a21131 100644
--- a/hw/xfree86/dri2/meson.build
+++ b/hw/xfree86/dri2/meson.build
@@ -8,7 +8,7 @@ xorg_dri2 = static_library('xorg_dri2',
     include_directories: [inc, xorg_inc],
     dependencies: [
         common_dep,
-        dependency('libdrm'),
+        libdrm_dep,
     ],
     c_args: xorg_c_args,
 )
diff --git a/hw/xfree86/drivers/modesetting/meson.build b/hw/xfree86/drivers/modesetting/meson.build
index 518d6c19e..e97dac36d 100644
--- a/hw/xfree86/drivers/modesetting/meson.build
+++ b/hw/xfree86/drivers/modesetting/meson.build
@@ -18,7 +18,7 @@ shared_module(
     dependencies: [
         common_dep,
         udev_dep,
-        dependency('libdrm', version: '>= 2.4.46'),
+        libdrm_dep,
     ],
 
     install: true,
diff --git a/hw/xfree86/meson.build b/hw/xfree86/meson.build
index 22de2fdd6..5360c22b9 100644
--- a/hw/xfree86/meson.build
+++ b/hw/xfree86/meson.build
@@ -57,7 +57,9 @@ endif
 if build_vgahw
     subdir('vgahw')
 endif
-subdir('drivers/modesetting')
+if build_modesetting
+   subdir('drivers/modesetting')
+endif
 
 srcs_xorg = [
     '../../mi/miinitext.c'
@@ -106,7 +108,7 @@ executable(
         xfont2_dep,
         xshmfence_dep,
         config_dep,
-        dependency('libdrm'),
+        libdrm_dep,
     ],
     link_args: '-Wl,--export-dynamic',
     c_args: xorg_c_args,
diff --git a/hw/xfree86/os-support/meson.build b/hw/xfree86/os-support/meson.build
index a3c3b5688..e48944761 100644
--- a/hw/xfree86/os-support/meson.build
+++ b/hw/xfree86/os-support/meson.build
@@ -117,7 +117,7 @@ xorg_os_support = static_library('xorg_os_support',
     dependencies: [
         common_dep,
         dbus_dep,
-        dependency('libdrm'),
+        libdrm_dep,
     ],
     c_args: xorg_c_args,
 )
diff --git a/include/meson.build b/include/meson.build
index b7414bd67..a95cd7a19 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -61,8 +61,8 @@ conf_data.set_quoted('SHMDIR', '/tmp')
 
 conf_data.set('HAVE_SIGACTION', '1') # XXX
 conf_data.set('BUSFAULT', '1') # XXX
-conf_data.set('XSHMFENCE', '1') # XXX
-conf_data.set('WITH_LIBDRM', '1') # XXX
+conf_data.set('XSHMFENCE', xshmfence_dep.found())
+conf_data.set('WITH_LIBDRM', libdrm_dep.found())
 conf_data.set('GLAMOR_HAS_DRM_NAME_FROM_FD_2',
               dependency('libdrm', version: '>= 2.4.74', required: false).found())
 conf_data.set('GLXEXT', build_glx)
diff --git a/meson.build b/meson.build
index df0d3aefa..4baf96365 100644
--- a/meson.build
+++ b/meson.build
@@ -32,16 +32,16 @@ compositeproto_dep = dependency('compositeproto', version: '>= 0.4')
 recordproto_dep = dependency('recordproto', version: '>= 1.13.99.1')
 scrnsaverproto_dep = dependency('scrnsaverproto', version: '>= 1.1')
 resourceproto_dep = dependency('resourceproto', version: '>= 1.2.0')
-xf86driproto_dep = dependency('xf86driproto', version: '>= 2.1.0')
-dri2proto_dep = dependency('dri2proto', version: '>= 2.8')
-dri3proto_dep = dependency('dri3proto', version: '>= 1.0')
+xf86driproto_dep = dependency('xf86driproto', version: '>= 2.1.0', required: get_option('dri1') == 'yes')
+dri2proto_dep = dependency('dri2proto', version: '>= 2.8', required: get_option('dri2') == 'yes')
+dri3proto_dep = dependency('dri3proto', version: '>= 1.0', required: get_option('dri3') == 'yes')
 xineramaproto_dep = dependency('xineramaproto')
 xf86bigfontproto_dep = dependency('xf86bigfontproto', version: '>= 1.2.0')
 xf86dgaproto_dep = dependency('xf86dgaproto', version: '>= 2.0.99.1', required: false)
 xf86vidmodeproto_dep = dependency('xf86vidmodeproto', version: '>= 2.2.99.1', required: false)
 windowswmproto_dep = dependency('windowswmproto', required: false)
 applewmproto_dep = dependency('applewmproto', version: '>= 1.4', required: false)
-xshmfence_dep = dependency('xshmfence', version: '>= 1.1')
+xshmfence_dep = dependency('xshmfence', version: '>= 1.1', required: false)
 
 pixman_dep = dependency('pixman-1')
 libbsd_dep = dependency('libbsd', required: false)
@@ -216,12 +216,44 @@ endif
 
 build_glx = get_option('glx')
 
+if get_option('dri1') == 'auto'
+    build_dri1 = xf86driproto_dep.found()
+else
+    build_dri1 = get_option('dri1') == 'yes'
+endif
+
+if get_option('dri2') == 'auto'
+    build_dri2 = dri2proto_dep.found()
+else
+    build_dri2 = get_option('dri2') == 'yes'
+endif
+
+if get_option('dri3') == 'auto'
+    build_dri3 = dri3proto_dep.found() and xshmfence_dep.found()
+else
+    build_dri3 = get_option('dri3') == 'yes'
+    if build_dri3
+       if not xshmfence_dep.found()
+           error('DRI3 requested, but xshmfence not found')
+       endif
+    endif
+endif
+
+libdrm_required = (get_option('dri1') == 'yes') or (get_option('dri2') == 'yes') or (get_option('dri3') == 'yes')
+libdrm_dep = dependency('libdrm', version: '>= 2.3.1', required: libdrm_required)
+build_modesetting = false
+if libdrm_dep.found()
+  if build_dri2
+    # 2.4.65 is required for drmGetDevice
+    dependency('libdrm', version: '>= 2.4.65')
+  endif
+  # 2.4.46 is required for cursor hotspot support.
+  build_modesetting = libdrm_dep.version().version_compare('>= 2.4.46')
+endif
+
 # XXX: Allow configuration of these.
 build_apm = false
 build_acpi = false
-build_dri1 = true
-build_dri2 = true
-build_dri3 = true
 build_dpms = true
 build_mitshm = true
 build_res = true
@@ -346,7 +378,6 @@ libxserver = [
     libxserver_composite,
     libxserver_damageext,
     libxserver_dbe,
-    libxserver_dri3,
     libxserver_randr,
     libxserver_miext_damage,
     libxserver_render,
@@ -361,4 +392,6 @@ libxserver = [
     libxserver_os,
 ]
 
+libxserver += libxserver_dri3
+
 subdir('hw')
diff --git a/meson_options.txt b/meson_options.txt
index a5d7de6f4..88423e25e 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -44,3 +44,7 @@ option('hal', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto',
        description: 'Enable HAL integration')
 option('systemd_logind', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto',
        description: 'Enable systemd-logind integration')
+
+option('dri1', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto', description: 'Build DRI1 extension (default: auto)')
+option('dri2', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto', description: 'Build DRI2 extension (default: auto)')
+option('dri3', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto', description: 'Build DRI3 extension (default: auto)')
-- 
2.12.2



More information about the xorg-devel mailing list