summaryrefslogtreecommitdiff
path: root/recipes/build-tools/gettext-tools.recipe
blob: c5a46dcef74e4706cf1aaa737a569f059204f1fd (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
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
import shutil
from pathlib import Path

from cerbero.utils import shell

class Recipe(recipe.Recipe):
    name = 'gettext-tools'
    version = '0.19.8.1'
    licenses = [License.GPLv3]
    srcdir = 'gettext-tools'
    stype = SourceType.TARBALL
    tarball_dirname = 'gettext-%(version)s'
    url = 'https://ftp.gnu.org/pub/gnu/gettext/gettext-%(version)s.tar.gz'
    platform_deps = {
            Platform.DARWIN:  ['sed'],
            Platform.WINDOWS: ['libiconv', 'mingw-runtime'],}
    configure_options = ' --disable-java --disable-csharp --disable-native-java --without-csv'
    patches = ['../gettext/0001-Fix-linker-error-redefinition-of-vasprintf.patch',
               '../gettext/0001-Undefine-__USE_MINGW_ANSI_STDIO-as-otherwise-stdio.h.patch',
               '../gettext/0001-Fix-build-invalid-instruction-on-macOS-10.13.patch' ]

    def prepare(self):
        if self.config.target_platform == Platform.WINDOWS:
            self.configure_options += ' --enable-threads=win32'
            self.append_env('LDFLAGS', '-liconv')

    def post_install(self):
        if self.config.platform == Platform.WINDOWS:
            # The msgmerge built by us randomly hangs on Windows when called
            # during configure, so replace it with the msgmerge from MSYS-MinGW
            # which works fine.
            build_tools_bin = Path(self.config.build_tools_prefix) / 'bin'
            msys_mingw_bindir = Path(shutil.which('mingw-get')).parent
            msys_msgmerge = msys_mingw_bindir / 'msgmerge.exe'
            if msys_msgmerge.is_file():
                if (build_tools_bin / 'msgmerge.exe').is_file():
                    os.replace(str(build_tools_bin / 'msgmerge.exe'),
                               str(build_tools_bin / 'msgmerge.exe.bck'))
                shutil.copy(str(msys_msgmerge), str(build_tools_bin))