# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python from cerbero.errors import FatalError from cerbero.utils import shell from cerbero.utils import messages as m import shutil class Recipe(recipe.Recipe): name = 'libvpx' version = 'v1.2.0' licenses = [License.BSD] stype = SourceType.TARBALL url = 'http://webm.googlecode.com/files/libvpx-v1.2.0.tar.bz2' configure_tpl = "%(config-sh)s --prefix=%(prefix)s "\ "--libdir=%(libdir)s %(options)s" configure_options = "--enable-pic --as=yasm --disable-unit-tests " add_host_build_target = False supports_cache_variables = False can_use_configure_cache = False make = 'make HAVE_GNU_STRIP=no' patches = ['libvpx/0001-darwin-add-support-for-newer-sdk-s.patch', 'libvpx/0002-Include-Android-cpu-features.c-instead-of-.h.patch', 'libvpx/0003-configure-add-support-for-android-x86.patch', 'libvpx/0004-configure-add-support-for-iOS-6.patch', 'libvpx/0005-Add-support-for-iOS-7.0-toolchain.patch'] files_libs = ['libvpx'] files_bins = ['vpxenc', 'vpxdec'] files_devel = ['include/vpx', 'lib/pkgconfig/vpx.pc'] # libvpx does not have check target make_check = None def prepare (self): if self.config.target_arch == Architecture.X86_64: arch = 'x86_64' elif self.config.target_arch == Architecture.X86: arch = 'x86' elif self.config.target_arch == Architecture.PPC: arch = 'ppc32' elif self.config.target_arch == Architecture.ARM: arch = 'arm' elif self.config.target_arch == Architecture.ARMv7: arch = 'armv7' if self.config.target_platform == Platform.DARWIN: if self.config.target_distro_version in [DistroVersion.OS_X_MOUNTAIN_LION, DistroVersion.OS_X_LION, DistroVersion.OS_X_MAVERICKS] and arch != 'x86': platform = 'darwin11' else: platform = 'darwin10' if self.config.target_arch == Architecture.PPC: platform = 'darwin9' elif self.config.target_platform == Platform.IOS: if self.config.target_distro_version == DistroVersion.IOS_7_0: platform = 'ios7' else: platform = 'ios6' if self.config.target_arch == Architecture.ARM: arch = 'armv6' self.config_sh = 'LD=$CC ./configure' elif self.config.target_platform == Platform.WINDOWS: self.config_sh = 'LD=$CC ./configure' if self.config.target_arch == Architecture.X86_64: platform = 'win64' else: platform = 'win32' # FIXME: elif self.config.target_platform == Platform.ANDROID: platform = 'android' self.append_env['CFLAGS'] = " -Dandroid_getCpuFamily=vpx_android_getCpuFamily "\ "-Dandroid_getCpuFeatures=vpx_android_getCpuFeatures "\ "-Dandroid_getCpuCount=vpx_android_getCpuCount " if self.config.target_arch == Architecture.ARM: arch = 'armv5te' # Fix compiler error with -mthumb self.new_env['CFLAGS'] = os.environ['CFLAGS'].replace('-mthumb', '') elif self.config.target_arch == Architecture.ARMv7: pass elif self.config.target_arch == Architecture.X86: pass else: raise FatalError("Unsupported Android architecture %s" % self.config.target_arch) self.config_sh = 'LD=$CC ./configure' self.configure_options.replace('--as=yasm', '') self.configure_options += ' --sdk-path=%s ' % self.config.toolchain_prefix else: self.configure_options += '--enable-shared ' platform = 'linux' self.configure_options += '--target=%s-%s-gcc ' % (arch, platform) def configure(self): if self.config.target_platform == Platform.ANDROID: cpufeatures_path = os.path.join(self.config.toolchain_prefix, 'sources', 'android', 'cpufeatures') o = os.path.join(cpufeatures_path, 'cpu-features.h') f = os.path.join(self.make_dir, 'vpx_ports') m.action("copying %s to %s" % (o, f)) shutil.copy(o, f) o = os.path.join(cpufeatures_path, 'cpu-features.c') f = os.path.join(self.make_dir, 'vpx_ports') m.action("copying %s to %s" % (o, f)) shutil.copy(o, f) super(recipe.Recipe, self).configure() def install(self): if self.config.target_platform in [Platform.DARWIN, Platform.IOS]: for f in ['vpxenc', 'vpxdec', 'libvpx.a']: shell.touch(os.path.join(self.build_dir, f)) super(Recipe, self).install()