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-10'
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   ]),
26   language: 'c'
27 )
28
29 add_project_arguments([
30     '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
31     '-D_GNU_SOURCE',
32     '-D_ALL_SOURCE',
33   ],
34   language: 'c'
35 )
36
37 optional_libc_funcs = [ 'memfd_create', 'strchrnul' ]
38 foreach func: optional_libc_funcs
39     if cc.has_function(func)
40         add_project_arguments('-DHAVE_@0@=1'.format(func.to_upper()), language: 'c')
41     endif
42 endforeach
43
44 dep_libsystemd = dependency('libsystemd', required: false)
45 dep_scanner = dependency('wayland-scanner')
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 agl_shell_xml = files('protocol/agl-shell.xml')
67 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
68 agl_screenshooter = files('protocol/agl-screenshooter.xml')
69 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
70
71 protocols = [
72   { 'name': 'agl-shell', 'source': 'internal' },
73   { 'name': 'agl-shell-desktop', 'source': 'internal' },
74   { 'name': 'agl-screenshooter', 'source': 'internal' },
75   { 'name': 'xdg-shell', 'source': 'wp-stable' },
76   { 'name': 'xdg-output', 'source': 'unstable', 'version': 'v1' },
77 ]
78
79 foreach proto: protocols
80     proto_name = proto['name']
81     if proto['source'] == 'internal'
82         base_file = proto_name
83         xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
84     elif proto['source'] == 'wp-stable'
85         base_file = proto_name
86         xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
87     else
88         base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
89         xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
90     endif
91
92     foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
93         if output_type == 'client-header'
94             output_file = '@0@-client-protocol.h'.format(base_file)
95         elif output_type == 'server-header'
96             output_file = '@0@-server-protocol.h'.format(base_file)
97         else
98             output_file = '@0@-protocol.c'.format(base_file)
99             if dep_scanner.version().version_compare('< 1.14.91')
100                 output_type = 'code'
101             endif
102         endif
103
104         var_name = output_file.underscorify()
105         target = custom_target(
106             '@0@ @1@'.format(base_file, output_type),
107             command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
108             input: xml_path,
109             output: output_file,
110         )
111
112         set_variable(var_name, target)
113     endforeach
114 endforeach
115
116 prefix_path = get_option('prefix')
117 dir_data = join_paths(prefix_path, get_option('datadir'))
118 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
119 dir_data_pc = join_paths(dir_data, 'pkgconfig')
120 libweston_dep = dependency(libweston_version)
121
122 deps_libweston = [
123   dependency('wayland-server'),
124   dependency('weston'),
125   libweston_dep,
126   dependency('libweston-desktop-10'),
127 ]
128
129
130 srcs_agl_compositor = [
131         'src/compositor.c',
132         'src/desktop.c',
133         'src/layout.c',
134         'src/policy.c',
135         'src/shell.c',
136         'src/screenshooter.c',
137         'src/input.c',
138         'shared/option-parser.c',
139         'shared/os-compatibility.c',
140         'shared/process-util.c',
141         agl_shell_server_protocol_h,
142         agl_shell_desktop_server_protocol_h,
143         agl_screenshooter_server_protocol_h,
144         agl_shell_protocol_c,
145         agl_shell_desktop_protocol_c,
146         agl_screenshooter_protocol_c,
147         xdg_shell_protocol_c,
148 ]
149
150 policy_to_install = get_option('policy-default')
151 if policy_to_install == 'auto' or policy_to_install == 'allow-all'
152   srcs_agl_compositor += 'src/policy-default.c'
153   message('Installing allow all policy')
154 elif policy_to_install == 'deny-all'
155   srcs_agl_compositor += 'src/policy-deny.c'
156   message('Installing deny all policy')
157 elif policy_to_install == 'rba'
158   srcs_agl_compositor += ['src/policy-rba.c', 'src/rba_adapter.cpp']
159   deps_libweston += dependency('librba')
160   message('Installing rba policy')
161 endif
162
163 # From meson documentation:
164 # In order to look for headers in a specific directory you can use args :
165 # '-I/extra/include/dir, but this should only be used in exceptional cases for
166 # includes that can't be detected via pkg-config and passed via dependencies.
167 if libweston_dep.found()
168   if not meson.is_cross_build()
169     if not prefix_path.contains('/usr')
170       dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
171       dir_path_headless_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-headless.h')
172       dir_path_rdp_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-rdp.h')
173     else
174       dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
175       dir_path_headless_backend = join_paths(libweston_version, 'libweston', 'backend-headless.h')
176       dir_path_rdp = join_paths(libweston_version, 'libweston', 'backend-rdp.h')
177     endif
178   else
179     message('Building with cross environment')
180     dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
181     dir_path_headless_backend = join_paths(libweston_version, 'libweston', 'backend-headless.h')
182     dir_path_rdp_backend = join_paths(libweston_version, 'libweston', 'backend-rdp.h')
183   endif
184
185   # do the test
186   if cc.has_header(dir_path_x11_backend)
187     config_h.set('HAVE_BACKEND_X11', 1)
188     message('Building with X11 backend')
189   endif
190
191   if cc.has_header(dir_path_headless_backend)
192     config_h.set('HAVE_BACKEND_HEADLESS', 1)
193     message('Building with headless backend')
194   endif
195
196   if cc.has_header(dir_path_rdp_backend)
197     config_h.set('HAVE_BACKEND_RDP', 1)
198     message('Building with RDP backend')
199   endif
200 endif
201
202 if dep_libsystemd.found()
203   config_h.set('HAVE_SYSTEMD', 1)
204
205   srcs_agl_compositor += 'src/systemd-notify.c'
206   deps_libweston += dep_libsystemd
207
208   message('Found systemd, enabling notify support')
209 endif
210
211 if deps_remoting.length() == depnames.length()
212   config_h.set('HAVE_REMOTING', 1)
213   message('Found remoting depends, enabling remoting')
214 endif
215
216 if get_option('xwayland')
217         config_h.set('BUILD_XWAYLAND', '1')
218
219         srcs_agl_compositor += 'src/xwayland.c'
220         config_h.set_quoted('XSERVER_PATH', get_option('xwayland-path'))
221 endif
222
223 dir_module_agl_compositor = join_paths(join_paths(prefix_path, get_option('libdir')), 'agl-compositor')
224
225 libexec_compositor = shared_library(
226         'exec_compositor',
227         sources: srcs_agl_compositor,
228         dependencies: deps_libweston,
229         install_dir: dir_module_agl_compositor,
230         install: true,
231         version: meson.project_version(),
232         soversion: 0
233 )
234
235 dep_libexec_compositor = declare_dependency(
236         link_with: libexec_compositor,
237         include_directories: [ include_directories('.') ],
238         dependencies: deps_libweston,
239 )
240
241 configure_file(output: 'config.h', configuration: config_h)
242
243 exe_agl_compositor = executable(
244         'agl-compositor',
245         'src/main.c',
246         dependencies: dep_libexec_compositor,
247         install_rpath: dir_module_agl_compositor,
248         install: true
249 )
250
251 pkgconfig.generate(
252         filebase: 'agl-compositor-@0@-protocols'.format(meson.project_version()),
253         name: 'agl-compositor private protocols',
254         version: meson.project_version(),
255         description: 'agl-compositor protocol files',
256         variables: [
257                 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
258                 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
259         ],
260         install_dir: dir_data_pc
261 )
262
263 install_data(
264         [ agl_shell_xml, agl_shell_desktop_xml ],
265         install_dir: join_paths(dir_data, dir_data_agl_compositor)
266 )
267
268 common_inc = [ include_directories('src'), include_directories('.') ]
269 subdir('clients')
270
271 if get_option('grpc-proxy')
272   subdir('grpc-proxy')
273 endif