From e05764806ac14c2cce19837eb4459137d78ece71 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 22 Oct 2023 20:38:32 +0200 Subject: [PATCH] build: Change where we get drm_fourcc.h from The canonical source for userspace is libdrm, not kernel headers. Fixes compilation on Arch Linux. --- gdk/gdkdmabuf.c | 2 +- gdk/gdkdmabufformatsbuilder.c | 2 +- gdk/gdkdmabuftexture.c | 2 +- gdk/gdkdmabuftexturebuilder.c | 4 ++-- gdk/meson.build | 1 + meson.build | 22 ++++++++++++++-------- tests/testdmabuf.c | 2 +- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/gdk/gdkdmabuf.c b/gdk/gdkdmabuf.c index 4b17fe563f..b3ef559ea5 100644 --- a/gdk/gdkdmabuf.c +++ b/gdk/gdkdmabuf.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include typedef struct _GdkDrmFormatInfo GdkDrmFormatInfo; diff --git a/gdk/gdkdmabufformatsbuilder.c b/gdk/gdkdmabufformatsbuilder.c index 223eada0a7..7987c05701 100644 --- a/gdk/gdkdmabufformatsbuilder.c +++ b/gdk/gdkdmabufformatsbuilder.c @@ -23,7 +23,7 @@ #include "gdkdmabufformatsprivate.h" #ifdef HAVE_DMABUF -#include +#include #endif #define GDK_ARRAY_NAME gdk_dmabuf_formats_builder diff --git a/gdk/gdkdmabuftexture.c b/gdk/gdkdmabuftexture.c index 97bb473bd9..be54b36138 100644 --- a/gdk/gdkdmabuftexture.c +++ b/gdk/gdkdmabuftexture.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #endif diff --git a/gdk/gdkdmabuftexturebuilder.c b/gdk/gdkdmabuftexturebuilder.c index 8301f37308..1569c2d6fe 100644 --- a/gdk/gdkdmabuftexturebuilder.c +++ b/gdk/gdkdmabuftexturebuilder.c @@ -28,7 +28,7 @@ #include #ifdef HAVE_DMABUF -#include +#include #else #define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1) #endif @@ -86,7 +86,7 @@ struct _GdkDmabufTextureBuilderClass * * The format of the data (for graphics data, essentially its colorspace) is described * by a 32-bit integer. These format identifiers are defined in the header file - * [drm/drm_fourcc.h](https://github.com/torvalds/linux/blob/master/include/uapi/drm/drm_fourcc.h) + * [drm_fourcc.h](https://github.com/torvalds/linux/blob/master/include/uapi/drm_fourcc.h) * and commonly referred to as **_fourcc_** values, since they are identified by 4 ASCII * characters. Additionally, each DMA buffer has a **_modifier_**, which is a 64-bit integer * that describes driver-specific details of the memory layout, such as tiling or compression. diff --git a/gdk/meson.build b/gdk/meson.build index 30f63d0451..68a6102564 100644 --- a/gdk/meson.build +++ b/gdk/meson.build @@ -216,6 +216,7 @@ gdk_deps = [ platform_gio_dep, pangocairo_dep, vulkan_dep, + dmabuf_dep, png_dep, tiff_dep, jpeg_dep, diff --git a/meson.build b/meson.build index 666332e1a6..1d6cdcdd85 100644 --- a/meson.build +++ b/meson.build @@ -185,14 +185,6 @@ foreach h : check_headers endif endforeach -if cc.has_header('linux/dma-buf.h') and cc.has_header('drm/drm_fourcc.h') - cdata.set('HAVE_DMABUF', 1) -else - if os_linux - error('OS is Linux, but linux/dma-buf.h and drm/drm-fourcc.h not found.') - endif -endif - # Maths functions might be implemented in libm libm = cc.find_library('m', required: false) @@ -626,6 +618,20 @@ else vulkan_pkg_found = false endif +if cc.has_header('linux/dma-buf.h') + dmabuf_dep = dependency('libdrm', + required: os_linux) +else + if os_linux + error('OS is Linux, but linux/dma-buf.h not found.') + endif + dmabuf_dep = dependency('', required: false) +endif +cdata.set('HAVE_DMABUF', dmabuf_dep.found()) +# We only care about drm_fourcc.h for all the fourccs, +# but not about linking to libdrm +dmabuf_dep = dmabuf_dep.partial_dependency(includes: true, compile_args: true) + cloudproviders_dep = dependency('cloudproviders', required: get_option('cloudproviders'), version: cloudproviders_req, diff --git a/tests/testdmabuf.c b/tests/testdmabuf.c index ce7544de61..be26591cea 100644 --- a/tests/testdmabuf.c +++ b/tests/testdmabuf.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include /* For this to work, you may need to give /dev/dma_heap/system * lax permissions.