main: Add support loading waltham transmitter plug-in
[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 deps_remoting = []
57 foreach depname : depnames
58   dep = dependency(depname, required: false)
59   if not dep.found()
60     message('Remoting requires @0@ which was not found. '.format(depname))
61   endif
62   deps_remoting += dep
63 endforeach
64
65
66 # the transmitter plug-in requires waltham but we don't have a cflags or libs
67 # for it so we add waltham depends here. Further more, the output is being
68 # handled by remoting plug-in
69 depnames_waltham = [
70   'waltham'
71 ]
72
73 deps_waltham = []
74 foreach depname : depnames_waltham
75   dep = dependency(depname, required: false)
76   if not dep.found()
77     message('Waltham requires @0@ which was not found. '.format(depname))
78   endif
79   deps_waltham += dep
80 endforeach
81
82 deps_waltham += deps_remoting
83
84 agl_shell_xml = files('protocol/agl-shell.xml')
85 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
86 agl_screenshooter = files('protocol/agl-screenshooter.xml')
87 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
88
89 protocols = [
90   { 'name': 'agl-shell', 'source': 'internal' },
91   { 'name': 'agl-shell-desktop', 'source': 'internal' },
92   { 'name': 'agl-screenshooter', 'source': 'internal' },
93   { 'name': 'xdg-shell', 'source': 'wp-stable' },
94   { 'name': 'xdg-output', 'source': 'unstable', 'version': 'v1' },
95 ]
96
97 foreach proto: protocols
98     proto_name = proto['name']
99     if proto['source'] == 'internal'
100         base_file = proto_name
101         xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
102     elif proto['source'] == 'wp-stable'
103         base_file = proto_name
104         xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
105     else
106         base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
107         xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
108     endif
109
110     foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
111         if output_type == 'client-header'
112             output_file = '@0@-client-protocol.h'.format(base_file)
113         elif output_type == 'server-header'
114             output_file = '@0@-server-protocol.h'.format(base_file)
115         else
116             output_file = '@0@-protocol.c'.format(base_file)
117             if dep_scanner.version().version_compare('< 1.14.91')
118                 output_type = 'code'
119             endif
120         endif
121
122         var_name = output_file.underscorify()
123         target = custom_target(
124             '@0@ @1@'.format(base_file, output_type),
125             command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
126             input: xml_path,
127             output: output_file,
128         )
129
130         set_variable(var_name, target)
131     endforeach
132 endforeach
133
134 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
135 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
136 # path as to allow building and installing the compositor locally
137 prefix_path = get_option('prefix')
138 message('prefix_path ' + prefix_path)
139 if not prefix_path.contains('/usr')
140   additional_include_dir = include_directories(prefix_path + '/' + 'include')
141   local_dep = declare_dependency(include_directories: additional_include_dir)
142 else
143   local_dep = []
144 endif
145
146 dir_data = join_paths(prefix_path, get_option('datadir'))
147 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
148 dir_data_pc = join_paths(dir_data, 'pkgconfig')
149 libweston_dep = dependency(libweston_version)
150
151 deps_libweston = [
152   dependency('wayland-server'),
153   libweston_dep,
154   dependency('libweston-desktop-8'),
155   local_dep,
156 ]
157
158 srcs_agl_compositor = [
159         'src/main.c',
160         'src/desktop.c',
161         'src/layout.c',
162         'src/policy.c',
163         'src/shell.c',
164         'src/screenshooter.c',
165         'src/input.c',
166         'shared/option-parser.c',
167         'shared/os-compatibility.c',
168         agl_shell_server_protocol_h,
169         agl_shell_desktop_server_protocol_h,
170         agl_screenshooter_server_protocol_h,
171         agl_shell_protocol_c,
172         agl_shell_desktop_protocol_c,
173         agl_screenshooter_protocol_c,
174         xdg_shell_protocol_c,
175 ]
176
177 policy_to_install = get_option('policy-default')
178 if policy_to_install == 'auto' or policy_to_install == 'allow-all'
179   srcs_agl_compositor += 'src/policy-default.c'
180   message('Installing allow all policy')
181 elif policy_to_install == 'deny-all'
182   srcs_agl_compositor += 'src/policy-deny.c'
183   message('Installing deny all policy')
184 endif
185
186
187 # From meson documentation:
188 # In order to look for headers in a specific directory you can use args :
189 # '-I/extra/include/dir, but this should only be used in exceptional cases for
190 # includes that can't be detected via pkg-config and passed via dependencies.
191 if libweston_dep.found()
192   if not prefix_path.contains('/usr')
193     dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
194   else
195     dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
196   endif
197
198   # do the test
199   if cc.has_header(dir_path_x11_backend)
200     config_h.set('HAVE_BACKEND_X11', 1)
201   endif
202 endif
203
204 if dep_libsystemd.found()
205   config_h.set('HAVE_SYSTEMD', 1)
206
207   srcs_agl_compositor += 'src/systemd-notify.c'
208   deps_libweston += dep_libsystemd
209
210   message('Found systemd, enabling notify support')
211 endif
212
213 if deps_remoting.length() == depnames.length()
214   config_h.set('HAVE_REMOTING', 1)
215   message('Found remoting depends, enabling remoting')
216 endif
217
218 if deps_waltham.length() == depnames_waltham.length() + depnames.length()
219   config_h.set('HAVE_WALTHAM', 1)
220   message('Found waltham depends, enabling waltham')
221 endif
222
223 if dep_libsmack.found()
224   config_h.set('HAVE_SMACK', 1)
225   deps_libweston += dep_libsmack
226 endif
227
228 configure_file(output: 'config.h', configuration: config_h)
229
230 exe_agl_compositor = executable(
231         'agl-compositor',
232         srcs_agl_compositor,
233         dependencies: deps_libweston,
234         install: true
235 )
236
237 pkgconfig.generate(
238         filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
239         name: 'agl-compositor private protocols',
240         version: agl_compositor_version,
241         description: 'agl-compositor protocol files',
242         variables: [
243                 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
244                 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
245         ],
246         install_dir: dir_data_pc
247 )
248
249 install_data(
250         [ agl_shell_xml, agl_shell_desktop_xml ],
251         install_dir: join_paths(dir_data, dir_data_agl_compositor)
252 )
253
254 common_inc = [ include_directories('src'), include_directories('.') ]
255 subdir('clients')