1project('gst-plugins-ugly', 'c',
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
19have_cxx = add_languages('cpp', required : false)
20
21glib_req = '>= 2.40.0'
22gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
23
24api_version = '1.0'
25
26plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
27
28cc = meson.get_compiler('c')
29if have_cxx
30  cxx = meson.get_compiler('cpp')
31endif
32
33if cc.get_id() == 'msvc'
34  # Ignore several spurious warnings for things gstreamer does very commonly
35  # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
36  # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
37  # NOTE: Only add warnings here if you are sure they're spurious
38  add_project_arguments(
39      '/wd4018', # implicit signed/unsigned conversion
40      '/wd4146', # unary minus on unsigned (beware INT_MIN)
41      '/wd4244', # lossy type conversion (e.g. double -> int)
42      '/wd4305', # truncating type conversion (e.g. double -> float)
43      cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
44      language : 'c')
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']
48else
49  noseh_link_args = []
50endif
51
52if cc.has_link_argument('-Wl,-Bsymbolic-functions')
53  add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
54endif
55if have_cxx and cxx.has_link_argument('-Wl,-Bsymbolic-functions')
56  add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'cpp')
57endif
58
59cdata = configuration_data()
60check_headers = [
61  ['HAVE_DLFCN_H', 'dlfcn.h'],
62  ['HAVE_INTTYPES_H', 'inttypes.h'],
63  ['HAVE_MALLOC_H', 'malloc.h'],
64  ['HAVE_MEMORY_H', 'memory.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_STAT_H', 'sys/stat.h'],
70  ['HAVE_SYS_TYPES_H', 'sys/types.h'],
71  ['HAVE_UNISTD_H', 'unistd.h'],
72  ['HAVE_WINSOCK2_H', 'winsock2.h'],
73]
74
75foreach h : check_headers
76  if cc.has_header(h.get(1))
77    cdata.set(h.get(0), 1)
78  endif
79endforeach
80
81check_functions = [
82  ['HAVE_DCGETTEXT', 'dcgettext'], # FIXME: this looks unused
83]
84
85foreach f : check_functions
86  if cc.has_function(f.get(1))
87    cdata.set(f.get(0), 1)
88  endif
89endforeach
90
91cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
92cdata.set('SIZEOF_INT', cc.sizeof('int'))
93cdata.set('SIZEOF_LONG', cc.sizeof('long'))
94cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
95cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
96
97cdata.set_quoted('VERSION', gst_version)
98cdata.set_quoted('PACKAGE', 'gst-plugins-ugly')
99cdata.set_quoted('GST_LICENSE', 'LGPL')
100cdata.set_quoted('GETTEXT_PACKAGE', 'gst-plugins-ugly-1.0')
101cdata.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
102
103# GStreamer package name and origin url
104gst_package_name = get_option('package-name')
105if gst_package_name == ''
106  if gst_version_nano == 0
107    gst_package_name = 'GStreamer Ugly Plug-ins source release'
108  elif gst_version_nano == 1
109    gst_package_name = 'GStreamer Ugly Plug-ins git'
110  else
111    gst_package_name = 'GStreamer Ugly Plug-ins prerelease'
112  endif
113endif
114cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
115cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
116
117# Mandatory GST deps
118gst_dep = dependency('gstreamer-1.0', version : gst_req,
119    fallback : ['gstreamer', 'gst_dep'])
120gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
121    fallback : ['gst-plugins-base', 'app_dep'])
122gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
123    fallback : ['gst-plugins-base', 'video_dep'])
124gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
125    fallback : ['gst-plugins-base', 'pbutils_dep'])
126gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
127    fallback : ['gst-plugins-base', 'tag_dep'])
128gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
129    fallback : ['gst-plugins-base', 'fft_dep'])
130gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
131    fallback : ['gst-plugins-base', 'audio_dep'])
132gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
133  fallback : ['gstreamer', 'gst_base_dep'])
134gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
135    fallback : ['gst-plugins-base', 'riff_dep'])
136gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
137    fallback : ['gst-plugins-base', 'rtp_dep'])
138gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
139  fallback : ['gstreamer', 'gst_net_dep'])
140gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
141    fallback : ['gst-plugins-base', 'sdp_dep'])
142gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
143    fallback : ['gst-plugins-base', 'rtsp_dep'])
144gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
145    required : get_option('tests'),
146    fallback : ['gstreamer', 'gst_check_dep'])
147gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
148  fallback : ['gstreamer', 'gst_controller_dep'])
149
150orc_dep = dependency('orc-0.4', version : '>= 0.4.16', required : get_option('orc'),
151    fallback : ['orc', 'orc_dep'])
152if orc_dep.found()
153  cdata.set('HAVE_ORC', 1) # used by a52dec for cpu detection
154else
155  cdata.set('DISABLE_ORC', 1)
156endif
157
158gmodule_dep = dependency('gmodule-2.0', fallback : ['glib', 'libgmodule_dep'])
159
160ugly_args = ['-DHAVE_CONFIG_H']
161configinc = include_directories('.')
162libsinc = include_directories('gst-libs')
163
164# Disable compiler warnings for unused variables and args if gst debug system is disabled
165if gst_dep.type_name() == 'internal'
166  gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
167else
168  # We can't check that in the case of subprojects as we won't
169  # be able to build against an internal dependency (which is not built yet)
170  gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
171endif
172
173if gst_debug_disabled
174  message('GStreamer debug system is disabled')
175  if cc.has_argument('-Wno-unused')
176    add_project_arguments('-Wno-unused', language: 'c')
177  endif
178  if have_cxx and cxx.has_argument ('-Wno-unused')
179    add_project_arguments('-Wno-unused', language: 'cpp')
180  endif
181else
182  message('GStreamer debug system is enabled')
183endif
184
185warning_flags = [
186  '-Wmissing-declarations',
187  '-Wredundant-decls',
188  '-Wwrite-strings',
189  '-Wformat',
190  '-Wformat-nonliteral',
191  '-Wformat-security',
192  '-Winit-self',
193  '-Wmissing-include-dirs',
194  '-Waddress',
195  '-Wno-multichar',
196  '-Wvla',
197  '-Wpointer-arith',
198  '-Waggregate-return',
199  '-fno-strict-aliasing',
200  # Symbol visibility
201  '-fvisibility=hidden',
202]
203
204warning_c_flags = [
205  '-Wmissing-prototypes',
206  '-Wold-style-definition',
207  '-Wdeclaration-after-statement',
208  '-Wnested-externs'
209]
210
211foreach extra_arg : warning_flags
212  if cc.has_argument (extra_arg)
213    add_project_arguments([extra_arg], language: 'c')
214  endif
215  if have_cxx and cxx.has_argument (extra_arg)
216    add_project_arguments([extra_arg], language: 'cpp')
217  endif
218endforeach
219
220foreach extra_arg : warning_c_flags
221  if cc.has_argument (extra_arg)
222    add_project_arguments([extra_arg], language: 'c')
223  endif
224endforeach
225
226# Define G_DISABLE_DEPRECATED for development versions
227if gst_version_is_dev
228  message('Disabling deprecated GLib API')
229  add_project_arguments('-DG_DISABLE_DEPRECATED', language: 'c')
230endif
231
232cast_checks = get_option('gobject-cast-checks')
233if cast_checks.disabled() or (cast_checks.auto() and not gst_version_is_dev)
234  message('Disabling GLib cast checks')
235  add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: 'c')
236endif
237
238glib_asserts = get_option('glib-asserts')
239if glib_asserts.disabled() or (glib_asserts.auto() and not gst_version_is_dev)
240  message('Disabling GLib asserts')
241  add_project_arguments('-DG_DISABLE_ASSERT', language: 'c')
242endif
243
244glib_checks = get_option('glib-checks')
245if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev)
246  message('Disabling GLib checks')
247  add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
248endif
249
250presetdir = join_paths(get_option('datadir'), 'gstreamer-' + api_version, 'presets')
251
252pkgconfig = import('pkgconfig')
253plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
254if get_option('default_library') == 'shared'
255  # If we don't build static plugins there is no need to generate pc files
256  plugins_pkgconfig_install_dir = disabler()
257endif
258
259subdir('gst')
260subdir('ext')
261subdir('tests')
262
263# xgettext is optional (on Windows for instance)
264if find_program('xgettext', required : get_option('nls')).found()
265  cdata.set('ENABLE_NLS', 1)
266  subdir('po')
267endif
268
269configure_file(output : 'config.h', configuration : cdata)
270
271python3 = import('python').find_installation()
272run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')
273