summaryrefslogtreecommitdiff
path: root/recipes/gnutls.recipe
blob: 13602d3f56378f8f89a7a2b1d85de5d01be5933d (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
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

from cerbero.utils import shell
from cerbero.utils import needs_xcode8_sdk_workaround

class Recipe(recipe.Recipe):
    name = 'gnutls'
    version = '3.5.19'
    url = 'https://www.gnupg.org/ftp/gcrypt/%(name)s/v%(maj_ver)s/%(name)s-%(version)s.tar.xz'
    tarball_checksum = '1936eb64f03aaefd6eb16cef0567457777618573826b94d03376bb6a4afadc44'
    stype = SourceType.TARBALL
    # main library is LGPLv2+ and binaries is GPLv3+ and defined below
    licenses = [{License.LGPLv2Plus: None, License.Misc: ['LICENSE']}]
    configure_options = "--enable-local-libopts --disable-guile --disable-openssl-compatibility \
        --without-p11-kit --enable-static --enable-zlib --enable-shared \
        --disable-doc --disable-tests --with-included-unistring"
    deps = ['zlib', 'nettle', 'libtasn1']
    platform_deps = {
        Platform.WINDOWS: ['proxy-libintl'],
        Platform.ANDROID: ['proxy-libintl'],
        Platform.IOS: ['proxy-libintl'],
        Platform.DARWIN: ['proxy-libintl']
    }
    patches = [name + "/0003-Disable-ncrypt-support.patch",
               name + "/0001-Undefine-__USE_MINGW_ANSI_STDIO-as-otherwise-stdio.h.patch",
               name + "/0001-pgusage-remove-system-call.patch",
               name + "/0001-asm-rename-some-assembly-functions-to-not-conflict-w.patch",
               name + "/0001-Make-headers-MSVC-compatible-when-built-with-GCC.patch",
               name + "/0001-vasnprintf-Don-t-use-n-on-Android.patch",
               name + "/0001-Add-version-check-for-internal-idn2-symbols.patch",]
    autoreconf = True

    files_libs = ['libgnutls', 'libgnutlsxx']
    files_bins = ['gnutls-cli', 'gnutls-serv', 'gnutls-cli-debug']
    licenses_bins = [License.GPLv3Plus]
    files_devel = ['lib/pkgconfig/gnutls.pc', 'include/gnutls']
    files_lang = ['gnutls']

    def prepare(self):
        if needs_xcode8_sdk_workaround(self.config):
            self.set_env('ac_cv_func_clock_gettime', 'no')
            self.set_env('ac_cv_func_clock_settime', 'no')
        if self.config.target_platform == Platform.WINDOWS:
            self.configure_options += ' --enable-threads=win32'
            self.can_use_configure_cache = False
        if self.config.target_platform == Platform.DARWIN:
            self.configure_options += ' --disable-hardware-acceleration'
        if self.config.target_platform == Platform.ANDROID:
            self.configure_options += ' --disable-cxx'
            self.files_libs.remove('libgnutlsxx')
            # Fix build with NDK 16
            self.set_env('ac_cv_header_stdatomic_h', 'no')
            v = DistroVersion.get_android_api_version(self.config.target_distro_version)
            if self.config.target_arch in [Architecture.ARM, Architecture.ARMv7, Architecture.X86] and v < 21:
                # FIXME: HACK to make projects compile with NDK 16
                # we fail to compile with -D_FILE_OFFSET_BITS=64
                # because we don't use clang and we use a platform < 21 (Lollipop)
                # See $NDK_ROOT/sysroot/usr/include/sys/mman.h as one example
                self.set_env('ac_cv_func_mmap', 'no')
        if self.config.target_platform == Platform.IOS:
            if self.config.target_arch == Architecture.ARM64:
                self.configure_options += ' --disable-hardware-acceleration'
            self.configure_options += ' --disable-cxx'
            self.files_libs.remove('libgnutlsxx')

    async def configure(self):
        if needs_xcode8_sdk_workaround(self.config):
            # There is no env var that can be set to make the AC_COMPILE_IFELSE
            # macro that checks this evaluate to 'no', so we change the symbol.
            # Edit configure.ac and not configure because we autoreconf later.
            shell.replace(os.path.join(self.build_dir, 'configure.ac'),
                          {'getentropy': 'getentropy_DISABLED_NOT_FOR_MACOS10_12'})
        if self.config.target_platform == Platform.ANDROID:
            # On Android, SIZE_MAX is define under limits.h
            shell.replace(os.path.join(self.build_dir, 'gl', 'read-file.c'),
                {'#include <stdint.h>':
                 '#include <limits.h>'})
        # Call configure from the base class
        await super(recipe.Recipe, self).configure()