c4e5067c1b521247988b573d9d59ad2b1711a0d1
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-plugins-bad', 'c', 'cpp',
2   version : '1.15.0.1',
3   meson_version : '>= 0.46',
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
18 glib_req = '>= 2.40.0'
19 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
20
21 api_version = '1.0'
22 soversion = 0
23 # maintaining compatibility with the previous libtool versioning
24 # current = minor * 100 + micro
25 libversion = '@0@.@1@.0'.format(soversion, gst_version_minor * 100 + gst_version_micro)
26
27 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
28
29 cc = meson.get_compiler('c')
30 cxx = meson.get_compiler('cpp')
31
32 if cc.get_id() == 'msvc'
33   # Ignore several spurious warnings for things gstreamer does very commonly
34   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
35   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
36   # NOTE: Only add warnings here if you are sure they're spurious
37   msvc_args = [
38       '/wd4018', # implicit signed/unsigned conversion
39       '/wd4146', # unary minus on unsigned (beware INT_MIN)
40       '/wd4244', # lossy type conversion (e.g. double -> int)
41       '/wd4305', # truncating type conversion (e.g. double -> float)
42   ]
43   add_project_arguments(msvc_args, language : 'c')
44   add_project_arguments(msvc_args, language : 'cpp')
45   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
46   # are built with MinGW
47   noseh_link_args = ['/SAFESEH:NO']
48 else
49   if cxx.has_argument('-Wno-non-virtual-dtor')
50     add_project_arguments('-Wno-non-virtual-dtor', language: 'cpp')
51   endif
52
53   noseh_link_args = []
54 endif
55
56 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
57   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
58 endif
59
60 # Symbol visibility
61 if cc.has_argument('-fvisibility=hidden')
62   add_project_arguments('-fvisibility=hidden', language: 'c')
63 endif
64 if cxx.has_argument('-fvisibility=hidden')
65   add_project_arguments('-fvisibility=hidden', language: 'cpp')
66 endif
67
68 # Disable strict aliasing
69 if cc.has_argument('-fno-strict-aliasing')
70   add_project_arguments('-fno-strict-aliasing', language: 'c')
71 endif
72 if cxx.has_argument('-fno-strict-aliasing')
73   add_project_arguments('-fno-strict-aliasing', language: 'cpp')
74 endif
75
76 cdata = configuration_data()
77 check_headers = [
78   ['HAVE_DLFCN_H', 'dlfcn.h'],
79   ['HAVE_FCNTL_H', 'fcntl.h'],
80   ['HAVE_HIGHGUI_H', 'highgui.h'],
81   ['HAVE_INTTYPES_H', 'inttypes.h'],
82   ['HAVE_MEMORY_H', 'memory.h'],
83   ['HAVE_MSACM_H', 'msacm.h'],
84   ['HAVE_NETINET_IN_H', 'netinet/in.h'],
85   ['HAVE_NETINET_IP_H', 'netinet/ip.h'],
86   ['HAVE_NETINET_TCP_H', 'netinet/tcp.h'],
87   ['HAVE_OPENCV2_HIGHGUI_HIGHGUI_C_H', 'opencv2/highgui/highgui_c.h'],
88   ['HAVE_PTHREAD_H', 'pthread.h'],
89   ['HAVE_STDINT_H', 'stdint.h'],
90   ['HAVE_STDLIB_H', 'stdlib.h'],
91   ['HAVE_STRINGS_H', 'strings.h'],
92   ['HAVE_STRING_H', 'string.h'],
93   ['HAVE_SYS_PARAM_H', 'sys/param.h'],
94   ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
95   ['HAVE_SYS_STAT_H', 'sys/stat.h'],
96   ['HAVE_SYS_TIME_H', 'sys/time.h'],
97   ['HAVE_SYS_TYPES_H', 'sys/types.h'],
98   ['HAVE_SYS_UTSNAME_H', 'sys/utsname.h'],
99   ['HAVE_UNISTD_H', 'unistd.h'],
100   ['HAVE_WINDOWS_H', 'windows.h'],
101   ['HAVE_WINSOCK2_H', 'winsock2.h'],
102   ['HAVE_WS2TCPIP_H', 'ws2tcpip.h'],
103 ]
104
105 foreach h : check_headers
106   if cc.has_header(h.get(1))
107     cdata.set(h.get(0), 1)
108   endif
109 endforeach
110
111 check_functions = [
112 # check token HAVE_ACM
113 # check token HAVE_ANDROID_MEDIA
114 # check token HAVE_APEXSINK
115 # check token HAVE_APPLE_MEDIA
116 # check token HAVE_ASSRENDER
117 # check token HAVE_AVC
118 # check token HAVE_AVFOUNDATION
119 # check token HAVE_BLUEZ
120 # check token HAVE_BZ2
121 # check token HAVE_CFLOCALECOPYCURRENT
122 # check token HAVE_CFPREFERENCESCOPYAPPVALUE
123 # check token HAVE_CHROMAPRINT
124 # check token HAVE_CPU_ALPHA
125 # check token HAVE_CPU_ARM
126 # check token HAVE_CPU_CRIS
127 # check token HAVE_CPU_CRISV32
128 # check token HAVE_CPU_HPPA
129 # check token HAVE_CPU_I386
130 # check token HAVE_CPU_IA64
131 # check token HAVE_CPU_M68K
132 # check token HAVE_CPU_MIPS
133 # check token HAVE_CPU_PPC
134 # check token HAVE_CPU_PPC64
135 # check token HAVE_CPU_S390
136 # check token HAVE_CPU_SPARC
137 # check token HAVE_CPU_X86_64
138 # check token HAVE_CURL
139 # check token HAVE_DAALA
140 # check token HAVE_DASH
141 # check token HAVE_DC1394
142   ['HAVE_DCGETTEXT', 'dcgettext'],
143 # check token HAVE_DECKLINK
144 # check token HAVE_DIRECT3D
145 # check token HAVE_DIRECTDRAW
146 # check token HAVE_DIRECTFB
147 # check token HAVE_DIRECTSOUND
148 # check token HAVE_DOWHILE_MACROS
149 # check token HAVE_DTS
150 # check token HAVE_DVB
151 # check token HAVE_EXPERIMENTAL
152 # check token HAVE_EXTERNAL
153 # check token HAVE_FAAC
154 # check token HAVE_FAAD
155 # check token HAVE_FBDEV
156 # check token HAVE_FLITE
157 # check token HAVE_FLUIDSYNTH
158   ['HAVE_GETPAGESIZE', 'getpagesize'],
159 # check token HAVE_GETTEXT
160 # check token HAVE_GL
161 # check token HAVE_GLCHAR
162 # check token HAVE_GLEGLIMAGEOES
163 # check token HAVE_GLINTPTR
164 # check token HAVE_GLSIZEIPTR
165 # check token HAVE_GME
166   ['HAVE_GMTIME_R', 'gmtime_r'],
167 # check token HAVE_GRAPHENE
168 # check token HAVE_GSETTINGS
169 # check token HAVE_GSM
170 # check token HAVE_GUDEV
171 # check token HAVE_HLS
172 # check token HAVE_ICONV
173 # check token HAVE_IOS
174 # check token HAVE_JPEG
175 # check token HAVE_KATE
176 # check token HAVE_LADSPA
177 # check token HAVE_LIBGCRYPT
178 # check token HAVE_LIBGME_ACCURACY
179 # check token HAVE_LIBMMS
180 # check token HAVE_LIBNSL
181 # check token HAVE_LIBSOCKET
182 # check token HAVE_LIBUSB
183 # check token HAVE_LIBVISUAL
184 # check token HAVE_LINSYS
185 # check token HAVE_LRDF
186 # check token HAVE_LV2
187 # check token HAVE_MIMIC
188   ['HAVE_MMAP', 'mmap'],
189 # check token HAVE_MODPLUG
190 # check token HAVE_MPEG2ENC
191 # check token HAVE_MPG123
192 # check token HAVE_MPLEX
193 # check token HAVE_MUSEPACK
194 # check token HAVE_MYTHTV
195 # check token HAVE_NAS
196 # check token HAVE_NEON
197 # check token HAVE_NETTLE
198 # check token HAVE_OFA
199 # check token HAVE_OPENAL
200 # check token HAVE_OPENCV
201 # check token HAVE_OPENEXR
202 # check token HAVE_OPENJPEG
203 # check token HAVE_OPENJPEG_1
204 # check token HAVE_OPENNI2
205 # check token HAVE_OPENSLES
206 # check token HAVE_OPUS
207 # check token HAVE_ORC
208 # check token HAVE_OSX
209 # check token HAVE_OSX_VIDEO
210   ['HAVE_PIPE2', 'pipe2'],
211 # check token HAVE_PNG
212 # check token HAVE_PVR
213 # check token HAVE_QUICKTIME
214 # check token HAVE_RDTSC
215 # check token HAVE_RESINDVD
216 # check token HAVE_RSVG
217 # check token HAVE_RSVG_2_36_2
218 # check token HAVE_RTMP
219 # check token HAVE_SBC
220 # check token HAVE_SDL
221 # check token HAVE_SHM
222 # check token HAVE_SMOOTHSTREAMING
223 # check token HAVE_SNDFILE
224 # check token HAVE_SNDIO
225 # check token HAVE_SOUNDTOUCH
226 # check token HAVE_SOUNDTOUCH_1_4
227 # check token HAVE_SPANDSP
228 # check token HAVE_SPC
229 # check token HAVE_SRTP
230 # check token HAVE_SSH2
231 # check token HAVE_TELETEXTDEC
232 # check token HAVE_TIGER
233 # check token HAVE_TIMIDITY
234 # check token HAVE_UVCH264
235 # check token HAVE_VALGRIND
236 # check token HAVE_VCD
237 # check token HAVE_VDPAU
238 # check token HAVE_VIDEOTOOLBOX
239 # check token HAVE_VIDEOTOOLBOX_10_9_6
240 # check token HAVE_VOAACENC
241 # check token HAVE_VOAMRWBENC
242 # check token HAVE_WASAPI
243 # check token HAVE_WAYLAND
244 # check token HAVE_WEBP
245 # check token HAVE_WILDMIDI
246 # check token HAVE_WIN32
247 # check token HAVE_WININET
248 # check token HAVE_WINKS
249 # check token HAVE_WINSCREENCAP
250 # check token HAVE_XVID
251 # check token HAVE_ZBAR
252 ]
253
254 foreach f : check_functions
255   if cc.has_function(f.get(1))
256     cdata.set(f.get(0), 1)
257   endif
258 endforeach
259
260 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
261 cdata.set('SIZEOF_INT', cc.sizeof('int'))
262 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
263 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
264 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
265
266 cdata.set_quoted('VERSION', gst_version)
267 cdata.set_quoted('PACKAGE', 'gst-plugins-bad')
268 cdata.set_quoted('PACKAGE_VERSION', gst_version)
269 cdata.set_quoted('PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer')
270 cdata.set_quoted('PACKAGE_NAME', 'GStreamer Bad Plug-ins')
271 cdata.set_quoted('GETTEXT_PACKAGE', 'gst-plugins-bad-1.0')
272 cdata.set_quoted('GST_API_VERSION', api_version)
273 cdata.set_quoted('GST_LICENSE', 'LGPL')
274 cdata.set_quoted('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
275
276 warning_flags = [
277   '-Wmissing-declarations',
278   '-Wredundant-decls',
279   '-Wwrite-strings',
280   '-Wformat',
281   '-Wformat-security',
282   '-Winit-self',
283   '-Wmissing-include-dirs',
284   '-Waddress',
285   '-Wno-multichar',
286   '-Wvla',
287   '-Wpointer-arith',
288 ]
289
290 warning_c_flags = [
291   '-Wmissing-prototypes',
292   '-Wdeclaration-after-statement',
293   '-Wold-style-definition',
294   '-Wnested-externs',
295 ]
296
297 warning_cxx_flags = [
298   '-Wformat-nonliteral',
299 ]
300
301 foreach extra_arg : warning_c_flags
302   if cc.has_argument (extra_arg)
303     add_project_arguments([extra_arg], language: 'c')
304   endif
305 endforeach
306
307 foreach extra_arg : warning_cxx_flags
308   if cxx.has_argument (extra_arg)
309     add_project_arguments([extra_arg], language: 'cpp')
310   endif
311 endforeach
312
313 foreach extra_arg : warning_flags
314   if cc.has_argument (extra_arg)
315     add_project_arguments([extra_arg], language: 'c')
316   endif
317   if cxx.has_argument (extra_arg)
318     add_project_arguments([extra_arg], language: 'cpp')
319   endif
320 endforeach
321
322 # GStreamer package name and origin url
323 gst_package_name = get_option('package-name')
324 if gst_package_name == ''
325   if gst_version_nano == 0
326     gst_package_name = 'GStreamer Bad Plug-ins source release'
327   elif gst_version_nano == 1
328     gst_package_name = 'GStreamer Bad Plug-ins git'
329   else
330     gst_package_name = 'GStreamer Bad Plug-ins prerelease'
331   endif
332 endif
333 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
334 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
335
336 # FIXME: This should be exposed as a configuration option
337 host_system = host_machine.system()
338 if host_system == 'linux'
339   cdata.set_quoted('DEFAULT_VIDEOSRC', 'v4l2src')
340 elif host_system == 'osx'
341   cdata.set_quoted('DEFAULT_VIDEOSRC', 'avfvideosrc')
342 else
343   cdata.set_quoted('DEFAULT_VIDEOSRC', 'videotestsrc')
344 endif
345
346 if host_system == 'darwin'
347   cdata.set_quoted('GST_EXTRA_MODULE_SUFFIX', '.dylib')
348 endif
349
350 # Mandatory GST deps
351 gst_dep = dependency('gstreamer-1.0', version : gst_req,
352   fallback : ['gstreamer', 'gst_dep'])
353 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
354   fallback : ['gstreamer', 'gst_base_dep'])
355 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
356   fallback : ['gstreamer', 'gst_net_dep'])
357 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
358   fallback : ['gstreamer', 'gst_controller_dep'])
359
360 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
361     fallback : ['gst-plugins-base', 'pbutils_dep'])
362 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
363     fallback : ['gst-plugins-base', 'allocators_dep'])
364 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
365     fallback : ['gst-plugins-base', 'app_dep'])
366 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
367     fallback : ['gst-plugins-base', 'audio_dep'])
368 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
369     fallback : ['gst-plugins-base', 'fft_dep'])
370 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
371     fallback : ['gst-plugins-base', 'riff_dep'])
372 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
373     fallback : ['gst-plugins-base', 'rtp_dep'])
374 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
375     fallback : ['gst-plugins-base', 'rtsp_dep'])
376 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
377     fallback : ['gst-plugins-base', 'sdp_dep'])
378 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
379     fallback : ['gst-plugins-base', 'tag_dep'])
380 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
381     fallback : ['gst-plugins-base', 'video_dep'])
382 if host_machine.system() != 'windows'
383   gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
384     fallback : ['gstreamer', 'gst_check_dep'])
385 endif
386
387 # GStreamer OpenGL
388 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
389     fallback : ['gst-plugins-base', 'gstgl_dep'], required: false)
390
391 build_gstgl = gstgl_dep.found() # FIXME: add option?
392
393 if build_gstgl
394   if gstgl_dep.type_name() == 'pkgconfig'
395     gst_gl_apis = gstgl_dep.get_pkgconfig_variable('gl_apis').split()
396     gst_gl_winsys = gstgl_dep.get_pkgconfig_variable('gl_winsys').split()
397     gst_gl_platforms = gstgl_dep.get_pkgconfig_variable('gl_platforms').split()
398   else
399     gstbase = subproject('gst-plugins-base')
400     gst_gl_apis = gstbase.get_variable('enabled_gl_apis')
401     gst_gl_winsys = gstbase.get_variable('enabled_gl_winsys')
402     gst_gl_platforms = gstbase.get_variable('enabled_gl_platforms')
403   endif
404
405   message('GStreamer OpenGL window systems: @0@'.format(' '.join(gst_gl_winsys)))
406   message('GStreamer OpenGL platforms: @0@'.format(' '.join(gst_gl_platforms)))
407   message('GStreamer OpenGL apis: @0@'.format(' '.join(gst_gl_apis)))
408
409   foreach ws : ['x11', 'wayland', 'android', 'cocoa', 'eagl', 'win32', 'dispmanx', 'viv_fb']
410     set_variable('gst_gl_have_window_@0@'.format(ws), gst_gl_winsys.contains(ws))
411   endforeach
412
413   foreach p : ['glx', 'egl', 'cgl', 'eagl', 'wgl']
414     set_variable('gst_gl_have_platform_@0@'.format(p), gst_gl_platforms.contains(p))
415   endforeach
416
417   foreach api : ['opengl', 'gles2']
418     set_variable('gst_gl_have_api_@0@'.format(api), gst_gl_apis.contains(api))
419   endforeach
420 endif
421
422 libm = cc.find_library('m', required : false)
423 glib_dep = dependency('glib-2.0', version : glib_req,
424   fallback: ['glib', 'libglib_dep'])
425 gmodule_dep = dependency('gmodule-2.0',
426   fallback: ['glib', 'libgmodule_dep'])
427 gio_dep = dependency('gio-2.0',
428   fallback: ['glib', 'libgio_dep'])
429 x11_dep = dependency('x11', required : false)
430
431 # Used by dtls and hls
432 openssl_dep = dependency('openssl', version : '>= 1.0.1', required : false)
433
434 # Used by mpeg2enc and mplex
435 # mjpegtools upstream breaks API constantly and doesn't export the version in
436 # a header anywhere. The configure file has a lot of logic to support old
437 # versions, but it all seems untested and broken. Require 2.0.0. Can be changed
438 # if someone complains.
439 mjpegtools_dep = dependency('mjpegtools', version : '>=2.0.0', required : false)
440 mjpegtools_api = '0'
441 if mjpegtools_dep.found()
442   mjpegtools_api = '20000'
443 endif
444
445 if x11_dep.found()
446   cdata.set('HAVE_X11', 1)
447 endif
448
449 mathlib = cc.find_library('m', required : false)
450
451 if host_machine.system() == 'windows'
452   winsock2 = [cc.find_library('ws2_32')]
453 else
454   winsock2 = []
455 endif
456
457 have_orcc = false
458 orcc_args = []
459 if get_option('orc') != 'no'
460   need_orc = get_option('orc') == 'yes'
461   # Used by various libraries/elements that use Orc code
462   orc_dep = dependency('orc-0.4', required : need_orc)
463   orcc = find_program('orcc', required : need_orc)
464   if orc_dep.found() and orcc.found()
465     have_orcc = true
466     orcc_args = [orcc, '--include', 'glib.h']
467     cdata.set('HAVE_ORC', 1)
468   else
469     message('Orc Compiler not found, will use backup C code')
470     cdata.set('DISABLE_ORC', 1)
471   endif
472 else
473   cdata.set('DISABLE_ORC', 1)
474 endif
475
476 if gst_dep.type_name() == 'internal'
477   gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
478 else
479   # We can't check that in the case of subprojects as we won't
480   # be able to build against an internal dependency (which is not built yet)
481   gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
482 endif
483
484 if gst_debug_disabled and cc.has_argument('-Wno-unused')
485   add_project_arguments('-Wno-unused', language: 'c')
486 endif
487
488 gst_plugins_bad_args = ['-DHAVE_CONFIG_H']
489 configinc = include_directories('.')
490 libsinc = include_directories('gst-libs')
491
492 python3 = import('python3').find_python()
493
494 gir = find_program('g-ir-scanner', required : false)
495 gnome = import('gnome')
496 build_gir = gir.found() and not meson.is_cross_build() and get_option('introspection')
497 gir_init_section = [ '--add-init-section=extern void gst_init(gint*,gchar**);' + \
498     'g_setenv("GST_REGISTRY_1.0", "@0@", TRUE);'.format(meson.current_build_dir() + '/gir_empty_registry.reg') + \
499     'g_setenv("GST_PLUGIN_PATH_1_0", "", TRUE);' + \
500     'g_setenv("GST_PLUGIN_SYSTEM_PATH_1_0", "", TRUE);' + \
501     'gst_init(NULL,NULL);' ]
502
503 pkgconfig = import('pkgconfig')
504 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
505 if get_option('default_library') == 'shared'
506   # If we don't build static plugins there is no need to generate pc files
507   plugins_pkgconfig_install_dir = disabler()
508 endif
509
510 subdir('gst-libs')
511 subdir('gst')
512 subdir('sys')
513 subdir('ext')
514 subdir('tests')
515 subdir('pkgconfig')
516
517 configure_file(output : 'config.h', configuration : cdata)
518
519 # xgettext is optional (on Windows for instance)
520 if find_program('xgettext', required : false).found()
521   subdir('po')
522 endif
523
524 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')