meson: dist pot file in tarball
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-plugins-bad', 'c', 'cpp',
2   version : '1.17.90',
3   meson_version : '>= 0.49',
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_dev = gst_version_minor % 2 == 1 and gst_version_micro < 90
18
19 glib_req = '>= 2.44.0'
20 orc_req = '>= 0.4.17'
21 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
22
23 api_version = '1.0'
24 soversion = 0
25 # maintaining compatibility with the previous libtool versioning
26 # current = minor * 100 + micro
27 curversion = gst_version_minor * 100 + gst_version_micro
28 libversion = '@0@.@1@.0'.format(soversion, curversion)
29 osxversion = curversion + 1
30
31 plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
32 plugins = []
33
34 cc = meson.get_compiler('c')
35 cxx = meson.get_compiler('cpp')
36 host_system = host_machine.system()
37
38 if host_system in ['ios', 'darwin']
39   have_objc = add_languages('objc', native: false)
40   have_objcpp = add_languages('objcpp', native: false)
41 else
42   have_objc = false
43   have_objcpp = false
44 endif
45
46 cdata = configuration_data()
47
48 if cc.get_id() == 'msvc'
49   # Ignore several spurious warnings for things gstreamer does very commonly
50   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
51   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
52   # NOTE: Only add warnings here if you are sure they're spurious
53   msvc_args = [
54       '/wd4018', # implicit signed/unsigned conversion
55       '/wd4146', # unary minus on unsigned (beware INT_MIN)
56       '/wd4244', # lossy type conversion (e.g. double -> int)
57       '/wd4305', # truncating type conversion (e.g. double -> float)
58       cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
59   ]
60   add_project_arguments(msvc_args, language : 'c')
61   add_project_arguments(msvc_args, language : 'cpp')
62   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
63   # are built with MinGW
64   noseh_link_args = ['/SAFESEH:NO']
65 else
66   if cxx.has_argument('-Wno-non-virtual-dtor')
67     add_project_arguments('-Wno-non-virtual-dtor', language: 'cpp')
68   endif
69
70   noseh_link_args = []
71 endif
72
73 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
74   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
75 endif
76
77 # Symbol visibility
78 if cc.get_id() == 'msvc'
79   export_define = '__declspec(dllexport) extern'
80 elif cc.has_argument('-fvisibility=hidden')
81   add_project_arguments('-fvisibility=hidden', language: 'c')
82   add_project_arguments('-fvisibility=hidden', language: 'cpp')
83   if have_objc
84     add_project_arguments('-fvisibility=hidden', language: 'objc')
85   endif
86   export_define = 'extern __attribute__ ((visibility ("default")))'
87 else
88   export_define = 'extern'
89 endif
90
91 # Passing this through the command line would be too messy
92 cdata.set('GST_API_EXPORT', export_define)
93
94 # Disable strict aliasing
95 if cc.has_argument('-fno-strict-aliasing')
96   add_project_arguments('-fno-strict-aliasing', language: 'c')
97 endif
98 if cxx.has_argument('-fno-strict-aliasing')
99   add_project_arguments('-fno-strict-aliasing', language: 'cpp')
100 endif
101
102 # Define G_DISABLE_DEPRECATED for development versions
103 if gst_version_is_dev
104   message('Disabling deprecated GLib API')
105   add_project_arguments('-DG_DISABLE_DEPRECATED', language: 'c')
106 endif
107
108 cast_checks = get_option('gobject-cast-checks')
109 if cast_checks.disabled() or (cast_checks.auto() and not gst_version_is_dev)
110   message('Disabling GLib cast checks')
111   add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: 'c')
112 endif
113
114 glib_asserts = get_option('glib-asserts')
115 if glib_asserts.disabled() or (glib_asserts.auto() and not gst_version_is_dev)
116   message('Disabling GLib asserts')
117   add_project_arguments('-DG_DISABLE_ASSERT', language: 'c')
118 endif
119
120 glib_checks = get_option('glib-checks')
121 if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev)
122   message('Disabling GLib checks')
123   add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
124 endif
125
126 check_headers = [
127   ['HAVE_DLFCN_H', 'dlfcn.h'],
128   ['HAVE_FCNTL_H', 'fcntl.h'],
129   ['HAVE_INTTYPES_H', 'inttypes.h'],
130   ['HAVE_MEMORY_H', 'memory.h'],
131   ['HAVE_NETINET_IN_H', 'netinet/in.h'],
132   ['HAVE_NETINET_IP_H', 'netinet/ip.h'],
133   ['HAVE_NETINET_TCP_H', 'netinet/tcp.h'],
134   ['HAVE_PTHREAD_H', 'pthread.h'],
135   ['HAVE_STDINT_H', 'stdint.h'],
136   ['HAVE_STDLIB_H', 'stdlib.h'],
137   ['HAVE_STRINGS_H', 'strings.h'],
138   ['HAVE_STRING_H', 'string.h'],
139   ['HAVE_SYS_PARAM_H', 'sys/param.h'],
140   ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
141   ['HAVE_SYS_STAT_H', 'sys/stat.h'],
142   ['HAVE_SYS_TIME_H', 'sys/time.h'],
143   ['HAVE_SYS_TYPES_H', 'sys/types.h'],
144   ['HAVE_SYS_UTSNAME_H', 'sys/utsname.h'],
145   ['HAVE_UNISTD_H', 'unistd.h'],
146   ['HAVE_WINDOWS_H', 'windows.h'],
147   ['HAVE_WINSOCK2_H', 'winsock2.h'],
148   ['HAVE_WS2TCPIP_H', 'ws2tcpip.h'],
149 ]
150
151 foreach h : check_headers
152   if cc.has_header(h.get(1))
153     cdata.set(h.get(0), 1)
154   endif
155 endforeach
156
157 check_functions = [
158   ['HAVE_DCGETTEXT', 'dcgettext'],
159   ['HAVE_GETPAGESIZE', 'getpagesize'],
160   ['HAVE_GMTIME_R', 'gmtime_r'],
161   ['HAVE_MMAP', 'mmap'],
162   ['HAVE_PIPE2', 'pipe2'],
163   ['HAVE_GETRUSAGE', 'getrusage', '#include<sys/resource.h>'],
164 ]
165
166 foreach f : check_functions
167   prefix = ''
168   if f.length() == 3
169     prefix = f.get(2)
170   endif
171   if cc.has_function(f.get(1), prefix: prefix)
172     cdata.set(f.get(0), 1)
173   endif
174 endforeach
175
176 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
177 cdata.set('SIZEOF_INT', cc.sizeof('int'))
178 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
179 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
180 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
181
182 cdata.set_quoted('VERSION', gst_version)
183 cdata.set_quoted('PACKAGE', 'gst-plugins-bad')
184 cdata.set_quoted('PACKAGE_VERSION', gst_version)
185 cdata.set_quoted('PACKAGE_BUGREPORT', 'https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/new')
186 cdata.set_quoted('PACKAGE_NAME', 'GStreamer Bad Plug-ins')
187 cdata.set_quoted('GETTEXT_PACKAGE', 'gst-plugins-bad-1.0')
188 cdata.set_quoted('GST_API_VERSION', api_version)
189 cdata.set_quoted('GST_LICENSE', 'LGPL')
190 cdata.set_quoted('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
191 cdata.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
192
193 warning_flags = [
194   '-Wmissing-declarations',
195   '-Wredundant-decls',
196   '-Wwrite-strings',
197   '-Wformat',
198   '-Wformat-security',
199   '-Winit-self',
200   '-Wmissing-include-dirs',
201   '-Waddress',
202   '-Wno-multichar',
203   '-Wvla',
204   '-Wpointer-arith',
205 ]
206
207 warning_c_flags = [
208   '-Wmissing-prototypes',
209   '-Wdeclaration-after-statement',
210   '-Wold-style-definition',
211 ]
212
213 warning_cxx_flags = [
214   '-Wformat-nonliteral',
215 ]
216
217 foreach extra_arg : warning_c_flags
218   if cc.has_argument (extra_arg)
219     add_project_arguments([extra_arg], language: 'c')
220   endif
221 endforeach
222
223 foreach extra_arg : warning_cxx_flags
224   if cxx.has_argument (extra_arg)
225     add_project_arguments([extra_arg], language: 'cpp')
226   endif
227 endforeach
228
229 foreach extra_arg : warning_flags
230   if cc.has_argument (extra_arg)
231     add_project_arguments([extra_arg], language: 'c')
232   endif
233   if cxx.has_argument (extra_arg)
234     add_project_arguments([extra_arg], language: 'cpp')
235   endif
236 endforeach
237
238 # GStreamer package name and origin url
239 gst_package_name = get_option('package-name')
240 if gst_package_name == ''
241   if gst_version_nano == 0
242     gst_package_name = 'GStreamer Bad Plug-ins source release'
243   elif gst_version_nano == 1
244     gst_package_name = 'GStreamer Bad Plug-ins git'
245   else
246     gst_package_name = 'GStreamer Bad Plug-ins prerelease'
247   endif
248 endif
249 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
250 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
251
252 # FIXME: This should be exposed as a configuration option
253 if host_system == 'linux'
254   cdata.set_quoted('DEFAULT_VIDEOSRC', 'v4l2src')
255 elif ['darwin', 'ios'].contains(host_system)
256   cdata.set_quoted('DEFAULT_VIDEOSRC', 'avfvideosrc')
257   cdata.set_quoted('GST_EXTRA_MODULE_SUFFIX', '.dylib')
258   # Yes, we set this for iOS too. Same as Autotools.
259   cdata.set('HAVE_OSX', 1)
260 else
261   cdata.set_quoted('DEFAULT_VIDEOSRC', 'videotestsrc')
262 endif
263
264 # Mandatory GST deps
265 gst_dep = dependency('gstreamer-1.0', version : gst_req,
266   fallback : ['gstreamer', 'gst_dep'])
267 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
268   fallback : ['gstreamer', 'gst_base_dep'])
269 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
270   fallback : ['gstreamer', 'gst_net_dep'])
271 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
272   fallback : ['gstreamer', 'gst_controller_dep'])
273
274 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
275     fallback : ['gst-plugins-base', 'pbutils_dep'])
276 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
277     fallback : ['gst-plugins-base', 'allocators_dep'])
278 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
279     fallback : ['gst-plugins-base', 'app_dep'])
280 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
281     fallback : ['gst-plugins-base', 'audio_dep'])
282 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
283     fallback : ['gst-plugins-base', 'fft_dep'])
284 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
285     fallback : ['gst-plugins-base', 'riff_dep'])
286 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
287     fallback : ['gst-plugins-base', 'rtp_dep'])
288 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
289     fallback : ['gst-plugins-base', 'rtsp_dep'])
290 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
291     fallback : ['gst-plugins-base', 'sdp_dep'])
292 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
293     fallback : ['gst-plugins-base', 'tag_dep'])
294 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
295     fallback : ['gst-plugins-base', 'video_dep'])
296 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
297     required : get_option('tests'),
298     fallback : ['gstreamer', 'gst_check_dep'])
299
300 # GStreamer OpenGL
301 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
302     fallback : ['gst-plugins-base', 'gstgl_dep'], required: get_option('gl'))
303 gstglproto_dep = dependency('gstreamer-gl-prototypes-1.0', version : gst_req,
304     fallback : ['gst-plugins-base', 'gstglproto_dep'], required: get_option('gl'))
305 gstglx11_dep = dependency('', required : false)
306 gstglwayland_dep = dependency('', required : false)
307 gstglegl_dep = dependency('', required : false)
308
309 if gstgl_dep.found()
310   if gstgl_dep.type_name() == 'pkgconfig'
311     gst_gl_apis = gstgl_dep.get_pkgconfig_variable('gl_apis').split()
312     gst_gl_winsys = gstgl_dep.get_pkgconfig_variable('gl_winsys').split()
313     gst_gl_platforms = gstgl_dep.get_pkgconfig_variable('gl_platforms').split()
314   else
315     gstbase = subproject('gst-plugins-base')
316     gst_gl_apis = gstbase.get_variable('enabled_gl_apis')
317     gst_gl_winsys = gstbase.get_variable('enabled_gl_winsys')
318     gst_gl_platforms = gstbase.get_variable('enabled_gl_platforms')
319   endif
320
321   message('GStreamer OpenGL window systems: @0@'.format(' '.join(gst_gl_winsys)))
322   message('GStreamer OpenGL platforms: @0@'.format(' '.join(gst_gl_platforms)))
323   message('GStreamer OpenGL apis: @0@'.format(' '.join(gst_gl_apis)))
324
325   foreach ws : ['x11', 'wayland', 'android', 'cocoa', 'eagl', 'win32', 'dispmanx', 'viv_fb']
326     set_variable('gst_gl_have_window_@0@'.format(ws), gst_gl_winsys.contains(ws))
327   endforeach
328
329   foreach p : ['glx', 'egl', 'cgl', 'eagl', 'wgl']
330     set_variable('gst_gl_have_platform_@0@'.format(p), gst_gl_platforms.contains(p))
331   endforeach
332
333   foreach api : ['gl', 'gles2']
334     set_variable('gst_gl_have_api_@0@'.format(api), gst_gl_apis.contains(api))
335   endforeach
336
337   # Behind specific checks because meson fails at optional dependencies with a
338   # fallback to the same subproject.  On the first failure, meson will never
339   # check the system again even if the fallback never existed.
340   # Last checked with meson 0.54.3
341   if gst_gl_have_window_x11
342     gstglx11_dep = dependency('gstreamer-gl-x11-1.0', version : gst_req,
343         fallback : ['gst-plugins-base', 'gstglx11_dep'], required: true)
344   endif
345   if gst_gl_have_window_wayland
346     gstglwayland_dep = dependency('gstreamer-gl-wayland-1.0', version : gst_req,
347         fallback : ['gst-plugins-base', 'gstglwayland_dep'], required: true)
348   endif
349   if gst_gl_have_platform_egl
350     gstglegl_dep = dependency('gstreamer-gl-egl-1.0', version : gst_req,
351         fallback : ['gst-plugins-base', 'gstglegl_dep'], required: true)
352   endif
353 endif
354
355 libm = cc.find_library('m', required : false)
356 glib_dep = dependency('glib-2.0', version : glib_req, fallback: ['glib', 'libglib_dep'])
357 gmodule_dep = dependency('gmodule-2.0', fallback: ['glib', 'libgmodule_dep'])
358 gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep'])
359 # gio-unix-2.0 is used by sys/bluez
360
361 # Optional dep of ext/gl and gst/librfb
362 x11_dep = dependency('x11', required : get_option('x11'))
363 if x11_dep.found()
364   cdata.set('HAVE_X11', 1)
365 endif
366
367 if host_machine.system() == 'windows'
368   winsock2 = [cc.find_library('ws2_32')]
369 else
370   winsock2 = []
371 endif
372
373 if ['darwin', 'ios'].contains(host_system)
374   if not have_objc
375     error('Building on MacOS/iOS/etc requires an ObjC compiler')
376   endif
377   if host_system == 'ios'
378     cdata.set('HAVE_IOS', 1)
379   endif
380
381   avfoundation_dep = dependency('AVFoundation', required : false)
382   if avfoundation_dep.found()
383       cdata.set('HAVE_AVFOUNDATION', 1)
384   endif
385
386   videotoolbox_dep = dependency('VideoToolbox', required : false)
387   if videotoolbox_dep.found()
388       cdata.set('HAVE_VIDEOTOOLBOX', 1)
389   endif
390
391 #  FIXME: framework.version() returns 'unknown'
392 #  if videotoolbox_dep.version().version_compare('>=10.9.6')
393 #    cdata.set('HAVE_VIDEOTOOLBOX_10_9_6', 1)
394 #  endif
395 endif
396
397 have_orcc = false
398 orcc_args = []
399 orc_targets = []
400 # Used by various libraries/elements that use Orc code
401 orc_dep = dependency('orc-0.4', version : orc_req, required : get_option('orc'),
402     fallback : ['orc', 'orc_dep'])
403 orcc = find_program('orcc', required : get_option('orc'))
404 if orc_dep.found() and orcc.found()
405   have_orcc = true
406   orcc_args = [orcc, '--include', 'glib.h']
407   cdata.set('HAVE_ORC', 1)
408 else
409   message('Orc Compiler not found or disabled, will use backup C code')
410   cdata.set('DISABLE_ORC', 1)
411 endif
412 cdata.set('GST_ENABLE_EXTRA_CHECKS', not get_option('extra-checks').disabled())
413
414 gnustl_dep = declare_dependency()
415 if host_system == 'android'
416   gnustl_dep = dependency('gnustl', required : false)
417 endif
418
419 # Disable compiler warnings for unused variables and args if gst debug system is disabled
420 if gst_dep.type_name() == 'internal'
421   gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
422 else
423   # We can't check that in the case of subprojects as we won't
424   # be able to build against an internal dependency (which is not built yet)
425   gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
426 endif
427
428 if gst_debug_disabled
429   message('GStreamer debug system is disabled')
430   if cc.has_argument('-Wno-unused')
431     add_project_arguments('-Wno-unused', language: 'c')
432   endif
433   if cxx.has_argument ('-Wno-unused')
434     add_project_arguments('-Wno-unused', language: 'cpp')
435   endif
436 else
437   message('GStreamer debug system is enabled')
438 endif
439
440 gst_plugins_bad_args = ['-DHAVE_CONFIG_H']
441 configinc = include_directories('.')
442 libsinc = include_directories('gst-libs')
443
444 python3 = import('python').find_installation()
445
446 gir = find_program('g-ir-scanner', required : get_option('introspection'))
447 gnome = import('gnome')
448 build_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled())
449 gir_init_section = [ '--add-init-section=extern void gst_init(gint*,gchar**);' + \
450     'g_setenv("GST_REGISTRY_1.0", "@0@", TRUE);'.format(meson.current_build_dir() + '/gir_empty_registry.reg') + \
451     'g_setenv("GST_PLUGIN_PATH_1_0", "", TRUE);' + \
452     'g_setenv("GST_PLUGIN_SYSTEM_PATH_1_0", "", TRUE);' + \
453     'gst_init(NULL,NULL);', '--quiet']
454
455 presetdir = join_paths(get_option('datadir'), 'gstreamer-' + api_version, 'presets')
456
457 pkgconfig = import('pkgconfig')
458 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
459 if get_option('default_library') == 'shared'
460   # If we don't build static plugins there is no need to generate pc files
461   plugins_pkgconfig_install_dir = disabler()
462 endif
463
464 subdir('gst-libs')
465 subdir('gst')
466 subdir('sys')
467 subdir('ext')
468 subdir('tests')
469 subdir('data')
470 subdir('tools')
471 subdir('pkgconfig')
472
473 if have_orcc
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 meson.version().version_compare('>= 0.52') and 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-bad.doap'))
508   if run_result.returncode() == 0
509     release_date = run_result.stdout().strip()
510     cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
511     message('Package release date: ' + release_date)
512   else
513     # Error out if our release can't be found in the .doap file
514     error(run_result.stderr())
515   endif
516 endif
517
518 configure_file(output : 'config.h', configuration : cdata)
519
520 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')
521
522 subdir('docs')
523
524 if meson.version().version_compare('>= 0.54')
525   plugin_names = []
526   foreach plugin: plugins
527     # FIXME: Use str.subtring() when we can depend on Meson 0.56
528     split = plugin.name().split('gst')
529     if split.length() == 2
530       plugin_names += [split[1]]
531     else
532       warning('Need substring API in meson >= 0.56 to properly parse plugin name: ' + plugin.name())
533       plugin_names += [plugin.name()]
534     endif
535   endforeach
536   summary({'Plugins':plugin_names}, list_sep: ', ')
537 endif