input: Add basic seat handling
[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 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 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
117 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
118 # path as to allow building and installing the compositor locally
119 prefix_path = get_option('prefix')
120 message('prefix_path ' + prefix_path)
121 if not prefix_path.contains('/usr')
122   additional_include_dir = include_directories(prefix_path + '/' + 'include')
123   local_dep = declare_dependency(include_directories: additional_include_dir)
124 else
125   local_dep = []
126 endif
127
128 dir_data = join_paths(prefix_path, get_option('datadir'))
129 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
130 dir_data_pc = join_paths(dir_data, 'pkgconfig')
131 libweston_dep = dependency(libweston_version)
132
133 deps_libweston = [
134   dependency('wayland-server'),
135   libweston_dep,
136   dependency('libweston-desktop-8'),
137   local_dep,
138 ]
139
140 srcs_agl_compositor = [
141         'src/main.c',
142         'src/desktop.c',
143         'src/layout.c',
144         'src/policy.c',
145         'src/shell.c',
146         'src/screenshooter.c',
147         'src/input.c',
148         'shared/option-parser.c',
149         'shared/os-compatibility.c',
150         agl_shell_server_protocol_h,
151         agl_shell_desktop_server_protocol_h,
152         agl_screenshooter_server_protocol_h,
153         agl_shell_protocol_c,
154         agl_shell_desktop_protocol_c,
155         agl_screenshooter_protocol_c,
156         xdg_shell_protocol_c,
157 ]
158
159 policy_to_install = get_option('policy-default')
160 if policy_to_install == 'auto' or policy_to_install == 'allow-all'
161   srcs_agl_compositor += 'src/policy-default.c'
162   message('Installing allow all policy')
163 elif policy_to_install == 'deny-all'
164   srcs_agl_compositor += 'src/policy-deny.c'
165   message('Installing deny all policy')
166 endif
167
168
169 # From meson documentation:
170 # In order to look for headers in a specific directory you can use args :
171 # '-I/extra/include/dir, but this should only be used in exceptional cases for
172 # includes that can't be detected via pkg-config and passed via dependencies.
173 if libweston_dep.found()
174   if not prefix_path.contains('/usr')
175     dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
176   else
177     dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
178   endif
179
180   # do the test
181   if cc.has_header(dir_path_x11_backend)
182     config_h.set('HAVE_BACKEND_X11', 1)
183   endif
184 endif
185
186 if dep_libsystemd.found()
187   config_h.set('HAVE_SYSTEMD', 1)
188
189   srcs_agl_compositor += 'src/systemd-notify.c'
190   deps_libweston += dep_libsystemd
191
192   message('Found systemd, enabling notify support')
193 endif
194
195 if deps_remoting.length() == depnames.length()
196   config_h.set('HAVE_REMOTING', 1)
197   message('Found remoting depends, enabling remoting')
198 endif
199
200 if dep_libsmack.found()
201   config_h.set('HAVE_SMACK', 1)
202   deps_libweston += dep_libsmack
203 endif
204
205 configure_file(output: 'config.h', configuration: config_h)
206
207 exe_agl_compositor = executable(
208         'agl-compositor',
209         srcs_agl_compositor,
210         dependencies: deps_libweston,
211         install: true
212 )
213
214 pkgconfig.generate(
215         filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
216         name: 'agl-compositor private protocols',
217         version: agl_compositor_version,
218         description: 'agl-compositor protocol files',
219         variables: [
220                 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
221                 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
222         ],
223         install_dir: dir_data_pc
224 )
225
226 install_data(
227         [ agl_shell_xml, agl_shell_desktop_xml ],
228         install_dir: join_paths(dir_data, dir_data_agl_compositor)
229 )
230
231 common_inc = [ include_directories('src'), include_directories('.') ]
232 subdir('clients')