# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python import shutil from cerbero.utils import shell from cerbero.tools.libtool import LibtoolLibrary class Recipe(custom.GStreamerStatic): name = 'gst-libav-1.0-static' version = '1.0' gstreamer_version = '1.0' # TODO - check license - plugin is certainly LGPLv2+, but need to check # the linked libs licenses = [License.LGPLv2Plus] extra_configure_options = "--enable-static --enable-lgpl --disable-example" commit = 'origin/1.2' deps = ['gstreamer-1.0', 'gst-plugins-base-1.0', 'bzip2', 'zlib' ] files_plugins_codecs_restricted_devel = ['libgstlibav'] def prepare(self): if self.config.target_platform != Platform.LINUX: self.configure_options += ' --disable-gtk-doc' if self.config.target_platform == Platform.DARWIN: if self.config.target_arch == Architecture.X86_64: asflags = ' -arch x86_64 -m64' elif self.config.target_arch == Architecture.X86: asflags = ' -arch i386 -m32' elif self.config.target_arch == Architecture.PPC: asflags = ' -arch ppc' self.configure_options += ' ASFLAGS="%s"' % asflags super(Recipe, self).prepare() self.remotes['origin'] = ('%s/%s' % ('git://anongit.freedesktop.org/gstreamer', 'gst-libav')) self.remotes['upstream'] = self.remotes['origin'] for f in ['libavcodec', 'libavformat', 'libavutil', 'libswscale']: for ext in ['.a', '.la']: path = os.path.join('lib', f + ext) self.files_plugins_codecs_restricted_devel.append(path) def configure(self): super(recipe.Recipe, self).configure() libav_path = os.path.join(self.build_dir, 'gst-libs', 'ext', 'libav') if self.config.target_platform == Platform.WINDOWS: replacements = {'RANLIB=ranlib': 'RANLIB=%s' % os.environ['RANLIB']} shell.replace(os.path.join(libav_path, 'config.mak'), replacements) elif self.config.target_platform in [Platform.DARWIN, Platform.IOS]: if self.config.target_arch == Architecture.X86: replacements = {'HAVE_EBX_AVAILABLE=yes': 'HAVE_EBX_AVAILABLE=no', 'HAVE_EBX_AVAILABLE 1': 'HAVE_EBX_AVAILABLE 0',} shell.replace(os.path.join(libav_path, 'config.mak'), replacements) shell.replace(os.path.join(libav_path, 'config.h'), replacements) # log2 and log2f are not provided by bionic, but they are not checked # properly elif self.config.target_platform == Platform.ANDROID: replacements = {'HAVE_LOG2 1': 'HAVE_LOG2 0', 'HAVE_LOG2F 1': 'HAVE_LOG2F 0',} shell.replace(os.path.join(libav_path, 'config.h'), replacements) def post_install(self): for n in ['avutil', 'avcodec', 'avformat', 'swscale']: name = 'lib%s' % n lib = '%s.a' % name path = os.path.join(self.build_dir, 'gst-libs', 'ext', 'libav', name, lib) shutil.copy(path, self.config.libdir) deps = ['z', 'bz2'] if n == 'avcodec': deps += ['avutil'] if n == 'avformat': deps += ['avutil', 'avcodec'] if n == 'swscale': deps += ['avutil'] libtool_la = LibtoolLibrary(n, None, None, None, self.config.libdir, self.config.target_platform, deps) libtool_la.change_value ('dlname', '') libtool_la.change_value ('library_names', '') libtool_la.save() super(Recipe, self).post_install() gstlibavlib = os.path.join(self.config.prefix, 'lib', 'gstreamer-1.0', 'static', 'libgstlibav.la') shell.replace (gstlibavlib, {'-lavformat': os.path.join(self.config.libdir, 'libavformat.la'), '-lavcodec': os.path.join(self.config.libdir, 'libavcodec.la'), '-lavutil': os.path.join(self.config.libdir, 'libavutil.la'), '-lswscale': os.path.join(self.config.libdir, 'libswscale.la')})