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