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