db8792c25074ea28d95d4cbb2ee22a46169a0402
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-good / meson.build
1 project('gst-plugins-good', 'c',
2   version : '1.21.0.1',
3   meson_version : '>= 0.59',
4   default_options : [ 'warning_level=1',
5                       'buildtype=debugoptimized' ])
6
7 gst_version = meson.project_version()
8 version_arr = gst_version.split('.')
9 gst_version_major = version_arr[0].to_int()
10 gst_version_minor = version_arr[1].to_int()
11 gst_version_micro = version_arr[2].to_int()
12  if version_arr.length() == 4
13   gst_version_nano = version_arr[3].to_int()
14 else
15   gst_version_nano = 0
16 endif
17 gst_version_is_stable = gst_version_minor.is_even()
18 gst_version_is_dev = gst_version_minor.is_odd() and gst_version_micro < 90
19
20 have_cxx = add_languages('cpp', native: false, required: false)
21
22 glib_req = '>= 2.56.0'
23 orc_req = '>= 0.4.17'
24
25 if gst_version_is_stable
26   gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
27 else
28   gst_req = '>= ' + gst_version
29 endif
30
31 api_version = '1.0'
32
33 plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
34 plugins = []
35
36 cc = meson.get_compiler('c')
37 host_system = host_machine.system()
38
39 if cc.get_id() == 'msvc'
40   msvc_args = [
41       # Ignore several spurious warnings for things gstreamer does very commonly
42       # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
43       # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
44       # NOTE: Only add warnings here if you are sure they're spurious
45       '/wd4018', # implicit signed/unsigned conversion
46       '/wd4146', # unary minus on unsigned (beware INT_MIN)
47       '/wd4244', # lossy type conversion (e.g. double -> int)
48       '/wd4305', # truncating type conversion (e.g. double -> float)
49       cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
50   ]
51
52   if gst_version_is_dev
53     # Enable some warnings on MSVC to match GCC/Clang behaviour
54     msvc_args += cc.get_supported_arguments([
55       '/we4002', # too many actual parameters for macro 'identifier'
56       '/we4003', # not enough actual parameters for macro 'identifier'
57       '/we4013', # 'function' undefined; assuming extern returning int
58       '/we4020', # 'function' : too many actual parameters
59       '/we4027', # function declared without formal parameter list
60       '/we4029', # declared formal parameter list different from definition
61       '/we4033', # 'function' must return a value
62       '/we4045', # 'array' : array bounds overflow
63       '/we4047', # 'operator' : 'identifier1' differs in levels of indirection from 'identifier2'
64       '/we4053', # one void operand for '?:'
65       '/we4062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
66       '/we4098', # 'function' : void function returning a value
67       '/we4101', # 'identifier' : unreferenced local variable
68       '/we4189', # 'identifier' : local variable is initialized but not referenced
69     ])
70   endif
71   if have_cxx
72     add_project_arguments(msvc_args, language: ['c', 'cpp'])
73   else
74     add_project_arguments(msvc_args, language: 'c')
75   endif
76   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
77   # are built with MinGW
78   noseh_link_args = ['/SAFESEH:NO']
79 else
80   noseh_link_args = []
81 endif
82
83 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
84   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
85 endif
86
87 # Symbol visibility
88 if cc.has_argument('-fvisibility=hidden')
89   add_project_arguments('-fvisibility=hidden', language: 'c')
90 endif
91
92 # Disable strict aliasing
93 if cc.has_argument('-fno-strict-aliasing')
94   add_project_arguments('-fno-strict-aliasing', language: 'c')
95 endif
96
97 # Define G_DISABLE_DEPRECATED for development versions
98 if gst_version_is_dev
99   message('Disabling deprecated GLib API')
100   add_project_arguments('-DG_DISABLE_DEPRECATED', language: 'c')
101 endif
102
103 cast_checks = get_option('gobject-cast-checks')
104 if cast_checks.disabled() or (cast_checks.auto() and not gst_version_is_dev)
105   message('Disabling GLib cast checks')
106   add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: 'c')
107 endif
108
109 glib_asserts = get_option('glib-asserts')
110 if glib_asserts.disabled() or (glib_asserts.auto() and not gst_version_is_dev)
111   message('Disabling GLib asserts')
112   add_project_arguments('-DG_DISABLE_ASSERT', language: 'c')
113 endif
114
115 glib_checks = get_option('glib-checks')
116 if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev)
117   message('Disabling GLib checks')
118   add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
119 endif
120
121 cdata = configuration_data()
122
123 check_headers = [
124   ['HAVE_DLFCN_H', 'dlfcn.h'],
125   ['HAVE_FCNTL_H', 'fcntl.h'],
126   ['HAVE_INTTYPES_H', 'inttypes.h'],
127   ['HAVE_MEMORY_H', 'memory.h'],
128   ['HAVE_PROCESS_H', 'process.h'],
129   ['HAVE_STDINT_H', 'stdint.h'],
130   ['HAVE_STDLIB_H', 'stdlib.h'],
131   ['HAVE_STRINGS_H', 'strings.h'],
132   ['HAVE_STRING_H', 'string.h'],
133   ['HAVE_SYS_IOCTL_H', 'sys/ioctl.h'],
134   ['HAVE_SYS_PARAM_H', 'sys/param.h'],
135   ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
136   ['HAVE_SYS_STAT_H', 'sys/stat.h'],
137   ['HAVE_SYS_TIME_H', 'sys/time.h'],
138   ['HAVE_SYS_TYPES_H', 'sys/types.h'],
139   ['HAVE_UNISTD_H', 'unistd.h'],
140 ]
141
142 foreach h : check_headers
143   if cc.has_header(h.get(1))
144     cdata.set(h.get(0), 1)
145   endif
146 endforeach
147
148 check_functions = [
149   ['HAVE_ASINH', 'asinh', '#include<math.h>'],
150   ['HAVE_CLOCK_GETTIME', 'clock_gettime', '#include<time.h>'],
151   ['HAVE_COSH', 'cosh', '#include<math.h>'],
152 # check token HAVE_CPU_ALPHA
153 # check token HAVE_CPU_ARM
154 # check token HAVE_CPU_CRIS
155 # check token HAVE_CPU_CRISV32
156 # check token HAVE_CPU_HPPA
157 # check token HAVE_CPU_I386
158 # check token HAVE_CPU_IA64
159 # check token HAVE_CPU_M68K
160 # check token HAVE_CPU_MIPS
161 # check token HAVE_CPU_PPC
162 # check token HAVE_CPU_PPC64
163 # check token HAVE_CPU_S390
164 # check token HAVE_CPU_SPARC
165 # check token HAVE_CPU_X86_64
166   ['HAVE_DCGETTEXT', 'dcgettext', '#include<libintl.h>'],
167 # check token HAVE_DIRECTSOUND
168 # check token HAVE_EXPERIMENTAL
169 # check token HAVE_EXTERNAL
170 # check token HAVE_FPCLASS
171 # check token HAVE_GCC_ASM
172   ['HAVE_GETPAGESIZE', 'getpagesize', '#include<unistd.h>'],
173 # check token HAVE_GETTEXT
174 # check token HAVE_GST_V4L2
175   ['HAVE_ISINF', 'isinf', '#include<math.h>'],
176 # check token HAVE_LIBV4L2
177   ['HAVE_MMAP', 'mmap', '#include<sys/mman.h>'],
178   ['HAVE_MMAP64', 'mmap64', '#include<sys/mman.h>'],
179 # check token HAVE_OSX_AUDIO
180 # check token HAVE_OSX_VIDEO
181 # check token HAVE_RDTSC
182   ['HAVE_SINH', 'sinh', '#include<math.h>'],
183 # check token HAVE_WAVEFORM
184   ['HAVE_GMTIME_R', 'gmtime_r', '#include<time.h>'],
185 ]
186
187 libm = cc.find_library('m', required : false)
188
189 foreach f : check_functions
190   if cc.has_function(f.get(1), prefix : f.get(2), dependencies : libm)
191     cdata.set(f.get(0), 1)
192   endif
193 endforeach
194
195 cdata.set('HAVE_IOS', host_system == 'ios')
196
197 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
198 cdata.set('SIZEOF_INT', cc.sizeof('int'))
199 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
200 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
201 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
202 cdata.set('SIZEOF_OFF_T', cc.sizeof('off_t'))
203
204 have_rtld_noload = cc.has_header_symbol('dlfcn.h', 'RTLD_NOLOAD')
205 cdata.set('HAVE_RTLD_NOLOAD', have_rtld_noload)
206
207 # Here be fixmes.
208 # FIXME: check if this is correct
209 cdata.set('HAVE_CPU_X86_64', host_machine.cpu() == 'amd64')
210 cdata.set('HAVE_GCC_ASM', cc.get_id() != 'msvc')
211 cdata.set_quoted('VERSION', gst_version)
212 cdata.set_quoted('PACKAGE_VERSION', gst_version)
213 cdata.set_quoted('GST_LICENSE', 'LGPL')
214 cdata.set_quoted('PACKAGE', 'gst-plugins-good')
215 cdata.set_quoted('GETTEXT_PACKAGE', 'gst-plugins-good-1.0')
216 cdata.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
217
218 warning_flags = [
219   '-Wmissing-declarations',
220   '-Wredundant-decls',
221   '-Wwrite-strings',
222   '-Winit-self',
223   '-Wmissing-include-dirs',
224   '-Wno-multichar',
225   '-Wvla',
226   '-Wpointer-arith',
227 ]
228
229 warning_c_flags = [
230   '-Wmissing-prototypes',
231   '-Wdeclaration-after-statement',
232   '-Wold-style-definition',
233   '-Waggregate-return',
234 ]
235
236 if have_cxx
237   cxx = meson.get_compiler('cpp')
238 endif
239
240 foreach extra_arg : warning_flags
241   if cc.has_argument (extra_arg)
242     add_project_arguments([extra_arg], language: 'c')
243   endif
244   if have_cxx and cxx.has_argument (extra_arg)
245     add_project_arguments([extra_arg], language: 'cpp')
246   endif
247 endforeach
248
249 foreach extra_arg : warning_c_flags
250   if cc.has_argument (extra_arg)
251     add_project_arguments([extra_arg], language: 'c')
252   endif
253 endforeach
254
255 # GStreamer package name and origin url
256 gst_package_name = get_option('package-name')
257 if gst_package_name == ''
258   if gst_version_nano == 0
259     gst_package_name = 'GStreamer Good Plug-ins source release'
260   elif gst_version_nano == 1
261     gst_package_name = 'GStreamer Good Plug-ins git'
262   else
263     gst_package_name = 'GStreamer Good Plug-ins prerelease'
264   endif
265 endif
266 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
267 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
268
269 # Mandatory GST deps
270 gst_dep = dependency('gstreamer-1.0', version : gst_req,
271   fallback : ['gstreamer', 'gst_dep'])
272 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
273   fallback : ['gstreamer', 'gst_base_dep'])
274 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
275   fallback : ['gstreamer', 'gst_net_dep'])
276 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
277   fallback : ['gstreamer', 'gst_controller_dep'])
278 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
279   required : get_option('tests'),
280   fallback : ['gstreamer', 'gst_check_dep'])
281 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
282     fallback : ['gst-plugins-base', 'pbutils_dep'])
283 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
284     fallback : ['gst-plugins-base', 'allocators_dep'])
285 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
286     fallback : ['gst-plugins-base', 'app_dep'])
287 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
288     fallback : ['gst-plugins-base', 'audio_dep'])
289 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
290     fallback : ['gst-plugins-base', 'fft_dep'])
291 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
292     fallback : ['gst-plugins-base', 'riff_dep'])
293 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
294     fallback : ['gst-plugins-base', 'rtp_dep'])
295 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
296     fallback : ['gst-plugins-base', 'rtsp_dep'])
297 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
298     fallback : ['gst-plugins-base', 'sdp_dep'])
299 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
300     fallback : ['gst-plugins-base', 'tag_dep'])
301 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
302     fallback : ['gst-plugins-base', 'video_dep'])
303
304 # GStreamer OpenGL
305 # FIXME: automagic
306 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
307     fallback : ['gst-plugins-base', 'gstgl_dep'], required: false)
308 gstglproto_dep = dependency('', required : false)
309 gstglx11_dep = dependency('', required : false)
310 gstglwayland_dep = dependency('', required : false)
311 gstglegl_dep = dependency('', required : false)
312
313 have_gstgl = gstgl_dep.found()
314
315 if have_gstgl
316   if gstgl_dep.type_name() == 'pkgconfig'
317     gst_gl_apis = gstgl_dep.get_variable('gl_apis').split()
318     gst_gl_winsys = gstgl_dep.get_variable('gl_winsys').split()
319     gst_gl_platforms = gstgl_dep.get_variable('gl_platforms').split()
320   else
321     gstbase = subproject('gst-plugins-base')
322     gst_gl_apis = gstbase.get_variable('enabled_gl_apis')
323     gst_gl_winsys = gstbase.get_variable('enabled_gl_winsys')
324     gst_gl_platforms = gstbase.get_variable('enabled_gl_platforms')
325   endif
326
327   message('GStreamer OpenGL window systems: @0@'.format(' '.join(gst_gl_winsys)))
328   message('GStreamer OpenGL platforms: @0@'.format(' '.join(gst_gl_platforms)))
329   message('GStreamer OpenGL apis: @0@'.format(' '.join(gst_gl_apis)))
330
331   foreach ws : ['x11', 'wayland', 'android', 'cocoa', 'eagl', 'win32', 'dispmanx', 'viv_fb']
332     set_variable('gst_gl_have_window_@0@'.format(ws), gst_gl_winsys.contains(ws))
333   endforeach
334
335   foreach p : ['glx', 'egl', 'cgl', 'eagl', 'wgl']
336     set_variable('gst_gl_have_platform_@0@'.format(p), gst_gl_platforms.contains(p))
337   endforeach
338
339   foreach api : ['gl', 'gles2']
340     set_variable('gst_gl_have_api_@0@'.format(api), gst_gl_apis.contains(api))
341   endforeach
342
343   gstglproto_dep = dependency('gstreamer-gl-prototypes-1.0', version : gst_req,
344       fallback : ['gst-plugins-base', 'gstglproto_dep'], required: true)
345   # Behind specific checks because meson fails at optional dependencies with a
346   # fallback to the same subproject.  On the first failure, meson will never
347   # check the system again even if the fallback never existed.
348   # Last checked with meson 0.54.3
349   if gst_gl_have_window_x11
350     gstglx11_dep = dependency('gstreamer-gl-x11-1.0', version : gst_req,
351        fallback : ['gst-plugins-base', 'gstglx11_dep'], required: true)
352   endif
353   if gst_gl_have_window_wayland
354     gstglwayland_dep = dependency('gstreamer-gl-wayland-1.0', version : gst_req,
355         fallback : ['gst-plugins-base', 'gstglwayland_dep'], required: true)
356   endif
357   if gst_gl_have_platform_egl
358     gstglegl_dep = dependency('gstreamer-gl-egl-1.0', version : gst_req,
359         fallback : ['gst-plugins-base', 'gstglegl_dep'], required: true)
360   endif
361 endif
362
363 zlib_dep = dependency('zlib', required : false)
364 if not zlib_dep.found()
365   zlib_dep = cc.find_library('z', required : false)
366   if not zlib_dep.found() or not cc.has_header('zlib.h')
367     zlib_dep = subproject('zlib').get_variable('zlib_dep')
368   endif
369 endif
370 cdata.set('HAVE_ZLIB', true)
371
372 glib_deps = [dependency('glib-2.0', version : glib_req, fallback: ['glib', 'libglib_dep']),
373              dependency('gobject-2.0', fallback: ['glib', 'libgobject_dep'])]
374 gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep'])
375
376 gst_plugins_good_args = ['-DHAVE_CONFIG_H']
377 configinc = include_directories('.')
378 libsinc = include_directories('gst-libs')
379
380 have_orcc = false
381 orcc_args = []
382 orc_targets = []
383 # Used by various libraries/elements that use Orc code
384 orc_dep = dependency('orc-0.4', version : orc_req, required : get_option('orc'),
385     fallback : ['orc', 'orc_dep'])
386 orcc = find_program('orcc', required : get_option('orc'))
387 if orc_dep.found() and orcc.found()
388   have_orcc = true
389   orcc_args = [orcc, '--include', 'glib.h']
390   cdata.set('HAVE_ORC', 1)
391 else
392   message('Orc Compiler not found, will use backup C code')
393   cdata.set('DISABLE_ORC', 1)
394 endif
395
396 have_nasm = false
397 # FIXME: nasm path needs testing on non-Linux, esp. Windows
398 host_cpu = host_machine.cpu_family()
399 if host_cpu == 'x86_64'
400   if cc.get_define('__ILP32__') == '1'
401     message('Nasm disabled on x32')
402   else
403     asm_option = get_option('asm')
404     nasm = find_program('nasm', native: true, required: asm_option)
405     if nasm.found()
406       # We can't use the version: kwarg for find_program because old versions
407       # of nasm don't support --version
408       ret = run_command(nasm, '-v', check: false)
409       if ret.returncode() == 0
410         nasm_version = ret.stdout().strip().split()[2]
411         nasm_req = '>=2.13'
412         if nasm_version.version_compare(nasm_req)
413           message('nasm found on x86-64')
414           cdata.set('HAVE_NASM', 1)
415           have_nasm = true
416         else
417           if asm_option.enabled()
418             error('asm option is enabled, and nasm @0@ was found, but @1@ is required'.format(nasm_version, nasm_req))
419           endif
420           message('nasm @0@ was found, but @1@ is required'.format(nasm_version, nasm_req))
421         endif
422       else
423         if asm_option.enabled()
424           error('asm option is enabled, but nasm is not usable: @0@\n@1@'.format(ret.stdout(), ret.stderr()))
425         endif
426         message('nasm was found, but it\'s not usable')
427       endif
428       # Unset nasm to not be 'found'
429       if not have_nasm
430         nasm = disabler()
431       endif
432     endif
433   endif
434 endif
435
436 # Disable compiler warnings for unused variables and args if gst debug system is disabled
437 if gst_dep.type_name() == 'internal'
438   gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
439 else
440   # We can't check that in the case of subprojects as we won't
441   # be able to build against an internal dependency (which is not built yet)
442   gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
443 endif
444
445 if gst_debug_disabled
446   message('GStreamer debug system is disabled')
447   if cc.has_argument('-Wno-unused')
448     add_project_arguments('-Wno-unused', language: 'c')
449   endif
450   if have_cxx and cxx.has_argument ('-Wno-unused')
451     add_project_arguments('-Wno-unused', language: 'cpp')
452   endif
453 else
454   message('GStreamer debug system is enabled')
455 endif
456
457 presetdir = join_paths(get_option('datadir'), 'gstreamer-' + api_version, 'presets')
458
459 python3 = import('python').find_installation()
460 pkgconfig = import('pkgconfig')
461 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
462 if get_option('default_library') == 'shared'
463   # If we don't build static plugins there is no need to generate pc files
464   plugins_pkgconfig_install_dir = disabler()
465 endif
466
467 subdir('gst')
468 subdir('sys')
469 subdir('ext')
470 subdir('tests')
471 subdir('docs')
472
473 if have_orcc and orc_targets.length() > 0
474   update_orc_dist_files = find_program('scripts/update-orc-dist-files.py')
475
476   orc_update_targets = []
477   foreach t : orc_targets
478     orc_name = t.get('name')
479     orc_file = t.get('orc-source')
480     header = t.get('header')
481     source = t.get('source')
482     # alias_target() only works with build targets, so can't use run_target() here
483     orc_update_targets += [
484       custom_target('update-orc-@0@'.format(orc_name),
485         input: [header, source],
486         command: [update_orc_dist_files, orc_file, header, source],
487         output: ['@0@-dist.c'.format(orc_name)]) # not entirely true
488     ]
489   endforeach
490
491   if orc_update_targets.length() > 0
492     update_orc_dist_target = alias_target('update-orc-dist', orc_update_targets)
493   endif
494 endif
495
496 # xgettext is optional (on Windows for instance)
497 if find_program('xgettext', required : get_option('nls')).found()
498   cdata.set('ENABLE_NLS', 1)
499   subdir('po')
500 endif
501
502 subdir('scripts')
503
504 # Set release date
505 if gst_version_nano == 0
506   extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
507   run_result = run_command(extract_release_date, gst_version, files('gst-plugins-good.doap'), check: true)
508   release_date = run_result.stdout().strip()
509   cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
510   message('Package release date: ' + release_date)
511 endif
512
513 if gio_dep.version().version_compare('< 2.67.4')
514   cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
515 endif
516
517 configure_file(output : 'config.h', configuration : cdata)
518
519 plugin_names = []
520 foreach plugin: plugins
521   if plugin.name().startswith('gst')
522     plugin_names += [plugin.name().substring(3)]
523   else
524     plugin_names += [plugin.name()]
525   endif
526 endforeach
527
528 summary({
529     'Plugins': plugin_names,
530 }, list_sep: ', ')