summaryrefslogtreecommitdiff
path: root/recipes/libvpx.recipe
blob: 3c1e8a4d23a9b857ce779977cade5e5a173b519d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- 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.1.0'
    licenses = [License.BSD]
    configure_tpl = "%(config-sh)s --prefix=%(prefix)s "\
                    "--libdir=%(libdir)s %(options)s"
    configure_options = "--enable-pic --as=yasm "
    add_host_build_target = False
    supports_cache_variables = False
    can_use_configure_cache = False

    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] and arch != 'x86':
                platform = 'darwin11'
            else:
                platform = 'darwin10'
            if self.config.target_arch == Architecture.PPC:
                platform = 'darwin9'
        elif self.config.target_platform == Platform.IOS:
            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()