summaryrefslogtreecommitdiff
path: root/recipes/openh264.recipe
blob: cab945bd4426b1294f189b6bf57bc54aae3091d6 (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
114
115
116
117
118
119
120
121
122
123
124
125
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

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

class Recipe(recipe.Recipe):
    name = 'openh264'
    version = '1.7.0'
    url = 'https://github.com/cisco/%(name)s/archive/v%(version)s.tar.gz'
    stype = SourceType.TARBALL
    btype = BuildType.MAKEFILE
    licenses = [License.BSD]
    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-14'
            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'
        elif self.config.target_platform == Platform.LINUX:
            if 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'

        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:
            shell.replace(os.path.join(self.build_dir, 'Makefile'),
                          # Use correct compiler flag for iOS simulator
                          {'STATIC_LDFLAGS=-lstdc++': 'STATIC_LDFLAGS=-lc++'})
            shell.replace(os.path.join(self.build_dir, 'build',
                                       'platform-ios.mk'),
                          # Use correct compiler flag for iOS simulator
                          {'SDK_MIN = 5.1': 'SDK_MIN = 7.0'})
            if 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'})

        fix_android_ndk16_cxx (self.config, self.make_dir)

        # 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.platform == Platform.DARWIN:
            dependency_libs += ['-lc++']
        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()