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_scanner = dependency('wayland-scanner', native: true)
45 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
46 dep_wp = dependency('wayland-protocols', version: '>= 1.18')
47 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
50 'gstreamer-1.0', 'gstreamer-allocators-1.0',
51 'gstreamer-app-1.0', 'gstreamer-video-1.0',
52 'gobject-2.0', 'glib-2.0'
56 foreach depname : depnames
57 dep = dependency(depname, required: false)
59 message('Remoting requires @0@ which was not found. '.format(depname))
65 agl_shell_xml = files('protocol/agl-shell.xml')
66 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
67 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
70 { 'name': 'agl-shell', 'source': 'internal' },
71 { 'name': 'agl-shell-desktop', 'source': 'internal' },
72 { 'name': 'xdg-shell', 'source': 'wp-stable' },
75 foreach proto: protocols
76 proto_name = proto['name']
77 if proto['source'] == 'internal'
78 base_file = proto_name
79 xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
80 elif proto['source'] == 'wp-stable'
81 base_file = proto_name
82 xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
84 base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
85 xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
88 foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
89 if output_type == 'client-header'
90 output_file = '@0@-client-protocol.h'.format(base_file)
91 elif output_type == 'server-header'
92 output_file = '@0@-server-protocol.h'.format(base_file)
94 output_file = '@0@-protocol.c'.format(base_file)
95 if dep_scanner.version().version_compare('< 1.14.91')
100 var_name = output_file.underscorify()
101 target = custom_target(
102 '@0@ @1@'.format(base_file, output_type),
103 command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
108 set_variable(var_name, target)
112 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
113 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
114 # path as to allow building and installing the compositor locally
115 prefix_path = get_option('prefix')
116 message('prefix_path ' + prefix_path)
117 if not prefix_path.contains('/usr')
118 additional_include_dir = include_directories(prefix_path + '/' + 'include')
119 local_dep = declare_dependency(include_directories: additional_include_dir)
124 dir_data = join_paths(prefix_path, get_option('datadir'))
125 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
126 dir_data_pc = join_paths(dir_data, 'pkgconfig')
127 libweston_dep = dependency(libweston_version)
130 dependency('wayland-server'),
132 dependency('libweston-desktop-8'),
136 srcs_agl_compositor = [
141 'src/policy-default.c',
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 # From meson documentation:
153 # In order to look for headers in a specific directory you can use args :
154 # '-I/extra/include/dir, but this should only be used in exceptional cases for
155 # includes that can't be detected via pkg-config and passed via dependencies.
156 if libweston_dep.found()
157 if not prefix_path.contains('/usr')
158 dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
160 dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
164 if cc.has_header(dir_path_x11_backend)
165 config_h.set('HAVE_BACKEND_X11', 1)
169 if dep_libsystemd.found()
170 config_h.set('HAVE_SYSTEMD', 1)
172 srcs_agl_compositor += 'src/systemd-notify.c'
173 deps_libweston += dep_libsystemd
175 message('Found systemd, enabling notify support')
178 if deps_remoting.length() == depnames.length()
179 config_h.set('HAVE_REMOTING', 1)
180 message('Found remoting depends, enabling remoting')
183 configure_file(output: 'config.h', configuration: config_h)
185 exe_agl_compositor = executable(
188 dependencies: deps_libweston,
193 filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
194 name: 'agl-compositor private protocols',
195 version: agl_compositor_version,
196 description: 'agl-compositor protocol files',
198 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
199 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
201 install_dir: dir_data_pc
205 [ agl_shell_xml, agl_shell_desktop_xml ],
206 install_dir: join_paths(dir_data, dir_data_agl_compositor)