1srcs = [
2    'xwayland.c',
3    'xwayland-input.c',
4    'xwayland-input.h',
5    'xwayland-cursor.c',
6    'xwayland-cursor.h',
7    'xwayland-drm-lease.h',
8    'xwayland-drm-lease.c',
9    'xwayland-ext.c',
10    'xwayland-ext.h',
11    'xwayland-glamor.h',
12    'xwayland-glx.h',
13    'xwayland-pixmap.c',
14    'xwayland-pixmap.h',
15    'xwayland-present.h',
16    'xwayland-screen.c',
17    'xwayland-screen.h',
18    'xwayland-shm.c',
19    'xwayland-shm.h',
20    'xwayland-types.h',
21    'xwayland-output.c',
22    'xwayland-output.h',
23    'xwayland-cvt.c',
24    'xwayland-cvt.h',
25    'xwayland-vidmode.c',
26    'xwayland-vidmode.h',
27    'xwayland-window.c',
28    'xwayland-window.h',
29    'xwayland-window-buffers.c',
30    'xwayland-window-buffers.h',
31    '../../mi/miinitext.c',
32    '../../mi/miinitext.h',
33]
34
35scanner_dep = dependency('wayland-scanner', native: true)
36scanner = find_program(scanner_dep.get_pkgconfig_variable('wayland_scanner'))
37
38protocols_dep = dependency('wayland-protocols', version: wayland_protocols_req)
39protodir = protocols_dep.get_pkgconfig_variable('pkgdatadir')
40
41pointer_xml = join_paths(protodir, 'unstable', 'pointer-constraints', 'pointer-constraints-unstable-v1.xml')
42relative_xml = join_paths(protodir, 'unstable', 'relative-pointer', 'relative-pointer-unstable-v1.xml')
43gestures_xml = join_paths(protodir, 'unstable', 'pointer-gestures', 'pointer-gestures-unstable-v1.xml')
44tablet_xml = join_paths(protodir, 'unstable', 'tablet', 'tablet-unstable-v2.xml')
45kbgrab_xml = join_paths(protodir, 'unstable', 'xwayland-keyboard-grab', 'xwayland-keyboard-grab-unstable-v1.xml')
46xdg_output_xml = join_paths(protodir, 'unstable', 'xdg-output', 'xdg-output-unstable-v1.xml')
47dmabuf_xml = join_paths(protodir, 'unstable', 'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml')
48viewporter_xml = join_paths(protodir, 'stable', 'viewporter', 'viewporter.xml')
49xdg_shell_xml = join_paths(protodir, 'stable', 'xdg-shell', 'xdg-shell.xml')
50drm_lease_xml = join_paths(protodir, 'staging', 'drm-lease', 'drm-lease-v1.xml')
51
52client_header = generator(scanner,
53    output : '@BASENAME@-client-protocol.h',
54    arguments : ['client-header', '@INPUT@', '@OUTPUT@']
55)
56
57if scanner_dep.version().version_compare('>= 1.14.91')
58    scanner_argument = 'private-code'
59else
60    scanner_argument = 'code'
61endif
62
63code = generator(scanner,
64    output : '@BASENAME@-protocol.c',
65    arguments : [scanner_argument, '@INPUT@', '@OUTPUT@']
66)
67srcs += client_header.process(relative_xml)
68srcs += client_header.process(pointer_xml)
69srcs += client_header.process(gestures_xml)
70srcs += client_header.process(tablet_xml)
71srcs += client_header.process(kbgrab_xml)
72srcs += client_header.process(xdg_output_xml)
73srcs += client_header.process(dmabuf_xml)
74srcs += client_header.process(viewporter_xml)
75srcs += client_header.process(xdg_shell_xml)
76srcs += client_header.process(drm_lease_xml)
77srcs += code.process(relative_xml)
78srcs += code.process(pointer_xml)
79srcs += code.process(gestures_xml)
80srcs += code.process(tablet_xml)
81srcs += code.process(kbgrab_xml)
82srcs += code.process(xdg_output_xml)
83srcs += code.process(dmabuf_xml)
84srcs += code.process(viewporter_xml)
85srcs += code.process(xdg_shell_xml)
86srcs += code.process(drm_lease_xml)
87
88xwayland_glamor = []
89eglstream_srcs = []
90if build_glamor
91    srcs += 'xwayland-glamor.c'
92    if build_glx
93        srcs += 'xwayland-glx.c'
94    endif
95    if gbm_dep.found()
96        srcs += 'xwayland-glamor-gbm.c'
97    endif
98    if build_eglstream
99        eglstream_protodir = eglstream_dep.get_pkgconfig_variable('pkgdatadir')
100        eglstream_xml = join_paths(eglstream_protodir, 'wayland-eglstream.xml')
101        eglstream_controller_xml = join_paths(eglstream_protodir, 'wayland-eglstream-controller.xml')
102
103        srcs += client_header.process(eglstream_xml)
104        srcs += client_header.process(eglstream_controller_xml)
105        srcs += code.process(eglstream_xml)
106        srcs += code.process(eglstream_controller_xml)
107
108        srcs += 'xwayland-glamor-eglstream.c'
109    endif
110    srcs += 'xwayland-present.c'
111    if build_xv
112        srcs += 'xwayland-glamor-xv.c'
113    endif
114
115    srcs += client_header.process('drm.xml')
116    srcs += code.process('drm.xml')
117    xwayland_dep += gbm_dep
118    xwayland_glamor += glamor
119endif
120
121wayland_inc = [ inc, ]
122if build_glx
123    wayland_inc += glx_inc
124endif
125
126if libdrm_dep.found()
127    xwayland_dep += libdrm_dep
128endif
129
130xwayland_server = executable(
131    'Xwayland',
132    srcs,
133    include_directories: wayland_inc,
134    dependencies: [
135        common_dep,
136        xwayland_dep,
137    ],
138    link_with: [
139        libxserver_main,
140        xwayland_glamor,
141        libxserver_fb,
142        libxserver,
143        libxserver_xext_vidmode,
144        libxserver_xkb_stubs,
145        libxserver_xi_stubs,
146        libxserver_glx,
147        libglxvnd,
148    ],
149    install: true,
150    install_dir: xwayland_path
151)
152
153xwayland_data = configuration_data()
154xwayland_data.set('prefix', get_option('prefix'))
155xwayland_data.set('exec_prefix', '${prefix}')
156xwayland_data.set('PACKAGE_VERSION', meson.project_version())
157xwayland_data.set('xwayland_path', xwayland_path)
158xwayland_data.set('have_glamor', build_glamor ? 'true' : 'false')
159xwayland_data.set('have_eglstream', build_eglstream ? 'true' : 'false')
160configure_file(
161    input: 'xwayland.pc.in',
162    output: 'xwayland.pc',
163    configuration: xwayland_data,
164    install_dir: join_paths(get_option('prefix'),
165                            get_option('libdir'),
166                            'pkgconfig'),
167)
168
169xwayland_manpage = configure_file(
170    input: 'man/Xwayland.man',
171    output: 'Xwayland.1',
172    configuration: manpage_config,
173)
174install_man(xwayland_manpage)
175