1 project('agl-compositor',
8 meson_version: '>= 0.47',
12 config_h = configuration_data()
13 agl_compositor_version = '0.0.19'
14 libweston_version = 'libweston-9'
15 pkgconfig = import('pkgconfig')
17 cc = meson.get_compiler('c')
18 cxx = meson.get_compiler('cpp')
20 add_project_arguments(
21 cc.get_supported_arguments([
22 '-Wno-missing-field-initializers',
23 '-Wno-unused-parameter',
31 add_project_arguments([
32 '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
39 optional_libc_funcs = [ 'memfd_create', 'strchrnul' ]
40 foreach func: optional_libc_funcs
41 if cc.has_function(func)
42 add_project_arguments('-DHAVE_@0@=1'.format(func.to_upper()), language: 'c')
46 dep_libsystemd = dependency('libsystemd', required: false)
47 dep_libsmack = dependency('libsmack', required: false)
48 dep_scanner = dependency('wayland-scanner', native: true)
49 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
50 dep_wp = dependency('wayland-protocols', version: '>= 1.18')
51 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
54 'gstreamer-1.0', 'gstreamer-allocators-1.0',
55 'gstreamer-app-1.0', 'gstreamer-video-1.0',
56 'gobject-2.0', 'glib-2.0'
60 foreach depname : depnames
61 dep = dependency(depname, required: false)
63 message('Remoting requires @0@ which was not found. '.format(depname))
69 # the transmitter plug-in requires waltham but we don't have a cflags or libs
70 # for it so we add waltham depends here. Further more, the output is being
71 # handled by remoting plug-in
77 foreach depname : depnames_waltham
78 dep = dependency(depname, required: false)
82 message('Waltham requires @0@ which was not found. '.format(depname))
86 deps_waltham += deps_remoting
88 agl_shell_xml = files('protocol/agl-shell.xml')
89 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
90 agl_screenshooter = files('protocol/agl-screenshooter.xml')
91 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
94 { 'name': 'agl-shell', 'source': 'internal' },
95 { 'name': 'weston-test', 'source': 'internal' },
96 { 'name': 'agl-shell-desktop', 'source': 'internal' },
97 { 'name': 'agl-screenshooter', 'source': 'internal' },
98 { 'name': 'xdg-shell', 'source': 'wp-stable' },
99 { 'name': 'viewporter', 'source': 'wp-stable' },
100 { 'name': 'xdg-output', 'source': 'unstable', 'version': 'v1' },
103 foreach proto: protocols
104 proto_name = proto['name']
105 if proto['source'] == 'internal'
106 base_file = proto_name
107 xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
108 elif proto['source'] == 'wp-stable'
109 base_file = proto_name
110 xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
112 base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
113 xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
116 foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
117 if output_type == 'client-header'
118 output_file = '@0@-client-protocol.h'.format(base_file)
119 elif output_type == 'server-header'
120 output_file = '@0@-server-protocol.h'.format(base_file)
122 output_file = '@0@-protocol.c'.format(base_file)
123 if dep_scanner.version().version_compare('< 1.14.91')
128 var_name = output_file.underscorify()
129 target = custom_target(
130 '@0@ @1@'.format(base_file, output_type),
131 command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
136 set_variable(var_name, target)
140 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
141 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
142 # path as to allow building and installing the compositor locally
143 prefix_path = get_option('prefix')
144 message('prefix_path ' + prefix_path)
145 if not prefix_path.contains('/usr')
146 additional_include_dir = include_directories(prefix_path + '/' + 'include')
147 local_dep = declare_dependency(include_directories: additional_include_dir)
152 dir_data = join_paths(prefix_path, get_option('datadir'))
153 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
154 dir_data_pc = join_paths(dir_data, 'pkgconfig')
155 libweston_dep = dependency(libweston_version)
158 dependency('wayland-server'),
160 dependency('libweston-desktop-9'),
165 srcs_agl_compositor = [
171 'src/screenshooter.c',
173 'shared/option-parser.c',
174 'shared/os-compatibility.c',
175 agl_shell_server_protocol_h,
176 agl_shell_desktop_server_protocol_h,
177 agl_screenshooter_server_protocol_h,
178 agl_shell_protocol_c,
179 agl_shell_desktop_protocol_c,
180 agl_screenshooter_protocol_c,
181 xdg_shell_protocol_c,
184 policy_to_install = get_option('policy-default')
185 if policy_to_install == 'auto' or policy_to_install == 'allow-all'
186 srcs_agl_compositor += 'src/policy-default.c'
187 message('Installing allow all policy')
188 elif policy_to_install == 'deny-all'
189 srcs_agl_compositor += 'src/policy-deny.c'
190 message('Installing deny all policy')
191 elif policy_to_install == 'rba'
192 srcs_agl_compositor += ['src/policy-rba.c', 'src/rba_adapter.cpp']
193 deps_libweston += dependency('librba')
194 message('Installing rba policy')
197 # From meson documentation:
198 # In order to look for headers in a specific directory you can use args :
199 # '-I/extra/include/dir, but this should only be used in exceptional cases for
200 # includes that can't be detected via pkg-config and passed via dependencies.
201 if libweston_dep.found()
202 if not meson.is_cross_build()
203 if not prefix_path.contains('/usr')
204 dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
206 dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
209 message('Building with cross environment')
210 dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
214 if cc.has_header(dir_path_x11_backend)
215 config_h.set('HAVE_BACKEND_X11', 1)
219 if dep_libsystemd.found()
220 config_h.set('HAVE_SYSTEMD', 1)
222 srcs_agl_compositor += 'src/systemd-notify.c'
223 deps_libweston += dep_libsystemd
225 message('Found systemd, enabling notify support')
228 if deps_remoting.length() == depnames.length()
229 config_h.set('HAVE_REMOTING', 1)
230 message('Found remoting depends, enabling remoting')
233 if deps_waltham.length() == depnames_waltham.length() + depnames.length()
234 config_h.set('HAVE_WALTHAM', 1)
235 message('Found waltham depends, enabling waltham')
238 if dep_libsmack.found()
239 config_h.set('HAVE_SMACK', 1)
240 deps_libweston += dep_libsmack
244 libexec_compositor = shared_library(
246 sources: srcs_agl_compositor,
247 dependencies: deps_libweston,
253 dep_libexec_compositor = declare_dependency(
254 link_with: libexec_compositor,
255 include_directories: [ include_directories('.') ],
256 dependencies: deps_libweston,
259 configure_file(output: 'config.h', configuration: config_h)
261 exe_agl_compositor = executable(
264 dependencies: dep_libexec_compositor,
269 filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
270 name: 'agl-compositor private protocols',
271 version: agl_compositor_version,
272 description: 'agl-compositor protocol files',
274 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
275 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
277 install_dir: dir_data_pc
281 [ agl_shell_xml, agl_shell_desktop_xml ],
282 install_dir: join_paths(dir_data, dir_data_agl_compositor)
285 common_inc = [ include_directories('src'), include_directories('.') ]