diff mbox

[libdrm,1/1] Add meson build system

Message ID 20170928233118.10329-2-dylan@pnwbakers.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dylan Baker Sept. 28, 2017, 11:31 p.m. UTC
This patch adds a meson build system that is equivalent to the autotools
build system with a few exceptions but is about 4x faster than
autotools.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>

---
 amdgpu/meson.build          |  73 ++++++++++
 data/meson.build            |  24 ++++
 etnaviv/meson.build         |  59 +++++++++
 exynos/meson.build          |  49 +++++++
 freedreno/meson.build       |  78 +++++++++++
 intel/meson.build           |  85 ++++++++++++
 libkms/meson.build          |  71 ++++++++++
 man/meson.build             |  66 +++++++++
 meson.build                 | 317 ++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt           |  38 ++++++
 nouveau/meson.build         |  61 +++++++++
 omap/meson.build            |  49 +++++++
 radeon/meson.build          |  61 +++++++++
 tegra/meson.build           |  48 +++++++
 tests/amdgpu/meson.build    |  42 ++++++
 tests/etnaviv/meson.build   |  57 ++++++++
 tests/exynos/meson.build    |  54 ++++++++
 tests/kms/meson.build       |  54 ++++++++
 tests/kmstest/meson.build   |  30 +++++
 tests/meson.build           |  85 ++++++++++++
 tests/modeprint/meson.build |  29 ++++
 tests/nouveau/meson.build   |  30 +++++
 tests/proptest/meson.build  |  30 +++++
 tests/radeon/meson.build    |  27 ++++
 tests/tegra/meson.build     |  27 ++++
 tests/util/meson.build      |  37 ++++++
 tests/vbltest/meson.build   |  28 ++++
 vc4/meson.build             |  28 ++++
 28 files changed, 1637 insertions(+)
 create mode 100644 amdgpu/meson.build
 create mode 100644 data/meson.build
 create mode 100644 etnaviv/meson.build
 create mode 100644 exynos/meson.build
 create mode 100644 freedreno/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_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/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 mbox

Patch

