'Push' or foward depending on the remote output the app_id to the
[src/agl-compositor.git] / meson.build
1 project('agl-compositor',
2   'c',
3   version: '0.0.18',
4   default_options: [
5     'warning_level=3',
6     'c_std=gnu99',
7   ],
8   meson_version: '>= 0.47',
9   license: 'MIT/Expat',
10 )
11
12 config_h = configuration_data()
13 agl_compositor_version = '0.0.18'
14 libweston_version = 'libweston-8'
15 pkgconfig = import('pkgconfig')
16
17 cc = meson.get_compiler('c')
18 add_project_arguments(
19   cc.get_supported_arguments([
20     '-Wno-unused-parameter',
21     '-Wno-pedantic',
22     '-Wextra',
23     '-Werror'
24   ]),
25   language: 'c'
26 )
27
28 add_project_arguments([
29     '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
30     '-D_GNU_SOURCE',
31     '-D_ALL_SOURCE',
32   ],
33   language: 'c'
34 )
35
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')
40     endif
41 endforeach
42
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')
49
50 depnames = [
51   'gstreamer-1.0', 'gstreamer-allocators-1.0',
52   'gstreamer-app-1.0', 'gstreamer-video-1.0',
53   'gobject-2.0', 'glib-2.0'
54 ]
55
56 depnames_waltham = [
57   'waltham'
58 ]
59
60 deps_remoting = []
61 foreach depname : depnames
62   dep = dependency(depname, required: false)
63   if not dep.found()
64     message('Remoting requires @0@ which was not found. '.format(depname))
65   endif
66   deps_remoting += dep
67 endforeach
68
69
70 deps_waltham = []
71 foreach depname : depnames_waltham
72   dep = dependency(depname, required: false)
73   if not dep.found()
74     message('Waltham requires @0@ which was not found. '.format(depname))
75   endif
76   deps_waltham += dep
77 endforeach
78
79 agl_shell_xml = files('protocol/agl-shell.xml')
80 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
81 agl_screenshooter = files('protocol/agl-screenshooter.xml')
82 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
83
84 protocols = [
85   { 'name': 'agl-shell', 'source': 'internal' },
86   { 'name': 'agl-shell-desktop', 'source': 'internal' },
87   { 'name': 'agl-screenshooter', 'source': 'internal' },
88   { 'name': 'xdg-shell', 'source': 'wp-stable' },
89   { 'name': 'xdg-output', 'source': 'unstable', 'version': 'v1' },
90 ]
91
92 foreach proto: protocols
93     proto_name = proto['name']
94     if proto['source'] == 'internal'
95         base_file = proto_name
96         xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
97     elif proto['source'] == 'wp-stable'
98         base_file = proto_name
99         xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
100     else
101         base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
102         xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
103     endif
104
105     foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
106         if output_type == 'client-header'
107             output_file = '@0@-client-protocol.h'.format(base_file)
108         elif output_type == 'server-header'
109             output_file = '@0@-server-protocol.h'.format(base_file)
110         else
111             output_file = '@0@-protocol.c'.format(base_file)
112             if dep_scanner.version().version_compare('< 1.14.91')
113                 output_type = 'code'
114             endif
115         endif
116
117         var_name = output_file.underscorify()
118         target = custom_target(
119             '@0@ @1@'.format(base_file, output_type),
120             command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
121             input: xml_path,
122             output: output_file,
123         )
124
125         set_variable(var_name, target)
126     endforeach
127 endforeach
128
129 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
130 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
131 # path as to allow building and installing the compositor locally
132 prefix_path = get_option('prefix')
133 message('prefix_path ' + prefix_path)
134 if not prefix_path.contains('/usr')
135   additional_include_dir = include_directories(prefix_path + '/' + 'include')
136   local_dep = declare_dependency(include_directories: additional_include_dir)
137 else
138   local_dep = []
139 endif
140
141 dir_data = join_paths(prefix_path, get_option('datadir'))
142 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
143 dir_data_pc = join_paths(dir_data, 'pkgconfig')
144 libweston_dep = dependency(libweston_version)
145
146 deps_libweston = [
147   dependency('wayland-server'),
148   libweston_dep,
149   dependency('libweston-desktop-8'),
150   local_dep,
151 ]
152
153 srcs_agl_compositor = [
154         'src/main.c',
155         'src/desktop.c',
156         'src/layout.c',
157         'src/policy.c',
158         'src/shell.c',
159         'src/screenshooter.c',
160         'src/input.c',
161         'shared/option-parser.c',
162         'shared/os-compatibility.c',
163         agl_shell_server_protocol_h,
164         agl_shell_desktop_server_protocol_h,
165         agl_screenshooter_server_protocol_h,
166         agl_shell_protocol_c,
167         agl_shell_desktop_protocol_c,
168         agl_screenshooter_protocol_c,
169         xdg_shell_protocol_c,
170 ]
171
172 policy_to_install = get_option('policy-default')
173 if policy_to_install == 'auto' or policy_to_install == 'allow-all'
174   srcs_agl_compositor += 'src/policy-default.c'
175   message('Installing allow all policy')
176 elif policy_to_install == 'deny-all'
177   srcs_agl_compositor += 'src/policy-deny.c'
178   message('Installing deny all policy')
179 endif
180
181
182 # From meson documentation:
183 # In order to look for headers in a specific directory you can use args :
184 # '-I/extra/include/dir, but this should only be used in exceptional cases for
185 # includes that can't be detected via pkg-config and passed via dependencies.
186 if libweston_dep.found()
187   if not prefix_path.contains('/usr')
188     dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
189   else
190     dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
191   endif
192
193   # do the test
194   if cc.has_header(dir_path_x11_backend)
195     config_h.set('HAVE_BACKEND_X11', 1)
196   endif
197 endif
198
199 if dep_libsystemd.found()
200   config_h.set('HAVE_SYSTEMD', 1)
201
202   srcs_agl_compositor += 'src/systemd-notify.c'
203   deps_libweston += dep_libsystemd
204
205   message('Found systemd, enabling notify support')
206 endif
207
208 if deps_remoting.length() == depnames.length()
209   config_h.set('HAVE_REMOTING', 1)
210   message('Found remoting depends, enabling remoting')
211 endif
212
213 if deps_waltham.length() == depnames_waltham.length()
214   config_h.set('HAVE_WALTHAM', 1)
215   message('Found waltham depends, enabling waltham')
216 endif
217
218 if dep_libsmack.found()
219   config_h.set('HAVE_SMACK', 1)
220   deps_libweston += dep_libsmack
221 endif
222
223 configure_file(output: 'config.h', configuration: config_h)
224
225 exe_agl_compositor = executable(
226         'agl-compositor',
227         srcs_agl_compositor,
228         dependencies: deps_libweston,
229         install: true
230 )
231
232 pkgconfig.generate(
233         filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
234         name: 'agl-compositor private protocols',
235         version: agl_compositor_version,
236         description: 'agl-compositor protocol files',
237         variables: [
238                 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
239                 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
240         ],
241         install_dir: dir_data_pc
242 )
243
244 install_data(
245         [ agl_shell_xml, agl_shell_desktop_xml ],
246         install_dir: join_paths(dir_data, dir_data_agl_compositor)
247 )
248
249 common_inc = [ include_directories('src'), include_directories('.') ]
250 subdir('clients')