[PATCH xserver 3/3] Add a Meson build system alongside autotools.

Eric Anholt eric at anholt.net
Tue Apr 25 23:03:01 UTC 2017


This is a work in progress that builds Xvfb, Xephyr, Xwayland, Xnest,
and Xdmx so far.  The outline of Xquartz/Xwin support is in tree, but
hasn't been built yet.  The unit tests are also not done.

The intent is to build this as a complete replacement for the
autotools system, then eventually replace autotools.  meson is faster
to generate the build, faster to run the bulid, shorter to write the
build files in, and less error-prone than autotools.

Signed-off-by: Eric Anholt <eric at anholt.net>
---
 Xext/meson.build                           |  61 +++++
 Xi/meson.build                             |  67 ++++++
 composite/meson.build                      |  13 ++
 config/meson.build                         |  35 +++
 damageext/meson.build                      |   9 +
 dbe/meson.build                            |  10 +
 dix/meson.build                            |  47 ++++
 dri3/meson.build                           |  12 +
 exa/meson.build                            |  24 ++
 fb/meson.build                             |  36 +++
 glamor/meson.build                         |  58 +++++
 glx/meson.build                            |  50 ++++
 hw/dmx/config/meson.build                  |  81 +++++++
 hw/dmx/examples/meson.build                |  33 +++
 hw/dmx/glxProxy/meson.build                |  27 +++
 hw/dmx/input/meson.build                   |  32 +++
 hw/dmx/meson.build                         |  68 ++++++
 hw/kdrive/ephyr/meson.build                |  62 +++++
 hw/kdrive/meson.build                      |   2 +
 hw/kdrive/src/meson.build                  |  22 ++
 hw/meson.build                             |  25 ++
 hw/vfb/meson.build                         |  21 ++
 hw/xfree86/common/meson.build              |  93 ++++++++
 hw/xfree86/common/xf86Build.sh             |   6 +
 hw/xfree86/ddc/meson.build                 |  15 ++
 hw/xfree86/dixmods/meson.build             |  38 +++
 hw/xfree86/dri/meson.build                 |  23 ++
 hw/xfree86/dri2/meson.build                |  16 ++
 hw/xfree86/drivers/modesetting/meson.build |  42 ++++
 hw/xfree86/exa/meson.build                 |   9 +
 hw/xfree86/glamor_egl/meson.build          |  22 ++
 hw/xfree86/i2c/meson.build                 |  12 +
 hw/xfree86/int10/meson.build               |  54 +++++
 hw/xfree86/loader/loader.c                 |   4 +
 hw/xfree86/loader/meson.build              |  16 ++
 hw/xfree86/loader/symbol-test.c            |  53 +++++
 hw/xfree86/meson.build                     | 106 +++++++++
 hw/xfree86/modes/meson.build               |  30 +++
 hw/xfree86/os-support/meson.build          | 125 ++++++++++
 hw/xfree86/parser/meson.build              |  32 +++
 hw/xfree86/ramdac/meson.build              |  27 +++
 hw/xfree86/x86emu/meson.build              |  15 ++
 hw/xnest/meson.build                       |  37 +++
 hw/xquartz/meson.build                     |  40 ++++
 hw/xwayland/meson.build                    |  66 ++++++
 include/meson.build                        | 329 ++++++++++++++++++++++++++
 include/xorg-config.h.meson.in             | 151 ++++++++++++
 meson.build                                | 360 +++++++++++++++++++++++++++++
 meson_options.txt                          |  46 ++++
 mi/meson.build                             |  39 ++++
 miext/damage/meson.build                   |   9 +
 miext/shadow/meson.build                   |  32 +++
 miext/sync/meson.build                     |  17 ++
 os/meson.build                             |  65 ++++++
 present/meson.build                        |  19 ++
 pseudoramiX/meson.build                    |   5 +
 randr/meson.build                          |  26 +++
 record/meson.build                         |  10 +
 render/meson.build                         |  19 ++
 xfixes/meson.build                         |  13 ++
 xkb/meson.build                            |  42 ++++
 61 files changed, 2858 insertions(+)
 create mode 100644 Xext/meson.build
 create mode 100644 Xi/meson.build
 create mode 100644 composite/meson.build
 create mode 100644 config/meson.build
 create mode 100644 damageext/meson.build
 create mode 100644 dbe/meson.build
 create mode 100644 dix/meson.build
 create mode 100644 dri3/meson.build
 create mode 100644 exa/meson.build
 create mode 100644 fb/meson.build
 create mode 100644 glamor/meson.build
 create mode 100644 glx/meson.build
 create mode 100644 hw/dmx/config/meson.build
 create mode 100644 hw/dmx/examples/meson.build
 create mode 100644 hw/dmx/glxProxy/meson.build
 create mode 100644 hw/dmx/input/meson.build
 create mode 100644 hw/dmx/meson.build
 create mode 100644 hw/kdrive/ephyr/meson.build
 create mode 100644 hw/kdrive/meson.build
 create mode 100644 hw/kdrive/src/meson.build
 create mode 100644 hw/meson.build
 create mode 100644 hw/vfb/meson.build
 create mode 100644 hw/xfree86/common/meson.build
 create mode 100755 hw/xfree86/common/xf86Build.sh
 create mode 100644 hw/xfree86/ddc/meson.build
 create mode 100644 hw/xfree86/dixmods/meson.build
 create mode 100644 hw/xfree86/dri/meson.build
 create mode 100644 hw/xfree86/dri2/meson.build
 create mode 100644 hw/xfree86/drivers/modesetting/meson.build
 create mode 100644 hw/xfree86/exa/meson.build
 create mode 100644 hw/xfree86/glamor_egl/meson.build
 create mode 100644 hw/xfree86/i2c/meson.build
 create mode 100644 hw/xfree86/int10/meson.build
 create mode 100644 hw/xfree86/loader/meson.build
 create mode 100644 hw/xfree86/loader/symbol-test.c
 create mode 100644 hw/xfree86/meson.build
 create mode 100644 hw/xfree86/modes/meson.build
 create mode 100644 hw/xfree86/os-support/meson.build
 create mode 100644 hw/xfree86/parser/meson.build
 create mode 100644 hw/xfree86/ramdac/meson.build
 create mode 100644 hw/xfree86/x86emu/meson.build
 create mode 100644 hw/xnest/meson.build
 create mode 100644 hw/xquartz/meson.build
 create mode 100644 hw/xwayland/meson.build
 create mode 100644 include/meson.build
 create mode 100644 include/xorg-config.h.meson.in
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 mi/meson.build
 create mode 100644 miext/damage/meson.build
 create mode 100644 miext/shadow/meson.build
 create mode 100644 miext/sync/meson.build
 create mode 100644 os/meson.build
 create mode 100644 present/meson.build
 create mode 100644 pseudoramiX/meson.build
 create mode 100644 randr/meson.build
 create mode 100644 record/meson.build
 create mode 100644 render/meson.build
 create mode 100644 xfixes/meson.build
 create mode 100644 xkb/meson.build