diff --git a/amdgpu/meson.build b/amdgpu/meson.build
new file mode 100644
index 00000000..72150f9e
--- /dev/null
+++ b/amdgpu/meson.build
@@ -0,0 +1,73 @@ 
+# 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.
+
+ids = join_paths(meson.source_root(), 'data/amdgpu.ids')
+
+prog_egrep = find_program('egrep')
+amdgpu_asic_count = run_command(
+  prog_egrep, ['-ci', '\'^[0-9a-f]{4},.*[0-9a-f]+,\'', ids]
+).stdout().strip()
+
+datadir = get_option('datadir')
+
+files_amdgpu = files(
+  'amdgpu_asic_id.c',
+  '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',
+  [files_amdgpu, config_file],
+  c_args : [c_args,
+	    '-DAMDGPU_ASIC_ID_TABLE="@0@"'.format(join_paths(datadir, 'libdrm', 'amdgpu.ids')),
+	    '-DAMDGPU_ASIC_ID_TABLE_NUM_ENTRIES=@0@'.format(amdgpu_asic_count)],
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  dependencies : [dep_pthread_stubs],
+  version : '1.0.0',
+  install : true,
+)
+
+install_headers('amdgpu.h', subdir : 'libdrm')
+
+pkg.generate(
+  name : 'libdrm_amdgpu',
+  libraries : libdrm_amdgpu,
+  subdirs : ['.', 'libdrm'],
+  version : meson.project_version(),
+  requires_private : 'libdrm',
+  description : 'Userspace interface to kernel DRM services for amdgpu',
+)
+
+ext_libdrm_amdgpu = declare_dependency(
+  link_with : [libdrm, libdrm_amdgpu],
+  include_directories : [inc_drm, include_directories('.')],
+)
+
+test('amdgpu-symbol-check', find_program('amdgpu-symbol-check'))
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 00000000..58eb5772
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,24 @@ 
+# 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 with_amdgpu != 'no'
+  install_data('amdgpu.ids', install_mode : 'r--r--r--',
+               install_dir : join_paths(get_option('datadir'), 'libdrm'))
+endif
diff --git a/etnaviv/meson.build b/etnaviv/meson.build
new file mode 100644
index 00000000..23c3a436
--- /dev/null
+++ b/etnaviv/meson.build
@@ -0,0 +1,59 @@ 
+# 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.
+
+files_etnaviv = 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',
+)
+
+libdrm_etnaviv = shared_library(
+  'drm_etnaviv',
+  [files_etnaviv, config_file],
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  c_args : c_args,
+  dependencies : [dep_pthread_stubs, dep_rt],
+  version : '1.0.0',
+  install : true,
+)
+
+install_headers('etnaviv_drmif.h', subdir : 'libdrm')
+
+pkg.generate(
+  name : 'libdrm_etnaviv',
+  libraries : libdrm_etnaviv,
+  subdirs : ['.', 'libdrm'],
+  version : meson.project_version(),
+  requires_private : 'libdrm',
+  description : 'Userspace interface to Tegra kernel DRM services',
+)
+
+ext_libdrm_etnaviv = declare_dependency(
+  link_with : [libdrm, libdrm_etnaviv],
+  include_directories : [inc_drm, include_directories('.')],
+)
+
+test('etnaviv-symbol-check', find_program('etnaviv-symbol-check'))
diff --git a/exynos/meson.build b/exynos/meson.build
new file mode 100644
index 00000000..d548803d
--- /dev/null
+++ b/exynos/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.
+
+libdrm_exynos = shared_library(
+  'drm_exynos',
+  [files('exynos_drm.c', 'exynos_fimg2d.c', 'fimg2d_reg.h'), config_file],
+  c_args : c_args,
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  dependencies : [dep_pthread_stubs],
+  version : '1.0.0',
+  install : true,
+)
+
+install_headers('exynos_drmif.h', subdir : 'libdrm')
+install_headers('exynos_drm.h', 'exynos_fimg2d.h', subdir : 'exynos')
+
+ext_libdrm_exynos = declare_dependency(
+  link_with : [libdrm, libdrm_exynos],
+  include_directories : [inc_drm, include_directories('.')],
+)
+
+pkg.generate(
+  name : 'libdrm_exynos',
+  libraries : libdrm_exynos,
+  subdirs : ['.', 'libdrm', 'exynos'],
+  version : '0.7',
+  requires_private : 'libdrm',
+  description : 'Userspace interface to exynos kernel DRM services',
+)
+
+test('exynos-symbol-check', find_program('exynos-symbol-check'))
diff --git a/freedreno/meson.build b/freedreno/meson.build
new file mode 100644
index 00000000..b6655afb
--- /dev/null
+++ b/freedreno/meson.build
@@ -0,0 +1,78 @@ 
+# 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.
+
+files_freedreno = 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 with_freedreno_kgsl != 'no'
+  files_freedreno += 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',
+  )
+endif
+
+libdrm_freedreno = shared_library(
+  'drm_freedreno',
+  [files_freedreno, config_file],
+  c_args : c_args,
+  include_directories : [inc_root, inc_drm],
+  dependencies : [dep_valgrind, dep_pthread_stubs, dep_rt],
+  link_with : libdrm,
+  version : '1.0.0',
+  install : true,
+)
+
+ext_libdrm_freedreno = declare_dependency(
+  link_with : [libdrm, libdrm_freedreno],
+  include_directories : [inc_drm, include_directories('.')],
+)
+
+install_headers(
+  'freedreno_drmif.h', 'freedreno_ringbuffer.h',
+  subdir : 'freedreno'
+)
+
+pkg.generate(
+  name : 'libdrm_freedreno',
+  libraries : libdrm_freedreno,
+  subdirs : ['.', 'libdrm', 'freedreno'],
+  version : '0.7',
+  requires_private : 'libdrm',
+  description : 'Userspace interface to freedreno kernel DRM services',
+)
+
+test('freedreno-symbol-check', find_program('freedreno-symbol-check'))
diff --git a/intel/meson.build b/intel/meson.build
new file mode 100644
index 00000000..ec4ac014
--- /dev/null
+++ b/intel/meson.build
@@ -0,0 +1,85 @@ 
+# 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.
+
+files_intel = 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',
+  [files_intel, config_file],
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind],
+  c_args : c_args,
+  version : '1.0.0',
+  install : true,
+)
+
+ext_libdrm_intel = declare_dependency(
+  link_with : [libdrm, libdrm_intel],
+  include_directories : [inc_drm, include_directories('.')],
+)
+
+install_headers(
+  'intel_bufmgr.h', 'intel_aub.h', 'intel_debug.h',
+  subdir : 'intel',
+)
+
+pkg.generate(
+  name : 'libdrm_intel',
+  libraries : libdrm_intel,
+  subdirs : ['.', 'libdrm'],
+  version : meson.project_version(),
+  requires : 'libdrm',
+  description : 'Userspace interface to intel kernel DRM services',
+)
+
+test_decode = executable(
+  'test_decode',
+  files('test_decode.c'),
+  include_directories : [inc_root, inc_drm],
+  link_with : [libdrm, libdrm_intel],
+  c_args : c_args,
+)
+
+test('gen4-3d.batch', find_program('tests/gen4-3d.batch.sh'),
+     workdir : meson.current_build_dir())
+test('gen45-3d.batch', find_program('tests/gm45-3d.batch.sh'),
+     workdir : meson.current_build_dir())
+test('gen5-3d.batch', find_program('tests/gen5-3d.batch.sh'),
+     workdir : meson.current_build_dir())
+test('gen6-3d.batch', find_program('tests/gen6-3d.batch.sh'),
+     workdir : meson.current_build_dir())
+test('gen7-3d.batch', find_program('tests/gen7-3d.batch.sh'),
+     workdir : meson.current_build_dir())
+test('gen7-3d.batch', find_program('tests/gen7-3d.batch.sh'),
+     workdir : meson.current_build_dir())
+test('gen7-2d-copy.batch', find_program('tests/gen7-2d-copy.batch.sh'),
+     workdir : meson.current_build_dir())
+test('intel-symbol-check', find_program('intel-symbol-check'))
diff --git a/libkms/meson.build b/libkms/meson.build
new file mode 100644
index 00000000..5a0b3bd8
--- /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_include = [inc_root, inc_drm]
+files_libkms = files(
+	'internal.h',
+	'linux.c',
+	'dumb.c',
+	'api.c',
+)
+if with_vmwgfx != 'no'
+  files_libkms += files('vmwgfx.c')
+endif
+if with_intel != 'no'
+  files_libkms += files('intel.c')
+endif
+if with_nouveau != 'no'
+  files_libkms += files('nouveau.c')
+endif
+if with_radeon != 'no'
+  files_libkms += files('radeon.c')
+endif
+if with_exynos != 'no'
+  files_libkms += files('exynos.c')
+  libkms_include += include_directories('../exynos')
+endif
+
+libkms = shared_library(
+  'kms',
+  [files_libkms, config_file],
+  c_args : c_args,
+  include_directories : libkms_include,
+  link_with : libdrm,
+  version : '1.0.0',
+  install : true,
+)
+
+ext_libkms = declare_dependency(
+  link_with : [libdrm, libkms],
+  include_directories : [libkms_include],
+)
+
+install_headers('libkms.h', subdir : 'libkms')
+
+pkg.generate(
+  name : 'libkms',
+  libraries : libkms,
+  subdirs : ['libkms'],
+  version : '1.0.0',
+  requires_private : 'libdrm',
+  description : 'Library that abstracts away the different mm interfaces for kernel drivers',
+)
+
+test('kms-symbol-check', find_program('kms-symbol-check'))
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 00000000..0b2efe5f
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,66 @@ 
+# 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_args = [
+  '--stringparam', 'man.authors.section.enabled', '0',
+  '--stringparam', 'man.copyright.section.enabled', '0',
+  '--stringparam', 'funcsynopsis.style', 'ansi',
+  '--stringparam', 'man.output.quietly', '1',
+  '--nonet', manpage_style,
+]
+
+xmls = [
+  ['drm', '7'], ['drm-kms', '7'], ['drm-memory', '7'], ['drmAvailable', '3'],
+  ['drmHandleEvent', '3'], ['drmModeGetResources', '3']
+]
+foreach x : xmls
+  m = x[0]
+  s = x[1]
+  custom_target(
+    m,
+    input : files('@0@.xml'.format(m)),
+    output : '@0@.@1@'.format(m, s),
+    command : [prog_xslt, '-o', '@OUTPUT@', xsltproc_args, '@INPUT0@'],
+    install : true,
+    install_dir : join_paths(get_option('datadir'), 'man', 'man@0@'.format(s)),
+    build_by_default : true,
+  )
+endforeach
+
+foreach x : ['drm-mm', 'drm-gem', 'drm-ttm']
+  gen = custom_target(
+    'gen-@0@'.format(x),
+    input : 'drm-memory.xml',
+    output : '@0@.xml'.format(x),
+    command : [prog_sed, '-e',
+               's@^\.so \([a-z_]\+\)\.\([0-9]\)$$@\.so man\2\/\1\.\2@',
+               '@INPUT@'],
+    capture : true,
+  )
+  custom_target(
+    '@0@.7'.format(x),
+    input : gen,
+    output : '@0@.7'.format(x, '7'),
+    command : [prog_xslt, '-o', '@OUTPUT@', xsltproc_args, '@INPUT@'],
+    install : true,
+    install_dir : join_paths(get_option('datadir'), 'man', 'man7'),
+    build_by_default : true,
+  )
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 00000000..969245e3
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,317 @@ 
+# 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.82', license : 'MIT',
+        default_options : ['c_std=gnu99'])
+
+pkg = import('pkgconfig')
+
+with_udev = get_option('udev')
+with_libkms = get_option('libkms')
+with_intel = get_option('intel')
+with_radeon = get_option('radeon')
+with_amdgpu = get_option('amdgpu')
+with_nouveau = get_option('nouveau')
+with_vmwgfx = get_option('vmwgfx')
+with_omap = get_option('omap')
+with_exynos = get_option('exynos')
+with_freedreno = get_option('freedreno')
+with_freedreno_kgsl = get_option('freedreno-kgls')
+with_tegra = get_option('tegra')
+with_vc4 = get_option('vc4')
+with_etnaviv = get_option('etnaviv')
+with_install_tests = get_option('install_test_programs')
+with_cairo_tests = get_option('cairo_tests')
+with_man_pages = get_option('man_pages')
+with_valgrind = get_option('valgrind')
+
+config = configuration_data()
+
+if host_machine.system() == 'bsd'
+  dep_pthread_stubs = dependency('pthread-stubs', version : '>= 0.4')
+else
+  dep_pthread_stubs = []
+endif
+dep_threads = dependency('threads')
+
+cc = meson.get_compiler('c')
+dep_dl = cc.find_library('dl', required : with_nouveau != 'no')
+# clock_gettime might require -rt, or it might not. find out
+dep_rt = []
+if not cc.has_function('clock_gettime', prefix : '#define _GNU_SOURCE\n#include <time.h>')
+  # XXX: untested
+  dep_rt = dependency('rt')
+  cc.has_function('clock_gettime', dependencies : dep_rt)
+endif
+dep_m = cc.find_library('m', required : false)
+if cc.has_header('sys/sysctl.h')
+  config.set10('SYS_SYSCTL_H', true)
+endif
+if cc.has_header('sys/select.h')
+  config.set10('SYS_SELECT_H', true)
+endif
+if cc.has_header_symbol('sys/sysmacros.h', 'major')
+  config.set10('MAJOR_IN_SYSMACROS', true)
+elif cc.has_header_symbol('sys/mkdev.h', 'major')
+  config.set10('MAJOR_IN_MKDEV', true)
+endif
+if cc.has_function('open_memstream')
+  config.set10('HAVE_OPEN_MEMSTREAM', true)
+endif
+
+c_args = []
+foreach a : ['-Wall', '-Wextra', '-Wsign-compare', 
+             '-Werror-implicit-function-declaration', '-Wpointer-arith',
+             '-Wwrite-strings', '-Wstrict-prototypes', '-Wmissing-prototypes',
+             '-Wmissing-declarations', '-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']
+  if cc.has_argument(a)
+    c_args += a
+  endif
+endforeach
+
+# Check for atomics
+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); }
+    ''',
+    name : 'Intel Atomics')
+  config.set10('HAVE_LIBDRM_ATOMIC_PRIMITIVES', true)
+elif cc.has_header('atomic_ops.h')
+  config.set10('HAVE_LIB_ATOMIC_OPS', true)
+elif cc.has_function('atomic_cas_uint')
+else
+  foreach c : [['intel', with_intel], ['radeon', with_radeon],
+               ['amdgpu', with_amdgpu], ['nouveau', with_nouveau],
+               ['omap', with_omap], ['freedreno', with_freedreo],
+               ['tegra', with_tegra], ['etnaviv', with_etnaviv]]
+    n = c[0]
+    d = c[1]
+    if d == 'auto'
+      message('Disabling libdrm_@0@ because it requiers atomic operations.'.format(n))
+      d == 'no'
+    elif d == 'yes'
+      error('libdrm_@0@ requires atomic operations, which cannot be found.'.format(n))
+    endif
+  endforeach
+endif
+
+if not target_machine.cpu_family().startswith('x86')
+  if with_intel == 'auto'
+    with_intel == 'no'
+  elif with_intel == 'yes'
+    error('cannot build libdrm_intel for non x86 architecture')
+  endif
+endif
+
+if not ['arm', 'aarch64'].contains(target_machine.cpu_family())
+  if with_freedreno == 'auto'
+    with_freedreno = 'no'
+    with_freedreno_kgsl = 'no'
+  endif
+  if with_vc4 == 'auto'
+    with_vc4 = 'no'
+  endif
+  if with_omap == 'auto'
+    with_omap = 'no'
+  endif
+  if with_etnaviv == 'auto'
+    with_etnaviv = 'no'
+  endif
+  if with_tegra == 'auto'
+    with_tegra = 'no'
+  endif
+endif
+
+# XXX: Aparently only freebsd and dragonfly bsd actually need this (and
+# gnu/kfreebsd), not openbsd and netbsd
+if with_libkms == 'auto'
+  if ['bsd', 'linux'].contains(target_machine.system())
+    with_libkms = 'yes'
+  else
+    with_libkms = 'no'
+  endif
+endif
+
+if with_udev
+  dep_udev = dependency('udev')
+  config.set10('UDEV', true)
+else
+  dep_udev = []
+endif
+
+dep_pciaccess = dependency('pciaccess', version : '>= 0.10', required : with_intel != 'no')
+dep_cunit = dependency('cunit', version : '>= 2.1', required : false)
+dep_cairo = dependency('cairo', required : with_cairo_tests == 'yes')
+dep_valgrind = dependency('valgrind', required : with_valgrind == 'yes')
+
+prog_xslt = find_program('xsltproc', required : with_man_pages == 'yes')
+prog_sed = find_program('sed', required : with_man_pages == 'yes')
+manpage_style = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
+if prog_xslt.found()
+  if run_command(prog_xslt, '--nonet', manpage_style).returncode() != 0
+    if with_man_pages == 'yes'
+      error('Manpage style sheet cannot be found')
+    endif
+    with_man_pages = 'no'
+  endif
+endif
+
+if cc.compiles('''int foo_hidden(void) __attribute__((visibility(("hidden"))));''',
+               name : 'compiler supports __attribute__(("hidden"))')
+  config.set10('HAVE_VISIBILITY', true)
+endif
+
+foreach t : [[with_intel, 'INTEL'], [with_vmwgfx, 'VMWGFX'],
+             [with_nouveau, 'NOUVEAU'], [with_omap, 'OMAP'],
+             [with_exynos, 'EXYNOS'], [with_freedreno, 'FREEDRENO'],
+             [with_tegra, 'TEGRA'], [with_vc4, 'VC4'],
+             [with_etnaviv, 'ETNAVIV'], [with_install_tests, 'INSTALL_TESTS']]
+  e = t[0]
+  if e != 'no'
+    config.set10('HAVE_@0@'.format(t[1]), true)
+  endif
+endforeach
+if with_freedreno_kgsl != 'no'
+  if with_freedreno == 'no'
+    error('cannot enable freedreno-kgsl without freedreno support')
+  endif
+  config.set10('HAVE_FREEDRENO_KGSL', true)
+endif
+if with_amdgpu != 'no'
+  config.set10('HAVE_AMDGPU', true)
+  if dep_cunit.found()
+    config.set10('HAVE_CUNIT', true)
+  endif
+endif
+if dep_cairo.found()
+  config.set10('HAVE_CAIRO', true)
+endif
+if dep_valgrind.found()
+  config.set10('HAVE_VALGRIND', true)
+endif
+
+config.set10('_GNU_SOURCE', true)
+config_file = configure_file(
+  configuration : config,
+  output : 'config.h',
+)
+c_args += '-DHAVE_CONFIG_H'
+
+inc_root = include_directories('.')
+inc_drm = include_directories('include/drm')
+
+files_libdrm = 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',
+)
+
+libdrm = shared_library(
+  'drm',
+  [files_libdrm, config_file],
+  c_args : c_args,
+  dependencies : [dep_udev, dep_valgrind, dep_rt, dep_m],
+  include_directories : inc_drm,
+  version : '2.4.0',
+  install : true,
+)
+
+ext_libdrm = declare_dependency(
+  link_with : libdrm,
+  include_directories : inc_drm,
+)
+
+install_headers('libsync.h', 'xf86drm.h', 'xf86drmMode.h')
+install_headers(
+	'include/drm/drm.h', 'include/drm/drm_fourcc.h', 'include/drm/drm_mode.h',
+	'include/drm/drm_sarea.h', 'include/drm/i915_drm.h',
+	'include/drm/mach64_drm.h', 'include/drm/mga_drm.h',
+	'include/drm/nouveau_drm.h', 'include/drm/qxl_drm.h',
+	'include/drm/r128_drm.h', 'include/drm/radeon_drm.h',
+	'include/drm/amdgpu_drm.h', 'include/drm/savage_drm.h',
+	'include/drm/sis_drm.h', 'include/drm/tegra_drm.h', 'include/drm/vc4_drm.h',
+	'include/drm/via_drm.h', 'include/drm/virtgpu_drm.h',
+  subdir : 'libdrm',
+)
+if with_vmwgfx != 'no'
+  install_headers('include/drm/vmwgfx_drm.h', subdir : 'libdrm')
+endif
+
+pkg.generate(
+  name : 'libdrm',
+  libraries : libdrm,
+  subdirs : ['.', 'libdrm'],
+  version : meson.project_version(),
+  description : 'Userspace interface to kernel DRM services',
+)
+ 
+if with_libkms != 'no'
+  subdir('libkms')
+endif
+if with_intel != 'no'
+  subdir('intel')
+endif
+if with_nouveau != 'no'
+  subdir('nouveau')
+endif
+if with_radeon != 'no'
+  subdir('radeon')
+endif
+if with_amdgpu != 'no'
+  subdir('amdgpu')
+endif
+if with_omap != 'no'
+  subdir('omap')
+endif
+if with_exynos != 'no'
+  subdir('exynos')
+endif
+if with_freedreno != 'no'
+  subdir('freedreno')
+endif
+if with_tegra != 'no'
+  subdir('tegra')
+endif
+if with_vc4 != 'no'
+  subdir('vc4')
+endif
+if with_etnaviv != 'no'
+  subdir('etnaviv')
+endif
+if with_man_pages != 'no' and prog_xslt.found() and prog_sed.found()
+  subdir('man')
+endif
+subdir('data')
+subdir('tests')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 00000000..16de3a40
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,38 @@ 
+# 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.
+
+option('libkms',      type : 'combo', value : 'auto', choices : ['yes', 'no', 'auto'])
+option('intel',       type : 'combo', value : 'auto', choices : ['yes', 'no', 'auto'])
+option('radeon',      type : 'combo', value : 'auto', choices : ['yes', 'no', 'auto'])
+option('amdgpu',      type : 'combo', value : 'auto', choices : ['yes', 'no', 'auto'])
+option('nouveau',     type : 'combo', value : 'auto', choices : ['yes', 'no', 'auto'])
+option('vmwgfx',      type : 'combo', value : 'yes',  choices : ['yes', 'no', 'auto'])
+option('omap',        type : 'combo', value : 'no',   choices : ['yes', 'no', 'auto'])
+option('exynos',      type : 'combo', value : 'no',   choices : ['yes', 'no', 'auto'])
+option('freedreno',   type : 'combo', value : 'auto', choices : ['yes', 'no', 'auto'])
+option('tegra',       type : 'combo', value : 'no',   choices : ['yes', 'no', 'auto'])
+option('vc4',         type : 'combo', value : 'auto', choices : ['yes', 'no', 'auto'])
+option('etnaviv',     type : 'combo', value : 'no',   choices : ['yes', 'no', 'auto'])
+option('cairo_tests', type : 'combo', value : 'auto', choices : ['yes', 'no', 'auto'])
+option('man_pages',   type : 'combo', value : 'auto', choices : ['yes', 'no', 'auto'])
+option('valgrind',    type : 'combo', value : 'auto', choices : ['yes', 'no', 'auto'])
+option('freedreno-kgls',        type : 'boolean', value : false)
+option('install_test_programs', type : 'boolean', value : false)
+option('udev',                  type : 'boolean', value : false)
diff --git a/nouveau/meson.build b/nouveau/meson.build
new file mode 100644
index 00000000..ae727c29
--- /dev/null
+++ b/nouveau/meson.build
@@ -0,0 +1,61 @@ 
+# 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.
+
+files_nouveau = files(
+	'nouveau.c',
+	'pushbuf.c',
+	'bufctx.c',
+	'abi16.c',
+	'private.h',
+)
+
+libdrm_nouveau = shared_library(
+  'drm_nouveau',
+  [files_nouveau, config_file],
+  c_args : c_args,
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  dependencies : dep_threads,
+  version : '2.0.0',
+  install : true,
+)
+
+ext_libdrm_nouveau = declare_dependency(
+  link_with : [libdrm, libdrm_nouveau],
+  include_directories : [inc_drm, include_directories('.')],
+)
+
+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 : 'libdrm/nouveau/nvif'
+)
+
+pkg.generate(
+  name : 'libdrm_nouveau',
+  libraries : libdrm_nouveau,
+  subdirs : ['.', 'nouveau'],
+  version : meson.project_version(),
+  requires_private : 'libdrm',
+  description : 'Userspace interface to nouveau kernel DRM services',
+)
+
+test('nouveau-symbol-check', find_program('nouveau-symbol-check'))
diff --git a/omap/meson.build b/omap/meson.build
new file mode 100644
index 00000000..34d17bcf
--- /dev/null
+++ b/omap/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.
+
+libdrm_omap = shared_library(
+  'drm_omap',
+  [files('omap_drm.c'), config_file],
+  include_directories : [inc_root, inc_drm],
+  c_args : c_args,
+  link_with : libdrm,
+  dependencies : [dep_pthread_stubs],
+  version : '1.0.0',
+  install : true,
+)
+
+ext_libdrm_omap = declare_dependency(
+  link_with : [libdrm, libdrm_omap],
+  include_directories : [inc_drm, include_directories('.')],
+)
+
+install_headers('omap_drmif.h', subdir : 'libdrm')
+install_headers('omap_drm.h', subdir : 'omap')
+
+pkg.generate(
+  name : 'libdrm_omap',
+  libraries : libdrm_omap,
+  subdirs : ['.', 'libdrm', 'omap'],
+  version : '0.6',
+  requires_private : 'libdrm',
+  description : 'Userspace interface to omap kernel DRM services',
+)
+
+test('omap-symbol-check', find_program('omap-symbol-check'))
diff --git a/radeon/meson.build b/radeon/meson.build
new file mode 100644
index 00000000..905ce77d
--- /dev/null
+++ b/radeon/meson.build
@@ -0,0 +1,61 @@ 
+# 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.
+
+files_radeon = 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',
+  [files_radeon, config_file],
+  c_args : c_args,
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+    
+  version : '1.0.1',
+  install : true,
+)
+
+ext_libdrm_radeon = declare_dependency(
+  link_with : [libdrm, libdrm_radeon],
+  include_directories : [inc_drm, include_directories('.')],
+)
+
+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',
+  libraries : libdrm_radeon,
+  subdirs : ['.', 'libdrm'],
+  version : meson.project_version(),
+  requires_private : 'libdrm',
+  description : 'Userspace interface to kernel DRM services for radeon',
+)
+
+test('radeon-symbol-check', find_program('radeon-symbol-check'))
diff --git a/tegra/meson.build b/tegra/meson.build
new file mode 100644
index 00000000..b42b3f8d
--- /dev/null
+++ b/tegra/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.
+
+libdrm_tegra = shared_library(
+  'drm_tegra',
+  [files('private.h', 'tegra.c'), config_file],
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  dependencies : [dep_pthread_stubs],
+  c_args : c_args,
+  version : '0.0.0',
+  install : true,
+)
+
+ext_libdrm_tegra = declare_dependency(
+  link_with : [libdrm, libdrm_tegra],
+  include_directories : [inc_drm, include_directories('.')],
+)
+
+install_headers('tegra.h', subdir : 'libdrm')
+
+pkg.generate(
+  name : 'libdrm_tegra',
+  libraries : libdrm_tegra,
+  subdirs : ['.', 'libdrm'],
+  version : meson.project_version(),
+  requires_private : 'libdrm',
+  description : 'Userspace interface to Tegra kernel DRM services',
+)
+
+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 00000000..08b02549
--- /dev/null
+++ b/tests/amdgpu/meson.build
@@ -0,0 +1,42 @@ 
+# 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.
+
+files_amdgpu_test = files(
+	'amdgpu_test.c',
+	'amdgpu_test.h',
+	'basic_tests.c',
+	'bo_tests.c',
+	'cs_tests.c',
+	'decode_messages.h',
+	'vce_tests.c',
+	'vce_ib.h',
+	'frame.h',
+	'vcn_tests.c',
+)
+
+amdgpu_test = executable(
+  'amdgpu_test',
+  files_amdgpu_test,
+  dependencies : dep_cunit,
+  c_args : c_args,
+  include_directories : [inc_root, inc_drm, include_directories('../../amdgpu')],
+  link_with : [libdrm, libdrm_amdgpu],
+  install : with_install_tests,
+)
diff --git a/tests/etnaviv/meson.build b/tests/etnaviv/meson.build
new file mode 100644
index 00000000..53ae6e33
--- /dev/null
+++ b/tests/etnaviv/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.
+
+inc_etnaviv_tests = [inc_root, inc_drm, include_directories('../../etnaviv')]
+
+etnaviv_2d_test_files = files(
+	'cmdstream.xml.h',
+	'etnaviv_2d_test.c',
+	'state.xml.h',
+	'state_2d.xml.h',
+	'write_bmp.c',
+	'write_bmp.h',
+)
+
+etnaviv_2d_test = executable(
+  'etnaviv_2d_test',
+  etnaviv_2d_test_files,
+  c_args : c_args,
+  include_directories : inc_etnaviv_tests,
+  link_with : [libdrm, libdrm_etnaviv],
+  install : with_install_tests,
+)
+
+etnaviv_cmd_stream_test = executable(
+  'etnaviv_cmd_stream_test',
+  files('etnaviv_cmd_stream_test.c'),
+  c_args : c_args,
+  include_directories : inc_etnaviv_tests,
+  link_with : [libdrm, libdrm_etnaviv],
+  install : with_install_tests,
+)
+
+etnaviv_bo_cache_test = executable(
+  'etnaviv_bo_cache_test',
+  files('etnaviv_bo_cache_test.c'),
+  c_args : c_args,
+  include_directories : inc_etnaviv_tests,
+  link_with : [libdrm, libdrm_etnaviv],
+  install : with_install_tests,
+)
diff --git a/tests/exynos/meson.build b/tests/exynos/meson.build
new file mode 100644
index 00000000..1ffaac15
--- /dev/null
+++ b/tests/exynos/meson.build
@@ -0,0 +1,54 @@ 
+# 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.
+
+inc_exynos = include_directories('../../exynos')
+
+if with_libkms != 'no'
+  exynos_fimg2d_test = executable(
+    'exynos_fimg2d_test',
+    files('exynos_fimg2d_test.c'),
+    c_args : c_args,
+    include_directories : [inc_root, inc_drm, inc_exynos,
+                           include_directories('../../libkms')],
+    link_with : [libdrm, libkms, libdrm_exynos],
+    dependencies : dep_threads,
+    install : with_install_tests,
+  )
+endif
+
+exynos_fimg2d_perf = executable(
+  'exynos_fimg2d_perf',
+  files('exynos_fimg2d_perf.c'),
+  c_args : c_args,
+  include_directories : [inc_root, inc_drm, inc_exynos],
+  link_with : [libdrm, libdrm_exynos],
+  dependencies : dep_threads,
+  install : with_install_tests,
+)
+
+exynos_fimg2d_event = executable(
+  'exynos_fimg2d_event',
+  files('exynos_fimg2d_event.c'),
+  c_args : c_args,
+  include_directories : [inc_root, inc_drm, inc_exynos],
+  link_with : [libdrm, libdrm_exynos],
+  dependencies : dep_threads,
+  install : with_install_tests,
+)
diff --git a/tests/kms/meson.build b/tests/kms/meson.build
new file mode 100644
index 00000000..7c02e218
--- /dev/null
+++ b/tests/kms/meson.build
@@ -0,0 +1,54 @@ 
+# 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_test_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',
+)
+
+libkms_test = static_library(
+  'kms-test',
+  libkms_test_files,
+  include_directories : [inc_root, inc_tests, inc_drm],
+  link_with : libdrm,
+  c_args : c_args,
+)
+
+kms_steal_crtc = executable(
+  'kms-steal-crtc',
+  files('kms-steal-crtc.c'),
+  dependencies : dep_cairo,
+  include_directories : [inc_root, inc_tests, inc_drm],
+  link_with : [libkms_test, libutil],
+  install : with_install_tests,
+)
+
+kms_universal_planes = executable(
+  'kms-universal-lanes',
+  files('kms-universal-planes.c'),
+  dependencies : dep_cairo,
+  include_directories : [inc_root, inc_tests, inc_drm],
+  link_with : [libkms_test],
+  install : with_install_tests,
+)
diff --git a/tests/kmstest/meson.build b/tests/kmstest/meson.build
new file mode 100644
index 00000000..a2f573ea
--- /dev/null
+++ b/tests/kmstest/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.
+
+kmstest = executable(
+  'kmstest',
+  files('main.c'),
+  c_args : c_args,
+  include_directories : [inc_root, inc_tests, include_directories('../../libkms'), inc_drm],
+  link_with : [libutil, libkms, libdrm],
+  install : with_install_tests,
+)
+
+test('kmstest', kmstest)
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 00000000..5c6b1e68
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,85 @@ 
+# 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.
+
+inc_tests = include_directories('.')
+
+subdir('util')
+subdir('kms')
+subdir('modeprint')
+subdir('proptest')
+subdir('vbltest')
+if with_libkms != 'no'
+  subdir('kmstest')
+endif
+if with_radeon != 'no'
+  subdir('radeon')
+endif
+if with_amdgpu != 'no' and dep_cunit.found()
+  subdir('amdgpu')
+endif
+if with_exynos != 'no'
+  subdir('exynos')
+endif
+if with_tegra != 'no'
+  subdir('tegra')
+endif
+if with_etnaviv != 'no'
+  subdir('etnaviv')
+endif
+if with_nouveau != 'no'
+  subdir('nouveau')
+endif
+
+drmsl = executable(
+  'drmsl',
+  files('drmsl.c'),
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  c_args : c_args,
+)
+
+hash = executable(
+  'hash',
+  files('hash.c'),
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  c_args : c_args,
+)
+
+random = executable(
+  'random',
+  files('random.c'),
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  c_args : c_args,
+)
+
+drmdevice = executable(
+  'drmdevice',
+  files('drmdevice.c'),
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  c_args : c_args,
+)
+
+test('random', random)
+test('hash', hash)
+test('drmsl', drmsl)
+test('drmdevice', drmdevice)
diff --git a/tests/modeprint/meson.build b/tests/modeprint/meson.build
new file mode 100644
index 00000000..4e2a1ddf
--- /dev/null
+++ b/tests/modeprint/meson.build
@@ -0,0 +1,29 @@ 
+# 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.
+
+modeprint = executable(
+  'modeprint',
+  files('modeprint.c'),
+  c_args : c_args,
+  include_directories : [inc_root, inc_tests, inc_drm],
+  link_with : libdrm,
+  dependencies : dep_threads,
+  install : with_install_tests,
+)
diff --git a/tests/nouveau/meson.build b/tests/nouveau/meson.build
new file mode 100644
index 00000000..f1afa63a
--- /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.
+
+threaded = executable(
+  'threaded',
+  files('threaded.c'),
+  dependencies : [dep_dl, dep_threads],
+  include_directories : [inc_root, inc_drm, include_directories('../../nouveau')],
+  link_with : [libdrm, libdrm_nouveau],
+  c_args : c_args,
+)
+
+test('threaded', threaded)
diff --git a/tests/proptest/meson.build b/tests/proptest/meson.build
new file mode 100644
index 00000000..aa9d62ff
--- /dev/null
+++ b/tests/proptest/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.
+
+proptest_files = files('proptest.c')
+
+proptest = executable(
+  'proptest',
+  files('proptest.c'),
+  c_args : c_args,
+  include_directories : [inc_root, inc_tests, inc_drm],
+  link_with : [libdrm, libutil],
+  install : with_install_tests,
+)
diff --git a/tests/radeon/meson.build b/tests/radeon/meson.build
new file mode 100644
index 00000000..12ed68c4
--- /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',
+  files('rbo.c', 'rbo.h', 'radeon_ttm.c'),
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  c_args : c_args,
+)
diff --git a/tests/tegra/meson.build b/tests/tegra/meson.build
new file mode 100644
index 00000000..b2da2947
--- /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.
+
+openclose = executable(
+  'openclose',
+  files('openclose.c'),
+  include_directories : [inc_root, inc_drm, include_directories('../../tegra')],
+  c_args : c_args,
+  link_with : [libdrm, libdrm_tegra],
+)
diff --git a/tests/util/meson.build b/tests/util/meson.build
new file mode 100644
index 00000000..76c73bd8
--- /dev/null
+++ b/tests/util/meson.build
@@ -0,0 +1,37 @@ 
+# 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.
+
+util_files = files(
+	'common.h',
+	'format.c',
+	'format.h',
+	'kms.c',
+	'kms.h',
+	'pattern.c',
+	'pattern.h',
+)
+
+libutil = static_library(
+  'util',
+  [util_files, config_file],
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  dependencies : dep_cairo
+)
diff --git a/tests/vbltest/meson.build b/tests/vbltest/meson.build
new file mode 100644
index 00000000..a5fe0b84
--- /dev/null
+++ b/tests/vbltest/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.
+
+vbltest = executable(
+  'vbltest',
+  files('vbltest.c'),
+  c_args : c_args,
+  include_directories : [inc_root, inc_tests, inc_drm],
+  link_with : [libdrm, libutil],
+  install : with_install_tests,
+)
diff --git a/vc4/meson.build b/vc4/meson.build
new file mode 100644
index 00000000..0136987b
--- /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',
+  version : meson.project_version(),
+  requires_private : 'libdrm',
+  description : 'Userspace interface to vc4 kernel DRM services',
+)