f368913f753b2c145566cffcc5663a07f69e4eb7
[platform/upstream/gstreamer.git] / subprojects / gst-omx / meson.build
1 project('gst-omx', 'c',
2   version : '1.21.0.1',
3   meson_version : '>= 0.60',
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 glib_req = '>= 2.56.0'
19 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
20 tizil_req = '>= 0.19.0'
21 api_version = '1.0'
22
23 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
24
25 cc = meson.get_compiler('c')
26
27 if cc.get_id() == 'msvc'
28   msvc_args = [
29       # Ignore several spurious warnings for things gstreamer does very commonly
30       # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
31       # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
32       # NOTE: Only add warnings here if you are sure they're spurious
33       '/wd4018', # implicit signed/unsigned conversion
34       '/wd4146', # unary minus on unsigned (beware INT_MIN)
35       '/wd4244', # lossy type conversion (e.g. double -> int)
36       '/wd4305', # truncating type conversion (e.g. double -> float)
37       cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
38
39       # Enable some warnings on MSVC to match GCC/Clang behaviour
40       '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
41       '/w14101', # 'identifier' : unreferenced local variable
42       '/w14189', # 'identifier' : local variable is initialized but not referenced
43   ]
44   add_project_arguments(msvc_args, 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']
48 else
49   noseh_link_args = []
50 endif
51
52 cdata = configuration_data()
53 check_headers = [
54 #  ['HAVE_DLFCN_H', 'dlfcn.h'],
55 #  ['HAVE_FCNTL_H', 'fcntl.h'],
56 #  ['HAVE_INTTYPES_H', 'inttypes.h'],
57 #  ['HAVE_MEMORY_H', 'memory.h'],
58 #  ['HAVE_MSACM_H', 'msacm.h'],
59 #  ['HAVE_PTHREAD_H', 'pthread.h'],
60 #  ['HAVE_STDINT_H', 'stdint.h'],
61 #  ['HAVE_STDLIB_H', 'stdlib.h'],
62 #  ['HAVE_STRINGS_H', 'strings.h'],
63 #  ['HAVE_STRING_H', 'string.h'],
64 #  ['HAVE_SYS_PARAM_H', 'sys/param.h'],
65 #  ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
66 #  ['HAVE_SYS_STAT_H', 'sys/stat.h'],
67 #  ['HAVE_SYS_TIME_H', 'sys/time.h'],
68 #  ['HAVE_SYS_TYPES_H', 'sys/types.h'],
69 #  ['HAVE_SYS_UTSNAME_H', 'sys/utsname.h'],
70 #  ['HAVE_UNISTD_H', 'unistd.h'],
71 ]
72
73 foreach h : check_headers
74   if cc.has_header(h.get(1))
75     cdata.set(h.get(0), 1)
76   endif
77 endforeach
78
79 check_functions = [
80 # check token HAVE_CPU_ALPHA
81 # check token HAVE_CPU_ARM
82 # check token HAVE_CPU_CRIS
83 # check token HAVE_CPU_CRISV32
84 # check token HAVE_CPU_HPPA
85 # check token HAVE_CPU_I386
86 # check token HAVE_CPU_IA64
87 # check token HAVE_CPU_M68K
88 # check token HAVE_CPU_MIPS
89 # check token HAVE_CPU_PPC
90 # check token HAVE_CPU_PPC64
91 # check token HAVE_CPU_S390
92 # check token HAVE_CPU_SPARC
93 # check token HAVE_CPU_X86_64
94 #  ['HAVE_DCGETTEXT', 'dcgettext'],
95 # check token HAVE_EXPERIMENTAL
96 # check token HAVE_EXTERNAL
97 #  ['HAVE_GETPAGESIZE', 'getpagesize'],
98 # check token HAVE_GETTEXT
99 ]
100
101 foreach f : check_functions
102   if cc.has_function(f.get(1))
103     cdata.set(f.get(0), 1)
104   endif
105 endforeach
106
107 #cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
108 #cdata.set('SIZEOF_INT', cc.sizeof('int'))
109 #cdata.set('SIZEOF_LONG', cc.sizeof('long'))
110 #cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
111 #cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
112
113 cdata.set('VERSION', '"@0@"'.format(gst_version))
114 cdata.set('PACKAGE', '"gst-omx"')
115 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
116 cdata.set('PACKAGE_BUGREPORT', '"https://gitlab.freedesktop.org/gstreamer/gst-omx/issues/new"')
117 cdata.set('PACKAGE_NAME', '"GStreamer OMX Plugins"')
118 cdata.set('GETTEXT_PACKAGE', '"gst-omx-1.0"')
119 cdata.set('GST_API_VERSION', '"@0@"'.format(api_version))
120 cdata.set('GST_PACKAGE_NAME', '"GStreamer OpenMAX Plug-ins"')
121 cdata.set('GST_PACKAGE_ORIGIN', '"Unknown package origin"')
122 cdata.set('GST_LICENSE', '"LGPL"')
123 cdata.set('LIBDIR', '"@0@"'.format(get_option('libdir')))
124
125 # FIXME: This should be exposed as a configuration option
126 host_system = host_machine.system()
127 if host_system == 'linux'
128   cdata.set('DEFAULT_VIDEOSRC', '"v4l2src"')
129 elif host_system == 'osx'
130   cdata.set('DEFAULT_VIDEOSRC', '"avfvideosrc"')
131 else
132   cdata.set('DEFAULT_VIDEOSRC', '"videotestsrc"')
133 endif
134
135 # Mandatory GST deps
136 gst_dep = dependency('gstreamer-1.0', version : gst_req,
137   fallback : ['gstreamer', 'gst_dep'])
138 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
139   fallback : ['gstreamer', 'gst_base_dep'])
140 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
141   fallback : ['gstreamer', 'gst_controller_dep'])
142 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
143   fallback : ['gst-plugins-base', 'allocators_dep'])
144
145 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
146     fallback : ['gst-plugins-base', 'pbutils_dep'])
147 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
148     fallback : ['gst-plugins-base', 'audio_dep'])
149 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
150     fallback : ['gst-plugins-base', 'fft_dep'])
151 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
152     fallback : ['gst-plugins-base', 'tag_dep'])
153 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
154     fallback : ['gst-plugins-base', 'video_dep'])
155
156 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
157     fallback : ['gst-plugins-base', 'gstgl_dep'], required : false)
158
159 x11_dep = dependency('x11', required : false)
160
161 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
162     required : get_option('tests'),
163     fallback : ['gstreamer', 'gst_check_dep'])
164
165 libm = cc.find_library('m', required : false)
166 gmodule_dep = dependency('gmodule-2.0', version: glib_req)
167
168 gst_omx_args = ['-DHAVE_CONFIG_H']
169 configinc = include_directories('.')
170 omx_header_path = get_option('header_path')
171 if omx_header_path != ''
172   omx_inc = []
173   gst_omx_args += ['-I' + omx_header_path]
174 else
175   omx_inc = include_directories (join_paths ('omx', 'openmax'))
176 endif
177
178 default_omx_struct_packing = 0
179 omx_target = get_option ('target')
180 if omx_target == 'generic'
181   cdata.set('USE_OMX_TARGET_GENERIC', 1)
182 elif omx_target == 'rpi'
183   cdata.set('USE_OMX_TARGET_RPI', 1)
184   cdata.set('OMX_SKIP64BIT', 1)
185   default_omx_struct_packing = 4
186
187   if gstgl_dep.found()
188     if gstgl_dep.type_name() == 'pkgconfig'
189       gl_winsys = gstgl_dep.get_variable('gl_winsys').split(' ')
190       gl_platforms = gstgl_dep.get_variable('gl_platforms').split(' ')
191     elif gstgl_dep.type_name() == 'internal'
192       # XXX assume gst-plugins-base was built with dispmanx and egl support
193       gl_winsys = ['dispmanx']
194       gl_platforms = ['egl']
195     else
196       error ('unreachable dependency type')
197     endif
198
199     if not gl_winsys.contains('dispmanx') or not gl_platforms.contains ('egl')
200       gstgl_dep = dependency('', required : false)
201     endif
202   endif
203 elif omx_target == 'bellagio'
204   cdata.set('USE_OMX_TARGET_BELLAGIO', 1)
205 elif omx_target == 'zynqultrascaleplus'
206   cdata.set('USE_OMX_TARGET_ZYNQ_USCALE_PLUS', 1)
207   have_allegro_header = cc.has_header (
208       'OMX_Allegro.h',
209       args : gst_omx_args,
210       include_directories : [omx_inc])
211   if not have_allegro_header
212     error ('Need Allegro OMX headers to build for Zynq UltraScale+. Use -Dheader_path option to specify the path of those headers.')
213   endif
214 elif omx_target == 'tizonia'
215   if omx_header_path != ''
216     warning('Ignoring -Dheader_path because path is in tizilheaders.pc')
217   endif
218   cdata.set('USE_OMX_TARGET_TIZONIA', 1)
219   tizil_dep = dependency('tizilheaders', version : tizil_req)
220   cdata.set('TIZONIA_LIBDIR', tizil_dep.get_variable('libdir'))
221   tizil_includedir = tizil_dep.get_variable('includedir')
222   gst_omx_args += ['-I' + tizil_includedir + '/tizonia']
223   omx_inc = []
224 else
225   error ('Unsupported omx target specified. Use the -Dtarget option')
226 endif
227
228 message ('OMX target: ' + omx_target)
229
230 extra_video_headers = ''
231 # Check for optional OpenMAX extension headers
232
233 if cc.has_header (
234     'OMX_VideoExt.h',
235     args : gst_omx_args,
236     include_directories : [omx_inc])
237   extra_video_headers += '''
238 #include <OMX_VideoExt.h>'''
239   cdata.set ('HAVE_VIDEO_EXT', 1)
240 endif
241
242 if cc.has_header (
243     'OMX_IndexExt.h',
244     args : gst_omx_args,
245     include_directories : [omx_inc])
246   cdata.set ('HAVE_INDEX_EXT', 1)
247 endif
248
249 if cc.has_header (
250     'OMX_ComponentExt.h',
251     args : gst_omx_args,
252     include_directories : [omx_inc])
253   cdata.set ('HAVE_COMPONENT_EXT', 1)
254 endif
255
256 if cc.has_header (
257     'OMX_CoreExt.h',
258     args : gst_omx_args)
259   cdata.set ('HAVE_CORE_EXT', 1)
260 endif
261
262 if cc.has_header (
263     'OMX_AudioExt.h',
264     args : gst_omx_args)
265   cdata.set ('HAVE_AUDIO_EXT', 1)
266 endif
267
268 if cc.has_header (
269     'OMX_IVCommonExt.h',
270     args : gst_omx_args)
271   cdata.set ('HAVE_IV_COMMON_EXT', 1)
272 endif
273
274 if cc.has_header (
275     'OMX_ImageExt.h',
276     args : gst_omx_args)
277   cdata.set ('HAVE_IMAGE_EXT', 1)
278 endif
279
280 if cc.has_header (
281     'OMX_OtherExt.h',
282     args : gst_omx_args)
283   cdata.set ('HAVE_OTHER_EXT', 1)
284 endif
285
286 have_omx_vp8 = cc.has_header_symbol(
287     'OMX_Video.h',
288     'OMX_VIDEO_CodingVP8',
289     prefix : extra_video_headers,
290     args : gst_omx_args,
291     include_directories : [omx_inc])
292 if have_omx_vp8
293   cdata.set('HAVE_VP8', 1)
294 endif
295
296 have_omx_theora = cc.has_header_symbol(
297     'OMX_Video.h',
298     'OMX_VIDEO_CodingTheora',
299     prefix : extra_video_headers,
300     args : gst_omx_args,
301     include_directories : [omx_inc])
302 if have_omx_theora
303   cdata.set('HAVE_THEORA', 1)
304 endif
305
306 have_omx_hevc = cc.has_header_symbol(
307     'OMX_Video.h',
308     'OMX_VIDEO_CodingHEVC',
309     prefix : extra_video_headers,
310     args : gst_omx_args,
311     include_directories : [omx_inc])
312 if have_omx_hevc
313   cdata.set('HAVE_HEVC', 1)
314 endif
315
316 if gstgl_dep.found()
317   cdata.set ('HAVE_GST_GL', 1)
318 endif
319
320 if x11_dep.found()
321   cdata.set ('HAVE_X11', 1)
322 endif
323
324 omx_struct_packing = get_option ('struct_packing').to_int()
325 if omx_struct_packing == 0
326   omx_struct_packing = default_omx_struct_packing
327 endif
328 if omx_struct_packing != 0
329   cdata.set('GST_OMX_STRUCT_PACKING', omx_struct_packing)
330 endif
331
332 omx_conf_dir = join_paths (get_option ('prefix'), get_option ('sysconfdir'), 'xdg')
333 cdata.set_quoted('GST_OMX_CONFIG_DIR', omx_conf_dir)
334
335 warning_flags = [
336   '-Wmissing-declarations',
337   '-Wredundant-decls',
338   '-Wwrite-strings',
339   '-Winit-self',
340   '-Wmissing-include-dirs',
341   '-Wno-multichar',
342   '-Wvla',
343   '-Wpointer-arith',
344   '-Wundef',
345 ]
346
347 warning_c_flags = [
348   '-Wmissing-prototypes',
349   '-Wdeclaration-after-statement',
350   '-Wold-style-definition',
351   '-Waggregate-return',
352 ]
353
354 have_cxx = add_languages('cpp', required : false)
355
356 if have_cxx
357   cxx = meson.get_compiler('cpp')
358 endif
359
360 foreach extra_arg : warning_flags
361   if cc.has_argument (extra_arg)
362     add_project_arguments([extra_arg], language: 'c')
363   endif
364   if have_cxx and cxx.has_argument (extra_arg)
365     add_project_arguments([extra_arg], language: 'cpp')
366   endif
367 endforeach
368
369 foreach extra_arg : warning_c_flags
370   if cc.has_argument (extra_arg)
371     add_project_arguments([extra_arg], language: 'c')
372   endif
373 endforeach
374
375 # Disable compiler warnings for unused variables and args if gst debug system is disabled
376 if gst_dep.type_name() == 'internal'
377   gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
378 else
379   # We can't check that in the case of subprojects as we won't
380   # be able to build against an internal dependency (which is not built yet)
381   gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
382 endif
383
384 if gst_debug_disabled
385   message('GStreamer debug system is disabled')
386   if cc.has_argument('-Wno-unused')
387     add_project_arguments('-Wno-unused', language: 'c')
388   endif
389   if have_cxx and cxx.has_argument ('-Wno-unused')
390     add_project_arguments('-Wno-unused', language: 'cpp')
391   endif
392 else
393   message('GStreamer debug system is enabled')
394 endif
395
396 subdir('config')
397
398 if not get_option('examples').disabled()
399   subdir('examples')
400 endif
401
402 subdir('omx')
403
404 if not get_option('tools').disabled()
405   subdir('tools')
406 endif
407
408 if not get_option('tests').disabled() and gstcheck_dep.found()
409   subdir('tests')
410 endif
411 subdir('docs')
412
413 # Set release date
414 if gst_version_nano == 0
415   extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
416   run_result = run_command(extract_release_date, gst_version, files('gst-omx.doap'), check: true)
417   release_date = run_result.stdout().strip()
418   cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
419   message('Package release date: ' + release_date)
420 endif
421
422 configure_file(output: 'config.h', configuration: cdata)