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