meson: Add feature options for all plugins
[platform/upstream/gst-plugins-good.git] / meson.build
1 project('gst-plugins-good', 'c',
2   version : '1.15.0.1',
3   meson_version : '>= 0.47',
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 # FIXME: automagic
19 have_cxx = add_languages('cpp', required : false)
20
21 glib_req = '>= 2.40.0'
22 orc_req = '>= 0.4.17'
23 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
24
25 api_version = '1.0'
26
27 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
28
29 cc = meson.get_compiler('c')
30 host_system = host_machine.system()
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   add_project_arguments(
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       language : 'c')
43   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
44   # are built with MinGW
45   noseh_link_args = ['/SAFESEH:NO']
46 else
47   noseh_link_args = []
48 endif
49
50 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
51   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
52 endif
53
54 # Symbol visibility
55 if cc.has_argument('-fvisibility=hidden')
56   add_project_arguments('-fvisibility=hidden', language: 'c')
57 endif
58
59 # Disable strict aliasing
60 if cc.has_argument('-fno-strict-aliasing')
61   add_project_arguments('-fno-strict-aliasing', language: 'c')
62 endif
63
64 cdata = configuration_data()
65
66 check_headers = [
67   ['HAVE_DLFCN_H', 'dlfcn.h'],
68   ['HAVE_FCNTL_H', 'fcntl.h'],
69   ['HAVE_INTTYPES_H', 'inttypes.h'],
70   ['HAVE_MEMORY_H', 'memory.h'],
71   ['HAVE_PROCESS_H', 'process.h'],
72   ['HAVE_STDINT_H', 'stdint.h'],
73   ['HAVE_STDLIB_H', 'stdlib.h'],
74   ['HAVE_STRINGS_H', 'strings.h'],
75   ['HAVE_STRING_H', 'string.h'],
76   ['HAVE_SYS_IOCTL_H', 'sys/ioctl.h'],
77   ['HAVE_SYS_PARAM_H', 'sys/param.h'],
78   ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
79   ['HAVE_SYS_STAT_H', 'sys/stat.h'],
80   ['HAVE_SYS_TIME_H', 'sys/time.h'],
81   ['HAVE_SYS_TYPES_H', 'sys/types.h'],
82   ['HAVE_UNISTD_H', 'unistd.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   ['HAVE_ASINH', 'asinh', '#include<math.h>'],
93   ['HAVE_CLOCK_GETTIME', 'clock_gettime', '#include<time.h>'],
94   ['HAVE_COSH', 'cosh', '#include<math.h>'],
95 # check token HAVE_CPU_ALPHA
96 # check token HAVE_CPU_ARM
97 # check token HAVE_CPU_CRIS
98 # check token HAVE_CPU_CRISV32
99 # check token HAVE_CPU_HPPA
100 # check token HAVE_CPU_I386
101 # check token HAVE_CPU_IA64
102 # check token HAVE_CPU_M68K
103 # check token HAVE_CPU_MIPS
104 # check token HAVE_CPU_PPC
105 # check token HAVE_CPU_PPC64
106 # check token HAVE_CPU_S390
107 # check token HAVE_CPU_SPARC
108 # check token HAVE_CPU_X86_64
109   ['HAVE_DCGETTEXT', 'dcgettext', '#include<libintl.h>'],
110 # check token HAVE_DIRECTSOUND
111 # check token HAVE_EXPERIMENTAL
112 # check token HAVE_EXTERNAL
113 # check token HAVE_FPCLASS
114 # check token HAVE_GCC_ASM
115   ['HAVE_GETPAGESIZE', 'getpagesize', '#include<unistd.h>'],
116 # check token HAVE_GETTEXT
117 # check token HAVE_GST_V4L2
118 # check token HAVE_IOS
119   ['HAVE_ISINF', 'isinf', '#include<math.h>'],
120 # check token HAVE_LIBV4L2
121   ['HAVE_MMAP', 'mmap', '#include<sys/mman.h>'],
122   ['HAVE_MMAP64', 'mmap64', '#include<sys/mman.h>'],
123 # check token HAVE_OSX_AUDIO
124 # check token HAVE_OSX_VIDEO
125 # check token HAVE_RDTSC
126   ['HAVE_SINH', 'sinh', '#include<math.h>'],
127 # check token HAVE_WAVEFORM
128 ]
129
130 libm = cc.find_library('m', required : false)
131
132 foreach f : check_functions
133   if cc.has_function(f.get(1), prefix : f.get(2), dependencies : libm)
134     cdata.set(f.get(0), 1)
135   endif
136 endforeach
137
138 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
139 cdata.set('SIZEOF_INT', cc.sizeof('int'))
140 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
141 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
142 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
143 cdata.set('SIZEOF_OFF_T', cc.sizeof('off_t'))
144
145 # Here be fixmes.
146 # FIXME: check if this is correct
147 cdata.set('HAVE_CPU_X86_64', host_machine.cpu() == 'amd64')
148 cdata.set('HAVE_GCC_ASM', cc.get_id() != 'msvc')
149 cdata.set_quoted('VERSION', gst_version)
150 cdata.set_quoted('PACKAGE_VERSION', gst_version)
151 cdata.set_quoted('GST_LICENSE', 'LGPL')
152 cdata.set_quoted('PACKAGE', 'gst-plugins-good')
153 cdata.set_quoted('GETTEXT_PACKAGE', 'gst-plugins-good-1.0')
154 cdata.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
155
156 warning_flags = [
157   '-Wmissing-declarations',
158   '-Wredundant-decls',
159   '-Wwrite-strings',
160   '-Winit-self',
161   '-Wmissing-include-dirs',
162   '-Wno-multichar',
163   '-Wvla',
164   '-Wpointer-arith',
165 ]
166
167 warning_c_flags = [
168   '-Wmissing-prototypes',
169   '-Wdeclaration-after-statement',
170   '-Wold-style-definition',
171   '-Waggregate-return',
172 ]
173
174 if have_cxx
175   cxx = meson.get_compiler('cpp')
176 endif
177
178 foreach extra_arg : warning_flags
179   if cc.has_argument (extra_arg)
180     add_project_arguments([extra_arg], language: 'c')
181   endif
182   if have_cxx and cxx.has_argument (extra_arg)
183     add_project_arguments([extra_arg], language: 'cpp')
184   endif
185 endforeach
186
187 foreach extra_arg : warning_c_flags
188   if cc.has_argument (extra_arg)
189     add_project_arguments([extra_arg], language: 'c')
190   endif
191 endforeach
192
193 # GStreamer package name and origin url
194 gst_package_name = get_option('package-name')
195 if gst_package_name == ''
196   if gst_version_nano == 0
197     gst_package_name = 'GStreamer Good Plug-ins source release'
198   elif gst_version_nano == 1
199     gst_package_name = 'GStreamer Good Plug-ins git'
200   else
201     gst_package_name = 'GStreamer Good Plug-ins prerelease'
202   endif
203 endif
204 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
205 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
206
207 # Mandatory GST deps
208 gst_dep = dependency('gstreamer-1.0', version : gst_req,
209   fallback : ['gstreamer', 'gst_dep'])
210 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
211   fallback : ['gstreamer', 'gst_base_dep'])
212 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
213   fallback : ['gstreamer', 'gst_net_dep'])
214 if host_system != 'windows'
215   gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
216     fallback : ['gstreamer', 'gst_check_dep'])
217 endif
218 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
219   fallback : ['gstreamer', 'gst_controller_dep'])
220
221 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
222     fallback : ['gst-plugins-base', 'pbutils_dep'])
223 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
224     fallback : ['gst-plugins-base', 'allocators_dep'])
225 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
226     fallback : ['gst-plugins-base', 'app_dep'])
227 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
228     fallback : ['gst-plugins-base', 'audio_dep'])
229 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
230     fallback : ['gst-plugins-base', 'fft_dep'])
231 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
232     fallback : ['gst-plugins-base', 'riff_dep'])
233 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
234     fallback : ['gst-plugins-base', 'rtp_dep'])
235 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
236     fallback : ['gst-plugins-base', 'rtsp_dep'])
237 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
238     fallback : ['gst-plugins-base', 'sdp_dep'])
239 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
240     fallback : ['gst-plugins-base', 'tag_dep'])
241 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
242     fallback : ['gst-plugins-base', 'video_dep'])
243
244 # GStreamer OpenGL
245 # FIXME: automagic
246 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
247     fallback : ['gst-plugins-base', 'gstgl_dep'], required: false)
248
249 build_gstgl = gstgl_dep.found() # FIXME: add option?
250
251 if build_gstgl
252   if gstgl_dep.type_name() == 'pkgconfig'
253     gst_gl_apis = gstgl_dep.get_pkgconfig_variable('gl_apis').split()
254     gst_gl_winsys = gstgl_dep.get_pkgconfig_variable('gl_winsys').split()
255     gst_gl_platforms = gstgl_dep.get_pkgconfig_variable('gl_platforms').split()
256   else
257     gstbase = subproject('gst-plugins-base')
258     gst_gl_apis = gstbase.get_variable('enabled_gl_apis')
259     gst_gl_winsys = gstbase.get_variable('enabled_gl_winsys')
260     gst_gl_platforms = gstbase.get_variable('enabled_gl_platforms')
261   endif
262
263   message('GStreamer OpenGL window systems: @0@'.format(' '.join(gst_gl_winsys)))
264   message('GStreamer OpenGL platforms: @0@'.format(' '.join(gst_gl_platforms)))
265   message('GStreamer OpenGL apis: @0@'.format(' '.join(gst_gl_apis)))
266
267   foreach ws : ['x11', 'wayland', 'android', 'cocoa', 'eagl', 'win32', 'dispmanx', 'viv_fb']
268     set_variable('gst_gl_have_window_@0@'.format(ws), gst_gl_winsys.contains(ws))
269   endforeach
270
271   foreach p : ['glx', 'egl', 'cgl', 'eagl', 'wgl']
272     set_variable('gst_gl_have_platform_@0@'.format(p), gst_gl_platforms.contains(p))
273   endforeach
274
275   foreach api : ['opengl', 'gles2']
276     set_variable('gst_gl_have_api_@0@'.format(api), gst_gl_apis.contains(api))
277   endforeach
278 endif
279
280 zlib_dep = dependency('zlib', fallback: ['zlib', 'zlib_dep'])
281 glib_deps = [dependency('glib-2.0', version : glib_req, fallback: ['glib', 'libglib_dep']),
282              dependency('gobject-2.0', fallback: ['glib', 'libgobject_dep'])]
283 gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep'])
284
285 cdata.set('HAVE_ZLIB', zlib_dep.found())
286
287 gst_plugins_good_args = ['-DHAVE_CONFIG_H']
288 configinc = include_directories('.')
289 libsinc = include_directories('gst-libs')
290
291 have_orcc = false
292 orcc_args = []
293 # Used by various libraries/elements that use Orc code
294 orc_dep = dependency('orc-0.4', version : orc_req, required : get_option('orc'))
295 orcc = find_program('orcc', required : get_option('orc'))
296 if orc_dep.found() and orcc.found()
297   have_orcc = true
298   orcc_args = [orcc, '--include', 'glib.h']
299   cdata.set('HAVE_ORC', 1)
300 else
301   message('Orc Compiler not found, will use backup C code')
302   cdata.set('DISABLE_ORC', 1)
303 endif
304
305 if gst_dep.type_name() == 'internal'
306     gst_proj = subproject('gstreamer')
307
308     if not gst_proj.get_variable('gst_debug')
309         message('GStreamer debug system is disabled')
310         add_project_arguments('-Wno-unused', language: 'c')
311     else
312         message('GStreamer debug system is enabled')
313     endif
314 else
315     # We can't check that in the case of subprojects as we won't
316     # be able to build against an internal dependency (which is not built yet)
317     if not cc.compiles('''
318 #include <gst/gstconfig.h>
319 #ifdef GST_DISABLE_GST_DEBUG
320 #error "debugging disabled, make compiler fail"
321 #endif''' , dependencies: gst_dep)
322         message('GStreamer debug system is disabled')
323         add_project_arguments('-Wno-unused', language: 'c')
324     else
325         message('GStreamer debug system is enabled')
326     endif
327 endif
328
329 presetdir = join_paths(get_option('datadir'), 'gstreamer-' + api_version, 'presets')
330
331 pkgconfig = import('pkgconfig')
332 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
333 if get_option('default_library') == 'shared'
334   # If we don't build static plugins there is no need to generate pc files
335   plugins_pkgconfig_install_dir = disabler()
336 endif
337
338 subdir('gst')
339 subdir('sys')
340 subdir('ext')
341 subdir('tests')
342 subdir('pkgconfig')
343
344 # xgettext is optional (on Windows for instance)
345 if find_program('xgettext', required : get_option('nls')).found()
346   cdata.set('ENABLE_NLS', 1)
347   subdir('po')
348 endif
349
350 configure_file(output : 'config.h', configuration : cdata)
351
352 python3 = import('python3').find_python()
353 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')