[RFC libdrm 1/2] Port build system to meson

Dylan Baker dylan at pnwbakers.com
Thu Mar 16 21:25:36 UTC 2017


This is a bit of a tech demo, a bit of a serious port to meson. This
provides almost all of the build system, except for the ability to
install the tests, it doesn't add -lrt for the clock (it's been in core
glibc for some time), has basically no comments, and hasn't been tested
on any platform except Linux (I have cross compiled for arm). It also
relies on unreviewed, unmerged patches to meson for valgrind support
(but will work fine without the patch and without valgrind)

What's not done:
- the install tests flag isn't implemented
- some of the extra data installs aren't implemented
- valgrind is set to "no" rather than "auto". To make valgrind work
  correctly you need a patch that's neither reviewed nor landed in
  meson, or to implement a hack that might make cross compiling
  difficult.
---
 .editorconfig               |   4 +-
 README                      |  21 +--
 amdgpu/meson.build          |  57 +++++++-
 etnaviv/meson.build         |  56 +++++++-
 exynos/meson.build          |  52 +++++++-
 freedreno/meson.build       |  72 +++++++++-
 include/drm/meson.build     |  48 ++++++-
 intel/intel_bufmgr_gem.c    |   8 +-
 intel/meson.build           |  55 +++++++-
 libkms/meson.build          |  71 +++++++++-
 man/meson.build             | 119 +++++++++++++++-
 meson.build                 | 288 +++++++++++++++++++++++++++++++++++++-
 meson_config.h.in           |  24 +++-
 meson_options.txt           |  16 ++-
 nouveau/meson.build         |  63 ++++++++-
 omap/meson.build            |  48 ++++++-
 radeon/meson.build          |  62 ++++++++-
 tegra/meson.build           |  50 ++++++-
 tests/amdgpu/meson.build    |  30 ++++-
 tests/etnaviv/meson.build   |  49 ++++++-
 tests/exynos/meson.build    |  43 ++++++-
 tests/kms/meson.build       |  46 ++++++-
 tests/kmstest/meson.build   |  28 ++++-
 tests/meson.build           |  87 +++++++++++-
 tests/modeprint/meson.build |  27 +++-
 tests/modetest/meson.build  |  27 +++-
 tests/nouveau/meson.build   |  30 ++++-
 tests/proptest/meson.build  |  27 +++-
 tests/radeon/meson.build    |  27 +++-
 tests/tegra/meson.build     |  27 +++-
 tests/util/meson.build      |  35 ++++-
 tests/vbltest/meson.build   |  27 +++-
 vc4/meson.build             |  28 ++++-
 xf86atomic.h                |   4 +-
 34 files changed, 1637 insertions(+), 19 deletions(-)
 create mode 100644 amdgpu/meson.build
 create mode 100644 etnaviv/meson.build
 create mode 100644 exynos/meson.build
 create mode 100644 freedreno/meson.build
 create mode 100644 include/drm/meson.build
 create mode 100644 intel/meson.build
 create mode 100644 libkms/meson.build
 create mode 100644 man/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_config.h.in
 create mode 100644 meson_options.txt
 create mode 100644 nouveau/meson.build
 create mode 100644 omap/meson.build
 create mode 100644 radeon/meson.build
 create mode 100644 tegra/meson.build
 create mode 100644 tests/amdgpu/meson.build
 create mode 100644 tests/etnaviv/meson.build
 create mode 100644 tests/exynos/meson.build
 create mode 100644 tests/kms/meson.build
 create mode 100644 tests/kmstest/meson.build
 create mode 100644 tests/meson.build
 create mode 100644 tests/modeprint/meson.build
 create mode 100644 tests/modetest/meson.build
 create mode 100644 tests/nouveau/meson.build
 create mode 100644 tests/proptest/meson.build
 create mode 100644 tests/radeon/meson.build
 create mode 100644 tests/tegra/meson.build
 create mode 100644 tests/util/meson.build
 create mode 100644 tests/vbltest/meson.build
 create mode 100644 vc4/meson.build

diff --git a/.editorconfig b/.editorconfig
index 893b7be..ffc477f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -17,3 +17,7 @@ indent_style = tab
 [*.m4]
 indent_style = space
 indent_size = 2
+
+[meson.build]
+indent_style = space
+indent_size = 2
diff --git a/README b/README
index 26cab9d..b567d7e 100644
--- a/README
+++ b/README
@@ -15,27 +15,22 @@ with an older kernel.
 Compiling
 ---------
 
-libdrm  is  a  standard  autotools  package and  follows  the  normal
-configure, build  and install steps.   The first step is  to configure
-the package, which is done by running the configure shell script:
+libdrm is compiled using meson and ninja. The first step for building for a
+tar-ball or from git is to configure, and set a build directory:
 
-	./configure
+    meson build
 
-By default, libdrm  will install into the /usr/local/  prefix.  If you
-want  to  install   this  DRM  to  replace  your   system  copy,  pass
---prefix=/usr and  --exec-prefix=/ to configure.  If  you are building
-libdrm  from a  git checkout,  you first  need to  run  the autogen.sh
-script.  You can  pass any options to autogen.sh  that you would other
-wise  pass to configure,  or you  can just  re-run configure  with the
-options you need once autogen.sh finishes.
+By default, libdrm will install into the /usr/local/ prefix. If you
+want to install this DRM to replace your system copy, pass
+--prefix=/usr to meson, or -Dprefix=/usr to mesonconf.
 
 Next step is to build libdrm:
 
-	make
+	ninja -C build
 
 and once make finishes successfully, install the package using
 
-	make install
+	ninja install
 
 If you are installing into a system location, you will need to be root
 to perform the install step.
