ivi-compositor: Add systemd notify message
[src/agl-compositor.git] / meson.build
1 project('agl-compositor',
2   'c',
3   version: '0.0.13',
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
14 cc = meson.get_compiler('c')
15 add_project_arguments(
16   cc.get_supported_arguments([
17     '-Wno-unused-parameter',
18     '-Wno-pedantic',
19   ]),
20   language: 'c'
21 )
22
23 add_project_arguments([
24     '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
25     '-D_GNU_SOURCE',
26     '-D_ALL_SOURCE',
27   ],
28   language: 'c'
29 )
30
31 optional_libc_funcs = [ 'memfd_create', 'strchrnul' ]
32 foreach func: optional_libc_funcs
33     if cc.has_function(func)
34         add_project_arguments('-DHAVE_@0@=1'.format(func.to_upper()), language: 'c')
35     endif
36 endforeach
37
38 dep_libsystemd = dependency('libsystemd', required: false)
39 dep_scanner = dependency('wayland-scanner', native: true)
40 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
41 dep_wp = dependency('wayland-protocols', version: '>= 1.12')
42 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
43
44 agl_shell_xml = files('protocol/agl-shell.xml')
45 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
46
47 protocols = [
48   { 'name': 'agl-shell', 'source': 'internal' },
49   { 'name': 'xdg-shell', 'source': 'wp-stable' },
50 ]
51
52 foreach proto: protocols
53     proto_name = proto['name']
54     if proto['source'] == 'internal'
55         base_file = proto_name
56         xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
57     elif proto['source'] == 'wp-stable'
58         base_file = proto_name
59         xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
60     else
61         base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
62         xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
63     endif
64
65     foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
66         if output_type == 'client-header'
67             output_file = '@0@-client-protocol.h'.format(base_file)
68         elif output_type == 'server-header'
69             output_file = '@0@-server-protocol.h'.format(base_file)
70         else
71             output_file = '@0@-protocol.c'.format(base_file)
72             if dep_scanner.version().version_compare('< 1.14.91')
73                 output_type = 'code'
74             endif
75         endif
76
77         var_name = output_file.underscorify()
78         target = custom_target(
79             '@0@ @1@'.format(base_file, output_type),
80             command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
81             input: xml_path,
82             output: output_file,
83         )
84
85         set_variable(var_name, target)
86     endforeach
87 endforeach
88
89 deps_libweston = [
90   dependency('wayland-server'),
91   dependency('libweston-6'),
92   dependency('libweston-desktop-6'),
93 ]
94
95 srcs_agl_compositor = [
96         'src/main.c',
97         'src/desktop.c',
98         'src/layout.c',
99         'src/shell.c',
100         'shared/option-parser.c',
101         'shared/os-compatibility.c',
102         agl_shell_server_protocol_h,
103         agl_shell_protocol_c,
104         xdg_shell_protocol_c,
105 ]
106
107 if dep_libsystemd.found()
108   config_h.set('HAVE_SYSTEMD', 1)
109
110   srcs_agl_compositor += 'src/systemd-notify.c'
111   deps_libweston += dep_libsystemd
112
113   message('Found systemd, enabling notify support')
114 endif
115
116 configure_file(output: 'config.h', configuration: config_h)
117
118 exe_agl_compositor = executable(
119         'agl-compositor',
120         srcs_agl_compositor,
121         dependencies: deps_libweston,
122         install: true
123 )