Add support for Meson as alternative/parallel build system
authorThibault Saunier <thibault.saunier@osg.samsung.com>
Mon, 29 Aug 2016 00:47:35 +0000 (21:47 -0300)
committerThibault Saunier <thibault.saunier@osg.samsung.com>
Mon, 29 Aug 2016 12:56:18 +0000 (09:56 -0300)
https://github.com/mesonbuild/meson

We only support building with ffmpeg installed system wide and not as
subproject yet.

config.h.meson [new file with mode: 0644]
ext/libav/meson.build [new file with mode: 0644]
meson.build [new file with mode: 0644]

diff --git a/config.h.meson b/config.h.meson
new file mode 100644 (file)
index 0000000..5d0b638
--- /dev/null
@@ -0,0 +1,6 @@
+#mesondefine HAVE_LZMA
+#mesondefine HAVE_BZ2
+#mesondefine LIBAV_SOURCE
+#mesondefine PACKAGE_VERSION
+#mesondefine PACKAGE
+
diff --git a/ext/libav/meson.build b/ext/libav/meson.build
new file mode 100644 (file)
index 0000000..7855d73
--- /dev/null
@@ -0,0 +1,24 @@
+sources = [
+    'gstav.c',
+    'gstavprotocol.c',
+    'gstavcodecmap.c',
+    'gstavutils.c',
+    'gstavaudenc.c',
+    'gstavvidenc.c',
+    'gstavauddec.c',
+    'gstavviddec.c',
+    'gstavcfg.c',
+    'gstavdemux.c',
+    'gstavmux.c',
+    'gstavdeinterlace.c',
+]
+
+gstlibav = library('gstlibav',
+    sources,
+    c_args : gst_libav_args,
+    include_directories : [configinc],
+    dependencies : libav_deps + [gst_dep, gstbase_dep, gstvideo_dep,
+        gstaudio_dep, gstpbutils_dep, libm, bz2lib],
+    install : true,
+    install_dir : plugins_install_dir,
+  )
diff --git a/meson.build b/meson.build
new file mode 100644 (file)
index 0000000..08d865a
--- /dev/null
@@ -0,0 +1,73 @@
+project('gst-libav', 'c', 'cpp',
+  version : '1.9.1.1',
+  meson_version : '>= 0.33.0',
+  default_options : [ 'warning_level=1',
+                      'c_std=gnu99',
+                      'buildtype=debugoptimized' ])
+
+gst_version = meson.project_version()
+version_arr = gst_version.split('.')
+gst_version_major = version_arr[0]
+gst_version_minor = version_arr[1]
+
+libavfilter_dep = dependency('libavfilter', version: '>= 6.47.100')
+libavformat_dep = dependency('libavformat', version: '>= 57.41.100')
+libavcodec_dep = dependency('libavcodec', version: '>= 57.48.101')
+libavutil_dep = dependency('libavutil', version: '>= 55.28.100')
+
+libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep]
+
+cc = meson.get_compiler('c')
+
+check_ffmpeg_src = '''#include <libavcodec/avcodec.h>
+#if LIBAVCODEC_VERSION_MICRO >= 100
+/* FFmpeg uses 100+ as its micro version */
+#else
+#error libav provider should be FFmpeg
+#endif'''
+
+if not cc.compiles(check_ffmpeg_src, name : 'whether libav is provided by FFmpeg')
+    error('Uncompatible libavcodec found')
+endif
+
+cdata = configuration_data()
+cdata.set('LIBAV_SOURCE', '"system install"')
+cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
+cdata.set('PACKAGE', '"gst-libav"')
+
+gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
+gst_dep = dependency('gstreamer-1.0', version : gst_req,
+  fallback : ['gstreamer', 'gst_dep'])
+gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
+  fallback : ['gstreamer', 'gst_base_dep'])
+
+gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
+    fallback : ['gst-plugins-base', 'video_dep'])
+gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
+    fallback : ['gst-plugins-base', 'audio_dep'])
+gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
+    fallback : ['gst-plugins-base', 'pbutils_dep'])
+libm = cc.find_library('m', required : false)
+
+bz2lib = cc.find_library('bz2', required : false)
+if bz2lib.found()
+  cdata.set('HAVE_BZ2', 1)
+else
+    message('WARN: libbz2 not found, matroska demuxer will not be able to read bz2 tracks')
+endif
+
+lzmalib = cc.find_library('lzma', required : false)
+if lzmalib.found()
+  cdata.set('HAVE_LZMA', 1)
+else
+    message('WARN: lzma not found, tiff reader will not be able to read lzma files')
+endif
+
+configure_file(input : 'config.h.meson',
+  output : 'config.h',
+  configuration : cdata)
+
+gst_libav_args = ['-DHAVE_CONFIG_H', '-Wno-deprecated-declarations']
+configinc = include_directories('.')
+plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
+subdir('ext/libav/')