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