compositor: Use stdint for specifing integer storage
[src/agl-compositor.git] / meson.build
1 project('agl-compositor',
2   'c','cpp',
3   version: '0.0.24',
4   default_options: [
5     'warning_level=3',
6     'c_std=gnu99',
7     'werror=true',
8   ],
9   meson_version: '>= 0.53',
10   license: 'MIT/Expat',
11 )
12
13 config_h = configuration_data()
14 libweston_version = 'libweston-13'
15 pkgconfig = import('pkgconfig')
16 fs = import('fs')
17
18 cc = meson.get_compiler('c')
19 cxx = meson.get_compiler('cpp')
20
21 add_project_arguments(
22   cc.get_supported_arguments([
23     '-Wno-unused-parameter',
24     '-Wno-pedantic',
25     '-Wno-deprecated-declarations'
26   ]),
27   language: 'c'
28 )
29
30 add_project_arguments([
31     '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
32     '-D_GNU_SOURCE',
33     '-D_ALL_SOURCE',
34   ],
35   language: 'c'
36 )
37
38 optional_libc_funcs = [ 'memfd_create', 'strchrnul' ]
39 foreach func: optional_libc_funcs
40     if cc.has_function(func)
41         add_project_arguments('-DHAVE_@0@=1'.format(func.to_upper()), language: 'c')
42     endif
43 endforeach
44
45 dep_libsystemd = dependency('libsystemd', required: false)
46 dep_scanner = dependency('wayland-scanner', native: true)
47 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
48 dep_wp = dependency('wayland-protocols', version: '>= 1.18')
49 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
50
51 depnames = [
52   'gstreamer-1.0', 'gstreamer-allocators-1.0',
53   'gstreamer-app-1.0', 'gstreamer-video-1.0',
54   'gobject-2.0', 'glib-2.0'
55 ]
56
57 deps_remoting = []
58 foreach depname : depnames
59   dep = dependency(depname, required: false)
60   if not dep.found()
61     message('Remoting requires @0@ which was not found. '.format(depname))
62   endif
63   deps_remoting += dep
64 endforeach
65
66 agl_shell_xml = files('protocol/agl-shell.xml')
67 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
68 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
69 dep_libweston_protocols = dependency('libweston-13-protocols', version: '>= 13')
70 dir_protocol_libweston = dep_libweston_protocols.get_pkgconfig_variable('pkgdatadir')
71
72 protocols = [
73   { 'name': 'agl-shell', 'source': 'internal' },
74   { 'name': 'agl-shell-desktop', 'source': 'internal' },
75   { 'name': 'xdg-shell', 'source': 'wp-stable' },
76   { 'name': 'xdg-output', 'source': 'unstable', 'version': 'v1' },
77   { 'name': 'weston-output-capture', 'source': 'libweston-protocols' },
78 ]
79
80 foreach proto: protocols
81     proto_name = proto['name']
82     if proto['source'] == 'internal'
83         base_file = proto_name
84         xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
85     elif proto['source'] == 'libweston-protocols'
86         base_file = proto_name
87         xml_path = join_paths(dir_protocol_libweston, '@0@.xml'.format(base_file))
88     elif proto['source'] == 'wp-stable'
89         base_file = proto_name
90         xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
91     else
92         base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
93         xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
94     endif
95
96     foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
97         if output_type == 'client-header'
98             output_file = '@0@-client-protocol.h'.format(base_file)
99         elif output_type == 'server-header'
100             output_file = '@0@-server-protocol.h'.format(base_file)
101         else
102             output_file = '@0@-protocol.c'.format(base_file)
103             if dep_scanner.version().version_compare('< 1.14.91')
104                 output_type = 'code'
105             endif
106         endif
107
108         var_name = output_file.underscorify()
109         target = custom_target(
110             '@0@ @1@'.format(base_file, output_type),
111             command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
112             input: xml_path,
113             output: output_file,
114         )
115
116         set_variable(var_name, target)
117     endforeach
118 endforeach
119
120 prefix_path = get_option('prefix')
121 dir_data = join_paths(prefix_path, get_option('datadir'))
122 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
123 dir_data_pc = join_paths(dir_data, 'pkgconfig')
124 libweston_dep = dependency(libweston_version)
125
126 deps_libweston = [
127   dependency('wayland-server'),
128   dependency('weston'),
129   libweston_dep,
130 ]
131
132 weston_module_dir = libweston_dep.get_pkgconfig_variable('libdir')
133 config_h.set_quoted('WESTON_MODULEDIR', join_paths(weston_module_dir, 'weston'))
134 config_h.set_quoted('LIBWESTON_MODULEDIR', join_paths(weston_module_dir, libweston_version))
135
136 srcs_agl_compositor = [
137         'src/compositor.c',
138         'src/desktop.c',
139         'src/layout.c',
140         'src/policy.c',
141         'src/shell.c',
142         'src/input.c',
143         'shared/option-parser.c',
144         'shared/os-compatibility.c',
145         'shared/process-util.c',
146         agl_shell_server_protocol_h,
147         agl_shell_desktop_server_protocol_h,
148         agl_shell_protocol_c,
149         agl_shell_desktop_protocol_c,
150         xdg_shell_protocol_c,
151 ]
152
153 policy_to_install = get_option('policy-default')
154 if policy_to_install == 'auto' or policy_to_install == 'allow-all'
155   srcs_agl_compositor += 'src/policy-default.c'
156   message('Installing allow all policy')
157 elif policy_to_install == 'deny-all'
158   srcs_agl_compositor += 'src/policy-deny.c'
159   message('Installing deny all policy')
160 elif policy_to_install == 'rba'
161   srcs_agl_compositor += ['src/policy-rba.c', 'src/rba_adapter.cpp']
162   deps_libweston += dependency('librba')
163   message('Installing rba policy')
164 endif
165
166 # From meson documentation:
167 # In order to look for headers in a specific directory you can use args :
168 # '-I/extra/include/dir, but this should only be used in exceptional cases for
169 # includes that can't be detected via pkg-config and passed via dependencies.
170 if libweston_dep.found()
171   if not meson.is_cross_build()
172     if not prefix_path.contains('/usr')
173       dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
174       dir_path_wayland_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-wayland.h')
175       dir_path_rdp_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-rdp.h')
176     else
177       dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
178       dir_path_wayland_backend = join_paths(libweston_version, 'libweston', 'backend-wayland.h')
179       dir_path_rdp_backend = join_paths(libweston_version, 'libweston', 'backend-rdp.h')
180     endif
181   else
182     message('Building with cross environment')
183     dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
184     dir_path_wayland_backend = join_paths(libweston_version, 'libweston', 'backend-wayland.h')
185     dir_path_rdp_backend = join_paths(libweston_version, 'libweston', 'backend-rdp.h')
186   endif
187
188   # do the test
189   if cc.has_header(dir_path_x11_backend)
190     config_h.set('HAVE_BACKEND_X11', 1)
191     message('Building with X11 backend')
192   endif
193
194   if cc.has_header(dir_path_wayland_backend)
195     config_h.set('HAVE_BACKEND_WAYLAND', 1)
196     message('Building with Wayland backend')
197   endif
198
199   if cc.has_header(dir_path_rdp_backend)
200     config_h.set('HAVE_BACKEND_RDP', 1)
201     message('Building with RDP backend')
202   endif
203 endif
204
205 if dep_libsystemd.found()
206   config_h.set('HAVE_SYSTEMD', 1)
207
208   srcs_agl_compositor += 'src/systemd-notify.c'
209   deps_libweston += dep_libsystemd
210
211   message('Found systemd, enabling notify support')
212 endif
213
214 if deps_remoting.length() == depnames.length()
215   config_h.set('HAVE_REMOTING', 1)
216   message('Found remoting depends, enabling remoting')
217 endif
218
219 if get_option('xwayland')
220         config_h.set('BUILD_XWAYLAND', '1')
221
222         srcs_agl_compositor += 'src/xwayland.c'
223         srcs_agl_compositor += 'shared/xalloc.c'
224         srcs_agl_compositor += 'shared/process-util.c'
225         config_h.set_quoted('XSERVER_PATH', get_option('xwayland-path'))
226 endif
227
228 dir_module_agl_compositor = join_paths(join_paths(prefix_path, get_option('libdir')), 'agl-compositor')
229
230 libexec_compositor = shared_library(
231         'exec_compositor',
232         sources: srcs_agl_compositor,
233         dependencies: deps_libweston,
234         install_dir: dir_module_agl_compositor,
235         install: true,
236         version: meson.project_version(),
237         soversion: 0
238 )
239
240 dep_libexec_compositor = declare_dependency(
241         link_with: libexec_compositor,
242         include_directories: [ include_directories('.') ],
243         dependencies: deps_libweston,
244 )
245
246 configure_file(output: 'config.h', configuration: config_h)
247
248 exe_agl_compositor = executable(
249         'agl-compositor',
250         'src/main.c',
251         dependencies: dep_libexec_compositor,
252         install_rpath: dir_module_agl_compositor,
253         install: true
254 )
255
256 pkgconfig.generate(
257         filebase: 'agl-compositor-@0@-protocols'.format(meson.project_version()),
258         name: 'agl-compositor private protocols',
259         version: meson.project_version(),
260         description: 'agl-compositor protocol files',
261         variables: [
262                 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
263                 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
264         ],
265         install_dir: dir_data_pc
266 )
267
268 install_data(
269         [ agl_shell_xml, agl_shell_desktop_xml ],
270         install_dir: join_paths(dir_data, dir_data_agl_compositor)
271 )
272
273 common_inc = [ include_directories('src'), include_directories('.') ]
274 subdir('clients')
275
276 if get_option('grpc-proxy')
277   subdir('grpc-proxy')
278 endif