summaryrefslogtreecommitdiff
path: root/recipes/openh264.recipe
blob: 1785744c924e4770f7d138f7b74ff7ea9fe4aa96 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

from cerbero.tools.libtool import LibtoolLibrary
from cerbero.utils import shell

class Recipe(recipe.Recipe):
    name = 'openh264'
    version = '1.6.0'
    url = 'https://github.com/cisco/%(name)s/archive/v%(version)s.tar.gz'
    stype = SourceType.TARBALL
    btype = BuildType.MAKEFILE
    licenses = [License.BSD]
    # XXX: Part of this has been sent upstream:
    # https://github.com/cisco/openh264/pull/1566
    # However, upstream didn't want the library to be versioned on Android, so
    # we'll need to carry forward that bit for ourselves.
    # 0002: Fixed upstream, remove patch on next update
    patches = [name + '/0001-Add-version-suffix.patch']
    files_libs = ['libopenh264']
    files_devel = ['include/wels', 'lib/pkgconfig/openh264.pc']

    def prepare(self):
        make = self.make
        if self.config.target_platform == Platform.IOS:
            make += ' OS=ios '
            if self.config.target_arch == Architecture.X86:
                make += ' ARCH=i386'
            elif self.config.target_arch == Architecture.X86_64:
                make += ' ARCH=x86_64'
            elif self.config.target_arch == Architecture.ARMv7:
                make += ' ARCH=armv7'
            elif self.config.target_arch == Architecture.ARMv7S:
                make += ' ARCH=armv7s'
            elif self.config.target_arch == Architecture.ARM:
                make += ' ARCH=arm APP_ABI=armeabi'
            elif self.config.target_arch == Architecture.ARM64:
                make += ' ARCH=arm64'
        elif self.config.target_platform == Platform.DARWIN:
            make += ' OS=darwin '
            if self.config.target_arch == Architecture.X86:
                make += ' ARCH=x86'
            elif self.config.target_arch == Architecture.X86_64:
                make += ' ARCH=x86_64'
        elif self.config.target_platform == Platform.ANDROID:
            if self.config.target_distro_version == DistroVersion.ANDROID_LOLLIPOP:
                make += ' OS=android TARGET=android-21 NDKLEVEL=21'
            else:
                make += ' OS=android TARGET=android-9'
            make += ' NDKROOT=' + self.config.toolchain_prefix
            if self.config.target_arch == Architecture.X86:
                make += ' ARCH=x86'
            elif self.config.target_arch == Architecture.ARM64:
                make += ' ARCH=arm64'
            elif self.config.target_arch == Architecture.X86_64:
                make += ' ARCH=x86_64'
        elif self.config.target_platform == Platform.WINDOWS:
            make += ' OS=mingw_nt'
            if self.config.target_arch == Architecture.X86:
                make += ' ARCH=x86'
            elif self.config.target_arch == Architecture.X86_64:
                make += ' ARCH=x86_64'
        self.make = make + ' libraries'
        # `make install` also needs the exact same parameters as `make`
        self.make_install = make + ' install'

    def configure(self):
        if self.config.platform == Platform.WINDOWS:
            # Convert c:/foo to /c/foo for this build system. It will add the
            # initial / by itself, /c:/foo does not work and and //c is not
            # the same as /c on Windows. //c/foo is a network path.
            if not self.config.prefix.startswith('/') and self.config.prefix[1] == ':':
                p = "/" + self.config.prefix[0] + self.config.prefix[2:]
            else:
                p = self.config.prefix
            shell.replace(os.path.join(self.build_dir, 'Makefile'),
                          # Fix hard-coded prefix
                          {'PREFIX=/usr/local': "PREFIX=" + p})
        else:
            shell.replace(os.path.join(self.build_dir, 'Makefile'),
                          # Fix hard-coded prefix
                          {'PREFIX=/usr/local': "PREFIX=" + self.config.prefix})
        shell.replace(os.path.join(self.build_dir, 'build',
                                   'x86-common.mk'),
                      # Use yasm instead of nasm, since that's what Cerbero
                      # ships with
                      {'ASM = nasm': "ASM = yasm"})

        if self.config.target_platform == Platform.IOS and self.config.target_arch in [Architecture.X86, Architecture.X86_64]:
            shell.replace(os.path.join(self.build_dir, 'build',
                                       'platform-ios.mk'),
                          # Use correct compiler flag for iOS simulator
                          {'-miphoneos-version-min': '-mios-simulator-version-min'})

        # No configure script

    def post_install(self):
        # XXX: Don't forget to keep this in sync with the library version!
        dependency_libs=[]
        if self.config.target_platform == Platform.IOS:
            dependency_libs += ['-lc++']
        elif self.config.target_platform == Platform.DARWIN:
            dependency_libs += ['-lstdc++']
        elif self.config.target_platform == Platform.ANDROID:
            dependency_libs += ['gnustl', '-lm']
        elif self.config.target_platform in [Platform.WINDOWS, Platform.LINUX]:
            dependency_libs += ['-lstdc++', '-lm']
        else:
            raise NotImplementedError

        libtool_la = LibtoolLibrary('openh264', 0, None, None, self.config.libdir,
                                    self.config.target_platform,
                                    deps=dependency_libs)
        libtool_la.save()