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-10'
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-unused-parameter',
30 add_project_arguments([
31 '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
38 optional_libc_funcs = [ 'memfd_create', 'strchrnul' ]
39 foreach func: optional_libc_funcs
40 if cc.has_function(func)
41 add_project_arguments('-DHAVE_@0@=1'.format(func.to_upper()), language: 'c')
45 dep_libsystemd = dependency('libsystemd', required: false)
46 dep_libsmack = dependency('libsmack', required: false)
47 dep_scanner = dependency('wayland-scanner', native: true)
48 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
49 dep_wp = dependency('wayland-protocols', version: '>= 1.18')
50 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
53 'gstreamer-1.0', 'gstreamer-allocators-1.0',
54 'gstreamer-app-1.0', 'gstreamer-video-1.0',
55 'gobject-2.0', 'glib-2.0'
59 foreach depname : depnames
60 dep = dependency(depname, required: false)
62 message('Remoting requires @0@ which was not found. '.format(depname))
68 # the transmitter plug-in requires waltham but we don't have a cflags or libs
69 # for it so we add waltham depends here. Further more, the output is being
70 # handled by remoting plug-in
76 foreach depname : depnames_waltham
77 dep = dependency(depname, required: false)
81 message('Waltham requires @0@ which was not found. '.format(depname))
85 deps_waltham += deps_remoting
87 agl_shell_xml = files('protocol/agl-shell.xml')
88 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
89 agl_screenshooter = files('protocol/agl-screenshooter.xml')
90 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
93 { 'name': 'agl-shell', 'source': 'internal' },
94 { 'name': 'agl-shell-desktop', 'source': 'internal' },
95 { 'name': 'agl-screenshooter', 'source': 'internal' },
96 { 'name': 'xdg-shell', 'source': 'wp-stable' },
97 { 'name': 'xdg-output', 'source': 'unstable', 'version': 'v1' },
100 foreach proto: protocols
101 proto_name = proto['name']
102 if proto['source'] == 'internal'
103 base_file = proto_name
104 xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
105 elif proto['source'] == 'wp-stable'
106 base_file = proto_name
107 xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
109 base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
110 xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
113 foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
114 if output_type == 'client-header'
115 output_file = '@0@-client-protocol.h'.format(base_file)
116 elif output_type == 'server-header'
117 output_file = '@0@-server-protocol.h'.format(base_file)
119 output_file = '@0@-protocol.c'.format(base_file)
120 if dep_scanner.version().version_compare('< 1.14.91')
125 var_name = output_file.underscorify()
126 target = custom_target(
127 '@0@ @1@'.format(base_file, output_type),
128 command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
133 set_variable(var_name, target)
137 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
138 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
139 # path as to allow building and installing the compositor locally
140 prefix_path = get_option('prefix')
141 message('prefix_path ' + prefix_path)
142 if not prefix_path.contains('/usr')
143 additional_include_dir = include_directories(prefix_path + '/' + 'include')
144 local_dep = declare_dependency(include_directories: additional_include_dir)
149 dir_data = join_paths(prefix_path, get_option('datadir'))
150 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
151 dir_data_pc = join_paths(dir_data, 'pkgconfig')
152 libweston_dep = dependency(libweston_version)
155 dependency('wayland-server'),
157 dependency('libweston-desktop-10'),
162 srcs_agl_compositor = [
168 'src/screenshooter.c',
170 'shared/option-parser.c',
171 'shared/os-compatibility.c',
172 agl_shell_server_protocol_h,
173 agl_shell_desktop_server_protocol_h,
174 agl_screenshooter_server_protocol_h,
175 agl_shell_protocol_c,
176 agl_shell_desktop_protocol_c,
177 agl_screenshooter_protocol_c,
178 xdg_shell_protocol_c,
181 policy_to_install = get_option('policy-default')
182 if policy_to_install == 'auto' or policy_to_install == 'allow-all'
183 srcs_agl_compositor += 'src/policy-default.c'
184 message('Installing allow all policy')
185 elif policy_to_install == 'deny-all'
186 srcs_agl_compositor += 'src/policy-deny.c'
187 message('Installing deny all policy')
188 elif policy_to_install == 'rba'
189 srcs_agl_compositor += ['src/policy-rba.c', 'src/rba_adapter.cpp']
190 deps_libweston += dependency('librba')
191 message('Installing rba policy')
194 # From meson documentation:
195 # In order to look for headers in a specific directory you can use args :
196 # '-I/extra/include/dir, but this should only be used in exceptional cases for
197 # includes that can't be detected via pkg-config and passed via dependencies.
198 if libweston_dep.found()
199 if not meson.is_cross_build()
200 if not prefix_path.contains('/usr')
201 dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
203 dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
206 message('Building with cross environment')
207 dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
211 if cc.has_header(dir_path_x11_backend)
212 config_h.set('HAVE_BACKEND_X11', 1)
216 if dep_libsystemd.found()
217 config_h.set('HAVE_SYSTEMD', 1)
219 srcs_agl_compositor += 'src/systemd-notify.c'
220 deps_libweston += dep_libsystemd
222 message('Found systemd, enabling notify support')
225 if deps_remoting.length() == depnames.length()
226 config_h.set('HAVE_REMOTING', 1)
227 message('Found remoting depends, enabling remoting')
230 if deps_waltham.length() == depnames_waltham.length() + depnames.length()
231 config_h.set('HAVE_WALTHAM', 1)
232 message('Found waltham depends, enabling waltham')
235 if dep_libsmack.found()
236 config_h.set('HAVE_SMACK', 1)
237 deps_libweston += dep_libsmack
241 libexec_compositor = shared_library(
243 sources: srcs_agl_compositor,
244 dependencies: deps_libweston,
250 dep_libexec_compositor = declare_dependency(
251 link_with: libexec_compositor,
252 include_directories: [ include_directories('.') ],
253 dependencies: deps_libweston,
256 configure_file(output: 'config.h', configuration: config_h)
258 exe_agl_compositor = executable(
261 dependencies: dep_libexec_compositor,
266 filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
267 name: 'agl-compositor private protocols',
268 version: agl_compositor_version,
269 description: 'agl-compositor protocol files',
271 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
272 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
274 install_dir: dir_data_pc
278 [ agl_shell_xml, agl_shell_desktop_xml ],
279 install_dir: join_paths(dir_data, dir_data_agl_compositor)
282 common_inc = [ include_directories('src'), include_directories('.') ]