diff --git a/amdgpu/meson.build b/amdgpu/meson.build
new file mode 100644
index 0000000..71054df
--- /dev/null
+++ b/amdgpu/meson.build
@@ -0,0 +1,57 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+amdgpu_files = files(
+  'amdgpu_asic_id.h',
+  'amdgpu_bo.c',
+  'amdgpu_cs.c',
+  'amdgpu_device.c',
+  'amdgpu_gpu_info.c',
+  'amdgpu_internal.h',
+  'amdgpu_vamgr.c',
+  'util_hash.c',
+  'util_hash.h',
+  'util_hash_table.c',
+  'util_hash_table.h',
+)
+
+libdrm_amdgpu = shared_library(
+  'drm_amdgpu',
+  amdgpu_files,
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+  dependencies : pthreadstubs_dep,
+  version : '1.0.0',
+  install : true,
+)
+
+install_headers('amdgpu.h', subdir : 'libdrm')
+
+pkg.generate(
+  name : 'libdrm_amdgpu',
+  description : 'Userspace interface to kernel DRM services for amdgpu',
+  version : meson.project_version(),
+  subdirs : ['', 'libdrm'],
+  libraries : [libdrm_amdgpu],
+  requires_private : 'libdrm',
+)
+
+test('amdgpu-symbol-check', find_program('amdgpu-symbol-check'))
diff --git a/etnaviv/meson.build b/etnaviv/meson.build
new file mode 100644
index 0000000..c57152f
--- /dev/null
+++ b/etnaviv/meson.build
@@ -0,0 +1,56 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+etnaviv_files = files(
+  'etnaviv_device.c',
+  'etnaviv_gpu.c',
+  'etnaviv_bo.c',
+  'etnaviv_bo_cache.c',
+  'etnaviv_pipe.c',
+  'etnaviv_cmd_stream.c',
+  'etnaviv_drm.h',
+  'etnaviv_priv.h',
+)
+
+etnaviv_include = include_directories('.')
+
+libdrm_etnaviv = shared_library(
+  'drm_etnaviv',
+  etnaviv_files,
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+  dependencies : [pthreadstubs_dep, valgrind_dep],
+  version : '1.0.0',
+  install : true,
+)
+
+install_headers('etnaviv_drmif.h', subdir : 'libdrm')
+
+pkg.generate(
+  name : 'libdrm_etnaviv',
+  description : 'Userspace interface to etnaviv kernel DRM services',
+  version : meson.project_version(),
+  subdirs : ['', 'libdrm'],
+  libraries : [libdrm_etnaviv],
+  requires_private : 'libdrm',
+)
+
+test('etnaviv-symbol-check', find_program('etnaviv-symbol-check'))
diff --git a/exynos/meson.build b/exynos/meson.build
new file mode 100644
index 0000000..5adc12e
--- /dev/null
+++ b/exynos/meson.build
@@ -0,0 +1,52 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+exynos_files = files(
+  'exynos_drm.c',
+  'exynos_fimg2d.c',
+  'fimg2d_reg.h',
+)
+
+libdrm_exynos = shared_library(
+  'drm_exynos',
+  exynos_files,
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+  dependencies : [pthreadstubs_dep, valgrind_dep],
+  version : '1.0.0',
+  install : true,
+)
+
+exynos_include = include_directories('.')
+
+install_headers('exynos_drm.h', 'exynos_fimg2d.h', subdir : 'exynos')
+install_headers('exynos_drmif.h', subdir : 'libdrm')
+
+pkg.generate(
+  name : 'libdrm_exynos',
+  description : 'Userspace interface to exynos kernel DRM services',
+  version : '0.7',
+  subdirs : ['', 'libdrm', 'exynos'],
+  libraries : [libdrm_exynos],
+  requires_private : 'libdrm',
+)
+
+test('exynos-symbol-check', find_program('exynos-symbol-check'))
diff --git a/freedreno/meson.build b/freedreno/meson.build
new file mode 100644
index 0000000..ac02a75
--- /dev/null
+++ b/freedreno/meson.build
@@ -0,0 +1,72 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+freedreno_files = files(
+  'freedreno_device.c',
+  'freedreno_pipe.c',
+  'freedreno_priv.h',
+  'freedreno_ringbuffer.c',
+  'freedreno_bo.c',
+  'freedreno_bo_cache.c',
+  'msm/msm_bo.c',
+  'msm/msm_device.c',
+  'msm/msm_drm.h',
+  'msm/msm_pipe.c',
+  'msm/msm_priv.h',
+  'msm/msm_ringbuffer.c',
+)
+
+if get_option('freedreno-kgsl') == 'yes'
+  freedreno_kgsl_files = files(
+    'kgsl/kgsl_bo.c',
+    'kgsl/kgsl_device.c',
+    'kgsl/kgsl_drm.h',
+    'kgsl/kgsl_pipe.c',
+    'kgsl/kgsl_priv.h',
+    'kgsl/kgsl_ringbuffer.c',
+    'kgsl/msm_kgsl.h',
+  )
+else
+  freedreno_kgsl_files = []
+endif
+
+libdrm_freedreno = shared_library(
+  'drm_freedreno',
+  [freedreno_files, freedreno_kgsl_files],
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+  dependencies : pthreadstubs_dep,
+  version : '1.0.0',
+  install : true,
+)
+
+install_headers('freedreno_drmif.h', 'freedreno_ringbuffer.h', subdir : 'freedreno')
+
+pkg.generate(
+  name : 'libdrm_freedreno',
+  description : 'Userspace interface to freedreno kernel DRM services',
+  version : meson.project_version(),
+  subdirs : ['', 'libdrm', 'freedreno'],
+  libraries : [libdrm_freedreno],
+  requires_private : 'libdrm',
+)
+
+test('freedreno-symbol-check', find_program('freedreno-symbol-check'))
diff --git a/include/drm/meson.build b/include/drm/meson.build
new file mode 100644
index 0000000..feaf9c8
--- /dev/null
+++ b/include/drm/meson.build
@@ -0,0 +1,48 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+install_headers(
+  'drm.h',
+  'drm_fourcc.h',
+  'drm_mode.h',
+  'drm_sarea.h',
+  'i915_drm.h',
+  'mach64_drm.h',
+  'mga_drm.h',
+  'nouveau_drm.h',
+  'qxl_drm.h',
+  'r128_drm.h',
+  'radeon_drm.h',
+  'amdgpu_drm.h',
+  'savage_drm.h',
+  'sis_drm.h',
+  'tegra_drm.h',
+  'vc4_drm.h',
+  'via_drm.h',
+  'virtgpu_drm.h',
+  subdir : 'libdrm',
+)
+
+if conf_data.get('HAVE_VMWGFX')
+  install_headers(
+    'vmwgfx_drm.h',
+    subdir : 'libdrm',
+  )
+endif
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index e260f2d..2ba72bb 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -1,7 +1,7 @@
 /**************************************************************************
  *
- * Copyright © 2007 Red Hat Inc.
- * Copyright © 2007-2012 Intel Corporation
+ * Copyright © 2007 Red Hat Inc.
+ * Copyright © 2007-2012 Intel Corporation
  * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
  * All Rights Reserved.
  *
@@ -28,7 +28,7 @@
  *
  **************************************************************************/
 /*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
+ * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
  *          Keith Whitwell <keithw-at-tungstengraphics-dot-com>
  *	    Eric Anholt <eric at anholt.net>
  *	    Dave Airlie <airlied at linux.ie>
@@ -1217,7 +1217,7 @@ drm_intel_gem_bo_free(drm_intel_bo *bo)
 static void
 drm_intel_gem_bo_mark_mmaps_incoherent(drm_intel_bo *bo)
 {
-#if HAVE_VALGRIND
+#ifdef HAVE_VALGRIND
 	drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
 
 	if (bo_gem->mem_virtual)
diff --git a/intel/meson.build b/intel/meson.build
new file mode 100644
index 0000000..6f455bb
--- /dev/null
+++ b/intel/meson.build
@@ -0,0 +1,55 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+libdrm_intel_files = files(
+  'intel_bufmgr.c',
+  'intel_bufmgr_priv.h',
+  'intel_bufmgr_fake.c',
+  'intel_bufmgr_gem.c',
+  'intel_decode.c',
+  'intel_chipset.h',
+  'mm.c',
+  'mm.h',
+  'uthash.h',
+)
+
+libdrm_intel = shared_library(
+  'drm_intel',
+  libdrm_intel_files,
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+  dependencies : [pthreadstubs_dep, pciaccess_dep, valgrind_dep],
+  version : '1.0.0',
+  install : true,
+)
+
+install_headers('intel_bufmgr.h', 'intel_aub.h', 'intel_debug.h', subdir : 'libdrm')
+
+pkg.generate(
+  name : 'libdrm_intel',
+  description : 'Userspace interface to intel kernel DRM services',
+  version : meson.project_version(),
+  requires : 'libdrm',
+  subdirs : ['', 'libdrm'],
+  libraries : [libdrm_intel],
+)
+
+test('intel-symbol-check', find_program('intel-symbol-check'))
diff --git a/libkms/meson.build b/libkms/meson.build
new file mode 100644
index 0000000..55e726d
--- /dev/null
+++ b/libkms/meson.build
@@ -0,0 +1,71 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+libkms_files = files(
+  'internal.h',
+  'linux.c',
+  'dumb.c',
+  'api.c',
+)
+
+libkms_include = include_directories('.')
+
+if conf_data.get('HAVE_VMWGFX', false)
+  libkms_files += files('vmwgfx.c')
+endif
+
+if conf_data.get('HAVE_INTEL', false)
+  libkms_files += files('intel.c')
+endif
+
+if conf_data.get('HAVE_NOUVEAU', false)
+  libkms_files += files('nouveau.c')
+endif
+
+if conf_data.get('HAVE_RADEON', false)
+  libkms_files += files('radeon.c')
+endif
+
+if conf_data.get('HAVE_EXYNOS', false)
+  libkms_files += files('exynos.c')
+endif
+
+libkms = shared_library(
+  'kms',
+  libkms_files,
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include, include_directories('../exynos')],
+  link_with : libdrm,
+  version : '1.0.0',
+  install : true,
+)
+
+install_headers('libkms.h', subdir : 'libkms')
+
+pkg.generate(
+  name : 'libkms',
+  description : 'Library that abstracts away the different mm interfaces for kernel drivers',
+  version : '1.0.0',
+  requires_private : 'libdrm',
+  subdirs : ['libkms'],
+  libraries : [libkms],
+)
+
+test('kms-symbol-check', find_program('kms-symbol-check'))
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 0000000..5108456
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,119 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+xsltproc = find_program('xsltproc')
+sed = find_program('sed')
+
+stylesheet_url = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
+ret = run_command(xsltproc, '--nonet', stylesheet_url)
+if ret.returncode() != 0
+  error('Cannot build man pages without docbook-xml')
+endif
+
+xsltproc_args = [xsltproc, '-o', '@OUTPUT@',
+                 '--stringparam', 'man.authors.section.enabled', '0',
+                 '--stringparam', 'man.copyright.section.enabled', '0',
+                 '--stringparam', 'funcsynopsis.style', 'ansi',
+                 '--stringparam', 'man.output.quietly', '1',
+                 '--noout', stylesheet_url, '@INPUT@']
+
+# TODO: https://github.com/mesonbuild/meson/issues/1364
+# This issue is about creating reusable custom_target templates, which would
+# simplify the following custom_targets considerably.
+drm_avail_man = custom_target(
+  'drmAvailable.3',
+  input : 'drmAvailable.xml',
+  output : '@BASENAME at .3',
+  command : xsltproc_args,
+  install : true,
+  install_dir : 'usr/share/man/man3',
+)
+
+drm_handleevent_man = custom_target(
+  'drmHandleEvent.3',
+  input : 'drmHandleEvent.xml',
+  output : '@BASENAME at .3',
+  command : xsltproc_args,
+  install : true,
+  install_dir : 'usr/share/man/man3',
+)
+
+drm_modegetresources_man = custom_target(
+  'drmModeGetResources.3',
+  input : 'drmModeGetResources.xml',
+  output : '@BASENAME at .3',
+  command : xsltproc_args,
+  install : true,
+  install_dir : 'usr/share/man/man3',
+)
+
+drm_man = custom_target(
+  'drm.7',
+  input : 'drm.xml',
+  output : '@BASENAME at .7',
+  command : xsltproc_args,
+  install : true,
+  install_dir : 'usr/share/man/man7',
+)
+
+drm_kms_man = custom_target(
+  'kms.7',
+  input : 'drm-kms.xml',
+  output : '@BASENAME at .7',
+  command : xsltproc_args,
+  install : true,
+  install_dir : 'usr/share/man/man7',
+)
+
+drm_memory_man = custom_target(
+  'memory.7',
+  input : 'drm-memory.xml',
+  output : '@BASENAME at .7',
+  command : xsltproc_args,
+  install : true,
+  install_dir : 'usr/share/man/man7',
+)
+
+drm_mm = custom_target(
+  'mm.7',
+  input : 'drm-memory.xml',
+  output : 'drm-mm.7',
+  command : xsltproc_args,
+  install : true,
+  install_dir : 'usr/share/man/man7',
+)
+
+drm_gem = custom_target(
+  'gem.7',
+  input : 'drm-memory.xml',
+  output : 'drm-gem.7',
+  command : xsltproc_args,
+  install : true,
+  install_dir : 'usr/share/man/man7',
+)
+
+drm_gem = custom_target(
+  'ttm.7',
+  input : 'drm-memory.xml',
+  output : 'drm-ttm.7',
+  command : xsltproc_args,
+  install : true,
+  install_dir : 'usr/share/man/man7',
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..f8a75a0
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,288 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+project('libdrm', 'c', version : '2.4.76-dev', default_options : ['-std=c99'])
+
+pkg = import('pkgconfig')
+
+conf_data = configuration_data()
+
+global_warn_flags = []
+
+atomic_dep = []
+cunit_dep = []
+pciaccess_dep = []
+valgrind_dep = []
+pthreadstubs_dep = dependency('pthread-stubs')  # TODO: is this always required?
+cairo_dep = dependency('cairo', required : false)
+if cairo_dep.found()
+  conf_data.set('HAVE_CAIRO', true)
+endif
+thread_dep = dependency('threads')
+
+system = host_machine.system()
+if system.startswith('linux')
+  add_project_arguments('-D_GNU_SOURCE', language : 'c')
+endif
+
+cc = meson.get_compiler('c')
+
+# TODO: resolve whether we need -lrt
+cc.find_library('m')
+if cc.has_header('sys/sysctl.h')
+  conf_data.set('HAVE_SYS_SYSCTL_H', true)
+endif
+if cc.has_header('sys/select.h')
+  conf_data.set('HAVE_SYS_SELECT_H', true)
+endif
+if cc.has_header('alloca.h')
+  conf_data.set('HAVE_ALLOCA_H', true)
+endif
+if cc.has_function('major', prefix : '#include <sys/sysmacros.h>')
+  conf_data.set('MAJOR_IN_SYSMACROS', true)
+elif cc.has_function('major', prefix : '#include <sys/mkdev.h>')
+  conf_data.set('MAJOR_IN_MKDEV', true)
+endif
+if cc.has_function('open_memstream')
+  conf_data.set('HAVE_OPEN_MEMSTREAM', true)
+endif
+
+if cc.compiles('''int foo_hidden(void) __attribute__((visibility("hidden")));''')
+  conf_data.set('HAVE_ATTRIBUTE_VISIBILITY', true)
+endif
+
+# TODO: copy comment from configure.ac
+global_warn_flag_opts = [
+  '-Wall', '-Wextra', '-Wsign-compare',
+  '-Werror-implicit-function-declaration', '-Wpointer-arith',
+  '-Wwrite-strings', '-Wstrict-prototypes', '-Wmissing-prototypes',
+  '-Wmissing-format-attribute', '-Wnested-externs', '-Wpacked',
+  '-Wswitch-enum', '-Wmissing-format-attribute', '-Wstrict-aliasing=2',
+  '-Winit-self', '-Wdeclaration-after-statement', '-Wold-style-definition',
+  '-Wno-unused-parameter', '-Wno-attributes', '-Wno-long-long', '-Winline',
+  '-Wshadow', '-Wno-missing-field-initializers',
+]
+foreach f : global_warn_flag_opts
+  if cc.has_argument(f)
+    global_warn_flags += f
+  endif
+endforeach
+
+# Check for atomic intrinsics
+if cc.compiles('''
+	int atomic_add(int *i) { return __sync_add_and_fetch (i, 1); }
+	int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }
+    ''')
+  conf_data.set('HAVE_LIBDRM_ATOMIC_PRIMITIVES', true)
+elif (system.startswith('solaris') or system.startswith('netbsd')
+      and cc.has_function('atomic_cas_uint'))
+  if not cc.has_header('sys/atomic.h')
+    error('wat?')
+  endif
+else
+  atomic_dep = dependency('atomic_ops')
+  conf_data.set('HAVE_LIB_ATOMIC_OPS', true)
+endif
+
+if get_option('udev') == 'yes'
+  dependency('udev')
+  conf_data.set('UDEV', true)
+endif
+
+cpu = host_machine.cpu_family()
+if get_option('intel') != 'no'
+  if cpu == 'x86' or cpu == 'x86_64'
+    pciaccess_dep = dependency('pciaccess', version : '>=0.10')
+    conf_data.set('HAVE_INTEL', true)
+  endif
+endif
+if get_option('radeon') != 'no'
+  conf_data.set('HAVE_RADEON', true)
+endif
+if get_option('amdgpu') != 'no'
+  conf_data.set('HAVE_AMDGPU', true)
+  cunit_dep = dependency('cunit', version : '>=2.1', required : false)
+  if cunit_dep.found()
+    conf_data.set('HAVE_CUNIT', true)
+  endif
+endif
+if get_option('nouveau') != 'no'
+  conf_data.set('HAVE_NOUVEAU', true)
+  dl_lib = cc.find_library('dl')
+  if dl_lib.found()
+    dl_dep = declare_dependency(link_args : '-ldl')
+  else
+    error('nouveau tests require dlopen')
+  endif
+endif
+if get_option('freedreno') != 'no'
+  if cpu == 'arm'
+    conf_data.set('HAVE_FREEDRENO', true)
+    if get_option('freedreno-kgsl') == 'yes'
+      conf_data.set('HAVE_FREEDRENO_KGSL', true)
+    endif
+  endif
+endif
+if get_option('vc4') != 'no'
+  if cpu == 'arm'
+    conf_data.set('HAVE_VC4', true)
+  endif
+endif
+if get_option('vmwgfx') == 'yes'
+  conf_data.set('HAVE_VMWGFX', true)
+endif
+if get_option('omap-experimental-api') == 'yes'
+  if cpu == 'arm'
+    conf_data.set('HAVE_OMAP', true)
+  endif
+endif
+if get_option('exynos-experimental-api') == 'yes'
+  if cpu == 'arm'
+    conf_data.set('HAVE_EXYNOS', true)
+  endif
+endif
+if get_option('tegra-experimental-api') == 'yes'
+  if cpu == 'arm'
+    conf_data.set('HAVE_TEGRA', true)
+  endif
+endif
+if get_option('etnaviv-experimental-api') == 'yes'
+  if cpu == 'arm'
+    conf_data.set('HAVE_ETNAVIV', true)
+  endif
+endif
+
+if get_option('libkms') == 'auto'
+  if (system.startswith('linux') or
+      system.startswith('freebsd') or
+      system.startswith('dragonfly') or
+      (system.startswith('kfreebsd') and system.endswith('-gnu')))
+    conf_data.set('HAVE_LIBKMS', true)
+  elif get_option('libkms') == 'no'
+    conf_data.set('HAVE_LIBKMS', false)
+  endif
+elif get_option('libkms') == 'yes'
+  conf_data.set('HAVE_LIBKMS', true)
+else
+  conf_data.set('HAVE_LIBKMS', false)
+endif
+
+# TODO: https://github.com/mesonbuild/meson/issues/826
+# This only works with a dev build of meson
+if get_option('valgrind') != 'no'
+  valgrind_dep = dependency(
+    'valgrind',
+    headers_only : true,
+    required : get_option('valgrind') == 'yes'
+  )
+  if valgrind_dep.found()
+    conf_data.set('HAVE_VALGRIND', true)
+  endif
+endif
+
+config_h = configure_file(
+  input : 'meson_config.h.in',
+  output : 'config.h',
+  configuration : conf_data,
+)
+add_project_arguments('-DHAVE_CONFIG_H', language : 'c')
+
+libdrm_files = files(
+  'xf86drm.c',
+  'xf86drmHash.c',
+  'xf86drmHash.h',
+  'xf86drmRandom.c',
+  'xf86drmRandom.h',
+  'xf86drmSL.c',
+  'xf86drmMode.c',
+  'xf86atomic.h',
+  'libdrm_macros.h',
+  'libdrm_lists.h',
+  'util_double_list.h',
+  'util_math.h',
+)
+
+drm_include = include_directories('include/drm')
+base_include = include_directories('.')
+
+libdrm = shared_library(
+  'drm',
+  libdrm_files,
+  include_directories : [base_include, drm_include],
+  dependencies : valgrind_dep,
+  c_args : global_warn_flags,
+  link_args : '-lm',
+  version : '2.4.0',
+  install : true,
+)
+
+install_headers(
+  'libsync.h',
+  'xf86drm.h',
+  'xf86drmMode.h',
+)
+
+pkg.generate(
+  name : 'libdrm',
+  filebase : 'libdrm',
+  description : 'Userspace interface to kernel DRM services',
+  version : meson.project_version(),
+  libraries : [libdrm],
+  subdirs : ['', 'libdrm'],
+)
+
+subdir('include/drm')
+if conf_data.get('HAVE_LIBKMS', false)
+  subdir('libkms')
+endif
+if conf_data.get('HAVE_INTEL', false)
+  subdir('intel')
+endif
+if conf_data.get('HAVE_NOUVEAU', false)
+  subdir('nouveau')
+endif
+if conf_data.get('HAVE_RADEON', false)
+  subdir('radeon')
+endif
+if conf_data.get('HAVE_AMDGPU', false)
+  subdir('amdgpu')
+endif
+if conf_data.get('HAVE_OMAP', false)
+  subdir('omap')
+endif
+if conf_data.get('HAVE_EXYNOS', false)
+  subdir('exynos')
+endif
+if conf_data.get('HAVE_FREEDRENO', false)
+  subdir('freedreno')
+endif
+if conf_data.get('HAVE_TEGRA', false)
+  subdir('tegra')
+endif
+if conf_data.get('HAVE_VC4', false)
+  subdir('vc4')
+endif
+if conf_data.get('HAVE_ETNAVIV', false)
+  subdir('etnaviv')
+endif
+subdir('tests')
+if get_option('manpages')
+  subdir('man')
+endif
diff --git a/meson_config.h.in b/meson_config.h.in
new file mode 100644
index 0000000..a45723c
--- /dev/null
+++ b/meson_config.h.in
@@ -0,0 +1,24 @@
+#mesondefine HAVE_LIBDRM_ATOMIC_PRIMITIVES
+#mesondefine HAVE_LIB_ATOMIC_OPS
+#mesondefine HAVE_INTEL
+#mesondefine HAVE_RADEON
+#mesondefine HAVE_AMDGPU
+#mesondefine HAVE_NOUVEAU
+#mesondefine HAVE_FREEDRENO
+#mesondefine HAVE_FREEDRENO_KGSL
+#mesondefine HAVE_VC4
+#mesondefine HAVE_OMAP
+#mesondefine HAVE_EXYNOS
+#mesondefine HAVE_TEGRA
+#mesondefine HAVE_ETNAVIV
+#mesondefine HAVE_LIBKMS
+#mesondefine HAVE_SYS_SYSCTL_H
+#mesondefine HAVE_SYS_SELECT_H
+#mesondefine HAVE_VALGRIND
+#mesondefine HAVE_OPEN_MEMSTREAM
+#mesondefine HAVE_CAIRO
+#mesondefine UDEV
+#mesondefine HAVE_ATTRIBUTE_VISIBILITY
+#mesondefine HAVE_ALLOCA_H
+#mesondefine MAJOR_IN_SYSMACROS
+#mesondefine MAJOR_IN_MKDEV
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..d1d7190
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,16 @@
+option('intel',                    type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
+option('radeon',                   type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
+option('amdgpu',                   type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
+option('nouveau',                  type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
+option('vmwgfx',                   type : 'combo', choices : ['yes',   'no',     ], value : 'yes')
+option('freedreno',                type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
+option('freedreno-kgsl',           type : 'combo', choices : ['yes',   'no',     ], value : 'no')
+option('vc4',                      type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
+option('omap-experimental-api',    type : 'combo', choices : ['auto', 'yes', 'no'], value : 'no')
+option('exynos-experimental-api',  type : 'combo', choices : ['auto', 'yes', 'no'], value : 'no')
+option('tegra-experimental-api',   type : 'combo', choices : ['auto', 'yes', 'no'], value : 'no')
+option('etnaviv-experimental-api', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'no')
+option('libkms',                   type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
+option('valgrind',                 type : 'combo', choices : ['auto', 'yes', 'no'], value : 'no')
+option('udev',                     type : 'combo', choices : ['yes',   'no',     ], value : 'no')
+option('manpages',                 type : 'boolean', value : false)
diff --git a/nouveau/meson.build b/nouveau/meson.build
new file mode 100644
index 0000000..6101b3c
--- /dev/null
+++ b/nouveau/meson.build
@@ -0,0 +1,63 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+nouveau_files = files(
+  'nouveau.c',
+  'pushbuf.c',
+  'bufctx.c',
+  'abi16.c',
+  'private.h',
+)
+
+nouveau_include = include_directories('.')
+
+libdrm_nouveau = shared_library(
+  'drm_nouveau',
+  nouveau_files,
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+  dependencies : pthreadstubs_dep,
+  version : '2.0.0',
+  install : true,
+)
+
+install_headers('nouveau.h', subdir : 'libdrm/nouveau')
+install_headers(
+  'nvif/class.h',
+  'nvif/cl0080.h',
+  'nvif/cl9097.h',
+  'nvif/if0002.h',
+  'nvif/if0003.h',
+  'nvif/ioctl.h',
+  'nvif/unpack.h',
+  subdir : 'nouveau/nvif',
+)
+
+pkg.generate(
+  name : 'libdrm_nouveau',
+  description : 'Userspace interface to nouveau kernel DRM services',
+  version : meson.project_version(),
+  subdirs : ['', 'libdrm'],
+  libraries : [libdrm_nouveau],
+  requires_private : 'libdrm',
+)
+
+test('nouveau-symbol-check', find_program('nouveau-symbol-check'))
diff --git a/omap/meson.build b/omap/meson.build
new file mode 100644
index 0000000..83f3003
--- /dev/null
+++ b/omap/meson.build
@@ -0,0 +1,48 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+omap_files = files(
+  'omap_drm.c',
+)
+
+libdrm_omap = shared_library(
+  'drm_omap',
+  omap_files,
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+  dependencies : [pthreadstubs_dep, valgrind_dep],
+  version : '1.0.0',
+  install : true,
+)
+
+install_headers('omap_drm.h', subdir : 'omap')
+install_headers('omap_drmif.h', subdir : 'libdrm')
+
+pkg.generate(
+  name : 'libdrm_omap',
+  description : 'Userspace interface to omap kernel DRM services',
+  version : '0.6',
+  subdirs : ['', 'libdrm', 'omap'],
+  libraries : [libdrm_omap],
+  requires_private : 'libdrm',
+)
+
+test('omap-symbol-check', find_program('omap-symbol-check'))
diff --git a/radeon/meson.build b/radeon/meson.build
new file mode 100644
index 0000000..b1630fc
--- /dev/null
+++ b/radeon/meson.build
@@ -0,0 +1,62 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+radeon_files = files(
+  'radeon_bo_gem.c',
+  'radeon_cs_gem.c',
+  'radeon_cs_space.c',
+  'radeon_bo.c',
+  'radeon_cs.c',
+  'radeon_surface.c',
+)
+
+libdrm_radeon = shared_library(
+  'drm_radeon',
+  radeon_files,
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+  dependencies : pthreadstubs_dep,
+  version : '1.0.1',
+  install : true,
+)
+
+install_headers(
+  'radeon_bo.h',
+  'radeon_cs.h',
+  'radeon_surface.h',
+  'radeon_bo_gem.h',
+  'radeon_cs_gem.h',
+  'radeon_bo_int.h',
+  'radeon_cs_int.h',
+  'r600_pci_ids.h',
+  subdir : 'libdrm'
+)
+
+pkg.generate(
+  name : 'libdrm_radeon',
+  description : 'Userspace interface to kernel DRM services for radeon',
+  version : meson.project_version(),
+  subdirs : ['', 'libdrm'],
+  libraries : [libdrm_radeon],
+  requires_private : 'libdrm',
+)
+
+test('radeon-symbol-check', find_program('radeon-symbol-check'))
diff --git a/tegra/meson.build b/tegra/meson.build
new file mode 100644
index 0000000..4a90fc1
--- /dev/null
+++ b/tegra/meson.build
@@ -0,0 +1,50 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+tegra_files = files(
+  'private.h',
+  'tegra.c',
+)
+
+libdrm_tegra = shared_library(
+  'drm_tegra',
+  tegra_files,
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+  dependencies : [pthreadstubs_dep, valgrind_dep],
+  version : '1.0.0',
+  install : true,
+)
+
+tegra_include = include_directories('.')
+
+install_headers('tegra.h', subdir : 'libdrm')
+
+pkg.generate(
+  name : 'libdrm_tegra',
+  description : 'Userspace interface to Tegra kernel DRM services',
+  version : meson.project_version(),
+  subdirs : ['', 'libdrm'],
+  libraries : [libdrm_tegra],
+  requires_private : 'libdrm',
+)
+
+test('tegra-symbol-check', find_program('tegra-symbol-check'))
diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build
new file mode 100644
index 0000000..86bd516
--- /dev/null
+++ b/tests/amdgpu/meson.build
@@ -0,0 +1,30 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+if conf_data.get('HAVE_CUNIT', false)
+  amdgpu_test = executable(
+    'amdgpu_test',
+    ['amdgpu_test.c', 'amdgpu_test.h', 'basic_tests.c', 'bo_tests.c',
+     'cs_tests.c', 'uvd_messages.h', 'vce_tests.c', 'vce_ib.h', 'frame.h'],
+    include_directories : [base_include, include_directories('../../amdgpu'), drm_include],
+    dependencies : cunit_dep,
+    link_with : [libdrm, libdrm_amdgpu],
+  )
+endif
diff --git a/tests/etnaviv/meson.build b/tests/etnaviv/meson.build
new file mode 100644
index 0000000..cb75c03
--- /dev/null
+++ b/tests/etnaviv/meson.build
@@ -0,0 +1,49 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+if conf_data.get('HAVE_LIBKMS', false)
+  test_etnaviv_2d = executable(
+    'etnaviv_2d_test',
+    ['cmdstream.xml.h', 'etnaviv_2d_test.c', 'state.xml.h', 'state_2d.xml.h',
+     'write_bmp.c', 'write_bmp.h'],
+    c_args : global_warn_flags,
+    include_directories : [base_include, drm_include, etnaviv_include],
+    link_with : [libdrm, libdrm_etnaviv],
+    dependencies : thread_dep
+  )
+endif
+
+test_etnaviv_cmd_stream = executable(
+  'etnaviv_cmd_stream_test',
+  'etnaviv_cmd_stream_test.c',
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include, etnaviv_include],
+  link_with : [libdrm_etnaviv],
+  dependencies : thread_dep
+)
+
+test_etnaviv_bo_cache = executable(
+  'etnaviv_bo_cache_test',
+  'etnaviv_bo_cache_test.c',
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include, etnaviv_include],
+  link_with : [libdrm, libdrm_etnaviv],
+  dependencies : thread_dep
+)
diff --git a/tests/exynos/meson.build b/tests/exynos/meson.build
new file mode 100644
index 0000000..b216e71
--- /dev/null
+++ b/tests/exynos/meson.build
@@ -0,0 +1,43 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+test_exynos_fimg2d_perf = executable(
+  'exynos_fimg2d_perf',
+  'exynos_fim2d_perf.c',
+  include_directories : [base_include, libkms_include, exynos_include, drm_include],
+  link_with : [libdrm, libdrm_exynos],
+)
+
+test_exynos_fimg2d_event = executable(
+  'exynos_fimg2d_event',
+  'exynos_fimg2d_event.c',
+  include_directories : [base_include, kms_include, exynos_include, drm_include],
+  link_with : [libdrm, libdrm_exynos],
+)
+
+if conf_data.get('HAVE_LIBKMS', false):
+  test_exynos_fimg2d_test = executable(
+    'exynos_fimg2d_test',
+    'exynos_fimg2d_test.c',
+    dependencies : test_util_dep,
+    include_directories : [base_include, kms_include, exynos_include, drm_include],
+    link_with : [libdrm, libdrm_exynos],
+  )
+endif
diff --git a/tests/kms/meson.build b/tests/kms/meson.build
new file mode 100644
index 0000000..430bdce
--- /dev/null
+++ b/tests/kms/meson.build
@@ -0,0 +1,46 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+kms_test_common_files = files(
+  'libkms-test.h',
+  'libkms-test-crtc.c',
+  'libkms-test-device.c',
+  'libkms-test-framebuffer.c',
+  'libkms-test-plane.c',
+  'libkms-test-screen.c',
+)
+
+test_kms_steal_crtc = executable(
+  'kms-steal-crtc',
+  [kms_test_common_files, 'kms-steal-crtc.c'],
+  c_args : global_warn_flags,
+  include_directories : drm_include,
+  dependencies : test_util_dep,
+  link_with : libdrm,
+)
+
+test_kms_universal_planes = executable(
+  'kms-universal-planes',
+  [kms_test_common_files, 'kms-universal-planes.c'],
+  c_args : global_warn_flags,
+  dependencies : cairo_dep,
+  include_directories : [base_include, test_include, drm_include],
+  link_with : libdrm,
+)
diff --git a/tests/kmstest/meson.build b/tests/kmstest/meson.build
new file mode 100644
index 0000000..e4cfa13
--- /dev/null
+++ b/tests/kmstest/meson.build
@@ -0,0 +1,28 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+kmstest = executable(
+  'kmstest',
+  'main.c',
+  include_directories : libkms_include,
+  dependencies : test_util_dep,
+  link_with : [libkms, libdrm],
+  c_args : global_warn_flags,
+)
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..1989ae1
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,87 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+test_drmsl = executable(
+  'drmsl',
+  'drmsl.c',
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+)
+
+test_hash = executable(
+  'hash',
+  'hash.c',
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+)
+
+test_random = executable(
+  'random',
+  'random.c',
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+)
+
+test_drmdevice = executable(
+  'drmdevice',
+  'drmdevice.c',
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+)
+
+test('drmsl', test_drmsl)
+test('hash', test_hash)
+# XXX: This test never seems to finish
+#test('random', test_random)
+test('drmdevice', test_drmdevice)
+
+test_include = include_directories('.')
+
+subdir('util')
+subdir('kms')
+subdir('modeprint')
+subdir('proptest')
+subdir('modetest')
+subdir('vbltest')
+if conf_data.get('HAVE_LIBKMS', false)
+  subdir('kmstest')
+endif
+if conf_data.get('HAVE_RADEON', false)
+  subdir('radeon')
+endif
+if conf_data.get('HAVE_AMDGPU', false) and conf_data.get('HAVE_CUNIT', false)
+  subdir('amdgpu')
+endif
+if conf_data.get('have_exynos', false)
+  subdir('exynos')
+endif
+if conf_data.get('HAVE_TEGRA', false)
+  subdir('tegra')
+endif
+if conf_data.get('HAVE_ETNAVIV', false)
+  subdir('etnaviv')
+endif
+if conf_data.get('HAVE_NOUVEAU', false)
+  subdir('nouveau')
+endif
diff --git a/tests/modeprint/meson.build b/tests/modeprint/meson.build
new file mode 100644
index 0000000..ea8d0de
--- /dev/null
+++ b/tests/modeprint/meson.build
@@ -0,0 +1,27 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+test_modeprint = executable(
+  'modeprint',
+  'modeprint.c',
+  include_directories : [drm_include, test_include, base_include], 
+  link_with : libdrm,
+  c_args : global_warn_flags,
+)
diff --git a/tests/modetest/meson.build b/tests/modetest/meson.build
new file mode 100644
index 0000000..6579a2f
--- /dev/null
+++ b/tests/modetest/meson.build
@@ -0,0 +1,27 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+modetest = executable(
+  'modetest',
+  ['buffers.c', 'buffers.h', 'cursor.c', 'cursor.h', 'modetest.c'],
+  c_args : [global_warn_flags, '-Wno-pointer-arith'],
+  dependencies : [test_util_dep, thread_dep],
+  link_with : libdrm,
+)
diff --git a/tests/nouveau/meson.build b/tests/nouveau/meson.build
new file mode 100644
index 0000000..bd87222
--- /dev/null
+++ b/tests/nouveau/meson.build
@@ -0,0 +1,30 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+test_nouveau_threaded = executable(
+  'threaded',
+  'threaded.c',
+  dependencies : [thread_dep, dl_dep],
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include, nouveau_include],
+  link_with : [libdrm_nouveau, libdrm],
+)
+
+test('nouveau-threaded', test_nouveau_threaded)
diff --git a/tests/proptest/meson.build b/tests/proptest/meson.build
new file mode 100644
index 0000000..9d20cb9
--- /dev/null
+++ b/tests/proptest/meson.build
@@ -0,0 +1,27 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+test_proptest = executable(
+  'proptest',
+  'proptest.c',
+  c_args : global_warn_flags,
+  dependencies : [test_util_dep],
+  link_with : libdrm,
+)
diff --git a/tests/radeon/meson.build b/tests/radeon/meson.build
new file mode 100644
index 0000000..8cc58cf
--- /dev/null
+++ b/tests/radeon/meson.build
@@ -0,0 +1,27 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+radeon_ttm = executable(
+  'radeon_ttm',
+  ['rbo.c', 'rbo.h', 'radeon_ttm.c'],
+  c_args : global_warn_flags,
+  include_directories : [base_include, drm_include],
+  link_with : libdrm,
+)
diff --git a/tests/tegra/meson.build b/tests/tegra/meson.build
new file mode 100644
index 0000000..dd3e15a
--- /dev/null
+++ b/tests/tegra/meson.build
@@ -0,0 +1,27 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+test_tegra_openclose = executable(
+  'openclose',
+  'openclose.c',
+  c_args : global_warn_flags,
+  include_directories : [base_include, tegra_include, drm_include],
+  link_with : [libdrm, libdrm_tegra],
+)
diff --git a/tests/util/meson.build b/tests/util/meson.build
new file mode 100644
index 0000000..0c12112
--- /dev/null
+++ b/tests/util/meson.build
@@ -0,0 +1,35 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+test_util_files = files(
+  'common.h',
+  'format.c',
+  'format.h',
+  'kms.c',
+  'kms.h',
+  'pattern.c',
+  'pattern.h',
+)
+
+test_util_dep = declare_dependency(
+  sources : test_util_files,
+  include_directories : [base_include, drm_include, test_include],
+  dependencies : cairo_dep,
+)
diff --git a/tests/vbltest/meson.build b/tests/vbltest/meson.build
new file mode 100644
index 0000000..b454b6d
--- /dev/null
+++ b/tests/vbltest/meson.build
@@ -0,0 +1,27 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+vbltest = executable(
+  'vbltest',
+  'vbltest.c',
+  c_args : global_warn_flags,
+  dependencies : test_util_dep,
+  link_with : libdrm,
+)
diff --git a/vc4/meson.build b/vc4/meson.build
new file mode 100644
index 0000000..a0d9e4f
--- /dev/null
+++ b/vc4/meson.build
@@ -0,0 +1,28 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+install_headers('vc4_packet.h', 'vc4_qpu_defines.h', subdir : 'libdrm')
+
+pkg.generate(
+  name : 'libdrm_vc4',
+  description : 'Userspace interface to vc4 kernel DRM services',
+  version : meson.project_version(),
+  requires_private : 'libdrm',
+)
diff --git a/xf86atomic.h b/xf86atomic.h
index 922b37d..57ccdfd 100644
--- a/xf86atomic.h
+++ b/xf86atomic.h
@@ -38,7 +38,7 @@
 #include "config.h"
 #endif
 
-#if HAVE_LIBDRM_ATOMIC_PRIMITIVES
+#ifdef HAVE_LIBDRM_ATOMIC_PRIMITIVES
 
 #define HAS_ATOMIC_OPS 1
 
@@ -57,7 +57,7 @@ typedef struct {
 
 #endif
 
-#if HAVE_LIB_ATOMIC_OPS
+#ifdef HAVE_LIB_ATOMIC_OPS
 #include <atomic_ops.h>
 
 #define HAS_ATOMIC_OPS 1
-- 
git-series 0.9.1


More information about the dri-devel mailing list