diff --git a/Xext/meson.build b/Xext/meson.build
new file mode 100644
index 000000000000..9968f2a9e312
--- /dev/null
+++ b/Xext/meson.build
@@ -0,0 +1,61 @@
+srcs_xext = [
+    'bigreq.c',
+    'geext.c',
+    'shape.c',
+    'sleepuntil.c',
+    'sync.c',
+    'xcmisc.c',
+    'xtest.c',
+]
+
+if build_dpms
+    srcs_xext += 'dpms.c'
+endif
+
+if build_mitshm
+    srcs_xext += 'shm.c'
+endif
+
+if build_res
+    srcs_xext += ['hashtable.c', 'xres.c']
+endif
+
+if build_screensaver
+    srcs_xext += 'saver.c'
+endif
+
+if build_xace
+    srcs_xext += 'xace.c'
+endif
+
+if build_xf86bigfont
+    srcs_xext += 'xf86bigfont.c'
+endif
+
+if build_xinerama
+    srcs_xext += ['panoramiX.c', 'panoramiXprocs.c', 'panoramiXSwap.c']
+endif
+
+if build_xsecurity
+    srcs_xext += ['security.c']
+endif
+
+if build_xselinux
+    srcs_xext += ['xselinux_ext.c', 'xselinux_hooks.c', 'xselinux_label.c']
+endif
+
+if build_xv
+    srcs_xext += ['xvmain.c', 'xvdisp.c', 'xvmc.c']
+endif
+
+libxserver_xext = static_library('libxserver_xext',
+    srcs_xext,
+    include_directories: inc,
+    dependencies: common_dep,
+)
+
+libxserver_xext_vidmode = static_library('libxserver_xext_vidmode',
+    'vidmode.c',
+    include_directories: inc,
+    dependencies: common_dep,
+)
diff --git a/Xi/meson.build b/Xi/meson.build
new file mode 100644
index 000000000000..717bb28e1253
--- /dev/null
+++ b/Xi/meson.build
@@ -0,0 +1,67 @@
+srcs_xi = [
+    'allowev.c',
+    'chgdctl.c',
+    'chgfctl.c',
+    'chgkbd.c',
+    'chgkmap.c',
+    'chgprop.c',
+    'chgptr.c',
+    'closedev.c',
+    'devbell.c',
+    'exevents.c',
+    'extinit.c',
+    'getbmap.c',
+    'getdctl.c',
+    'getfctl.c',
+    'getfocus.c',
+    'getkmap.c',
+    'getmmap.c',
+    'getprop.c',
+    'getselev.c',
+    'getvers.c',
+    'grabdev.c',
+    'grabdevb.c',
+    'grabdevk.c',
+    'gtmotion.c',
+    'listdev.c',
+    'opendev.c',
+    'queryst.c',
+    'selectev.c',
+    'sendexev.c',
+    'setbmap.c',
+    'setdval.c',
+    'setfocus.c',
+    'setmmap.c',
+    'setmode.c',
+    'ungrdev.c',
+    'ungrdevb.c',
+    'ungrdevk.c',
+    'xiallowev.c',
+    'xibarriers.c',
+    'xichangecursor.c',
+    'xichangehierarchy.c',
+    'xigetclientpointer.c',
+    'xigrabdev.c',
+    'xipassivegrab.c',
+    'xiproperty.c',
+    'xiquerydevice.c',
+    'xiquerypointer.c',
+    'xiqueryversion.c',
+    'xiselectev.c',
+    'xisetclientpointer.c',
+    'xisetdevfocus.c',
+    'xiwarppointer.c',
+]
+
+libxserver_xi = static_library('libxserver_xi',
+    srcs_xi,
+    include_directories: inc,
+    dependencies: common_dep,
+)
+
+srcs_xi_stubs = ['stubs.c']
+libxserver_xi_stubs = static_library('libxserver_xi_stubs',
+    srcs_xi_stubs,
+    include_directories: inc,
+    dependencies: common_dep,
+)
diff --git a/composite/meson.build b/composite/meson.build
new file mode 100644
index 000000000000..6c4a03fb80c2
--- /dev/null
+++ b/composite/meson.build
@@ -0,0 +1,13 @@
+srcs_composite = [
+	'compalloc.c',
+	'compext.c',
+	'compinit.c',
+	'compoverlay.c',
+	'compwindow.c',
+]
+
+libxserver_composite = static_library('libxserver_composite',
+	srcs_composite,
+	include_directories: inc,
+	dependencies: common_dep,
+)
diff --git a/config/meson.build b/config/meson.build
new file mode 100644
index 000000000000..d9052a37153f
--- /dev/null
+++ b/config/meson.build
@@ -0,0 +1,35 @@
+srcs_config = [
+    'config.c',
+]
+
+config_dep = [common_dep]
+
+if build_dbus
+    srcs_config += 'dbus-core.c'
+    config_dep += dbus_dep
+endif
+
+if build_hal
+    srcs_config += 'hal.c'
+    config_dep += hal_dep
+endif
+
+if build_udev
+    srcs_config += 'udev.c'
+    config_dep += udev_dep
+endif
+
+if host_machine.system() == 'openbsd'
+    srcs_config += 'wscons.c'
+endif
+
+if build_xorg
+    install_data('10-quirks.conf',
+                 install_dir: join_paths(get_option('datadir'), 'xorg.conf.d'))
+endif
+
+libxserver_config = static_library('libxserver_config',
+    srcs_config,
+    include_directories: inc,
+    dependencies: config_dep,
+)
diff --git a/damageext/meson.build b/damageext/meson.build
new file mode 100644
index 000000000000..688771d5835e
--- /dev/null
+++ b/damageext/meson.build
@@ -0,0 +1,9 @@
+srcs_damageext = [
+	'damageext.c',
+]
+
+libxserver_damageext = static_library('libxserver_damageext',
+	srcs_damageext,
+	include_directories: inc,
+	dependencies: common_dep,
+)
diff --git a/dbe/meson.build b/dbe/meson.build
new file mode 100644
index 000000000000..e10bde19913d
--- /dev/null
+++ b/dbe/meson.build
@@ -0,0 +1,10 @@
+srcs_dbe = [
+	'dbe.c',
+	'midbe.c',
+]
+
+libxserver_dbe = static_library('libxserver_dbe',
+	srcs_dbe,
+	include_directories: inc,
+	dependencies: common_dep,
+)
diff --git a/dix/meson.build b/dix/meson.build
new file mode 100644
index 000000000000..b3952a361529
--- /dev/null
+++ b/dix/meson.build
@@ -0,0 +1,47 @@
+srcs_dix = [
+    'atom.c',
+    'colormap.c',
+    'cursor.c',
+    'devices.c',
+    'dispatch.c',
+    'dixfonts.c',
+    'main.c',
+    'dixutils.c',
+    'enterleave.c',
+    'events.c',
+    'eventconvert.c',
+    'extension.c',
+    'ffs.c',
+    'gc.c',
+    'getevents.c',
+    'globals.c',
+    'glyphcurs.c',
+    'grabs.c',
+    'initatoms.c',
+    'inpututils.c',
+    'pixmap.c',
+    'privates.c',
+    'property.c',
+    'ptrveloc.c',
+    'region.c',
+    'registry.c',
+    'resource.c',
+    'selection.c',
+    'swaprep.c',
+    'swapreq.c',
+    'tables.c',
+    'touch.c',
+    'window.c',
+]
+
+libxserver_dix = static_library('libxserver_dix',
+    srcs_dix,
+    include_directories: inc,
+    dependencies: common_dep,
+)
+
+libxserver_main = static_library('libxserver_main',
+    'stubmain.c',
+    include_directories: inc,
+    dependencies: common_dep,
+)
diff --git a/dri3/meson.build b/dri3/meson.build
new file mode 100644
index 000000000000..abb13c63a6b9
--- /dev/null
+++ b/dri3/meson.build
@@ -0,0 +1,12 @@
+srcs_dri3 = [
+	'dri3.c',
+	'dri3_request.c',
+	'dri3_screen.c',
+]
+
+libxserver_dri3 = static_library('libxserver_dri3',
+	srcs_dri3,
+	include_directories: inc,
+	dependencies: common_dep,
+	c_args: '-DHAVE_XORG_CONFIG_H'
+)
diff --git a/exa/meson.build b/exa/meson.build
new file mode 100644
index 000000000000..832363d2720d
--- /dev/null
+++ b/exa/meson.build
@@ -0,0 +1,24 @@
+srcs_exa = [
+    'exa.c',
+    'exa_classic.c',
+    'exa_migration_classic.c',
+    'exa_driver.c',
+    'exa_mixed.c',
+    'exa_migration_mixed.c',
+    'exa_accel.c',
+    'exa_glyphs.c',
+    'exa_offscreen.c',
+    'exa_render.c',
+    'exa_unaccel.c',
+]
+
+libxserver_exa = static_library('libxserver_exa',
+    srcs_exa,
+    include_directories: inc,
+    dependencies: common_dep,
+    c_args: '-DHAVE_XORG_CONFIG_H'
+)
+
+if build_xorg
+    install_data('exa.h', install_dir: xorgsdkdir)
+endif
diff --git a/fb/meson.build b/fb/meson.build
new file mode 100644
index 000000000000..ef8e68ca24f2
--- /dev/null
+++ b/fb/meson.build
@@ -0,0 +1,36 @@
+srcs_fb = [
+	'fballpriv.c',
+	'fbarc.c',
+	'fbbits.c',
+	'fbblt.c',
+	'fbbltone.c',
+	'fbcmap_mi.c',
+	'fbcopy.c',
+	'fbfill.c',
+	'fbfillrect.c',
+	'fbfillsp.c',
+	'fbgc.c',
+	'fbgetsp.c',
+	'fbglyph.c',
+	'fbimage.c',
+	'fbline.c',
+	'fboverlay.c',
+	'fbpict.c',
+	'fbpixmap.c',
+	'fbpoint.c',
+	'fbpush.c',
+	'fbscreen.c',
+	'fbseg.c',
+	'fbsetsp.c',
+	'fbsolid.c',
+	'fbtrap.c',
+	'fbutil.c',
+	'fbwindow.c',
+]
+
+libxserver_fb = static_library('libxserver_fb',
+	srcs_fb,
+	include_directories: inc,
+	dependencies: common_dep,
+	pic: true,
+)
diff --git a/glamor/meson.build b/glamor/meson.build
new file mode 100644
index 000000000000..0b963275e169
--- /dev/null
+++ b/glamor/meson.build
@@ -0,0 +1,58 @@
+srcs_glamor = [
+    'glamor.c',
+    'glamor_copy.c',
+    'glamor_core.c',
+    'glamor_dash.c',
+    'glamor_font.c',
+    'glamor_glx.c',
+    'glamor_composite_glyphs.c',
+    'glamor_image.c',
+    'glamor_lines.c',
+    'glamor_segs.c',
+    'glamor_render.c',
+    'glamor_gradient.c',
+    'glamor_prepare.c',
+    'glamor_program.c',
+    'glamor_rects.c',
+    'glamor_spans.c',
+    'glamor_text.c',
+    'glamor_transfer.c',
+    'glamor_transform.c',
+    'glamor_trapezoid.c',
+    'glamor_triangles.c',
+    'glamor_addtraps.c',
+    'glamor_glyphblt.c',
+    'glamor_points.c',
+    'glamor_pixmap.c',
+    'glamor_largepixmap.c',
+    'glamor_picture.c',
+    'glamor_vbo.c',
+    'glamor_window.c',
+    'glamor_fbo.c',
+    'glamor_compositerects.c',
+    'glamor_utils.c',
+    'glamor_sync.c',
+]
+
+if build_xv
+    srcs_glamor += 'glamor_xv.c'
+endif
+
+glamor = static_library('glamor',
+    srcs_glamor,
+    include_directories: inc,
+    dependencies: [
+        common_dep,
+        dependency('epoxy'),
+    ],
+)
+
+glamor_egl_stubs = static_library('glamor_egl_stubs',
+    'glamor_egl_stubs.c',
+    include_directories: inc,
+    dependencies: common_dep,
+)
+
+if build_xorg
+    install_data('glamor.h', install_dir: xorgsdkdir)
+endif
diff --git a/glx/meson.build b/glx/meson.build
new file mode 100644
index 000000000000..a29e53cfac30
--- /dev/null
+++ b/glx/meson.build
@@ -0,0 +1,50 @@
+srcs_glx = [
+    'indirect_dispatch.c',
+    'indirect_dispatch_swap.c',
+    'indirect_reqsize.c',
+    'indirect_size_get.c',
+    'indirect_table.c',
+    'clientinfo.c',
+    'createcontext.c',
+    'extension_string.c',
+    'indirect_util.c',
+    'indirect_program.c',
+    'indirect_texture_compression.c',
+    'glxcmds.c',
+    'glxcmdsswap.c',
+    'glxext.c',
+    'glxdriswrast.c',
+    'glxdricommon.c',
+    'glxscreens.c',
+    'render2.c',
+    'render2swap.c',
+    'renderpix.c',
+    'renderpixswap.c',
+    'rensize.c',
+    'single2.c',
+    'single2swap.c',
+    'singlepix.c',
+    'singlepixswap.c',
+    'singlesize.c',
+    'swap_interval.c',
+    'xfont.c',
+]
+
+libxserver_glx = ''
+if build_glx
+    libxserver_glx = static_library('libxserver_glx',
+        srcs_glx,
+        include_directories: inc,
+        dependencies: [
+            common_dep,
+            dl_dep,
+            dependency('glproto', version: '>= 1.4.17'),
+            dependency('gl', version: '>= 9.2.0'),
+        ],
+        c_args: [
+            glx_align64,
+            # XXX: generated code includes an unused function
+            '-Wno-unused-function',
+        ]
+    )
+endif
diff --git a/hw/dmx/config/meson.build b/hw/dmx/config/meson.build
new file mode 100644
index 000000000000..c77cd0b44cc2
--- /dev/null
+++ b/hw/dmx/config/meson.build
@@ -0,0 +1,81 @@
+flex = find_program('flex')
+bison = find_program('bison')
+
+lgen = generator(
+    flex,
+    output : '@PLAINNAME at .yy.c',
+    arguments : ['-o', '@OUTPUT@', '@INPUT@']
+)
+lfiles = lgen.process('scanner.l')
+
+pgen = generator(
+    bison,
+    output : ['@BASENAME at .c', '@BASENAME at .h'],
+    arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']
+)
+pfiles = pgen.process('parser.y')
+
+srcs_dmx_config = [
+    'dmxparse.c',
+    'dmxprint.c',
+    'dmxcompat.c',
+    'dmxconfig.c',
+    pfiles,
+    lfiles,
+]
+
+dmx_inc = [
+    inc,
+    include_directories('../')
+]
+
+dmx_c_args = [
+    '-DHAVE_DMX_CONFIG_H',
+    '-DDMX_LOG_STANDALONE',
+]
+
+dmx_config = static_library('dmx_config',
+    srcs_dmx_config,
+    include_directories: dmx_inc,
+    dependencies: common_dep,
+    c_args: dmx_c_args,
+)
+
+executable('xdmxconfig',
+    [
+        'xdmxconfig.c',
+        '../dmxlog.c',
+        'Canvas.c',
+    ],
+    include_directories: [
+        inc,
+        include_directories('../')
+    ],
+    dependencies: [
+        common_dep,
+        dependency('xaw7'),
+        dependency('xmu'),
+        dependency('xt'),
+        dependency('xpm'),
+        dependency('x11'),
+    ],
+    link_with: dmx_config,
+    c_args: dmx_c_args,
+    install: true,
+)
+
+executable('vdltodmx',
+    'vdltodmx.c',
+    include_directories: dmx_inc,
+    link_with: dmx_config,
+    c_args: dmx_c_args,
+    install: true,
+)
+
+executable('dmxtodmx',
+    'dmxtodmx.c',
+    include_directories: dmx_inc,
+    link_with: dmx_config,
+    c_args: dmx_c_args,
+    install: true,
+)
diff --git a/hw/dmx/examples/meson.build b/hw/dmx/examples/meson.build
new file mode 100644
index 000000000000..6e160d0e094d
--- /dev/null
+++ b/hw/dmx/examples/meson.build
@@ -0,0 +1,33 @@
+dmxexamples_dep = [
+    dependency('xext'),
+    dependency('x11'),
+]
+
+dmx_dep = dependency('dmx', version: '>= 1.0.99.1')
+
+dmx_examples = [
+    ['dmxinfo', [dmx_dep]],
+    ['dmxwininfo', [dmx_dep, dependency('xmu')]],
+    ['dmxreconfig', [dmx_dep]],
+    ['dmxresize', [dmx_dep]],
+    ['dmxaddscreen', [dmx_dep]],
+    ['dmxrmscreen', [dmx_dep]],
+    ['dmxaddinput', [dmx_dep]],
+    ['xinput', [dmx_dep, dependency('xi')]],
+    ['xtest', [dependency('xtst')]],
+    ['evi', []],
+    ['xled', []],
+    ['xbell', []],
+    ['res', [dependency('xres')]],
+]
+
+foreach ex: dmx_examples
+    bin = ex[0]
+    extra_dep = ex[1]
+
+    executable(bin, bin + '.c', dependencies: [dmxexamples_dep, extra_dep])
+endforeach
+
+if cc.has_header('linux/input.h')
+    executable('ev', 'ev.c')
+endif
diff --git a/hw/dmx/glxProxy/meson.build b/hw/dmx/glxProxy/meson.build
new file mode 100644
index 000000000000..bbb93f40ab1a
--- /dev/null
+++ b/hw/dmx/glxProxy/meson.build
@@ -0,0 +1,27 @@
+srcs_dmx_glx = [
+    'compsize.c',
+    'g_disptab.c',
+    'global.c',
+    'glxcmds.c',
+    'glxcmdsswap.c',
+    'glxext.c',
+    'glxfbconfig.c',
+    'glxscreens.c',
+    'glxsingle.c',
+    'glxswap.c',
+    'glxvendor.c',
+    'glxvisuals.c',
+    'g_renderswap.c',
+    'render2swap.c',
+    'renderpixswap.c',
+]
+
+dmx_glx = static_library('dmx_glx',
+    srcs_dmx_glx,
+    include_directories: [
+        inc,
+        include_directories('../')
+    ],
+    dependencies: common_dep,
+    c_args: ['-DHAVE_DMX_CONFIG_H', glx_align64],
+)
diff --git a/hw/dmx/input/meson.build b/hw/dmx/input/meson.build
new file mode 100644
index 000000000000..cf058adfda20
--- /dev/null
+++ b/hw/dmx/input/meson.build
@@ -0,0 +1,32 @@
+srcs_dmx_input = [
+    'dmxdummy.c',
+    'dmxbackend.c',
+    'dmxconsole.c',
+    'dmxcommon.c',
+    'dmxinputinit.c',
+    'dmxarg.c',
+    'dmxevents.c',
+    'dmxxinput.c',
+    'dmxmotion.c',
+    'dmxmap.c',
+    'ChkNotMaskEv.c',
+]
+
+if cc.has_header('linux/input.h')
+    srcs_dmx_input += [
+        'usb-keyboard.c',
+        'usb-mouse.c',
+        'usb-other.c',
+        'usb-common.c',
+    ]
+endif
+
+dmx_input = static_library('dmx_input',
+	srcs_dmx_input,
+	include_directories: [
+            inc,
+            include_directories('../')
+        ],
+	dependencies: common_dep,
+        c_args: '-DHAVE_DMX_CONFIG_H',
+)
diff --git a/hw/dmx/meson.build b/hw/dmx/meson.build
new file mode 100644
index 000000000000..bc693c1c9def
--- /dev/null
+++ b/hw/dmx/meson.build
@@ -0,0 +1,68 @@
+srcs = [
+    'dmx.c',
+    'dmxcb.c',
+    'dmxcmap.c',
+    'dmxcursor.c',
+    'dmxdpms.c',
+    'dmxextension.c',
+    'dmxfont.c',
+    'dmxgc.c',
+    'dmxgcops.c',
+    'dmxinit.c',
+    'dmxinput.c',
+    'dmxlog.c',
+    'dmxpict.c',
+    'dmxpixmap.c',
+    'dmxprop.c',
+    'dmxscrinit.c',
+    'dmxstat.c',
+    'dmxsync.c',
+    'dmxvisual.c',
+    'dmxwindow.c',
+    '../../mi/miinitext.c',
+    '../../Xext/panoramiX.c',
+]
+
+subdir('config')
+subdir('input')
+subdir('examples')
+# XXX: subdir('doc')
+# XXX: subdir('doxygen')
+# XXX: subdir('man')
+
+dmx_dep = [
+    common_dep,
+    dependency('dmxproto', version: '>= 2.2.99.1'),
+    dependency('xext', version: '>= 1.0.99.4'),
+    dependency('xau'),
+    dependency('xmuu'),
+    dependency('xfixes'),
+    dependency('xrender'),
+    dependency('xi', version: '>= 1.2.99.1'),
+    xdmcp_dep,
+    dl_dep,
+]
+
+dmx_glx = ''
+if build_glx
+    srcs += 'dmx_glxvisuals.c'
+    subdir('glxProxy')
+endif
+
+executable(
+    'Xdmx',
+    srcs,
+    include_directories: inc,
+    dependencies: dmx_dep,
+    link_with: [
+        libxserver_main,
+        libxserver_fb,
+        libxserver,
+        libxserver_xkb_stubs,
+        dmx_input,
+        dmx_config,
+        dmx_glx,
+    ],
+    c_args: '-DHAVE_DMX_CONFIG_H',
+    install: true,
+)
diff --git a/hw/kdrive/ephyr/meson.build b/hw/kdrive/ephyr/meson.build
new file mode 100644
index 000000000000..cf1cfd5e0c6f
--- /dev/null
+++ b/hw/kdrive/ephyr/meson.build
@@ -0,0 +1,62 @@
+srcs = [
+    'ephyr.c',
+    'ephyrinit.c',
+    'ephyrcursor.c',
+    'ephyr_draw.c',
+    'hostx.c',
+    'os.c',
+]
+
+xephyr_dep = [
+    common_dep,
+    dependency('xcb'),
+    dependency('xcb-shape'),
+    dependency('xcb-render'),
+    dependency('xcb-renderutil'),
+    dependency('xcb-aux'),
+    dependency('xcb-image'),
+    dependency('xcb-icccm'),
+    dependency('xcb-shm'),
+    dependency('xcb-keysyms'),
+    dependency('xcb-randr'),
+    dependency('xcb-xkb'),
+]
+
+xephyr_glamor = []
+if build_glamor
+    srcs += 'ephyr_glamor_glx.c'
+    if build_xv
+        srcs += 'ephyr_glamor_xv.c'
+    endif
+    xephyr_glamor += glamor
+    xephyr_glamor += glamor_egl_stubs
+    xephyr_dep += dependency('x11-xcb')
+endif
+
+if build_xv
+    srcs += 'ephyrvideo.c'
+    xephyr_dep += dependency('xcb-xv')
+endif
+
+executable(
+    'Xephyr',
+    srcs,
+    include_directories: [
+        inc,
+        include_directories('../src')
+    ],
+    dependencies: xephyr_dep,
+    link_with: [
+        libxserver_main,
+        libxserver_exa,
+        xephyr_glamor,
+        kdrive,
+        libxserver_fb,
+        libxserver,
+        libxserver_config,
+        libxserver_xkb_stubs,
+        libxserver_xi_stubs,
+        libxserver_glx,
+    ],
+    install: true,
+)
diff --git a/hw/kdrive/meson.build b/hw/kdrive/meson.build
new file mode 100644
index 000000000000..16341e228136
--- /dev/null
+++ b/hw/kdrive/meson.build
@@ -0,0 +1,2 @@
+subdir('src')
+subdir('ephyr')
diff --git a/hw/kdrive/src/meson.build b/hw/kdrive/src/meson.build
new file mode 100644
index 000000000000..d257307cb8ab
--- /dev/null
+++ b/hw/kdrive/src/meson.build
@@ -0,0 +1,22 @@
+srcs_kdrive = [
+    'kcmap.c',
+    'kdrive.c',
+    'kinfo.c',
+    'kinput.c',
+    'kmode.c',
+    'kshadow.c',
+    '../../../mi/miinitext.c',
+]
+
+if build_xv
+    srcs_kdrive += 'kxv.c'
+endif
+
+#XXX: libconfig
+
+kdrive = static_library('kdrive',
+    srcs_kdrive,
+    include_directories: inc,
+    dependencies: common_dep,
+    link_with: libxserver_miext_shadow,
+)
diff --git a/hw/meson.build b/hw/meson.build
new file mode 100644
index 000000000000..c389a995b72b
--- /dev/null
+++ b/hw/meson.build
@@ -0,0 +1,25 @@
+if get_option('xephyr')
+    subdir('kdrive')
+endif
+
+if get_option('dmx')
+    subdir('dmx')
+endif
+
+subdir('vfb')
+
+if build_xnest
+    subdir('xnest')
+endif
+
+if build_xorg
+    subdir('xfree86')
+endif
+
+if build_xquartz
+    subdir('xquartz')
+endif
+
+if build_xwayland
+    subdir('xwayland')
+endif
diff --git a/hw/vfb/meson.build b/hw/vfb/meson.build
new file mode 100644
index 000000000000..6566b45907f1
--- /dev/null
+++ b/hw/vfb/meson.build
@@ -0,0 +1,21 @@
+srcs = [
+    'InitInput.c',
+    'InitOutput.c',
+    '../../mi/miinitext.c',
+]
+
+executable(
+    'Xvfb',
+    srcs,
+    include_directories: inc,
+    dependencies: common_dep,
+    link_with: [
+        libxserver_main,
+        libxserver_fb,
+        libxserver,
+        libxserver_xkb_stubs,
+        libxserver_xi_stubs,
+        libxserver_glx
+    ],
+    install: true,
+)
diff --git a/hw/xfree86/common/meson.build b/hw/xfree86/common/meson.build
new file mode 100644
index 000000000000..cdbc5e609231
--- /dev/null
+++ b/hw/xfree86/common/meson.build
@@ -0,0 +1,93 @@
+srcs_xorg_common = [
+    'xf86fbBus.c',
+    'xf86noBus.c',
+    'xf86Configure.c',
+    'xf86Bus.c',
+    'xf86Config.c',
+    'xf86Cursor.c',
+    'xf86DPMS.c',
+    'xf86Events.c',
+    'xf86Globals.c',
+    'xf86AutoConfig.c',
+    'xf86Option.c',
+    'xf86Init.c',
+    'xf86VidMode.c',
+    'xf86fbman.c',
+    'xf86cmap.c',
+    'xf86Helper.c',
+    'xf86PM.c',
+    'xf86RandR.c',
+    'xf86Xinput.c',
+    'xisb.c',
+    'xf86Mode.c',
+    'xorgHelper.c',
+    'xf86Extensions.c',
+]
+
+xorg_sdk_headers = [
+    'compiler.h',
+    'fourcc.h',
+    'xf86.h',
+    'xf86Module.h',
+    'xf86Opt.h',
+    'xf86PciInfo.h',
+    'xf86Priv.h',
+    'xf86Privstr.h',
+    'xf86cmap.h',
+    'xf86fbman.h',
+    'xf86str.h',
+    'xf86Xinput.h',
+    'xisb.h',
+    'xorgVersion.h',
+    'xf86sbusBus.h',
+    'xf86VGAarbiter.h',
+    'xf86Optionstr.h',
+    'xf86platformBus.h',
+    'xaarop.h',
+]
+
+if build_dga
+    srcs_xorg_common += 'xf86DGA.c'
+    xorg_sdk_headers += 'dgaproc.h'
+endif
+
+if build_xv
+    srcs_xorg_common += ['xf86xv.c', 'xf86xvmc.c']
+    xorg_sdk_headers += ['xf86xv.h', 'xf86xvmc.h', 'xf86xvpriv.h']
+endif
+
+if build_udev
+    srcs_xorg_common += 'xf86platformBus.c'
+endif
+
+if get_option('pciaccess')
+    srcs_xorg_common += ['xf86pciBus.c', 'xf86VGAarbiter.c']
+endif
+
+srcs_xorg_common += custom_target(
+    'xf86Build.h',
+    output: 'xf86Build.h',
+    command: [join_paths(meson.current_source_dir(), 'xf86Build.sh'), '@OUTPUT@'],
+    build_always: true,
+)
+
+srcs_xorg_common += custom_target(
+    'xf86DefModeSet.c',
+    output: 'xf86DefModeSet.c',
+    input: ['modeline2c.awk', 'vesamodes', 'extramodes'],
+    command: [find_program('awk'), '-f', '@INPUT0@', '@INPUT1@', '@INPUT2@'],
+    capture: true,
+)
+
+xorg_common = static_library('xorg_common',
+    srcs_xorg_common,
+    include_directories: [inc, xorg_inc],
+    dependencies: [
+        common_dep,
+        dbus_dep,
+        pciaccess_dep,
+    ],
+    c_args: xorg_c_args,
+)
+
+install_data(xorg_sdk_headers, install_dir: xorgsdkdir)
diff --git a/hw/xfree86/common/xf86Build.sh b/hw/xfree86/common/xf86Build.sh
new file mode 100755
index 000000000000..ae4a5513248b
--- /dev/null
+++ b/hw/xfree86/common/xf86Build.sh
@@ -0,0 +1,6 @@
+BUILD_DATE=`date +'%Y%m%d'`
+BUILD_TIME=`date +'1%H%M%S'`
+
+output=$1
+echo "#define BUILD_DATE $BUILD_DATE" > $output
+echo "#define BUILD_TIME $BUILD_TIME" > $output
diff --git a/hw/xfree86/ddc/meson.build b/hw/xfree86/ddc/meson.build
new file mode 100644
index 000000000000..c9b816f2e77a
--- /dev/null
+++ b/hw/xfree86/ddc/meson.build
@@ -0,0 +1,15 @@
+srcs_xorg_ddc = [
+    'ddc.c',
+    'interpret_edid.c',
+    'print_edid.c',
+    'ddcProperty.c',
+]
+
+xorg_ddc = static_library('xorg_ddc',
+    srcs_xorg_ddc,
+    include_directories: [inc, xorg_inc],
+    dependencies: common_dep,
+    c_args: xorg_c_args,
+)
+
+install_data(['edid.h', 'xf86DDC.h'], install_dir: xorgsdkdir)
diff --git a/hw/xfree86/dixmods/meson.build b/hw/xfree86/dixmods/meson.build
new file mode 100644
index 000000000000..2b8fe13496c4
--- /dev/null
+++ b/hw/xfree86/dixmods/meson.build
@@ -0,0 +1,38 @@
+srcs_xorg_dixmods = [
+    'xkbVT.c',
+    'xkbPrivate.c',
+    'xkbKillSrv.c',
+]
+
+xorg_dixmods = static_library('xorg_dixmods',
+    srcs_xorg_dixmods,
+    include_directories: [inc, xorg_inc],
+    dependencies: common_dep,
+    c_args: xorg_c_args,
+)
+
+shared_module(
+    'fb',
+    'fbmodule.c',
+
+    include_directories: [inc, xorg_inc],
+    c_args: xorg_c_args,
+    dependencies: common_dep,
+    objects: libxserver_fb.extract_all_objects(),
+
+    install: true,
+    install_dir: module_dir,
+)
+
+shared_module(
+    'shadow',
+    'shmodule.c',
+
+    include_directories: [inc, xorg_inc],
+    c_args: xorg_c_args,
+    dependencies: common_dep,
+    objects: libxserver_miext_shadow.extract_all_objects(),
+
+    install: true,
+    install_dir: module_dir,
+)
diff --git a/hw/xfree86/dri/meson.build b/hw/xfree86/dri/meson.build
new file mode 100644
index 000000000000..9baae100cabe
--- /dev/null
+++ b/hw/xfree86/dri/meson.build
@@ -0,0 +1,23 @@
+srcs_xorg_dri = [
+    'dri.c',
+    'xf86dri.c',
+]
+
+xorg_dri = static_library('xorg_dri',
+    srcs_xorg_dri,
+    include_directories: [inc, xorg_inc],
+    dependencies: [
+        common_dep,
+        dependency('libdrm'),
+    ],
+    c_args: xorg_c_args,
+)
+
+install_data(
+    [
+        'dri.h',
+        'sarea.h',
+        'dristruct.h',
+    ],
+    install_dir: xorgsdkdir,
+)
diff --git a/hw/xfree86/dri2/meson.build b/hw/xfree86/dri2/meson.build
new file mode 100644
index 000000000000..9e997d2f78aa
--- /dev/null
+++ b/hw/xfree86/dri2/meson.build
@@ -0,0 +1,16 @@
+srcs_xorg_dri2 = [
+    'dri2.c',
+    'dri2ext.c',
+]
+
+xorg_dri2 = static_library('xorg_dri2',
+    srcs_xorg_dri2,
+    include_directories: [inc, xorg_inc],
+    dependencies: [
+        common_dep,
+        dependency('libdrm'),
+    ],
+    c_args: xorg_c_args,
+)
+
+install_data('dri2.h', install_dir: xorgsdkdir)
diff --git a/hw/xfree86/drivers/modesetting/meson.build b/hw/xfree86/drivers/modesetting/meson.build
new file mode 100644
index 000000000000..518d6c19eec4
--- /dev/null
+++ b/hw/xfree86/drivers/modesetting/meson.build
@@ -0,0 +1,42 @@
+modesetting_srcs = [
+    'dri2.c',
+    'driver.c',
+    'drmmode_display.c',
+    'dumb_bo.c',
+    'pageflip.c',
+    'present.c',
+    'vblank.c',
+]
+
+shared_module(
+    'modesetting_drv',
+    modesetting_srcs,
+    name_prefix: '',
+
+    include_directories: [inc, xorg_inc],
+    c_args: xorg_c_args,
+    dependencies: [
+        common_dep,
+        udev_dep,
+        dependency('libdrm', version: '>= 2.4.46'),
+    ],
+
+    install: true,
+    install_dir: join_paths(module_dir, 'drivers'),
+)
+
+# Test that we don't have any unresolved symbols from our module to Xorg.
+xorg_build_root = join_paths(meson.build_root(), 'hw', 'xfree86')
+symbol_test_args = []
+symbol_test_args += join_paths(xorg_build_root, 'Xorg')
+symbol_test_args += join_paths(xorg_build_root, 'dixmods', 'libfb.so')
+symbol_test_args += join_paths(xorg_build_root, 'dixmods', 'libshadow.so')
+if build_glamor
+    symbol_test_args += join_paths(xorg_build_root, 'glamor_egl', 'libglamoregl.so')
+endif
+symbol_test_args += join_paths(xorg_build_root, 'drivers', 'modesetting', 'modesetting_drv.so')
+
+test('modesetting symbol test',
+    xorg_symbol_test,
+    args: symbol_test_args,
+)
diff --git a/hw/xfree86/exa/meson.build b/hw/xfree86/exa/meson.build
new file mode 100644
index 000000000000..bfc5590f847d
--- /dev/null
+++ b/hw/xfree86/exa/meson.build
@@ -0,0 +1,9 @@
+xorg_exa = shared_module('exa',
+    'examodule.c',
+    include_directories: [inc, xorg_inc],
+    dependencies: common_dep,
+    link_with: libxserver_exa,
+    c_args: xorg_c_args,
+    install: true,
+    install_dir: module_dir,
+)
diff --git a/hw/xfree86/glamor_egl/meson.build b/hw/xfree86/glamor_egl/meson.build
new file mode 100644
index 000000000000..7eae05812557
--- /dev/null
+++ b/hw/xfree86/glamor_egl/meson.build
@@ -0,0 +1,22 @@
+glamoregl_src = [
+    '../../../glamor/glamor_egl.c',
+    '../../../glamor/glamor_eglmodule.c',
+    'glamor_xf86_xv.c',
+]
+
+shared_module(
+    'glamoregl',
+    glamoregl_src,
+
+    include_directories: [inc, xorg_inc],
+    c_args: xorg_c_args,
+    dependencies: [
+        common_dep,
+        dependency('libdrm', version: '>= 2.4.46'),
+        gbm_dep,
+    ],
+    link_with: glamor,
+
+    install: true,
+    install_dir: module_dir,
+)
diff --git a/hw/xfree86/i2c/meson.build b/hw/xfree86/i2c/meson.build
new file mode 100644
index 000000000000..d22860e9ea0a
--- /dev/null
+++ b/hw/xfree86/i2c/meson.build
@@ -0,0 +1,12 @@
+srcs_xorg_i2c = [
+    'xf86i2c.c'
+]
+
+xorg_i2c = static_library('xorg_i2c',
+    srcs_xorg_i2c,
+    include_directories: [inc, xorg_inc],
+    dependencies: common_dep,
+    c_args: xorg_c_args,
+)
+
+install_data(['xf86i2c.h', 'i2c_def.h'], install_dir: xorgsdkdir)
diff --git a/hw/xfree86/int10/meson.build b/hw/xfree86/int10/meson.build
new file mode 100644
index 000000000000..3bcf99ab47b1
--- /dev/null
+++ b/hw/xfree86/int10/meson.build
@@ -0,0 +1,54 @@
+srcs_xorg_int10 = [
+    'helper_exec.c',
+    'helper_mem.c',
+    'xf86int10.c',
+    'xf86int10module.c',
+]
+
+int10_c_args = [xorg_c_args]
+int10_link = []
+
+if host_machine.cpu() == 'i386' or host_machine.cpu() == 'x86_64'
+    int10_c_args += '-D_PC'
+endif
+
+if int10 == 'stub'
+    srcs_xorg_int10 += 'stub.c'
+    int10_c_args += '-D_VM86_LINUX'
+endif
+
+if int10 == 'x86emu'
+    srcs_xorg_int10 += [
+        'generic.c',
+        'xf86x86emu.c',
+        'x86emu.c',
+    ]
+    int10_c_args += '-D_X86EMU'
+    int10_c_args += '-DNO_SYS_HEADERS'
+    int10_link += xorg_x86emu
+endif
+
+if int10 == 'vm86'
+    srcs_xorg_int10 += [
+        'vm86/linux_vm86.c',
+        'linux.c',
+    ]
+    int10_c_args += '-D_VM86_LINUX'
+endif
+
+xorg_int10 = shared_module('int10',
+    srcs_xorg_int10,
+    include_directories: [
+        inc,
+        xorg_inc,
+        include_directories('../x86emu')
+    ],
+    dependencies: common_dep,
+    link_with: int10_link,
+    c_args: int10_c_args,
+
+    install: true,
+    install_dir: module_dir,
+)
+
+install_data('xf86int10.h', install_dir: xorgsdkdir)
diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c
index 86629b26d54a..503c47e3ab55 100644
--- a/hw/xfree86/loader/loader.c
+++ b/hw/xfree86/loader/loader.c
@@ -64,12 +64,16 @@
 #error i have no dynamic linker and i must scream
 #endif
 
