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')
49 agl_shell_xml = files('protocol/agl-shell.xml')
50 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
51 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
54 { 'name': 'agl-shell', 'source': 'internal' },
55 { 'name': 'agl-shell-desktop', 'source': 'internal' },
56 { 'name': 'xdg-shell', 'source': 'wp-stable' },
59 foreach proto: protocols
60 proto_name = proto['name']
61 if proto['source'] == 'internal'
62 base_file = proto_name
63 xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
64 elif proto['source'] == 'wp-stable'
65 base_file = proto_name
66 xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
68 base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
69 xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
72 foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
73 if output_type == 'client-header'
74 output_file = '@0@-client-protocol.h'.format(base_file)
75 elif output_type == 'server-header'
76 output_file = '@0@-server-protocol.h'.format(base_file)
78 output_file = '@0@-protocol.c'.format(base_file)
79 if dep_scanner.version().version_compare('< 1.14.91')
84 var_name = output_file.underscorify()
85 target = custom_target(
86 '@0@ @1@'.format(base_file, output_type),
87 command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
92 set_variable(var_name, target)
96 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
97 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
98 # path as to allow building and installing the compositor locally
99 prefix_path = get_option('prefix')
100 message('prefix_path ' + prefix_path)
101 if not prefix_path.contains('/usr')
102 additional_include_dir = include_directories(prefix_path + '/' + 'include')
103 local_dep = declare_dependency(include_directories: additional_include_dir)
108 dir_data = join_paths(prefix_path, get_option('datadir'))
109 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
110 dir_data_pc = join_paths(dir_data, 'pkgconfig')
111 libweston_dep = dependency(libweston_version)
114 dependency('wayland-server'),
116 dependency('libweston-desktop-8'),
120 srcs_agl_compositor = [
125 'src/policy-default.c',
127 'shared/option-parser.c',
128 'shared/os-compatibility.c',
129 agl_shell_server_protocol_h,
130 agl_shell_desktop_server_protocol_h,
131 agl_shell_protocol_c,
132 agl_shell_desktop_protocol_c,
133 xdg_shell_protocol_c,
136 # From meson documentation:
137 # In order to look for headers in a specific directory you can use args :
138 # '-I/extra/include/dir, but this should only be used in exceptional cases for
139 # includes that can't be detected via pkg-config and passed via dependencies.
140 if libweston_dep.found()
141 if not prefix_path.contains('/usr')
142 dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
144 dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
148 if cc.has_header(dir_path_x11_backend)
149 config_h.set('HAVE_BACKEND_X11', 1)
153 if dep_libsystemd.found()
154 config_h.set('HAVE_SYSTEMD', 1)
156 srcs_agl_compositor += 'src/systemd-notify.c'
157 deps_libweston += dep_libsystemd
159 message('Found systemd, enabling notify support')
162 configure_file(output: 'config.h', configuration: config_h)
164 exe_agl_compositor = executable(
167 dependencies: deps_libweston,
172 filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
173 name: 'agl-compositor private protocols',
174 version: agl_compositor_version,
175 description: 'agl-compositor protocol files',
177 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
178 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
180 install_dir: dir_data_pc
184 [ agl_shell_xml, agl_shell_desktop_xml ],
185 install_dir: join_paths(dir_data, dir_data_agl_compositor)