Merge branch 'tizen_gst_1.22.7' into tizen_gst_1.22.8
[platform/upstream/gstreamer.git] / subprojects / gst-libav / meson.build
1 project('gst-libav', 'c',
2   version : '1.22.8',
3   meson_version : '>= 0.62',
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 gst_version_is_stable = gst_version_minor.is_even()
18 gst_version_is_dev = gst_version_minor.is_odd() and gst_version_micro < 90
19
20 api_version = '1.0'
21 libavfilter_dep = dependency('libavfilter', version: '>= 7.16.100',
22   fallback: ['FFmpeg', 'libavfilter_dep'])
23 libavformat_dep = dependency('libavformat', version: '>= 58.12.100',
24   fallback: ['FFmpeg', 'libavformat_dep'])
25 libavcodec_dep = dependency('libavcodec', version: '>= 58.18.100',
26   fallback: ['FFmpeg', 'libavcodec_dep'])
27 libavutil_dep = dependency('libavutil', version: '>= 56.14.100',
28   fallback: ['FFmpeg', 'libavutil_dep'])
29
30 libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep]
31
32 cc = meson.get_compiler('c')
33 static_build = get_option('default_library') == 'static'
34
35 check_ffmpeg_src = '''#include <libavcodec/avcodec.h>
36 #if LIBAVCODEC_VERSION_MICRO >= 100
37 /* FFmpeg uses 100+ as its micro version */
38 #else
39 #error libav provider should be FFmpeg
40 #endif'''
41
42 libav_deps_type_name = ''
43
44 foreach dep: libav_deps
45   if libav_deps_type_name != '' and dep.type_name() != libav_deps_type_name
46     error('Libav deps must be either all internal or all external')
47   endif
48   libav_deps_type_name = dep.type_name()
49 endforeach
50
51 if dep.type_name() != 'internal'
52   if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg')
53     error('Uncompatible libavcodec found')
54   endif
55 endif
56
57 cdata = configuration_data()
58 cdata.set('LIBAV_SOURCE', '"system install"')
59 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
60 cdata.set('PACKAGE', '"gst-libav"')
61
62 # GStreamer package name and origin url
63 gst_package_name = get_option('package-name')
64 if gst_package_name == ''
65   if gst_version_nano == 0
66     gst_package_name = 'GStreamer FFMPEG Plug-ins source release'
67   elif gst_version_nano == 1
68     gst_package_name = 'GStreamer FFMPEG Plug-ins git'
69   else
70     gst_package_name = 'GStreamer FFMPEG Plug-ins prerelease'
71   endif
72 endif
73 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
74 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
75
76
77 check_headers = [['unistd.h', 'HAVE_UNISTD_H']]
78
79 foreach h : check_headers
80   if cc.has_header(h.get(0))
81     cdata.set(h.get(1), 1)
82   endif
83 endforeach
84
85 if gst_version_is_stable
86   gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
87 else
88   gst_req = '>= ' + gst_version
89 endif
90
91 gst_dep = dependency('gstreamer-1.0', version : gst_req,
92   fallback : ['gstreamer', 'gst_dep'])
93 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
94   fallback : ['gstreamer', 'gst_base_dep'])
95 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
96   required : get_option('tests'),
97   fallback : ['gstreamer', 'gst_check_dep'])
98
99 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
100     fallback : ['gst-plugins-base', 'video_dep'])
101 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
102     fallback : ['gst-plugins-base', 'audio_dep'])
103 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
104     fallback : ['gst-plugins-base', 'pbutils_dep'])
105 libm = cc.find_library('m', required : false)
106
107 gst_libav_args = ['-DHAVE_CONFIG_H']
108 if cc.get_id() == 'msvc'
109   msvc_args = [
110       # Ignore several spurious warnings for things gstreamer does very commonly
111       # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
112       # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
113       # NOTE: Only add warnings here if you are sure they're spurious
114       '/wd4018', # implicit signed/unsigned conversion
115       '/wd4146', # unary minus on unsigned (beware INT_MIN)
116       '/wd4244', # lossy type conversion (e.g. double -> int)
117       '/wd4305', # truncating type conversion (e.g. double -> float)
118       cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
119   ]
120
121   if gst_version_is_dev
122     # Enable some warnings on MSVC to match GCC/Clang behaviour
123     msvc_args += cc.get_supported_arguments([
124       '/we4002', # too many actual parameters for macro 'identifier'
125       '/we4003', # not enough actual parameters for macro 'identifier'
126       '/we4013', # 'function' undefined; assuming extern returning int
127       '/we4020', # 'function' : too many actual parameters
128       '/we4027', # function declared without formal parameter list
129       '/we4029', # declared formal parameter list different from definition
130       '/we4033', # 'function' must return a value
131       '/we4045', # 'array' : array bounds overflow
132       '/we4047', # 'operator' : 'identifier1' differs in levels of indirection from 'identifier2'
133       '/we4053', # one void operand for '?:'
134       '/we4062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
135       '/we4098', # 'function' : void function returning a value
136       '/we4101', # 'identifier' : unreferenced local variable
137       '/we4189', # 'identifier' : local variable is initialized but not referenced
138     ])
139   endif
140   add_project_arguments(msvc_args, language: ['c', 'cpp'])
141 endif
142
143 # glib doesn't support unloading, which means that unloading and reloading
144 # any library that registers static types will fail
145 if cc.has_link_argument('-Wl,-z,nodelete')
146   add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
147 endif
148
149 # Symbol visibility
150 if cc.has_argument('-fvisibility=hidden')
151   add_project_arguments('-fvisibility=hidden', language: 'c')
152 endif
153
154 # Don't export any symbols from static ffmpeg libraries
155 if cc.has_link_argument('-Wl,--exclude-libs=ALL')
156   add_project_link_arguments('-Wl,--exclude-libs=ALL', language: 'c')
157 endif
158
159 # Disable strict aliasing
160 if cc.has_argument('-fno-strict-aliasing')
161   add_project_arguments('-fno-strict-aliasing', language: 'c')
162 endif
163
164 if gst_dep.type_name() == 'internal'
165     gst_proj = subproject('gstreamer')
166
167     if not gst_proj.get_variable('gst_debug')
168         message('GStreamer debug system is disabled')
169         add_project_arguments('-Wno-unused', language: 'c')
170     else
171         message('GStreamer debug system is enabled')
172     endif
173 else
174     # We can't check that in the case of subprojects as we won't
175     # be able to build against an internal dependency (which is not built yet)
176     if not cc.compiles('''
177 #include <gst/gstconfig.h>
178 #ifdef GST_DISABLE_GST_DEBUG
179 #error "debugging disabled, make compiler fail"
180 #endif''' , dependencies: gst_dep)
181         message('GStreamer debug system is disabled')
182         add_project_arguments('-Wno-unused', language: 'c')
183     else
184         message('GStreamer debug system is enabled')
185     endif
186 endif
187
188 # Tizen options
189 if get_option('tv-profile')
190 cdata.set ('TIZEN_PRODUCT_TV', true)
191 endif
192 cdata.set ('TIZEN_FEATURE_LIBAV', true)
193
194 warning_flags = [
195   '-Wmissing-declarations',
196   '-Wmissing-prototypes',
197   '-Wold-style-definition',
198   '-Wredundant-decls',
199   '-Wundef',
200   '-Wwrite-strings',
201   '-Wformat',
202   '-Wformat-nonliteral',
203   '-Wformat-security',
204   '-Winit-self',
205   '-Wmissing-include-dirs',
206   '-Waddress',
207   '-Wno-multichar',
208   '-Waggregate-return',
209   '-Wvla',
210   '-Wpointer-arith',
211 ]
212
213 foreach extra_arg : warning_flags
214   if cc.has_argument (extra_arg)
215     add_project_arguments([extra_arg], language: 'c')
216   endif
217 endforeach
218
219 configinc = include_directories('.')
220 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
221
222 pkgconfig = import('pkgconfig')
223 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
224 if get_option('default_library') == 'shared'
225   # If we don't build static plugins there is no need to generate pc files
226   plugins_pkgconfig_install_dir = disabler()
227 endif
228
229 plugins = []
230 subdir('ext/libav')
231 subdir('docs')
232 subdir('tests')
233
234 # Set release date
235 if gst_version_nano == 0
236   extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
237   run_result = run_command(extract_release_date, gst_version, files('gst-libav.doap'), check: true)
238   release_date = run_result.stdout().strip()
239   cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
240   message('Package release date: ' + release_date)
241 endif
242
243 configure_file(output: 'config.h', configuration: cdata)
244
245 meson.add_dist_script('scripts/gen-changelog.py', meson.project_name(), '1.20.0', meson.project_version())
246
247 gst_plugins = []
248 foreach plugin: plugins
249   pkgconfig.generate(plugin, install_dir: plugins_pkgconfig_install_dir)
250   dep = declare_dependency(link_with: plugin, variables: {'full_path': plugin.full_path()})
251   meson.override_dependency(plugin.name(), dep)
252   gst_plugins += [dep]
253 endforeach