+#ifndef XORG_NO_SDKSYMS
 extern void *xorg_symbols[];
+#endif
 
 void
 LoaderInit(void)
 {
+#ifndef XORG_NO_SDKSYMS
     LogMessageVerb(X_INFO, 2, "Loader magic: %p\n", (void *) xorg_symbols);
+#endif
     LogMessageVerb(X_INFO, 2, "Module ABI versions:\n");
     LogWrite(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC,
              GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion),
diff --git a/hw/xfree86/loader/meson.build b/hw/xfree86/loader/meson.build
new file mode 100644
index 000000000000..533c4f15cfc3
--- /dev/null
+++ b/hw/xfree86/loader/meson.build
@@ -0,0 +1,16 @@
+srcs_xorg_loader = [
+    'loader.c',
+    'loadmod.c',
+]
+
+xorg_loader = static_library('xorg_loader',
+    srcs_xorg_loader,
+    include_directories: [inc, xorg_inc],
+    dependencies: [common_dep, dl_dep],
+    c_args: xorg_c_args,
+)
+
+xorg_symbol_test = executable('xorg_symbol_test',
+    'symbol-test.c',
+    dependencies: dl_dep,
+)
diff --git a/hw/xfree86/loader/symbol-test.c b/hw/xfree86/loader/symbol-test.c
new file mode 100644
index 000000000000..a9a3031a4486
--- /dev/null
+++ b/hw/xfree86/loader/symbol-test.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2017 Broadcom
+ *
+ * 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 (including the next
+ * paragraph) 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.
+ */
+
+/* Small test program to see if we can successfully resolve all
+ * symbols of a set of X.Org modules when they're loaded in order.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+int main (int argc, char**argv)
+{
+    void *ret;
+
+    if (argc < 2) {
+        fprintf(stderr,
+                "Must pass path of Xorg executable and any "
+                "modules to be loaded.\n");
+        exit(1);
+    }
+
+    for (int i = 1; i < argc; i++) {
+	fprintf(stderr, "opening %s\n", argv[i]);
+	ret = dlopen(argv[i], RTLD_GLOBAL | RTLD_NOW);
+	if (!ret) {
+	    fprintf(stderr, "dlopen error: %s\n", dlerror());
+	    exit(1);
+	}
+    }
+
+    return 0;
+}
diff --git a/hw/xfree86/meson.build b/hw/xfree86/meson.build
new file mode 100644
index 000000000000..a9bb84af2f90
--- /dev/null
+++ b/hw/xfree86/meson.build
@@ -0,0 +1,106 @@
+xorg_inc = include_directories(
+    'common',
+    'ddc',
+    'dri2',
+    'i2c',
+    'int10',
+    'loader',
+    'modes',
+    'os-support',
+    'os-support/bus',
+    'parser',
+    'ramdac',
+    'vbe',
+    'vgahw',
+)
+
+xorg_c_args = []
+xorg_c_args += '-DHAVE_XORG_CONFIG_H'
+xorg_c_args += '-DXORG_NO_SDKSYMS'
+
+pciaccess_dep = []
+if get_option('pciaccess')
+    pciaccess_dep = dependency('pciaccess', version: '>= 0.12.901')
+endif
+
+subdir('common')
+subdir('ddc')
+subdir('dixmods')
+subdir('exa')
+if gbm_dep.found()
+    subdir('glamor_egl')
+endif
+subdir('i2c')
+if build_dri1
+    subdir('dri')
+endif
+if build_dri2
+    subdir('dri2')
+endif
+
+if int10 != 'disabled'
+    if int10 == 'x86emu'
+        subdir('x86emu')
+    endif
+    subdir('int10')
+endif
+subdir('loader')
+subdir('modes')
+subdir('os-support')
+subdir('parser')
+subdir('ramdac')
+subdir('drivers/modesetting')
+
+srcs_xorg = [
+    '../../mi/miinitext.c'
+]
+
+# Extract all the objects so that all symbols get brought into the
+# server.  This prevents us from needing a global table of all symbols
+# that should be exported to Xorg modules, at the expense of all
+# symbols being included and public
+
+xorg_link = [
+    libxserver,
+    xorg_common,
+    xorg_loader,
+    xorg_ddc,
+    xorg_dixmods,
+    xorg_i2c,
+    xorg_modes,
+    xorg_os_support,
+    xorg_parser,
+    xorg_ramdac,
+    libxserver_xext_vidmode,
+    libxserver_main,
+    libxserver_config,
+]
+if build_dri1
+    xorg_link += xorg_dri
+endif
+if build_dri2
+    xorg_link += xorg_dri2
+endif
+
+executable(
+    'Xorg',
+    srcs_xorg,
+    include_directories: [inc, xorg_inc],
+    link_whole: xorg_link,
+    dependencies: [
+        pixman_dep,
+        m_dep,
+        dl_dep,
+        pciaccess_dep,
+        sha1_dep,
+        dependency('xau'),
+        xdmcp_dep,
+        xfont2_dep,
+        xshmfence_dep,
+        config_dep,
+        dependency('libdrm'),
+    ],
+    link_args: '-Wl,--export-dynamic',
+    c_args: xorg_c_args,
+    install: true,
+)
diff --git a/hw/xfree86/modes/meson.build b/hw/xfree86/modes/meson.build
new file mode 100644
index 000000000000..ddacca15809a
--- /dev/null
+++ b/hw/xfree86/modes/meson.build
@@ -0,0 +1,30 @@
+srcs_xorg_modes = [
+    'xf86Crtc.c',
+    'xf86Cursors.c',
+    'xf86cvt.c',
+    'xf86gtf.c',
+    'xf86EdidModes.c',
+    'xf86Modes.c',
+    'xf86RandR12.c',
+    'xf86Rotate.c',
+]
+
+if build_dga
+    srcs_xorg_modes += 'xf86DiDGA.c'
+endif
+
+xorg_modes = static_library('xorg_modes',
+    srcs_xorg_modes,
+    include_directories: [inc, xorg_inc],
+    dependencies: common_dep,
+    c_args: xorg_c_args,
+)
+
+install_data(
+    [
+        'xf86Crtc.h',
+        'xf86Modes.h',
+        'xf86RandR12.h',
+    ],
+    install_dir: xorgsdkdir,
+)
diff --git a/hw/xfree86/os-support/meson.build b/hw/xfree86/os-support/meson.build
new file mode 100644
index 000000000000..a3c3b5688e67
--- /dev/null
+++ b/hw/xfree86/os-support/meson.build
@@ -0,0 +1,125 @@
+srcs_xorg_os_support = [
+    'bus/nobus.c',
+    'shared/posix_tty.c',
+    'shared/sigio.c',
+    'shared/vidmem.c',
+]
+os_support_flags = ['-DUSESTDRES']
+
+if get_option('pciaccess')
+    srcs_xorg_os_support += 'bus/Pci.c'
+    if host_machine.system() != 'linux' and host_machine.system() != 'solaris'
+        srcs_xorg_os_support += 'bus/bsd_pci.c'
+    endif
+    if host_machine.cpu() == 'sparc'
+        srcs_xorg_os_support += 'bus/Sbus.c'
+        install_data('bus/xf86Sbus.h', install_dir: xorgsdkdir)
+    endif
+endif
+
+if host_machine.system() == 'linux'
+    srcs_xorg_os_support += [
+        'linux/lnx_agp.c',
+        'linux/lnx_bell.c',
+        'linux/lnx_init.c',
+        'linux/lnx_kmod.c',
+        'linux/lnx_platform.c',
+        'linux/lnx_video.c',
+        'misc/SlowBcopy.c',
+        'shared/VTsw_usl.c',
+    ]
+    if build_systemd_logind
+        srcs_xorg_os_support += 'linux/systemd-logind.c'
+    endif
+
+    # this is ugly because the code is also
+    if build_apm or build_acpi
+        srcs_xorg_os_support += 'linux/lnx_apm.c'
+        if build_acpi
+            srcs_xorg_os_support += 'linux/lnx_acpi.c'
+        endif
+    endif
+
+    os_support_flags += '-DHAVE_SYSV_IPC'
+elif host_machine.system() == 'solaris'
+    srcs_xorg_os_support += [
+        'solaris/sun_apm.c',
+        'solaris/sun_bell.c',
+        'solaris/sun_init.c',
+        'solaris/sun_vid.c',
+        'shared/kmod_noop.c',
+    ]
+
+    if cc.has_header('sys/vt.h')
+        srcs_xorg_os_support += 'solaris/sun_VTsw.c'
+    else
+        srcs_xorg_os_support += 'shared/VTsw_noop.c'
+    endif
+
+    if cc.has_header('sys/agpio.h') or cc.has_header('sys/agpgart.h')
+        srcs_xorg_os_support += 'solaris/sun_agp.c'
+    else
+        srcs_xorg_os_support += 'shared/agp_noop.c'
+    endif
+
+    if host_machine.cpu_family() == 'sparc'
+        srcs_xorg_os_support += 'solaris/solaris-sparcv8plus.S'
+    elif host_machine.cpu_family() == 'x86_64'
+        srcs_xorg_os_support += 'solaris/solaris-amd64.S'
+    elif host_machine.cpu_family() == 'x86'
+        srcs_xorg_os_support += 'solaris/solaris-ia32.S'
+    else
+        error('Unknown CPU family for Solaris build')
+    endif
+
+    os_support_flags += '-DHAVE_SYSV_IPC'
+else
+    srcs_xorg_os_support += [
+        'bsd/bsd_VTsw.c',
+        'bsd/bsd_bell.c',
+        'bsd/bsd_init.c',
+    ]
+
+    # XXX: APM
+
+    if host_machine.cpu_family() == 'x86_64'
+        srcs_xorg_os_support += 'bsd/i386_video.c'
+    elif host_machine.cpu_family() == 'x86'
+        srcs_xorg_os_support += 'bsd/i386_video.c'
+    elif host_machine.cpu_family() == 'arm'
+        srcs_xorg_os_support += 'bsd/arm_video.c'
+    elif host_machine.cpu_family() == 'powerpc'
+        srcs_xorg_os_support += 'bsd/ppc_video.c'
+    elif host_machine.cpu_family() == 'sparc64'
+        srcs_xorg_os_support += 'bsd/sparc64_video.c'
+        srcs_xorg_os_support += 'shared/ioperm_noop.c'
+    elif host_machine.cpu_family() == 'alpha'
+        srcs_xorg_os_support += 'bsd/alpha_video.c'
+        srcs_xorg_os_support += 'bsd/bsd_ev56.c'
+    endif
+
+    if host_machine.system() == 'freebsd'
+        srcs_xorg_os_support += 'bsd/bsd_kmod.c'
+    else
+        srcs_xorg_os_support += 'shared/kmod_noop.c'
+    endif
+
+    if cc.has_header('sys/agpio.h') or cc.has_header('sys/agpgart.h')
+        srcs_xorg_os_support += 'linux/lnx_agp.c'
+    else
+        srcs_xorg_os_support += 'shared/agp_noop.c'
+    endif
+endif
+
+xorg_os_support = static_library('xorg_os_support',
+    srcs_xorg_os_support,
+    include_directories: [inc, xorg_inc],
+    dependencies: [
+        common_dep,
+        dbus_dep,
+        dependency('libdrm'),
+    ],
+    c_args: xorg_c_args,
+)
+
+install_data('bus/xf86Pci.h', install_dir: xorgsdkdir)
diff --git a/hw/xfree86/parser/meson.build b/hw/xfree86/parser/meson.build
new file mode 100644
index 000000000000..031dc2becafb
--- /dev/null
+++ b/hw/xfree86/parser/meson.build
@@ -0,0 +1,32 @@
+srcs_xorg_parser = [
+    'Device.c',
+    'Files.c',
+    'Flags.c',
+    'Input.c',
+    'InputClass.c',
+    'OutputClass.c',
+    'Layout.c',
+    'Module.c',
+    'Video.c',
+    'Monitor.c',
+    'Pointer.c',
+    'Screen.c',
+    'Vendor.c',
+    'read.c',
+    'scan.c',
+    'write.c',
+    'DRI.c',
+    'Extensions.c',
+]
+
+xorg_parser = static_library('xorg_parser',
+    srcs_xorg_parser,
+    include_directories: [inc, xorg_inc],
+    dependencies: common_dep,
+    c_args: [
+        xorg_c_args,
+        '-DDATADIR="' + join_paths(get_option('prefix'), get_option('datadir')) + '"',
+    ],
+)
+
+install_data(['xf86Parser.h', 'xf86Optrec.h'], install_dir: xorgsdkdir)
diff --git a/hw/xfree86/ramdac/meson.build b/hw/xfree86/ramdac/meson.build
new file mode 100644
index 000000000000..babf2b821ed3
--- /dev/null
+++ b/hw/xfree86/ramdac/meson.build
@@ -0,0 +1,27 @@
+srcs_xorg_ramdac = [
+    'xf86RamDac.c',
+    'xf86RamDacCmap.c',
+    'xf86CursorRD.c',
+    'xf86HWCurs.c',
+    'IBM.c',
+    'BT.c',
+    'TI.c',
+]
+
+xorg_ramdac = static_library('xorg_ramdac',
+    srcs_xorg_ramdac,
+    include_directories: [inc, xorg_inc],
+    dependencies: common_dep,
+    c_args: xorg_c_args,
+)
+
+install_data(
+    [
+        'BT.h',
+        'IBM.h',
+        'TI.h',
+        'xf86Cursor.h',
+        'xf86RamDac.h',
+    ],
+    install_dir: xorgsdkdir,
+)
diff --git a/hw/xfree86/x86emu/meson.build b/hw/xfree86/x86emu/meson.build
new file mode 100644
index 000000000000..4846da99dc2f
--- /dev/null
+++ b/hw/xfree86/x86emu/meson.build
@@ -0,0 +1,15 @@
+srcs_xorg_x86emu = [
+    'debug.c',
+    'decode.c',
+    'fpu.c',
+    'ops2.c',
+    'ops.c',
+    'prim_ops.c',
+    'sys.c',
+]
+
+xorg_x86emu = static_library('x86emu',
+    srcs_xorg_x86emu,
+    include_directories: [inc, xorg_inc],
+    dependencies: common_dep,
+)
diff --git a/hw/xnest/meson.build b/hw/xnest/meson.build
new file mode 100644
index 000000000000..adcf5e59c88a
--- /dev/null
+++ b/hw/xnest/meson.build
@@ -0,0 +1,37 @@
+srcs = [
+    'Args.c',
+    'Color.c',
+    'Cursor.c',
+    'Display.c',
+    'Events.c',
+    'Font.c',
+    'GC.c',
+    'GCOps.c',
+    'Handlers.c',
+    'Init.c',
+    'Keyboard.c',
+    'Pixmap.c',
+    'Pointer.c',
+    'Screen.c',
+    'Visual.c',
+    'Window.c',
+    '../../mi/miinitext.c',
+]
+
+executable(
+    'Xnest',
+    srcs,
+    include_directories: inc,
+    dependencies: [
+        common_dep,
+        xnest_dep,
+    ],
+    link_with: [
+        libxserver_main,
+        libxserver,
+        libxserver_xi_stubs,
+        libxserver_xkb_stubs,
+    ],
+    c_args: '-DHAVE_XNEST_CONFIG_H',
+    install: true,
+)
diff --git a/hw/xquartz/meson.build b/hw/xquartz/meson.build
new file mode 100644
index 000000000000..159a03415a43
--- /dev/null
+++ b/hw/xquartz/meson.build
@@ -0,0 +1,40 @@
+add_languages('objc')
+
+srcs = [
+    'X11Application.m',
+    'X11Controller.m',
+    'applewm.c',
+    'darwin.c',
+    'darwinEvents.c',
+    'darwinXinput.c',
+    'keysym2ucs.c',
+    'quartz.c',
+    'quartzCocoa.m',
+    'quartzKeyboard.c',
+    'quartzStartup.c',
+    'quartzRandR.c',
+    'console_redirect.c',
+    '../../mi/miinitext.c',
+]
+
+executable(
+    'Xquartz',
+    srcs,
+    include_directories: inc,
+    link_with: [
+        libxserver_main,
+        libxserver,
+        libxserver_xkb_stubs,
+        libxserver_xi_stubs,
+        libxserver_glx,
+        libxserver_pseudoramix,
+    ],
+    c_args: [
+        '-DXFree86Server',
+        # XXXX: BUILD_DATE
+        '-DXSERVER_VERSION="' + version_string + '"',
+	'-DINXQUARTZ',
+	'-DUSE_NEW_CLUT',
+    ],
+    install: true,
+)
diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
new file mode 100644
index 000000000000..fbbd213c3a03
--- /dev/null
+++ b/hw/xwayland/meson.build
@@ -0,0 +1,66 @@
+srcs = [
+    'xwayland.c',
+    'xwayland-input.c',
+    'xwayland-cursor.c',
+    'xwayland-shm.c',
+    'xwayland-output.c',
+    'xwayland-cvt.c',
+    'xwayland-vidmode.c',
+    '../../mi/miinitext.c',
+]
+
+scanner_dep = dependency('wayland-scanner', native: true)
+scanner = find_program(scanner_dep.get_pkgconfig_variable('wayland_scanner'))
+
+protocols_dep = dependency('wayland-protocols')
+protodir = protocols_dep.get_pkgconfig_variable('pkgdatadir')
+
+pointer_xml = join_paths(protodir, 'unstable', 'pointer-constraints', 'pointer-constraints-unstable-v1.xml')
+relative_xml = join_paths(protodir, 'unstable', 'relative-pointer', 'relative-pointer-unstable-v1.xml')
+
+client_header = generator(scanner,
+    output : '@BASENAME at -client-protocol.h',
+    arguments : ['client-header', '@INPUT@', '@OUTPUT@']
+)
+code = generator(scanner,
+    output : '@BASENAME at -protocol.c',
+    arguments : ['code', '@INPUT@', '@OUTPUT@']
+)
+srcs += client_header.process(relative_xml)
+srcs += client_header.process(pointer_xml)
+srcs += code.process(relative_xml)
+srcs += code.process(pointer_xml)
+
+xwayland_glamor = []
+if gbm_dep.found()
+    srcs += 'xwayland-glamor.c'
+    if build_xv
+        srcs += 'xwayland-glamor-xv.c'
+    endif
+
+    srcs += client_header.process('drm.xml')
+    srcs += code.process('drm.xml')
+    xwayland_dep += gbm_dep
+    xwayland_glamor += glamor
+endif
+
+executable(
+    'Xwayland',
+    srcs,
+    include_directories: inc,
+    dependencies: [
+        common_dep,
+        xwayland_dep,
+    ],
+    link_with: [
+        libxserver_main,
+        xwayland_glamor,
+        libxserver_fb,
+        libxserver,
+        libxserver_xext_vidmode,
+        libxserver_xkb_stubs,
+        libxserver_xi_stubs,
+        libxserver_glx,
+    ],
+    install: true,
+)
diff --git a/include/meson.build b/include/meson.build
new file mode 100644
index 000000000000..75469ff0a487
--- /dev/null
+++ b/include/meson.build
@@ -0,0 +1,329 @@
+
+dri_dep = dependency('dri', required: build_dri2 or build_dri3)
+
+conf_data = configuration_data()
+conf_data.set('_DIX_CONFIG_H_', '1')
+
+conf_data.set('MONOTONIC_CLOCK', cc.compiles('''
+    #include <time.h>
+    #include <unistd.h>
+    #ifndef CLOCK_MONOTONIC
+    #error CLOCK_MONOTONIC not defined
+    #endif
+''',
+    name: 'CLOCK_MONOTONIC'))
+
+#conf_data.set('XSERVER_DTRACE', '1') # XXX
+
+if host_machine.endian() == 'little'
+    conf_data.set('X_BYTE_ORDER', 'X_LITTLE_ENDIAN')
+else
+    conf_data.set('X_BYTE_ORDER', 'X_BIG_ENDIAN')
+endif
+
+glx_align64 = ''
+if cc.sizeof('unsigned long') == 8
+   conf_data.set('_XSERVER64', '1')
+   glx_align64 = '-D__GLX_ALIGN64'
+endif
+
+conf_data.set('_GNU_SOURCE', '1')
+# XXX: NO_LOCAL_CLIENT_CRED
+
+# autoconf checks for /dev/xf86 here, but the test should be based on
+# the target, not the build system.  Could we get rid of this and just
+# ifdef for openbsd?
+conf_data.set('HAS_APERTURE_DRV', host_machine.system() == 'openbsd')
+
+# XXX: USE_ALPHA_PIO and other bsd bits
+# XXX: FALLBACK_INPUT_DRIVER
+# XXX: BUNDLE_ID_PREFIX
+# XXX: HAVE_LIBDISPATCH
+conf_data.set_quoted('OSNAME', 'Linux') # XXX
+conf_data.set('HAVE_SYSV_IPC', '1') # XXX
+conf_data.set('HAVE_INPUTTHREAD', '1') # XXX
+conf_data.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', '1') # XXX
+conf_data.set('HAVE_LIBBSD', libbsd_dep.found())
+# XXX: HAVE_SYSTEMD_DAEMON
+# XXX: HAVE_LIBUDEV
+conf_data.set('CONFIG_UDEV', build_udev)
+conf_data.set('CONFIG_UDEV_KMS', build_udev)
+conf_data.set('HAVE_DBUS', build_dbus)
+conf_data.set('CONFIG_HAL', build_hal)
+conf_data.set('SYSTEMD_LOGIND', build_systemd_logind)
+conf_data.set('NEED_DBUS', build_systemd_logind or build_hal)
+conf_data.set('CONFIG_WSCONS', host_machine.system() == 'openbsd')
+
+# XXX: SHMDIR is weird in autoconf, probing the build system for
+# various tmp directories.  Could we replace it with C code at runtime
+# that just uses whatever directory works?
+conf_data.set_quoted('SHMDIR', '/tmp')
+
+conf_data.set('HAVE_SIGACTION', '1') # XXX
+conf_data.set('BUSFAULT', '1') # XXX
+conf_data.set('XSHMFENCE', '1') # XXX
+conf_data.set('WITH_LIBDRM', '1') # XXX
+conf_data.set('GLAMOR_HAS_DRM_NAME_FROM_FD_2',
+              dependency('libdrm', version: '>= 2.4.74', required: false).found())
+conf_data.set('GLXEXT', build_glx)
+conf_data.set('GLAMOR', build_glamor)
+conf_data.set('GLAMOR_HAS_GBM', gbm_dep.found())
+if gbm_dep.found() and dependency('gbm', version: '>= 10.6', required: false).found()
+    conf_data.set('GLAMOR_HAS_GBM_LINEAR', build_glamor)
+endif
+
+conf_data.set_quoted('SERVER_MISC_CONFIG_PATH', serverconfigdir)
+conf_data.set_quoted('PROJECTROOT', get_option('prefix'))
+conf_data.set_quoted('SYSCONFDIR', join_paths(get_option('prefix'), get_option('sysconfdir')))
+
+# XXX: Stopped enumerating at COMPILEDEFAULTFONTPATH
+
+conf_data.set('HASXDMAUTH', get_option('xdm-auth-1'))
+
+conf_data.set('HAVE_DBM_H', cc.has_header('dbm.h'))
+conf_data.set('HAVE_DLFCN_H', cc.has_header('dlfcn.h'))
+conf_data.set('HAVE_EXECINFO_H', cc.has_header('execinfo.h'))
+conf_data.set('HAVE_FCNTL_H', cc.has_header('fcntl.h'))
+conf_data.set('HAVE_FNMATCH_H', cc.has_header('fnmatch.h'))
+conf_data.set('HAVE_LINUX_AGPGART_H', cc.has_header('linux/agpgart.h'))
+conf_data.set('HAVE_NDBM_H', cc.has_header('ndbm.h'))
+conf_data.set('HAVE_RPCSVC_DBM_H', cc.has_header('rpcsvc/dbm.h'))
+conf_data.set('HAVE_STDLIB_H', cc.has_header('stdlib.h'))
+conf_data.set('HAVE_STRING_H', cc.has_header('string.h'))
+conf_data.set('HAVE_STRINGS_H', cc.has_header('strings.h'))
+conf_data.set('HAVE_STROPTS_H', cc.has_header('stropts.h'))
+conf_data.set('HAVE_SYS_AGPGART_H', cc.has_header('sys/agpgart.h'))
+conf_data.set('HAVE_SYS_AGPIO_H', cc.has_header('sys/agpio.h'))
+conf_data.set('HAVE_SYS_UTSNAME_H', cc.has_header('sys/utsname.h'))
+conf_data.set('HAVE_UNISTD_H', cc.has_header('unistd.h'))
+
+conf_data.set('HAVE_BACKTRACE', cc.has_function('backtrace'))
+conf_data.set('HAVE_CBRT', cc.has_function('cbrt'))
+conf_data.set('HAVE_EPOLL_CREATE', cc.has_function('epoll_create'))
+conf_data.set('HAVE_FFS', cc.has_function('ffs'))
+conf_data.set('HAVE_GETUID', cc.has_function('getuid'))
+conf_data.set('HAVE_GETEUID', cc.has_function('geteuid'))
+conf_data.set('HAVE_ISSETUGID', cc.has_function('issetugid'))
+conf_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs'))
+conf_data.set('HAVE_GETPEEREID', cc.has_function('getpeereid'))
+conf_data.set('HAVE_GETPEERUCRED', cc.has_function('getpeerucred'))
+conf_data.set('HAVE_GETPROGNAME', cc.has_function('getprogname'))
+conf_data.set('HAVE_GETZONEID', cc.has_function('getzoneid'))
+conf_data.set('HAVE_MMAP', cc.has_function('mmap'))
+conf_data.set('HAVE_POLL', cc.has_function('poll'))
+conf_data.set('HAVE_POSIX_FALLOCATE', cc.has_function('posix_fallocate'))
+conf_data.set('HAVE_SETEUID', cc.has_function('seteuid'))
+conf_data.set('HAVE_SETITIMER', cc.has_function('setitimer'))
+conf_data.set('HAVE_SHMCTL64', cc.has_function('shmctl64'))
+conf_data.set('HAVE_STRCASECMP', cc.has_function('strcasecmp'))
+conf_data.set('HAVE_STRNCASECMP', cc.has_function('strncasecmp'))
+conf_data.set('HAVE_STRNDUP', cc.has_function('strndup'))
+conf_data.set('HAVE_VASPRINTF', cc.has_function('vasprintf'))
+conf_data.set('HAVE_VSNPRINTF', cc.has_function('vsnprintf'))
+conf_data.set('HAVE_WALKCONTEXT', cc.has_function('walkcontext'))
+
+# Don't let X dependencies typedef 'pointer'
+conf_data.set('_XTYPEDEF_POINTER', '1')
+conf_data.set('_XITYPEDEF_POINTER', '1')
+
+# XXX: Configurable?
+conf_data.set('LISTEN_TCP', '1')
+conf_data.set('LISTEN_UNIX', '1')
+conf_data.set('LISTEN_LOCAL', '1')
+conf_data.set('XTRANS_SEND_FDS', '1')
+
+conf_data.set('TCPCONN', '1')
+conf_data.set('UNIXCONN', '1')
+conf_data.set('IPv6', build_ipv6)
+
+conf_data.set('CLIENTIDS', '1') # XXX
+
+conf_data.set('BIGREQS', '1')
+conf_data.set('COMPOSITE', '1')
+conf_data.set('DAMAGE', '1')
+conf_data.set('DBE', '1')
+conf_data.set('DPMSExtension', '1')
+conf_data.set('DRI2', build_dri2)
+conf_data.set('DRI3', build_dri3)
+conf_data.set_quoted('DRI_DRIVER_PATH', dri_dep.get_pkgconfig_variable('dridriverdir'))
+conf_data.set('HAS_SHM', '1')
+conf_data.set('MITSHM', build_mitshm)
+conf_data.set('PANORAMIX', '1')
+conf_data.set('PRESENT', '1')
+conf_data.set('RANDR', '1')
+conf_data.set('RES', build_res)
+conf_data.set('RENDER', '1')
+conf_data.set('SCREENSAVER', build_screensaver)
+conf_data.set('SHAPE', '1')
+conf_data.set('XACE', build_xace)
+conf_data.set('XCMISC', '1')
+conf_data.set('XCSECURITY', build_xsecurity)
+conf_data.set('XDMCP', get_option('xdmcp'))
+conf_data.set('XF86BIGFONT', build_xf86bigfont)
+conf_data.set('XF86DRI', build_dri1)
+conf_data.set('XF86VIDMODE', '1')
+conf_data.set('XFIXES	 ', '1')
+conf_data.set('XINERAMA', build_xinerama)
+conf_data.set('XINPUT', '1')
+conf_data.set('XRECORD', '1')
+conf_data.set('XSELINUX', build_xselinux)
+conf_data.set('XSYNC', '1')
+conf_data.set('XTEST', '1')
+conf_data.set('XV', build_xv)
+conf_data.set('XvExtension', build_xv)
+conf_data.set('XvMCExtension', build_xv)
+
+conf_data.set('HAVE_SHA1_IN_LIBNETTLE', '1') # XXX
+
+conf_data.set_quoted('XVENDORNAME', get_option('vendor_name'))
+conf_data.set_quoted('XVENDORNAMESHORT', get_option('vendor_name_short'))
+conf_data.set_quoted('__VENDORDWEBSUPPORT__', get_option('vendor_web'))
+conf_data.set_quoted('OSVENDOR', get_option('os_vendor'))
+
+configure_file(output : 'dix-config.h',
+               configuration : conf_data)
+
+major = 1
+minor = 19
+patch = 99
+subpatch = 1
+
+release = major * 10000000 + minor * 100000 + patch * 1000 + subpatch
+version_string = '@0 at .@1 at .@2 at .@3@'.format(major, minor, patch, subpatch)
+
+version_data = configuration_data()
+version_data.set('VENDOR_RELEASE', '@0@'.format(release))
+version_data.set_quoted('VENDOR_NAME', 'The X.Org Foundation')
+version_data.set_quoted('VENDOR_NAME_SHORT', 'X.Org')
+version_data.set_quoted('VENDOR_WEB', 'http://wiki.x.org')
+configure_file(output : 'version-config.h',
+               configuration : version_data)
+
+xkb_data = configuration_data()
+
+xkb_data.set_quoted('XKB_BIN_DIRECTORY', join_paths(get_option('prefix'), get_option('bindir')))
+xkb_data.set_quoted('XKB_BASE_DIRECTORY', xkb_dir)
+xkb_data.set_quoted('XKB_DFLT_RULES', get_option('xkb_default_rules'))
+xkb_data.set_quoted('XKB_DFLT_MODEL', get_option('xkb_default_model'))
+xkb_data.set_quoted('XKB_DFLT_LAYOUT', get_option('xkb_default_layout'))
+xkb_data.set_quoted('XKB_DFLT_VARIANT', get_option('xkb_default_variant'))
+xkb_data.set_quoted('XKB_DFLT_OPTIONS', get_option('xkb_default_options'))
+xkb_data.set_quoted('XKM_OUTPUT_DIR', xkb_output_dir)
+
+configure_file(output : 'xkb-config.h',
+               configuration : xkb_data)
+
+xorg_data = configuration_data()
+
+xorg_data.set_quoted('XORG_BIN_DIRECTORY', get_option('bindir'))
+xorg_data.set('XORG_VERSION_CURRENT', release)
+xorg_data.set_quoted('XF86CONFIGFILE', 'xorg.conf')
+xorg_data.set_quoted('XCONFIGFILE', join_paths(get_option('sysconfdir'), 'xorg.conf'))
+xorg_data.set_quoted('XCONFIGDIR', 'xorg.conf.d')
+xorg_data.set_quoted('DEFAULT_XDG_DATA_HOME', '.local/share')
+xorg_data.set_quoted('DEFAULT_XDG_DATA_HOME_LOGDIR', 'xorg')
+xorg_data.set_quoted('DEFAULT_LOGDIR', log_dir)
+xorg_data.set_quoted('DEFAULT_LOGPREFIX', 'Xorg.')
+xorg_data.set_quoted('FALLBACK_INPUT_DRIVER', 'libinput')
+xorg_data.set_quoted('DEFAULT_MODULE_PATH', join_paths(get_option('prefix'), module_dir))
+xorg_data.set_quoted('DEFAULT_LIBRARY_PATH', get_option('libdir'))
+xorg_data.set_quoted('__XSERVERNAME__', 'Xorg')
+xorg_data.set('XSERVER_LIBPCIACCESS', get_option('pciaccess'))
+xorg_data.set_quoted('PCI_TXT_IDS_PATH', '')
+xorg_data.set('XSERVER_PLATFORM_BUS', build_udev)
+xorg_data.set('WSCONS_SUPPORT', host_machine.system() == 'netbsd' or host_machine.system() == 'openbsd')
+
+if host_machine.system() == 'freebsd' or host_machine.system() == 'dragonflybsd'
+    if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'
+        xorg_data.set('USE_DEV_IO', true)
+    endif
+    # XXX: Add link to libio on alpha
+elif host_machine.system() == 'netbsd'
+    # XXX: USE_ALPHA_PIO
+    # XXX: Add link to libi386
+    if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'
+        xorg_data.set('USE_I386_IOPL', true)
+    endif
+elif host_machine.system() == 'openbsd'
+    # XXX: Add link to libi386, libamd64
+    if host_machine.cpu_family() == 'x86'
+        xorg_data.set('USE_I386_IOPL', true)
+    endif
+    if host_machine.cpu_family() == 'x86_64'
+        xorg_data.set('USE_AMD64_IOPL', true)
+    endif
+endif
+
+configure_file(output : 'xorg-config.h',
+               input : 'xorg-config.h.meson.in',
+               configuration : xorg_data)
+
+if build_xorg
+    install_data(
+        [
+            'XIstubs.h',
+            'Xprintf.h',
+            'callback.h',
+            'client.h',
+            'closestr.h',
+            'closure.h',
+            'colormap.h',
+            'colormapst.h',
+            'hotplug.h',
+            'cursor.h',
+            'cursorstr.h',
+            'dix.h',
+            'dixaccess.h',
+            'dixevents.h',
+            'dixfont.h',
+            'dixfontstr.h',
+            'dixgrabs.h',
+            'dixstruct.h',
+            'events.h',
+            'exevents.h',
+            'extension.h',
+            'extinit.h',
+            'extnsionst.h',
+            'gc.h',
+            'gcstruct.h',
+            'globals.h',
+            'glx_extinit.h',
+            'input.h',
+            'inputstr.h',
+            'list.h',
+            'misc.h',
+            'miscstruct.h',
+            'opaque.h',
+            'nonsdk_extinit.h',
+            'optionstr.h',
+            'os.h',
+            'pixmap.h',
+            'pixmapstr.h',
+            'privates.h',
+            'property.h',
+            'propertyst.h',
+            'ptrveloc.h',
+            'region.h',
+            'regionstr.h',
+            'registry.h',
+            'resource.h',
+            'rgb.h',
+            'screenint.h',
+            'scrnintstr.h',
+            'selection.h',
+            'servermd.h',
+            'site.h',
+            'validate.h',
+            'displaymode.h',
+            'window.h',
+            'windowstr.h',
+            'xkbfile.h',
+            'xkbsrv.h',
+            'xkbstr.h',
+            'xkbrules.h',
+            'xserver_poll.h',
+            'xserver-properties.h',
+        ],
+        install_dir: xorgsdkdir,
+    )
+endif
diff --git a/include/xorg-config.h.meson.in b/include/xorg-config.h.meson.in
new file mode 100644
index 000000000000..1e4213f9affb
--- /dev/null
+++ b/include/xorg-config.h.meson.in
@@ -0,0 +1,151 @@
+/* xorg-config.h.in: not at all generated.                      -*- c -*-
+ * 
+ * This file differs from xorg-server.h.in in that -server is installed
+ * with the rest of the SDK for external drivers/modules to use, whereas
+ * -config is for internal use only (i.e. building the DDX).
+ *
+ */
+
+#ifndef _XORG_CONFIG_H_
+#define _XORG_CONFIG_H_
+
+#include <dix-config.h>
+#include <xkb-config.h>
+
+/* Building Xorg server. */
+#mesondefine XORGSERVER
+
+/* Current X.Org version. */
+#mesondefine XORG_VERSION_CURRENT
+
+/* Name of X server. */
+#mesondefine __XSERVERNAME__
+
+/* URL to go to for support. */
+#mesondefine __VENDORDWEBSUPPORT__
+
+/* Built-in output drivers. */
+#mesondefine DRIVERS
+
+/* Built-in input drivers. */
+#mesondefine IDRIVERS
+
+/* Path to configuration file. */
+#mesondefine XF86CONFIGFILE
+
+/* Path to configuration file. */
+#mesondefine XCONFIGFILE
+
+/* Name of configuration directory. */
+#mesondefine XCONFIGDIR
+
+/* Path to loadable modules. */
+#mesondefine DEFAULT_MODULE_PATH
+
+/* Path to installed libraries. */
+#mesondefine DEFAULT_LIBRARY_PATH
+
+/* Default log location */
+#mesondefine DEFAULT_LOGDIR
+
+/* Default logfile prefix */
+#mesondefine DEFAULT_LOGPREFIX
+
+/* Default XDG_DATA dir under HOME */
+#mesondefine DEFAULT_XDG_DATA_HOME
+
+/* Default log dir under XDG_DATA_HOME */
+#mesondefine DEFAULT_XDG_DATA_HOME_LOGDIR
+
+/* Building DRI-capable DDX. */
+#mesondefine XF86DRI
+
+/* Build DRI2 extension */
+#mesondefine DRI2
+
+/* Define to 1 if you have the <stropts.h> header file. */
+#mesondefine HAVE_STROPTS_H
+
+/* Define to 1 if you have the <sys/kd.h> header file. */
+#mesondefine HAVE_SYS_KD_H
+
+/* Define to 1 if you have the <sys/vt.h> header file. */
+#mesondefine HAVE_SYS_VT_H
+
+/* Define to 1 if you have the `walkcontext' function (used on Solaris for
+   xorg_backtrace in hw/xfree86/common/xf86Events.c */
+#mesondefine HAVE_WALKCONTEXT
+
+/* Building vgahw module */
+#mesondefine WITH_VGAHW
+
+/* NetBSD PIO alpha IO */
+#mesondefine USE_ALPHA_PIO
+
+/* BSD AMD64 iopl */
+#mesondefine USE_AMD64_IOPL
+
+/* BSD /dev/io */
+#mesondefine USE_DEV_IO
+
+/* BSD i386 iopl */
+#mesondefine USE_I386_IOPL
+
+/* System is BSD-like */
+#mesondefine CSRG_BASED
+
+/* System has PC console */
+#mesondefine PCCONS_SUPPORT
+
+/* System has PCVT console */
+#mesondefine PCVT_SUPPORT
+
+/* System has syscons console */
+#mesondefine SYSCONS_SUPPORT
+
+/* System has wscons console */
+#mesondefine WSCONS_SUPPORT
+
+/* System has /dev/xf86 aperture driver */
+#mesondefine HAS_APERTURE_DRV
+
+/* Has backtrace support */
+#mesondefine HAVE_BACKTRACE
+
+/* Name of the period field in struct kbd_repeat */
+#mesondefine LNX_KBD_PERIOD_NAME
+
+/* Have execinfo.h */
+#mesondefine HAVE_EXECINFO_H
+
+/* Define to 1 if you have the <sys/mkdev.h> header file. */
+#mesondefine HAVE_SYS_MKDEV_H
+
+/* Path to text files containing PCI IDs */
+#mesondefine PCI_TXT_IDS_PATH
+
+/* Build with libdrm support */
+#mesondefine WITH_LIBDRM
+
+/* Use libpciaccess */
+#mesondefine XSERVER_LIBPCIACCESS
+
+/* Have setugid */
+#mesondefine HAVE_ISSETUGID
+
+/* Have getresuid */
+#mesondefine HAVE_GETRESUID
+
+/* Have X server platform bus support */
+#mesondefine XSERVER_PLATFORM_BUS
+
+/* Define to 1 if you have the `seteuid' function. */
+#mesondefine HAVE_SETEUID
+
+/* Support APM/ACPI power management in the server */
+#mesondefine XF86PM
+
+/* Fallback input driver if the assigned driver fails */
+#mesondefine FALLBACK_INPUT_DRIVER
+
+#endif /* _XORG_CONFIG_H_ */
diff --git a/meson.build b/meson.build
new file mode 100644
index 000000000000..3bd0a3afd9b1
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,360 @@
+project('xserver', 'c',
+        default_options: ['buildtype=debugoptimized'],
+        meson_version: '>= 0.40.0',
+)
+add_project_arguments('-DHAVE_DIX_CONFIG_H', language: 'c')
+cc = meson.get_compiler('c')
+
+add_global_arguments('-fno-strict-aliasing', language : 'c')
+add_global_arguments('-fvisibility=hidden', language : 'c')
+
+add_global_link_arguments('-fvisibility=hidden', language : 'c')
+
+# Quiet some EXA warnings.
+add_global_arguments('-Wno-discarded-qualifiers', language : 'c')
+
+xproto_dep = dependency('xproto', version: '>= 7.0.31')
+randrproto_dep = dependency('randrproto', version: '>= 1.5.0')
+renderproto_dep = dependency('renderproto', version: '>= 0.11')
+xextproto_dep = dependency('xextproto', version: '>= 7.2.99.901')
+inputproto_dep = dependency('inputproto', version: '>= 2.3')
+kbproto_dep = dependency('kbproto', version: '>= 1.0.3')
+fontsproto_dep = dependency('fontsproto', version: '>= 2.1.3')
+fixesproto_dep = dependency('fixesproto', version: '>= 5.0')
+damageproto_dep = dependency('damageproto', version: '>= 1.1')
+xcmiscproto_dep = dependency('xcmiscproto', version: '>= 1.2.0')
+bigreqsproto_dep = dependency('bigreqsproto', version: '>= 1.1.0')
+xtrans_dep = dependency('xtrans', version: '>= 1.3.5')
+
+videoproto_dep = dependency('videoproto')
+compositeproto_dep = dependency('compositeproto', version: '>= 0.4')
+recordproto_dep = dependency('recordproto', version: '>= 1.13.99.1')
+scrnsaverproto_dep = dependency('scrnsaverproto', version: '>= 1.1')
+resourceproto_dep = dependency('resourceproto', version: '>= 1.2.0')
+xf86driproto_dep = dependency('xf86driproto', version: '>= 2.1.0')
+dri2proto_dep = dependency('dri2proto', version: '>= 2.8')
+dri3proto_dep = dependency('dri3proto', version: '>= 1.0')
+xineramaproto_dep = dependency('xineramaproto')
+xf86bigfontproto_dep = dependency('xf86bigfontproto', version: '>= 1.2.0')
+xf86dgaproto_dep = dependency('xf86dgaproto', version: '>= 2.0.99.1')
+xf86vidmodeproto_dep = dependency('xf86vidmodeproto', version: '>= 2.2.99.1')
+windowswmproto_dep = dependency('windowswmproto', required: false)
+applewmproto_dep = dependency('applewmproto', version: '>= 1.4', required: false)
+xshmfence_dep = dependency('xshmfence', version: '>= 1.1')
+
+pixman_dep = dependency('pixman-1')
+libbsd_dep = dependency('libbsd', required: false)
+xkbfile_dep = dependency('xkbfile')
+xfont2_dep = dependency('xfont2', version: '>= 2.0')
+nettle_dep = dependency('nettle', required: false)
+
+dbus_required = get_option('systemd_logind') == 'yes'
+dbus_dep = dependency('dbus-1', version: '>= 1.0', required: dbus_required)
+
+# Resolve default values of some options
+xkb_dir = get_option('xkb_dir')
+if xkb_dir == ''
+    xkb_dir = join_paths(get_option('prefix'), 'share/X11/xkb')
+endif
+
+xkb_output_dir = get_option('xkb_output_dir')
+if xkb_output_dir == ''
+    xkb_output_dir = join_paths(get_option('prefix'), 'share/X11/xkb/compiled')
+endif
+
+hal_option = get_option('hal')
+glamor_option = get_option('glamor')
+
+build_udev = get_option('udev')
+if host_machine.system() == 'windows'
+    build_udev = false
+    hal_option = 'no'
+endif
+
+build_dbus = dbus_dep.found()
+
+if get_option('systemd_logind') == 'auto'
+    build_systemd_logind = build_udev and build_dbus
+else
+    build_systemd_logind = get_option('systemd_logind') == 'yes'
+endif
+
+build_xorg = false
+if (host_machine.system() != 'darwin' and
+    host_machine.system() != 'windows')
+    if get_option('xorg') == 'auto'
+        build_xorg = (host_machine.system() != 'darwin' and
+                      host_machine.system() != 'windows')
+    else
+        build_xorg = get_option('xorg') == 'yes'
+    endif
+endif
+xorgsdkdir = join_paths(get_option('prefix'), get_option('includedir'), 'xorg')
+
+build_xwayland = false
+if (host_machine.system() != 'darwin' and
+    host_machine.system() != 'windows')
+    if get_option('xwayland') != 'no'
+        xwayland_required = get_option('xwayland') == 'yes'
+
+        xwayland_dep = [
+            dependency('wayland-client', version: '>= 1.3.0', required: xwayland_required),
+            dependency('wayland-protocols', version: '>= 1.1.0', required: xwayland_required),
+            dependency('libdrm', version: '>= 2.3.1', required: xwayland_required),
+            dependency('epoxy', required: xwayland_required),
+        ]
+
+        build_xwayland = true
+        # check for all the deps being found, to handle 'auto' mode.
+        foreach d: xwayland_dep
+            if not d.found()
+                build_xwayland = false
+            endif
+        endforeach
+    endif
+endif
+
+build_xnest = false
+if (host_machine.system() != 'darwin' and
+    host_machine.system() != 'windows')
+    if get_option('xnest') != 'no'
+        xnest_required = get_option('xnest') == 'yes'
+
+        xnest_dep = [
+            dependency('xext', version: '>= 1.0.99.4', required: xnest_required),
+            dependency('x11', required: xnest_required),
+            dependency('xau', required: xnest_required),
+        ]
+
+        build_xnest = true
+        # check for all the deps being found, to handle 'auto' mode.
+        foreach d: xnest_dep
+            if not d.found()
+                build_xnest = false
+            endif
+        endforeach
+    endif
+endif
+
+# XXX: Finish these.
+build_xquartz = false
+build_xwin = false
+
+if get_option('ipv6') == 'auto'
+    build_ipv6 = cc.has_function('getaddrinfo')
+else
+    build_ipv6 = get_option('ipv6') == 'yes'
+endif
+
+int10 = get_option('int10')
+if int10 == 'auto'
+    int10 = 'x86emu'
+    if host_machine.cpu() == 'powerpc' and host_machine.system() == 'freebsd'
+        int10 = 'stub'
+    endif
+    if host_machine.cpu() == 'arm'
+        int10 = 'stub'
+    endif
+endif
+
+hal_dep = ''
+if hal_option == 'auto'
+    if not build_udev
+        hal_dep = dependency('hal', required: false)
+        build_hal = hal_dep.found()
+    else
+        build_hal = false
+    endif
+else
+    build_hal = hal_option == 'yes'
+    if build_hal
+        hal_dep = dependency('hal')
+    endif
+endif
+
+if build_udev and build_hal
+    error('Hotplugging through both libudev and hal not allowed')
+endif
+
+udev_dep = []
+if build_udev
+    udev_dep = dependency('libudev', version: '>= 143')
+endif
+
+log_dir = get_option('log_dir')
+if log_dir == ''
+    log_dir = join_paths(get_option('prefix'), get_option('localstatedir'), 'log')
+endif
+
+module_dir = get_option('module_dir')
+if module_dir == ''
+    module_dir = join_paths(get_option('libdir'), 'xorg/modules')
+endif
+
+bulid_wayland = false
+
+if glamor_option == 'auto'
+    build_glamor = build_xorg or build_wayland
+else
+    build_glamor = get_option('glamor') == 'yes'
+endif
+
+gbm_dep = []
+if build_glamor
+    gbm_dep = dependency('gbm', version: '>= 10.2', required: false)
+    if gbm_dep.found()
+        gbm_linear_dep = dependency('gbm', version: '>= 10.6', required: false)
+    endif
+endif
+
+# XXX: Add more sha1 options, because Linux is about choice
+sha1_dep = nettle_dep
+
+xdmcp_dep = ''
+if get_option('xdmcp')
+    xdmcp_dep = dependency('xdmcp')
+endif
+
+build_glx = get_option('glx')
+
+# XXX: Allow configuration of these.
+build_apm = false
+build_acpi = false
+build_dri1 = true
+build_dri2 = true
+build_dri3 = true
+build_dpms = true
+build_mitshm = true
+build_res = true
+build_screensaver = true
+build_xace = true
+build_xsecurity = true
+build_xf86bigfont = true
+build_xinerama = true
+build_xselinux = false
+build_xv = true
+build_dga = false
+
+m_dep = cc.find_library('m', required : false)
+dl_dep = cc.find_library('dl', required : false)
+
+common_dep = [
+    xproto_dep,
+    randrproto_dep,
+    renderproto_dep,
+    xextproto_dep,
+    inputproto_dep,
+    kbproto_dep,
+    fontsproto_dep,
+    fixesproto_dep,
+    damageproto_dep,
+    xcmiscproto_dep,
+    bigreqsproto_dep,
+    xtrans_dep,
+
+    videoproto_dep,
+    compositeproto_dep,
+    recordproto_dep,
+    scrnsaverproto_dep,
+    resourceproto_dep,
+    xf86driproto_dep,
+    dri2proto_dep,
+    dri3proto_dep,
+    xineramaproto_dep,
+    xf86bigfontproto_dep,
+    xf86dgaproto_dep,
+    xf86vidmodeproto_dep,
+    windowswmproto_dep,
+    applewmproto_dep,
+
+    pixman_dep,
+    libbsd_dep,
+    xkbfile_dep,
+    xfont2_dep,
+    xdmcp_dep,
+]
+
+inc = include_directories(
+    'Xext',
+    'Xi',
+    'composite',
+    'damageext',
+    'exa',
+    'fb',
+    'glamor',
+    'mi',
+    'miext/damage',
+    'miext/shadow',
+    'miext/sync',
+    'dbe',
+    'dri3',
+    'include',
+    'present',
+    'randr',
+    'render',
+    'xfixes',
+)
+
+serverconfigdir = join_paths(get_option('libdir'), '/xorg')
+
+# Include must come first, as it sets up dix-config.h
+subdir('include')
+
+# X server core
+subdir('config')
+subdir('dix')
+subdir('dri3')
+subdir('glx')
+subdir('fb')
+subdir('mi')
+subdir('os')
+# X extensions
+subdir('composite')
+subdir('damageext')
+subdir('dbe')
+subdir('miext/damage')
+subdir('miext/shadow')
+subdir('miext/sync')
+subdir('present')
+if build_xwin or build_xquartz
+    subdir('pseudoramiX')
+endif
+subdir('randr')
+subdir('record')
+subdir('render')
+subdir('xfixes')
+subdir('xkb')
+subdir('Xext')
+subdir('Xi')
+# other
+if build_glamor
+    subdir('glamor')
+endif
+if build_xorg or get_option('xephyr')
+    subdir('exa')
+endif
+
+# Common static libraries of all X servers
+libxserver = [
+    libxserver_mi,
+    libxserver_dix,
+
+    libxserver_composite,
+    libxserver_damageext,
+    libxserver_dbe,
+    libxserver_dri3,
+    libxserver_randr,
+    libxserver_miext_damage,
+    libxserver_render,
+    libxserver_present,
+    libxserver_xext,
+    libxserver_miext_sync,
+    libxserver_xfixes,
+    libxserver_xi,
+    libxserver_xkb,
+    libxserver_record,
+
+    libxserver_os,
+]
+
+subdir('hw')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 000000000000..b89fdaa2cc9b
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,46 @@
+option('xorg', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto',
+       description: 'Enable Xorg X Server')
+option('xephyr', type: 'boolean', value: false,
+       description: 'Enable Xephyr nexted X server')
+option('xwayland', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto',
+       description: 'Enable XWayland X server')
+option('glamor', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto',
+       description: 'Enable glamor (default yes for Xorg/Xwayland builds)')
+option('xnest', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto',
+       description: 'Enable Xnest nested X server')
+option('dmx', type: 'boolean', value: false,
+       description: 'Enable DMX nested X server')
+
+option('log_dir', type: 'string')
+option('module_dir', type: 'string',
+       description: 'X.Org modules directory')
+
+option('glx', type: 'boolean', value: true)
+option('xdmcp', type: 'boolean', value: true)
+option('xdm-auth-1', type: 'boolean', value: true)
+option('ipv6', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto')
+
+option('xkb_dir', type: 'string')
+option('xkb_output_dir', type: 'string')
+option('xkb_default_rules', type: 'string', value: 'evdev')
+option('xkb_default_model', type: 'string', value: 'pc105')
+option('xkb_default_layout', type: 'string', value: 'us')
+option('xkb_default_variant', type: 'string')
+option('xkb_default_options', type: 'string')
+
+option('vendor_name', type: 'string', value: 'The X.Org Foundation')
+option('vendor_name_short', type: 'string', value: 'X.Org')
+option('vendor_web', type: 'string', value: 'http://wiki.x.org')
+option('os_vendor', type: 'string', value: '')
+
+option('int10', type: 'combo', choices: ['stub', 'x86emu', 'vm86', 'auto', 'disabled'],
+       value: 'auto',
+       description: 'Xorg int10 backend (default: usually x86emu)')
+
+option('pciaccess', type: 'boolean', value: 'true',
+       description: 'Xorg pciaccess support')
+option('udev', type: 'boolean', value: 'true')
+option('hal', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto',
+       description: 'Enable HAL integration')
+option('systemd_logind', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto',
+       description: 'Enable systemd-logind integration')
diff --git a/mi/meson.build b/mi/meson.build
new file mode 100644
index 000000000000..32fcec1d05fe
--- /dev/null
+++ b/mi/meson.build
@@ -0,0 +1,39 @@
+srcs_mi = [
+    'miarc.c',
+    'mibitblt.c',
+    'micmap.c',
+    'micopy.c',
+    'midash.c',
+    'midispcur.c',
+    'mieq.c',
+    'miexpose.c',
+    'mifillarc.c',
+    'mifillrct.c',
+    'migc.c',
+    'miglblt.c',
+    'mioverlay.c',
+    'mipointer.c',
+    'mipoly.c',
+    'mipolypnt.c',
+    'mipolyrect.c',
+    'mipolyseg.c',
+    'mipolytext.c',
+    'mipushpxl.c',
+    'miscrinit.c',
+    'misprite.c',
+    'mivaltree.c',
+    'miwideline.c',
+    'miwindow.c',
+    'mizerarc.c',
+    'mizerclip.c',
+    'mizerline.c',
+]
+
+libxserver_mi = static_library('libxserver_mi',
+    srcs_mi,
+    include_directories: inc,
+    dependencies: [
+        common_dep,
+        m_dep,
+    ],
+)
diff --git a/miext/damage/meson.build b/miext/damage/meson.build
new file mode 100644
index 000000000000..2c51483964ab
--- /dev/null
+++ b/miext/damage/meson.build
@@ -0,0 +1,9 @@
+srcs_miext_damage = [
+	'damage.c',
+]
+
+libxserver_miext_damage = static_library('libxserver_miext_damage',
+	srcs_miext_damage,
+	include_directories: inc,
+	dependencies: common_dep,
+)
diff --git a/miext/shadow/meson.build b/miext/shadow/meson.build
new file mode 100644
index 000000000000..1b4ae8a47dd7
--- /dev/null
+++ b/miext/shadow/meson.build
@@ -0,0 +1,32 @@
+srcs_miext_shadow = [
+    'shadow.c',
+    'sh3224.c',
+    'shafb4.c',
+    'shafb8.c',
+    'shiplan2p4.c',
+    'shiplan2p8.c',
+    'shpacked.c',
+    'shplanar8.c',
+    'shplanar.c',
+    'shrot16pack_180.c',
+    'shrot16pack_270.c',
+    'shrot16pack_270YX.c',
+    'shrot16pack_90.c',
+    'shrot16pack_90YX.c',
+    'shrot16pack.c',
+    'shrot32pack_180.c',
+    'shrot32pack_270.c',
+    'shrot32pack_90.c',
+    'shrot32pack.c',
+    'shrot8pack_180.c',
+    'shrot8pack_270.c',
+    'shrot8pack_90.c',
+    'shrot8pack.c',
+    'shrotate.c',
+]
+
+libxserver_miext_shadow = static_library('libxserver_miext_shadow',
+    srcs_miext_shadow,
+    include_directories: inc,
+    dependencies: common_dep,
+)
diff --git a/miext/sync/meson.build b/miext/sync/meson.build
new file mode 100644
index 000000000000..da86fcc84935
--- /dev/null
+++ b/miext/sync/meson.build
@@ -0,0 +1,17 @@
+srcs_miext_sync = [
+    'misync.c',
+    'misyncfd.c',
+]
+
+if build_dri3
+    srcs_miext_sync += 'misyncshm.c'
+endif
+
+libxserver_miext_sync = static_library('libxserver_miext_sync',
+    srcs_miext_sync,
+    include_directories: inc,
+    dependencies: [
+        common_dep,
+        xshmfence_dep,
+    ],
+)
diff --git a/os/meson.build b/os/meson.build
new file mode 100644
index 000000000000..e26778a43013
--- /dev/null
+++ b/os/meson.build
@@ -0,0 +1,65 @@
+srcs_os = [
+    'WaitFor.c',
+    'access.c',
+    'auth.c',
+    'backtrace.c',
+    'client.c',
+    'connection.c',
+    'inputthread.c',
+    'io.c',
+    'mitauth.c',
+    'oscolor.c',
+    'osinit.c',
+    'ospoll.c',
+    'utils.c',
+    'xdmauth.c',
+    'xsha1.c',
+    'xstrans.c',
+    'xprintf.c',
+    'log.c',
+]
+
+# Wrapper code for missing C library functions
+if not cc.has_function('reallocarray')
+    srcs_os += 'reallocarray.c'
+endif
+if not cc.has_function('strcasecmp')
+    srcs_os += 'strcasecmp.c'
+endif
+if not cc.has_function('strcasestr')
+    srcs_os += 'strcasestr.c'
+endif
+if not cc.has_function('strlcat')
+    srcs_os += 'strlcat.c'
+endif
+if not cc.has_function('strlcpy')
+    srcs_os += 'strlcpy.c'
+endif
+if not cc.has_function('strndup')
+    srcs_os += 'strndup.c'
+endif
+if not cc.has_function('timingsafe_memcmp')
+    srcs_os += 'timingsafe_memcmp.c'
+endif
+
+if cc.has_function('poll')
+    srcs_os += 'xserver_poll.c'
+endif
+if cc.has_function('sigaction')
+    srcs_os += 'busfault.c'
+endif
+
+if get_option('xdmcp')
+    srcs_os += 'xdmcp.c'
+endif
+
+libxserver_os = static_library('libxserver_os',
+    srcs_os,
+    include_directories: inc,
+    dependencies: [
+        common_dep,
+        dl_dep,
+        sha1_dep,
+        dependency('xau')
+    ],
+)
diff --git a/present/meson.build b/present/meson.build
new file mode 100644
index 000000000000..a4296ca7a838
--- /dev/null
+++ b/present/meson.build
@@ -0,0 +1,19 @@
+srcs_present = [
+    'present.c',
+    'present_event.c',
+    'present_fake.c',
+    'present_fence.c',
+    'present_notify.c',
+    'present_request.c',
+    'present_screen.c',
+]
+
+libxserver_present = static_library('libxserver_present',
+    srcs_present,
+    include_directories: inc,
+    dependencies: [
+        common_dep,
+        dependency('presentproto', version: '>= 1.0')
+    ],
+    c_args: '-DHAVE_XORG_CONFIG_H'
+)
diff --git a/pseudoramiX/meson.build b/pseudoramiX/meson.build
new file mode 100644
index 000000000000..c3d93252978f
--- /dev/null
+++ b/pseudoramiX/meson.build
@@ -0,0 +1,5 @@
+libxserver_pseudoramix = static_library('libxserver_pseudoramiX',
+    'pseudoramiX.c',
+    include_directories: inc,
+    dependencies: common_dep,
+)
diff --git a/randr/meson.build b/randr/meson.build
new file mode 100644
index 000000000000..69fab24e231a
--- /dev/null
+++ b/randr/meson.build
@@ -0,0 +1,26 @@
+srcs_randr = [
+    'randr.c',
+    'rrcrtc.c',
+    'rrdispatch.c',
+    'rrinfo.c',
+    'rrmode.c',
+    'rrmonitor.c',
+    'rroutput.c',
+    'rrpointer.c',
+    'rrproperty.c',
+    'rrprovider.c',
+    'rrproviderproperty.c',
+    'rrscreen.c',
+    'rrsdispatch.c',
+    'rrtransform.c',
+]
+
+if build_xinerama
+    srcs_randr += 'rrxinerama.c'
+endif
+
+libxserver_randr = static_library('libxserver_randr',
+    srcs_randr,
+    include_directories: inc,
+    dependencies: common_dep,
+)
diff --git a/record/meson.build b/record/meson.build
new file mode 100644
index 000000000000..1c0b5d2caf32
--- /dev/null
+++ b/record/meson.build
@@ -0,0 +1,10 @@
+srcs_record = [
+	'record.c',
+	'set.c',
+]
+
+libxserver_record = static_library('libxserver_record',
+	srcs_record,
+	include_directories: inc,
+	dependencies: common_dep,
+)
diff --git a/render/meson.build b/render/meson.build
new file mode 100644
index 000000000000..d976f36f3b34
--- /dev/null
+++ b/render/meson.build
@@ -0,0 +1,19 @@
+srcs_render = [
+    'animcur.c',
+    'filter.c',
+    'glyph.c',
+    'matrix.c',
+    'miindex.c',
+    'mipict.c',
+    'mirect.c',
+    'mitrap.c',
+    'mitri.c',
+    'picture.c',
+    'render.c',
+]
+
+libxserver_render = static_library('libxserver_render',
+    srcs_render,
+    include_directories: inc,
+    dependencies: common_dep,
+)
diff --git a/xfixes/meson.build b/xfixes/meson.build
new file mode 100644
index 000000000000..4ca819c8d0f1
--- /dev/null
+++ b/xfixes/meson.build
@@ -0,0 +1,13 @@
+srcs_xfixes = [
+    'cursor.c',
+    'region.c',
+    'saveset.c',
+    'select.c',
+    'xfixes.c',
+]
+
+libxserver_xfixes = static_library('libxserver_xfixes',
+    srcs_xfixes,
+    include_directories: inc,
+    dependencies: common_dep,
+)
diff --git a/xkb/meson.build b/xkb/meson.build
new file mode 100644
index 000000000000..c21868c2bc82
--- /dev/null
+++ b/xkb/meson.build
@@ -0,0 +1,42 @@
+srcs_xkb = [
+    'ddxBeep.c',
+    'ddxCtrls.c',
+    'ddxLEDs.c',
+    'ddxLoad.c',
+    'maprules.c',
+    'xkmread.c',
+    'xkbtext.c',
+    'xkbfmisc.c',
+    'xkbout.c',
+    'xkb.c',
+    'xkbUtils.c',
+    'xkbEvents.c',
+    'xkbAccessX.c',
+    'xkbSwap.c',
+    'xkbLEDs.c',
+    'xkbInit.c',
+    'xkbActions.c',
+    'xkbPrKeyEv.c',
+    'XKBMisc.c',
+    'XKBAlloc.c',
+    'XKBGAlloc.c',
+    'XKBMAlloc.c',
+]
+
+libxserver_xkb = static_library('libxserver_xkb',
+    srcs_xkb,
+    include_directories: inc,
+    dependencies: common_dep,
+)
+
+srcs_xkb_stubs = [
+    'ddxKillSrv.c',
+    'ddxPrivate.c',
+    'ddxVT.c',
+]
+
+libxserver_xkb_stubs = static_library('libxserver_xkb_stubs',
+    srcs_xkb_stubs,
+    include_directories: inc,
+    dependencies: common_dep,
+)
-- 
2.11.0




More information about the xorg-devel mailing list