1 project('agl-compositor',
8 meson_version: '>= 0.47',
12 config_h = configuration_data()
13 agl_compositor_version = '0.0.16'
14 pkgconfig = import('pkgconfig')
16 cc = meson.get_compiler('c')
17 add_project_arguments(
18 cc.get_supported_arguments([
19 '-Wno-unused-parameter',
27 add_project_arguments([
28 '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
35 optional_libc_funcs = [ 'memfd_create', 'strchrnul' ]
36 foreach func: optional_libc_funcs
37 if cc.has_function(func)
38 add_project_arguments('-DHAVE_@0@=1'.format(func.to_upper()), language: 'c')
42 dep_libsystemd = dependency('libsystemd', required: false)
43 dep_scanner = dependency('wayland-scanner', native: true)
44 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
45 dep_wp = dependency('wayland-protocols', version: '>= 1.18')
46 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
48 agl_shell_xml = files('protocol/agl-shell.xml')
49 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
50 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
53 { 'name': 'agl-shell', 'source': 'internal' },
54 { 'name': 'agl-shell-desktop', 'source': 'internal' },
55 { 'name': 'xdg-shell', 'source': 'wp-stable' },
58 foreach proto: protocols
59 proto_name = proto['name']
60 if proto['source'] == 'internal'
61 base_file = proto_name
62 xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
63 elif proto['source'] == 'wp-stable'
64 base_file = proto_name
65 xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
67 base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
68 xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
71 foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
72 if output_type == 'client-header'
73 output_file = '@0@-client-protocol.h'.format(base_file)
74 elif output_type == 'server-header'
75 output_file = '@0@-server-protocol.h'.format(base_file)
77 output_file = '@0@-protocol.c'.format(base_file)
78 if dep_scanner.version().version_compare('< 1.14.91')
83 var_name = output_file.underscorify()
84 target = custom_target(
85 '@0@ @1@'.format(base_file, output_type),
86 command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
91 set_variable(var_name, target)
95 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
96 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
97 # path as to allow building and installing the compositor locally
98 prefix_path = get_option('prefix')
99 message('prefix_path ' + prefix_path)
100 if not prefix_path.contains('/usr')
101 additional_include_dir = include_directories(prefix_path + '/' + 'include')
102 local_dep = declare_dependency(include_directories: additional_include_dir)
107 dir_data = join_paths(prefix_path, get_option('datadir'))
108 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
109 dir_data_pc = join_paths(dir_data, 'pkgconfig')
110 libweston_dep = dependency('libweston-7')
113 dependency('wayland-server'),
115 dependency('libweston-desktop-7'),
119 srcs_agl_compositor = [
124 'shared/option-parser.c',
125 'shared/os-compatibility.c',
126 agl_shell_server_protocol_h,
127 agl_shell_desktop_server_protocol_h,
128 agl_shell_protocol_c,
129 agl_shell_desktop_protocol_c,
130 xdg_shell_protocol_c,
133 # From meson documentation:
134 # In order to look for headers in a specific directory you can use args :
135 # '-I/extra/include/dir, but this should only be used in exceptional cases for
136 # includes that can't be detected via pkg-config and passed via dependencies.
137 if libweston_dep.found()
138 if not prefix_path.contains('/usr')
139 dir_path_x11_backend = join_paths(prefix_path, 'include', 'libweston-7', 'libweston', 'backend-x11.h')
141 dir_path_x11_backend = join_paths('libweston-7', 'libweston', 'backend-x11.h')
145 if cc.has_header(dir_path_x11_backend)
146 config_h.set('HAVE_BACKEND_X11', 1)
150 if dep_libsystemd.found()
151 config_h.set('HAVE_SYSTEMD', 1)
153 srcs_agl_compositor += 'src/systemd-notify.c'
154 deps_libweston += dep_libsystemd
156 message('Found systemd, enabling notify support')
159 configure_file(output: 'config.h', configuration: config_h)
161 exe_agl_compositor = executable(
164 dependencies: deps_libweston,
169 filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
170 name: 'agl-compositor private protocols',
171 version: agl_compositor_version,
172 description: 'agl-compositor protocol files',
174 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
175 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
177 install_dir: dir_data_pc
181 [ agl_shell_xml, agl_shell_desktop_xml ],
182 install_dir: join_paths(dir_data, dir_data_agl_compositor)