1 project('agl-compositor',
8 meson_version: '>= 0.47',
12 config_h = configuration_data()
13 agl_compositor_version = '0.0.18'
14 libweston_version = 'libweston-8'
15 pkgconfig = import('pkgconfig')
17 cc = meson.get_compiler('c')
18 add_project_arguments(
19 cc.get_supported_arguments([
20 '-Wno-unused-parameter',
28 add_project_arguments([
29 '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
36 optional_libc_funcs = [ 'memfd_create', 'strchrnul' ]
37 foreach func: optional_libc_funcs
38 if cc.has_function(func)
39 add_project_arguments('-DHAVE_@0@=1'.format(func.to_upper()), language: 'c')
43 dep_libsystemd = dependency('libsystemd', required: false)
44 dep_libsmack = dependency('libsmack', required: false)
45 dep_scanner = dependency('wayland-scanner', native: true)
46 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
47 dep_wp = dependency('wayland-protocols', version: '>= 1.18')
48 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
51 'gstreamer-1.0', 'gstreamer-allocators-1.0',
52 'gstreamer-app-1.0', 'gstreamer-video-1.0',
53 'gobject-2.0', 'glib-2.0'
57 foreach depname : depnames
58 dep = dependency(depname, required: false)
60 message('Remoting requires @0@ which was not found. '.format(depname))
66 agl_shell_xml = files('protocol/agl-shell.xml')
67 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
68 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
71 { 'name': 'agl-shell', 'source': 'internal' },
72 { 'name': 'agl-shell-desktop', 'source': 'internal' },
73 { 'name': 'xdg-shell', 'source': 'wp-stable' },
76 foreach proto: protocols
77 proto_name = proto['name']
78 if proto['source'] == 'internal'
79 base_file = proto_name
80 xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
81 elif proto['source'] == 'wp-stable'
82 base_file = proto_name
83 xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
85 base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
86 xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
89 foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
90 if output_type == 'client-header'
91 output_file = '@0@-client-protocol.h'.format(base_file)
92 elif output_type == 'server-header'
93 output_file = '@0@-server-protocol.h'.format(base_file)
95 output_file = '@0@-protocol.c'.format(base_file)
96 if dep_scanner.version().version_compare('< 1.14.91')
101 var_name = output_file.underscorify()
102 target = custom_target(
103 '@0@ @1@'.format(base_file, output_type),
104 command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
109 set_variable(var_name, target)
113 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
114 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
115 # path as to allow building and installing the compositor locally
116 prefix_path = get_option('prefix')
117 message('prefix_path ' + prefix_path)
118 if not prefix_path.contains('/usr')
119 additional_include_dir = include_directories(prefix_path + '/' + 'include')
120 local_dep = declare_dependency(include_directories: additional_include_dir)
125 dir_data = join_paths(prefix_path, get_option('datadir'))
126 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
127 dir_data_pc = join_paths(dir_data, 'pkgconfig')
128 libweston_dep = dependency(libweston_version)
131 dependency('wayland-server'),
133 dependency('libweston-desktop-8'),
137 srcs_agl_compositor = [
143 'shared/option-parser.c',
144 'shared/os-compatibility.c',
145 agl_shell_server_protocol_h,
146 agl_shell_desktop_server_protocol_h,
147 agl_shell_protocol_c,
148 agl_shell_desktop_protocol_c,
149 xdg_shell_protocol_c,
152 policy_to_install = get_option('policy-default')
153 if policy_to_install == 'auto' or policy_to_install == 'allow-all'
154 srcs_agl_compositor += 'src/policy-default.c'
155 message('Installing allow all policy')
156 elif policy_to_install == 'deny-all'
157 srcs_agl_compositor += 'src/policy-deny.c'
158 message('Installing deny all policy')
162 # From meson documentation:
163 # In order to look for headers in a specific directory you can use args :
164 # '-I/extra/include/dir, but this should only be used in exceptional cases for
165 # includes that can't be detected via pkg-config and passed via dependencies.
166 if libweston_dep.found()
167 if not prefix_path.contains('/usr')
168 dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
170 dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
174 if cc.has_header(dir_path_x11_backend)
175 config_h.set('HAVE_BACKEND_X11', 1)
179 if dep_libsystemd.found()
180 config_h.set('HAVE_SYSTEMD', 1)
182 srcs_agl_compositor += 'src/systemd-notify.c'
183 deps_libweston += dep_libsystemd
185 message('Found systemd, enabling notify support')
188 if deps_remoting.length() == depnames.length()
189 config_h.set('HAVE_REMOTING', 1)
190 message('Found remoting depends, enabling remoting')
193 if dep_libsmack.found()
194 config_h.set('HAVE_SMACK', 1)
195 deps_libweston += dep_libsmack
198 configure_file(output: 'config.h', configuration: config_h)
200 exe_agl_compositor = executable(
203 dependencies: deps_libweston,
208 filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
209 name: 'agl-compositor private protocols',
210 version: agl_compositor_version,
211 description: 'agl-compositor protocol files',
213 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
214 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
216 install_dir: dir_data_pc
220 [ agl_shell_xml, agl_shell_desktop_xml ],
221 install_dir: join_paths(dir_data, dir_data_agl_compositor)