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

Eric Anholt eric at anholt.net
Mon May 8 17:12:03 UTC 2017


Jon Turney <jon.turney at dronecode.org.uk> writes:

> 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?)
>
> 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                                | 53 +++++++++++++++++++++++++-----
>  meson_options.txt                          |  4 +++
>  9 files changed, 68 insertions(+), 22 deletions(-)
>
> diff --git a/dri3/meson.build b/dri3/meson.build
> index abb13c63a..736ffaa49 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 = ''

Pretty sure this should be = []

> +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..c7c9c79c3 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 = dependency('libdrm', version: '>= 2.4.46', required: false).found()
> +endif

I think this is more clearly stated as:

build_modesetting = libdrm_dep.version().version_compare('>= 2.4.46')

It's a bit of an odd choice (modesetting driver if you have dri1/2/3
enabled, or if libdrm happened to be found anyway), but that should be
true so often I don't think it's worth worrying about.

>  # 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,10 @@ libxserver = [
>      libxserver_os,
>  ]
>  
> +if build_dri3
> +libserver += [
> +    libxserver_dri3
> +]
> +endif

These two hunks can be dropped if the [] construct is used, above.

With these little changes, patches 1-4 are:

Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.x.org/archives/xorg-devel/attachments/20170508/081f2812/attachment.sig>


More information about the xorg-devel mailing list