summaryrefslogtreecommitdiff
path: root/recipes/x264.recipe
blob: 8a90740a1b70e297811d41e3e8ff406c9afbdf2b (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
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
from cerbero.tools.libtool import LibtoolLibrary


class Recipe(recipe.Recipe):
    version = '20161218-2245'
    name = 'x264'
    licenses = [License.GPLv2Plus]
    stype = SourceType.TARBALL
    configure_tpl = "%(config-sh)s --prefix=%(prefix)s "\
                    "--libdir=%(libdir)s"
    configure_options = '--enable-shared --enable-static --enable-pic ' \
                        '--disable-strip --disable-lavf'
    url = 'https://download.videolan.org/pub/x264/snapshots/x264-snapshot-%(version)s-stable.tar.bz2'
    tarball_dirname= 'x264-snapshot-%(version)s-stable'
    tarball_checksum = 'd4d4fb146fbe64efb0f02d149118a0e93f575417011e4ff898a5079d548b9950'

    files_libs = ['libx264']
    files_bins = ['x264']
    files_devel = ['lib/pkgconfig/x264.pc', 'include/x264.h',
                   'include/x264_config.h']

    def prepare(self):
        # clang x86-32 fails at generating proper asm PIC code
        # See bug https://bugzilla.gnome.org/show_bug.cgi?id=727079
        enable_asm = True
        AS = ['yasm']

        arch = self.config.target_arch
        if self.config.target_arch == Architecture.X86:
            arch = 'i686'
        if self.config.target_platform == Platform.DARWIN:
            if self.config.target_arch == Architecture.X86:
                AS = ['yasm', '-O2', '-f', 'macho', '-DPREFIX']
                enable_asm = False
        if self.config.target_platform == Platform.WINDOWS:
            self.configure_options += ' --enable-win32thread'
        if self.config.target_arch == Architecture.ARM:
            # FIXME : Is disabling asm on ARM (< v7) still needed ?
            enable_asm = False
        elif Architecture.is_arm(self.config.target_arch):
            cc = self.get_env('CC')
            if cc:
                AS = [cc]
            else:
                AS = []
        if self.config.target_platform == Platform.IOS:
            if Architecture.is_arm(self.config.target_arch):
                # x264 ships its own gas-preprocessor.pl
                AS = ['tools/' + self.get_env('GAS')]
                self.patches = ['x264/0001-Disable-fembed-bitcode-incompatible-argument.patch']
            elif self.config.target_arch == Architecture.X86:
                enable_asm = False

        if self.config.target_platform == Platform.ANDROID:
            v = DistroVersion.get_android_api_version(self.config.target_distro_version)
            # Don't build the cli on Android, it fails with NDK 16
            self.configure_options += ' --disable-cli'
            self.files_bins.remove('x264')
            if self.config.target_arch in [Architecture.X86_64]:
                # Fails linking into an android application
                enable_asm = False
            elif self.config.target_arch in [Architecture.X86] and v < 24:
                # passing -mstackrealign consumes an extra register and will
                # fail compliation.
                # https://github.com/android-ndk/ndk/issues/690
                # https://github.com/android-ndk/ndk/issues/693
                enable_asm = False

        self.set_env('AS', *AS)
        if enable_asm is False:
            self.configure_options += ' --disable-asm '

    def post_install(self):
        libtool_la = LibtoolLibrary('x264', 148, None, None, self.config.libdir,
                self.config.target_platform)
        libtool_la.save()
        super().post_install()