meson: Allow using glib as a subproject
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-plugins-bad', 'c', 'cpp',
2   version : '1.13.0.1',
3   meson_version : '>= 0.40.1',
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]
10 gst_version_minor = version_arr[1]
11 gst_version_micro = version_arr[2]
12 if version_arr.length() == 4
13   gst_version_nano = version_arr[3]
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.to_int() * 100 + gst_version_micro.to_int())
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 cdata = configuration_data()
57 check_headers = [
58   ['HAVE_DLFCN_H', 'dlfcn.h'],
59   ['HAVE_FCNTL_H', 'fcntl.h'],
60   ['HAVE_HIGHGUI_H', 'highgui.h'],
61   ['HAVE_INTTYPES_H', 'inttypes.h'],
62   ['HAVE_MEMORY_H', 'memory.h'],
63   ['HAVE_MSACM_H', 'msacm.h'],
64   ['HAVE_NETINET_IN_H', 'netinet/in.h'],
65   ['HAVE_NETINET_IP_H', 'netinet/ip.h'],
66   ['HAVE_NETINET_TCP_H', 'netinet/tcp.h'],
67   ['HAVE_OPENCV2_HIGHGUI_HIGHGUI_C_H', 'opencv2/highgui/highgui_c.h'],
68   ['HAVE_PTHREAD_H', 'pthread.h'],
69   ['HAVE_STDINT_H', 'stdint.h'],
70   ['HAVE_STDLIB_H', 'stdlib.h'],
71   ['HAVE_STRINGS_H', 'strings.h'],
72   ['HAVE_STRING_H', 'string.h'],
73   ['HAVE_SYS_PARAM_H', 'sys/param.h'],
74   ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
75   ['HAVE_SYS_STAT_H', 'sys/stat.h'],
76   ['HAVE_SYS_TIME_H', 'sys/time.h'],
77   ['HAVE_SYS_TYPES_H', 'sys/types.h'],
78   ['HAVE_SYS_UTSNAME_H', 'sys/utsname.h'],
79   ['HAVE_UNISTD_H', 'unistd.h'],
80   ['HAVE_WINDOWS_H', 'windows.h'],
81   ['HAVE_WINSOCK2_H', 'winsock2.h'],
82   ['HAVE_WS2TCPIP_H', 'ws2tcpip.h'],
83 ]
84
85 foreach h : check_headers
86   if cc.has_header(h.get(1))
87     cdata.set(h.get(0), 1)
88   endif
89 endforeach
90
91 check_functions = [
92 # check token HAVE_ACM
93 # check token HAVE_ANDROID_MEDIA
94 # check token HAVE_APEXSINK
95 # check token HAVE_APPLE_MEDIA
96 # check token HAVE_ASSRENDER
97 # check token HAVE_AVC
98 # check token HAVE_AVFOUNDATION
99 # check token HAVE_BLUEZ
100 # check token HAVE_BZ2
101 # check token HAVE_CFLOCALECOPYCURRENT
102 # check token HAVE_CFPREFERENCESCOPYAPPVALUE
103 # check token HAVE_CHROMAPRINT
104 # check token HAVE_CPU_ALPHA
105 # check token HAVE_CPU_ARM
106 # check token HAVE_CPU_CRIS
107 # check token HAVE_CPU_CRISV32
108 # check token HAVE_CPU_HPPA
109 # check token HAVE_CPU_I386
110 # check token HAVE_CPU_IA64
111 # check token HAVE_CPU_M68K
112 # check token HAVE_CPU_MIPS
113 # check token HAVE_CPU_PPC
114 # check token HAVE_CPU_PPC64
115 # check token HAVE_CPU_S390
116 # check token HAVE_CPU_SPARC
117 # check token HAVE_CPU_X86_64
118 # check token HAVE_CURL
119 # check token HAVE_DAALA
120 # check token HAVE_DASH
121 # check token HAVE_DC1394
122   ['HAVE_DCGETTEXT', 'dcgettext'],
123 # check token HAVE_DECKLINK
124 # check token HAVE_DIRECT3D
125 # check token HAVE_DIRECTDRAW
126 # check token HAVE_DIRECTFB
127 # check token HAVE_DIRECTSOUND
128 # check token HAVE_DOWHILE_MACROS
129 # check token HAVE_DTS
130 # check token HAVE_DVB
131 # check token HAVE_EXPERIMENTAL
132 # check token HAVE_EXTERNAL
133 # check token HAVE_FAAC
134 # check token HAVE_FAAD
135 # check token HAVE_FBDEV
136 # check token HAVE_FLITE
137 # check token HAVE_FLUIDSYNTH
138   ['HAVE_GETPAGESIZE', 'getpagesize'],
139 # check token HAVE_GETTEXT
140 # check token HAVE_GL
141 # check token HAVE_GLCHAR
142 # check token HAVE_GLEGLIMAGEOES
143 # check token HAVE_GLINTPTR
144 # check token HAVE_GLSIZEIPTR
145 # check token HAVE_GME
146   ['HAVE_GMTIME_R', 'gmtime_r'],
147 # check token HAVE_GRAPHENE
148 # check token HAVE_GSETTINGS
149 # check token HAVE_GSM
150 # check token HAVE_GUDEV
151 # check token HAVE_HLS
152 # check token HAVE_ICONV
153 # check token HAVE_IOS
154 # check token HAVE_JPEG
155 # check token HAVE_KATE
156 # check token HAVE_LADSPA
157 # check token HAVE_LIBGCRYPT
158 # check token HAVE_LIBGME_ACCURACY
159 # check token HAVE_LIBMMS
160 # check token HAVE_LIBNSL
161 # check token HAVE_LIBSOCKET
162 # check token HAVE_LIBUSB
163 # check token HAVE_LIBVISUAL
164 # check token HAVE_LINSYS
165 # check token HAVE_LRDF
166 # check token HAVE_LV2
167 # check token HAVE_MIMIC
168   ['HAVE_MMAP', 'mmap'],
169 # check token HAVE_MODPLUG
170 # check token HAVE_MPEG2ENC
171 # check token HAVE_MPG123
172 # check token HAVE_MPLEX
173 # check token HAVE_MUSEPACK
174 # check token HAVE_MYTHTV
175 # check token HAVE_NAS
176 # check token HAVE_NEON
177 # check token HAVE_NETTLE
178 # check token HAVE_OFA
179 # check token HAVE_OPENAL
180 # check token HAVE_OPENCV
181 # check token HAVE_OPENEXR
182 # check token HAVE_OPENJPEG
183 # check token HAVE_OPENJPEG_1
184 # check token HAVE_OPENNI2
185 # check token HAVE_OPENSLES
186 # check token HAVE_OPUS
187 # check token HAVE_ORC
188 # check token HAVE_OSX
189 # check token HAVE_OSX_VIDEO
190 # check token HAVE_PNG
191 # check token HAVE_PVR
192 # check token HAVE_QUICKTIME
193 # check token HAVE_RDTSC
194 # check token HAVE_RESINDVD
195 # check token HAVE_RSVG
196 # check token HAVE_RSVG_2_36_2
197 # check token HAVE_RTMP
198 # check token HAVE_SBC
199 # check token HAVE_SCHRO
200 # check token HAVE_SDL
201 # check token HAVE_SHM
202 # check token HAVE_SMOOTHSTREAMING
203 # check token HAVE_SNDFILE
204 # check token HAVE_SNDIO
205 # check token HAVE_SOUNDTOUCH
206 # check token HAVE_SOUNDTOUCH_1_4
207 # check token HAVE_SPANDSP
208 # check token HAVE_SPC
209 # check token HAVE_SRTP
210 # check token HAVE_SSH2
211 # check token HAVE_TELETEXTDEC
212 # check token HAVE_TIGER
213 # check token HAVE_TIMIDITY
214 # check token HAVE_UVCH264
215 # check token HAVE_VALGRIND
216 # check token HAVE_VCD
217 # check token HAVE_VDPAU
218 # check token HAVE_VIDEOTOOLBOX
219 # check token HAVE_VIDEOTOOLBOX_10_9_6
220 # check token HAVE_VOAACENC
221 # check token HAVE_VOAMRWBENC
222 # check token HAVE_WASAPI
223 # check token HAVE_WAYLAND
224 # check token HAVE_WEBP
225 # check token HAVE_WILDMIDI
226 # check token HAVE_WIN32
227 # check token HAVE_WININET
228 # check token HAVE_WINKS
229 # check token HAVE_WINSCREENCAP
230 # check token HAVE_XVID
231 # check token HAVE_ZBAR
232 ]
233
234 foreach f : check_functions
235   if cc.has_function(f.get(1))
236     cdata.set(f.get(0), 1)
237   endif
238 endforeach
239
240 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
241 cdata.set('SIZEOF_INT', cc.sizeof('int'))
242 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
243 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
244 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
245
246 cdata.set('VERSION', '"@0@"'.format(gst_version))
247 cdata.set('PACKAGE', '"gst-plugins-bad"')
248 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
249 cdata.set('PACKAGE_BUGREPORT', '"http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer"')
250 cdata.set('PACKAGE_NAME', '"GStreamer Bad Plug-ins"')
251 cdata.set('GETTEXT_PACKAGE', '"gst-plugins-bad-1.0"')
252 cdata.set('GST_API_VERSION', '"@0@"'.format(api_version))
253 cdata.set('GST_LICENSE', '"LGPL"')
254 cdata.set('LIBDIR', '"@0@"'.format(get_option('libdir')))
255
256 # GStreamer package name and origin url
257 gst_package_name = get_option('with-package-name')
258 if gst_package_name == ''
259   if gst_version_nano == 0
260     gst_package_name = 'GStreamer Bad Plug-ins source release'
261   elif gst_version_nano == 1
262     gst_package_name = 'GStreamer Bad Plug-ins git'
263   else
264     gst_package_name = 'GStreamer Bad Plug-ins prerelease'
265   endif
266 endif
267 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
268 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('with-package-origin'))
269
270 # FIXME: This should be exposed as a configuration option
271 host_system = host_machine.system()
272 if host_system == 'linux'
273   cdata.set('DEFAULT_VIDEOSRC', '"v4l2src"')
274 elif host_system == 'osx'
275   cdata.set('DEFAULT_VIDEOSRC', '"avfvideosrc"')
276 else
277   cdata.set('DEFAULT_VIDEOSRC', '"videotestsrc"')
278 endif
279
280 # Mandatory GST deps
281 gst_dep = dependency('gstreamer-1.0', version : gst_req,
282   fallback : ['gstreamer', 'gst_dep'])
283 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
284   fallback : ['gstreamer', 'gst_base_dep'])
285 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
286   fallback : ['gstreamer', 'gst_net_dep'])
287 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
288   fallback : ['gstreamer', 'gst_controller_dep'])
289
290 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
291     fallback : ['gst-plugins-base', 'pbutils_dep'])
292 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
293     fallback : ['gst-plugins-base', 'allocators_dep'])
294 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
295     fallback : ['gst-plugins-base', 'app_dep'])
296 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
297     fallback : ['gst-plugins-base', 'audio_dep'])
298 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
299     fallback : ['gst-plugins-base', 'fft_dep'])
300 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
301     fallback : ['gst-plugins-base', 'riff_dep'])
302 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
303     fallback : ['gst-plugins-base', 'rtp_dep'])
304 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
305     fallback : ['gst-plugins-base', 'rtsp_dep'])
306 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
307     fallback : ['gst-plugins-base', 'sdp_dep'])
308 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
309     fallback : ['gst-plugins-base', 'tag_dep'])
310 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
311     fallback : ['gst-plugins-base', 'video_dep'])
312 if host_machine.system() != 'windows'
313   gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
314     fallback : ['gstreamer', 'gst_check_dep'])
315 endif
316
317 libm = cc.find_library('m', required : false)
318 glib_dep = dependency('glib-2.0', version : glib_req,
319   fallback: ['glib', 'libglib_dep'])
320 gmodule_dep = dependency('gmodule-2.0',
321   fallback: ['glib', 'libgmodule_dep'])
322 gio_dep = dependency('gio-2.0',
323   fallback: ['glib', 'libgio_dep'])
324 x11_dep = dependency('x11', required : false)
325
326 # Used by dtls and hls
327 openssl_dep = dependency('openssl', version : '>= 1.0.1', required : false)
328
329 # Used by mpeg2enc and mplex
330 # mjpegtools upstream breaks API constantly and doesn't export the version in
331 # a header anywhere. The configure file has a lot of logic to support old
332 # versions, but it all seems untested and broken. Require 2.0.0. Can be changed
333 # if someone complains.
334 mjpegtools_dep = dependency('mjpegtools', version : '>=2.0.0', required : false)
335 mjpegtools_api = '0'
336 if mjpegtools_dep.found()
337   mjpegtools_api = '20000'
338 endif
339
340 if x11_dep.found()
341   cdata.set('HAVE_X11', 1)
342 endif
343
344 mathlib = cc.find_library('m', required : false)
345
346 if host_machine.system() == 'windows'
347   winsock2 = [cc.find_library('ws2_32')]
348 else
349   winsock2 = []
350 endif
351
352 have_orcc = false
353 orcc_args = []
354 if get_option('use_orc') != 'no'
355   need_orc = get_option('use_orc') == 'yes'
356   # Used by various libraries/elements that use Orc code
357   orc_dep = dependency('orc-0.4', required : need_orc)
358   orcc = find_program('orcc', required : need_orc)
359   if orc_dep.found() and orcc.found()
360     have_orcc = true
361     orcc_args = [orcc, '--include', 'glib.h']
362     cdata.set('HAVE_ORC', 1)
363   else
364     message('Orc Compiler not found, will use backup C code')
365     cdata.set('DISABLE_ORC', 1)
366   endif
367 else
368   cdata.set('DISABLE_ORC', 1)
369 endif
370
371 if gst_dep.type_name() == 'internal'
372     gst_proj = subproject('gstreamer')
373
374     if gst_proj.get_variable('disable_gst_debug')
375         message('GStreamer debug system is disabled')
376         add_project_arguments('-Wno-unused', language: 'c')
377     else
378         message('GStreamer debug system is enabled')
379     endif
380 else
381     # We can't check that in the case of subprojects as we won't
382     # be able to build against an internal dependency (which is not built yet)
383     if not cc.compiles('''
384 #include <gst/gstconfig.h>
385 #ifdef GST_DISABLE_GST_DEBUG
386 #error "debugging disabled, make compiler fail"
387 #endif''' , dependencies: gst_dep)
388         message('GStreamer debug system is disabled')
389         add_global_arguments('-Wno-unused', language: 'c')
390     else
391         message('GStreamer debug system is enabled')
392     endif
393 endif
394
395 configure_file(output : 'config.h', configuration : cdata)
396
397 gst_plugins_bad_args = ['-DHAVE_CONFIG_H']
398 configinc = include_directories('.')
399 libsinc = include_directories('gst-libs')
400
401 vs_module_defs_dir = meson.current_source_dir() + '/win32/common/'
402
403 # Used by the *_mkenum.py helper scripts
404 glib_mkenums = find_program('glib-mkenums')
405
406 gir = find_program('g-ir-scanner', required : false)
407 gnome = import('gnome')
408 build_gir = gir.found() and not meson.is_cross_build() and not get_option('disable_introspection')
409 gir_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);' ]
414 subdir('gst-libs')
415 subdir('gst')
416 subdir('sys')
417 subdir('ext')
418 subdir('tests')
419 subdir('pkgconfig')
420
421 python3 = find_program('python3')
422 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')