Release 1.13.91
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-omx', 'c',
2   version : '1.13.91',
3   meson_version : '>= 0.36.0',
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.40.0'
19 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
20 tizil_req = '>= 0.1.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   # Ignore several spurious warnings for things gstreamer does very commonly
29   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
30   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
31   # NOTE: Only add warnings here if you are sure they're spurious
32   add_project_arguments(
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       language : 'c')
38   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
39   # are built with MinGW
40   noseh_link_args = ['/SAFESEH:NO']
41 else
42   noseh_link_args = []
43 endif
44
45 cdata = configuration_data()
46 check_headers = [
47 #  ['HAVE_DLFCN_H', 'dlfcn.h'],
48 #  ['HAVE_FCNTL_H', 'fcntl.h'],
49 #  ['HAVE_INTTYPES_H', 'inttypes.h'],
50 #  ['HAVE_MEMORY_H', 'memory.h'],
51 #  ['HAVE_MSACM_H', 'msacm.h'],
52 #  ['HAVE_PTHREAD_H', 'pthread.h'],
53 #  ['HAVE_STDINT_H', 'stdint.h'],
54 #  ['HAVE_STDLIB_H', 'stdlib.h'],
55 #  ['HAVE_STRINGS_H', 'strings.h'],
56 #  ['HAVE_STRING_H', 'string.h'],
57 #  ['HAVE_SYS_PARAM_H', 'sys/param.h'],
58 #  ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
59 #  ['HAVE_SYS_STAT_H', 'sys/stat.h'],
60 #  ['HAVE_SYS_TIME_H', 'sys/time.h'],
61 #  ['HAVE_SYS_TYPES_H', 'sys/types.h'],
62 #  ['HAVE_SYS_UTSNAME_H', 'sys/utsname.h'],
63 #  ['HAVE_UNISTD_H', 'unistd.h'],
64 ]
65
66 foreach h : check_headers
67   if cc.has_header(h.get(1))
68     cdata.set(h.get(0), 1)
69   endif
70 endforeach
71
72 check_functions = [
73 # check token HAVE_CPU_ALPHA
74 # check token HAVE_CPU_ARM
75 # check token HAVE_CPU_CRIS
76 # check token HAVE_CPU_CRISV32
77 # check token HAVE_CPU_HPPA
78 # check token HAVE_CPU_I386
79 # check token HAVE_CPU_IA64
80 # check token HAVE_CPU_M68K
81 # check token HAVE_CPU_MIPS
82 # check token HAVE_CPU_PPC
83 # check token HAVE_CPU_PPC64
84 # check token HAVE_CPU_S390
85 # check token HAVE_CPU_SPARC
86 # check token HAVE_CPU_X86_64
87 #  ['HAVE_DCGETTEXT', 'dcgettext'],
88 # check token HAVE_EXPERIMENTAL
89 # check token HAVE_EXTERNAL
90 #  ['HAVE_GETPAGESIZE', 'getpagesize'],
91 # check token HAVE_GETTEXT
92 ]
93
94 foreach f : check_functions
95   if cc.has_function(f.get(1))
96     cdata.set(f.get(0), 1)
97   endif
98 endforeach
99
100 #cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
101 #cdata.set('SIZEOF_INT', cc.sizeof('int'))
102 #cdata.set('SIZEOF_LONG', cc.sizeof('long'))
103 #cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
104 #cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
105
106 cdata.set('VERSION', '"@0@"'.format(gst_version))
107 cdata.set('PACKAGE', '"gst-omx"')
108 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
109 cdata.set('PACKAGE_BUGREPORT', '"http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer"')
110 cdata.set('PACKAGE_NAME', '"GStreamer OMX Plugins"')
111 cdata.set('GETTEXT_PACKAGE', '"gst-omx-1.0"')
112 cdata.set('GST_API_VERSION', '"@0@"'.format(api_version))
113 cdata.set('GST_PACKAGE_NAME', '"GStreamer OpenMAX Plug-ins"')
114 cdata.set('GST_PACKAGE_ORIGIN', '"Unknown package origin"')
115 cdata.set('GST_LICENSE', '"LGPL"')
116 cdata.set('LIBDIR', '"@0@"'.format(get_option('libdir')))
117
118 # FIXME: This should be exposed as a configuration option
119 host_system = host_machine.system()
120 if host_system == 'linux'
121   cdata.set('DEFAULT_VIDEOSRC', '"v4l2src"')
122 elif host_system == 'osx'
123   cdata.set('DEFAULT_VIDEOSRC', '"avfvideosrc"')
124 else
125   cdata.set('DEFAULT_VIDEOSRC', '"videotestsrc"')
126 endif
127
128 # Mandatory GST deps
129 gst_dep = dependency('gstreamer-1.0', version : gst_req,
130   fallback : ['gstreamer', 'gst_dep'])
131 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
132   fallback : ['gstreamer', 'gst_base_dep'])
133 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
134   fallback : ['gstreamer', 'gst_controller_dep'])
135 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
136   fallback : ['gst-plugins-base', 'allocators_dep'])
137
138 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
139     fallback : ['gst-plugins-base', 'pbutils_dep'])
140 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
141     fallback : ['gst-plugins-base', 'audio_dep'])
142 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
143     fallback : ['gst-plugins-base', 'fft_dep'])
144 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
145     fallback : ['gst-plugins-base', 'tag_dep'])
146 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
147     fallback : ['gst-plugins-base', 'video_dep'])
148
149 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
150     fallback : ['gst-plugins-base', 'gstgl_dep'], required : false)
151
152 x11_dep = dependency('x11', required : false)
153
154 if host_machine.system() != 'windows'
155   gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
156     fallback : ['gstreamer', 'gst_check_dep'])
157 endif
158
159 libm = cc.find_library('m', required : false)
160 glib_dep = dependency('glib-2.0', version : glib_req)
161 gio_dep = dependency('gio-2.0', version : glib_req)
162 gmodule_dep = dependency('gmodule-2.0', version : glib_req)
163
164 gst_omx_args = ['-DHAVE_CONFIG_H']
165 configinc = include_directories('.')
166 omx_header_path = get_option('with_omx_header_path')
167 if omx_header_path != ''
168   omx_inc = []
169   gst_omx_args += ['-I' + omx_header_path]
170 else
171   omx_inc = include_directories (join_paths ('omx', 'openmax'))
172 endif
173
174 default_omx_struct_packing = 0
175 omx_target = get_option ('with_omx_target')
176 if omx_target == 'generic'
177   cdata.set('USE_OMX_TARGET_GENERIC', 1)
178 elif omx_target == 'rpi'
179   cdata.set('USE_OMX_TARGET_RPI', 1)
180   cdata.set('OMX_SKIP64BIT', 1)
181   default_omx_struct_packing = 4
182
183   if gstgl_dep.found()
184     if gstgl_dep.type_name() == 'pkgconfig'
185       gl_winsys = gstgl_dep.get_pkgconfig_variable('gl_winsys').split(' ')
186       gl_platforms = gstgl_dep.get_pkgconfig_variable('gl_platforms').split(' ')
187     elif gstgl_dep.type_name() == 'internal'
188       # XXX assume gst-plugins-base was built with dispmanx and egl support
189       gl_winsys = ['dispmanx']
190       gl_platforms = ['egl']
191     else
192       error ('unreachable dependency type')
193     endif
194
195     if not gl_winsys.contains('dispmanx') or not gl_platforms.contains ('egl')
196       gstgl_dep = dependency('', required : false)
197     endif
198   endif
199 elif omx_target == 'bellagio'
200   cdata.set('USE_OMX_TARGET_BELLAGIO', 1)
201 elif omx_target == 'zynqultrascaleplus'
202   cdata.set('USE_OMX_TARGET_ZYNQ_USCALE_PLUS', 1)
203   have_allegro_header = cc.has_header (
204       'OMX_Allegro.h',
205       args : gst_omx_args,
206       include_directories : [omx_inc],
207       required : false)
208   if not have_allegro_header
209     error ('Need Allegro OMX headers to build for Zynq UltraScale+. Use with_omx_header_path option to specify the path of those headers.')
210   endif
211 elif omx_target == 'tizonia'
212   cdata.set('USE_OMX_TARGET_TIZONIA', 1)
213   tizil_dep = dependency('tizilheaders', version : tizil_req)
214   cdata.set('TIZONIA_LIBDIR', tizil_dep.get_pkgconfig_variable('libdir'))
215   tizil_includedir = tizil_dep.get_pkgconfig_variable('includedir')
216   gst_omx_args += ['-I' + tizil_includedir + '/tizonia']
217 else
218   error ('Unsupported omx target specified. Use the -Dwith_omx_target option')
219 endif
220
221 extra_video_headers = ''
222 # Check for optional OpenMAX extension headers
223
224 if cc.has_header (
225     'OMX_VideoExt.h',
226     args : gst_omx_args,
227     include_directories : [omx_inc],
228     required : false)
229   extra_video_headers += '''
230 #include <OMX_VideoExt.h>'''
231   cdata.set ('HAVE_VIDEO_EXT', 1)
232 endif
233
234 if cc.has_header (
235     'OMX_IndexExt.h',
236     args : gst_omx_args,
237     include_directories : [omx_inc],
238     required : false)
239   cdata.set ('HAVE_INDEX_EXT', 1)
240 endif
241
242 if cc.has_header (
243     'OMX_ComponentExt.h',
244     args : gst_omx_args,
245     include_directories : [omx_inc],
246     required : false)
247   cdata.set ('HAVE_COMPONENT_EXT', 1)
248 endif
249
250 if cc.has_header (
251     'OMX_CoreExt.h',
252     args : gst_omx_args,
253     required : false)
254   cdata.set ('HAVE_CORE_EXT', 1)
255 endif
256
257 if cc.has_header (
258     'OMX_AudioExt.h',
259     args : gst_omx_args,
260     required : false)
261   cdata.set ('HAVE_AUDIO_EXT', 1)
262 endif
263
264 if cc.has_header (
265     'OMX_IVCommonExt.h',
266     args : gst_omx_args,
267     required : false)
268   cdata.set ('HAVE_IV_COMMON_EXT', 1)
269 endif
270
271 if cc.has_header (
272     'OMX_ImageExt.h',
273     args : gst_omx_args,
274     required : false)
275   cdata.set ('HAVE_IMAGE_EXT', 1)
276 endif
277
278 if cc.has_header (
279     'OMX_OtherExt.h',
280     args : gst_omx_args,
281     required : false)
282   cdata.set ('HAVE_OTHER_EXT', 1)
283 endif
284
285 have_omx_vp8 = cc.has_header_symbol(
286     'OMX_Video.h',
287     'OMX_VIDEO_CodingVP8',
288     prefix : extra_video_headers, 
289     args : gst_omx_args,
290     include_directories : [omx_inc],
291     required : false)
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     required : false)
303 if have_omx_theora
304   cdata.set('HAVE_THEORA', 1)
305 endif
306
307 have_omx_hevc = cc.has_header_symbol(
308     'OMX_Video.h',
309     'OMX_VIDEO_CodingHEVC',
310     prefix : extra_video_headers,
311     args : gst_omx_args,
312     include_directories : [omx_inc],
313     required : false)
314 if have_omx_hevc
315   cdata.set('HAVE_HEVC', 1)
316 endif
317
318 if gstgl_dep.found()
319   cdata.set ('HAVE_GST_GL', 1)
320 endif
321
322 if x11_dep.found()
323   cdata.set ('HAVE_X11', 1)
324 endif
325
326 omx_struct_packing = get_option ('with_omx_struct_packing').to_int()
327 if omx_struct_packing == 0
328   omx_struct_packing = default_omx_struct_packing
329 endif
330 if omx_struct_packing != 0
331   cdata.set('GST_OMX_STRUCT_PACKING', omx_struct_packing)
332 endif
333
334 omx_conf_dir = join_paths (get_option ('prefix'), get_option ('sysconfdir'), 'xdg')
335 cdata.set_quoted('GST_OMX_CONFIG_DIR', omx_conf_dir)
336
337 configure_file(output : 'config.h', configuration : cdata)
338
339 subdir('config')
340 subdir('examples')
341 subdir('omx')
342 subdir('tools')
343 subdir('tests')
344
345 python3 = find_program('python3')
346 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')