main: Retrieve the transform and scale from config file
[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_scanner = dependency('wayland-scanner', native: true)
45 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
46 dep_wp = dependency('wayland-protocols', version: '>= 1.18')
47 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
48
49 depnames = [
50   'gstreamer-1.0', 'gstreamer-allocators-1.0',
51   'gstreamer-app-1.0', 'gstreamer-video-1.0',
52   'gobject-2.0', 'glib-2.0'
53 ]
54
55 deps_remoting = []
56 foreach depname : depnames
57   dep = dependency(depname, required: false)
58   if not dep.found()
59     message('Remoting requires @0@ which was not found. '.format(depname))
60   endif
61 deps_remoting += dep
62 endforeach
63
64
65 agl_shell_xml = files('protocol/agl-shell.xml')
66 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
67 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
68
69 protocols = [
70   { 'name': 'agl-shell', 'source': 'internal' },
71   { 'name': 'agl-shell-desktop', 'source': 'internal' },
72   { 'name': 'xdg-shell', 'source': 'wp-stable' },
73 ]
74
75 foreach proto: protocols
76     proto_name = proto['name']
77     if proto['source'] == 'internal'
78         base_file = proto_name
79         xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
80     elif proto['source'] == 'wp-stable'
81         base_file = proto_name
82         xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
83     else
84         base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
85         xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
86     endif
87
88     foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
89         if output_type == 'client-header'
90             output_file = '@0@-client-protocol.h'.format(base_file)
91         elif output_type == 'server-header'
92             output_file = '@0@-server-protocol.h'.format(base_file)
93         else
94             output_file = '@0@-protocol.c'.format(base_file)
95             if dep_scanner.version().version_compare('< 1.14.91')
96                 output_type = 'code'
97             endif
98         endif
99
100         var_name = output_file.underscorify()
101         target = custom_target(
102             '@0@ @1@'.format(base_file, output_type),
103             command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
104             input: xml_path,
105             output: output_file,
106         )
107
108         set_variable(var_name, target)
109     endforeach
110 endforeach
111
112 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
113 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
114 # path as to allow building and installing the compositor locally
115 prefix_path = get_option('prefix')
116 message('prefix_path ' + prefix_path)
117 if not prefix_path.contains('/usr')
118   additional_include_dir = include_directories(prefix_path + '/' + 'include')
119   local_dep = declare_dependency(include_directories: additional_include_dir)
120 else
121   local_dep = []
122 endif
123
124 dir_data = join_paths(prefix_path, get_option('datadir'))
125 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
126 dir_data_pc = join_paths(dir_data, 'pkgconfig')
127 libweston_dep = dependency(libweston_version)
128
129 deps_libweston = [
130   dependency('wayland-server'),
131   libweston_dep,
132   dependency('libweston-desktop-8'),
133   local_dep,
134 ]
135
136 srcs_agl_compositor = [
137         'src/main.c',
138         'src/desktop.c',
139         'src/layout.c',
140         'src/policy.c',
141         'src/policy-default.c',
142         'src/shell.c',
143         'shared/option-parser.c',
144         'shared/os-compatibility.c',
145         agl_shell_server_protocol_h,
146         agl_shell_desktop_server_protocol_h,
147         agl_shell_protocol_c,
148         agl_shell_desktop_protocol_c,
149         xdg_shell_protocol_c,
150 ]
151
152 # From meson documentation:
153 # In order to look for headers in a specific directory you can use args :
154 # '-I/extra/include/dir, but this should only be used in exceptional cases for
155 # includes that can't be detected via pkg-config and passed via dependencies.
156 if libweston_dep.found()
157   if not prefix_path.contains('/usr')
158     dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
159   else
160     dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
161   endif
162
163   # do the test
164   if cc.has_header(dir_path_x11_backend)
165     config_h.set('HAVE_BACKEND_X11', 1)
166   endif
167 endif
168
169 if dep_libsystemd.found()
170   config_h.set('HAVE_SYSTEMD', 1)
171
172   srcs_agl_compositor += 'src/systemd-notify.c'
173   deps_libweston += dep_libsystemd
174
175   message('Found systemd, enabling notify support')
176 endif
177
178 if deps_remoting.length() == depnames.length()
179   config_h.set('HAVE_REMOTING', 1)
180   message('Found remoting depends, enabling remoting')
181 endif
182
183 configure_file(output: 'config.h', configuration: config_h)
184
185 exe_agl_compositor = executable(
186         'agl-compositor',
187         srcs_agl_compositor,
188         dependencies: deps_libweston,
189         install: true
190 )
191
192 pkgconfig.generate(
193         filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
194         name: 'agl-compositor private protocols',
195         version: agl_compositor_version,
196         description: 'agl-compositor protocol files',
197         variables: [
198                 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
199                 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
200         ],
201         install_dir: dir_data_pc
202 )
203
204 install_data(
205         [ agl_shell_xml, agl_shell_desktop_xml ],
206         install_dir: join_paths(dir_data, dir_data_agl_compositor)
207 )