xref: /aosp_15_r20/external/libva/va/meson.build (revision 54e60f844a168e9a219354de272cd517ee8cd4b7)
1version_cfg = configuration_data()
2version_cfg.set('VA_API_MAJOR_VERSION', va_api_major_version)
3version_cfg.set('VA_API_MINOR_VERSION', va_api_minor_version)
4version_cfg.set('VA_API_MICRO_VERSION', va_api_micro_version)
5version_cfg.set('VA_API_VERSION', va_api_version)
6
7version_file = configure_file(
8  input : 'va_version.h.in',
9  output : 'va_version.h',
10  configuration : version_cfg)
11
12libva_sources = [
13  'va.c',
14  'va_compat.c',
15  'va_str.c',
16  'va_trace.c',
17]
18
19libva_headers = [
20  'va.h',
21  'va_backend.h',
22  'va_backend_prot.h',
23  'va_backend_vpp.h',
24  'va_compat.h',
25  'va_dec_hevc.h',
26  'va_dec_jpeg.h',
27  'va_dec_vp8.h',
28  'va_dec_vp9.h',
29  'va_dec_av1.h',
30  'va_dec_vvc.h',
31  'va_drmcommon.h',
32  'va_egl.h',
33  'va_enc_hevc.h',
34  'va_enc_h264.h',
35  'va_enc_jpeg.h',
36  'va_enc_vp8.h',
37  'va_fei.h',
38  'va_fei_h264.h',
39  'va_fei_hevc.h',
40  'va_enc_mpeg2.h',
41  'va_enc_vp9.h',
42  'va_enc_av1.h',
43  'va_str.h',
44  'va_tpi.h',
45  'va_prot.h',
46  'va_vpp.h',
47  version_file,
48]
49
50# headers that have be copied for subprojects
51libva_headers_subproject = []
52
53libva_headers_priv = [
54  'sysdeps.h',
55  'va_internal.h',
56  'va_trace.h',
57]
58
59libva_sym = 'libva.syms'
60libva_sym_arg = '-Wl,-version-script,' + '@0@/@1@'.format(meson.current_source_dir(), libva_sym)
61
62libva_link_args = []
63libva_link_depends = []
64if cc.links('void vaCreateSurfaces_0_32_0(void) {} void vaCreateSurfaces() {}', name: '-Wl,--version-script', args: ['-shared', libva_sym_arg])
65  libva_link_args = libva_sym_arg
66  libva_link_depends = libva_sym
67endif
68
69install_headers(libva_headers, subdir : 'va')
70
71libva = shared_library(
72  'va',
73  sources : libva_sources +
74            libva_headers +
75            libva_headers_priv,
76  vs_module_defs : 'libva.def',
77  soversion : host_machine.system() == 'windows' ? '' : libva_lt_current,
78  version : libva_lt_version,
79  c_args : [ '-DSYSCONFDIR="' + sysconfdir + '"'] + ['-DVA_DRIVERS_PATH="' + driverdir + '"'],
80  include_directories : configinc,
81  link_args : libva_link_args,
82  link_depends : libva_link_depends,
83  install : true,
84  dependencies : [ dl_dep ])
85
86libva_dep = declare_dependency(
87  link_with : libva,
88  include_directories : configinc,
89  dependencies : [ dl_dep ])
90
91if WITH_DRM
92  libva_drm_sources = [
93    'drm/va_drm.c',
94    'drm/va_drm_auth.c',
95    'drm/va_drm_utils.c',
96  ]
97
98  libva_drm_headers = [
99    'drm/va_drm.h',
100  ]
101
102  libva_headers_subproject += libva_drm_headers
103
104  libva_drm_headers_priv = [
105    'drm/va_drm_auth.h',
106    'drm/va_drm_auth_x11.h',
107    'drm/va_drm_utils.h',
108  ]
109
110  deps = [ libdrm_dep ]
111
112  libva_drm_args = []
113  if WITH_X11
114    libva_drm_sources += [ 'drm/va_drm_auth_x11.c' ]
115    libva_drm_args += [
116      '-DHAVE_VA_X11',
117      '-DLIBVA_MAJOR_VERSION=@0@'.format(libva_major_version)
118    ]
119    deps += [ x11_dep ]
120  endif
121
122  install_headers(libva_drm_headers, subdir : 'va')
123
124  libva_drm = shared_library(
125    'va-drm',
126    sources : libva_drm_sources +
127              libva_drm_headers +
128              libva_drm_headers_priv,
129    soversion : libva_lt_current,
130    version : libva_lt_version,
131    install : true,
132    c_args : libva_drm_args,
133    dependencies : deps + [ libva_dep ])
134
135  libva_drm_dep = declare_dependency(
136    link_with : libva_drm,
137    include_directories : configinc,
138    dependencies : deps)
139endif
140
141if WITH_X11
142  libva_x11_sources = [
143    'x11/dri2_util.c',
144    'x11/va_dri2.c',
145    'x11/va_dri3.c',
146    'drm/va_drm_utils.c',
147    'x11/va_dricommon.c',
148    'x11/va_fglrx.c',
149    'x11/va_nvctrl.c',
150    'x11/va_x11.c',
151  ]
152
153  libva_dri_headers = [
154    'x11/va_dri2.h',
155    'x11/va_dri3.h',
156    'x11/va_dricommon.h',
157  ]
158
159  libva_x11_headers = ['va_x11.h'] + libva_dri_headers + ['va_trace.h']
160
161  libva_headers_subproject += libva_dri_headers
162
163  libva_x11_headers_priv = [
164    'x11/va_dri2str.h',
165    'x11/va_dri2tokens.h',
166    'x11/va_dri3.h',
167    'x11/va_fglrx.h',
168    'x11/va_nvctrl.h',
169  ]
170
171  install_headers(libva_x11_headers, subdir : 'va')
172
173  deps = [ libdrm_dep, x11_dep, xext_dep, xfixes_dep, x11_xcb_dep, xcb_dep, xcb_dri3_dep, libva_dep ]
174
175  libva_x11 = shared_library(
176    'va-x11',
177    sources : libva_x11_sources +
178              libva_x11_headers +
179              libva_x11_headers_priv,
180    soversion : libva_lt_current,
181    version : libva_lt_version,
182    install : true,
183    dependencies : deps)
184
185  libva_x11_dep = declare_dependency(
186    link_with : libva_x11,
187    include_directories : configinc,
188    dependencies : deps)
189endif
190
191if WITH_GLX
192  libva_glx_sources = [
193    'glx/va_glx.c',
194    'glx/va_glx_impl.c',
195  ]
196
197  libva_glx_headers = [
198    'glx/va_backend_glx.h',
199    'glx/va_glx.h',
200  ]
201
202  libva_headers_subproject += libva_glx_headers
203
204  libva_glx_headers_priv = [
205    'glx/va_glx_impl.h',
206    'glx/va_glx_private.h',
207  ]
208
209  install_headers(libva_glx_headers, subdir : 'va')
210
211  deps = [ gl_dep, libva_x11_dep ]
212
213  libva_glx = shared_library(
214    'va-glx',
215    sources : libva_glx_sources +
216              libva_glx_headers +
217              libva_glx_headers_priv,
218    soversion : libva_lt_current,
219    version : libva_lt_version,
220    install : true,
221    dependencies : deps)
222
223  libva_glx_dep = declare_dependency(
224    link_with : libva_glx,
225    include_directories : configinc,
226    dependencies : deps)
227endif
228
229if WITH_WAYLAND
230  libva_wayland_sources = [
231    'wayland/va_wayland.c',
232    'wayland/va_wayland_linux_dmabuf.c',
233    'wayland/va_wayland_drm.c',
234    'wayland/va_wayland_emgd.c',
235    'drm/va_drm_utils.c',
236  ]
237
238  libva_wayland_headers = [
239    'wayland/va_backend_wayland.h',
240    'wayland/va_wayland.h',
241  ]
242
243  libva_headers_subproject += libva_wayland_headers
244
245  libva_wayland_headers_priv = [
246    'wayland/va_wayland_linux_dmabuf.h',
247    'wayland/va_wayland_drm.h',
248    'wayland/va_wayland_emgd.h',
249    'wayland/va_wayland_private.h',
250  ]
251
252  # XXX: grab linux-dmabuf-v1.xml from wayland-protocols
253  protocols = {
254    'wayland-drm': 'wayland/wayland-drm.xml',
255    'linux-dmabuf-v1': 'wayland/linux-dmabuf-v1.xml',
256  }
257
258  protocol_files = []
259  foreach name, xml : protocols
260    protocol_files += custom_target(
261      name + '-client-protocol.c',
262      output : name + '-client-protocol.c',
263      input : xml,
264      command : [wl_scanner, 'private-code', '@INPUT@', '@OUTPUT@'])
265    protocol_files += custom_target(
266      name + '-client-protocol.h',
267      output : name + '-client-protocol.h',
268      input : xml,
269      command : [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'])
270  endforeach
271
272  install_headers(libva_wayland_headers, subdir : 'va')
273
274  deps = [ libdrm_dep, wayland_dep, libva_dep ]
275
276  libva_wayland = shared_library(
277    'va-wayland',
278    sources : libva_wayland_sources +
279              libva_wayland_headers +
280              libva_wayland_headers_priv +
281              protocol_files,
282    soversion : libva_lt_current,
283    version : libva_lt_version,
284    install : true,
285    dependencies : deps)
286
287  libva_wayland_dep = declare_dependency(
288    link_with : libva_wayland,
289    include_directories : configinc,
290    dependencies : deps)
291endif
292
293fs = import('fs')
294if WITH_WIN32
295  libva_win32_sources = [
296    'win32/va_win32.c',
297  ]
298
299  libva_win32_headers = [
300    'win32/va_win32.h',
301  ]
302
303  libva_headers_subproject += libva_win32_headers
304
305  deps = [ libwin32_dep, libva_dep ]
306
307  libva_win32_args = [
308    '-DLIBVA_MAJOR_VERSION=@0@'.format(libva_major_version)
309  ]
310
311  install_headers(libva_win32_headers, subdir : 'va')
312
313  libva_win32 = shared_library(
314    'va_win32',
315    sources : libva_win32_sources +
316              libva_win32_headers,
317    soversion : host_machine.system() == 'windows' ? '' : libva_lt_current,
318    version : libva_lt_version,
319    install : true,
320    c_args : libva_win32_args,
321    vs_module_defs : 'libva_win32.def',
322    dependencies : deps)
323
324  libva_win32_dep = declare_dependency(
325    link_with : libva_win32,
326    include_directories : configinc,
327    dependencies : deps)
328endif
329
330foreach header : libva_headers_subproject
331  if meson.version().version_compare('>= 0.64')
332    fs.copyfile(header)
333  else
334    configure_file(output: fs.name(header), input: header, copy: true)
335  endif
336endforeach
337