summaryrefslogtreecommitdiff
path: root/scripts/build/companion_libs/330-gettext.sh
blob: 07ea02b81cb6afb431bae2a4ab8b21d89c988911 (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
126
127
128
129
130
131
132
133
134
135
136
137
138
# Build script for gettext

do_gettext_get() { :; }
do_gettext_extract() { :; }
do_gettext_for_build() { :; }
do_gettext_for_host() { :; }
do_gettext_for_target() { :; }

if [ "${CT_GETTEXT}" = "y" ]; then

do_gettext_get() {
    CT_GetFile "gettext-${CT_GETTEXT_VERSION}" \
               http://ftp.gnu.org/pub/gnu/gettext/
}

do_gettext_extract() {
    CT_Extract "gettext-${CT_GETTEXT_VERSION}"
    CT_Patch "gettext" "${CT_GETTEXT_VERSION}"
}

# Build gettext for running on build
do_gettext_for_build() {
    local -a gettext_opts

    case "$CT_BUILD" in
        *linux*)
            return 0
            ;;
    esac

    CT_DoStep INFO "Installing gettext for build"
    CT_mkdir_pushd "${CT_BUILD_DIR}/build-gettext-build-${CT_BUILD}"

    gettext_opts+=( "host=${CT_BUILD}" )
    gettext_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
    gettext_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
    gettext_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
    do_gettext_backend "${gettext_opts[@]}"

    CT_Popd
    CT_EndStep
}

# Build gettext for running on host
do_gettext_for_host() {
    local -a gettext_opts

    CT_DoStep INFO "Installing gettext for host"
    CT_mkdir_pushd "${CT_BUILD_DIR}/build-gettext-host-${CT_HOST}"

    gettext_opts+=( "host=${CT_HOST}" )
    gettext_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    gettext_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    gettext_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    do_gettext_backend "${gettext_opts[@]}"

    CT_Popd
    CT_EndStep
}

# Build gettext
#     Parameter     : description               : type      : default
#     host          : machine to run on         : tuple     : (none)
#     prefix        : prefix to install into    : dir       : (none)
#     shared        : build shared lib          : bool      : no
#     cflags        : host cflags to use        : string    : (empty)
#     ldflags       : host ldflags to use       : string    : (empty)
do_gettext_backend() {
    local host
    local prefix
    local shared
    local cflags
    local ldflags
    local arg
    local -a extra_config

    for arg in "$@"; do
        eval "${arg// /\\ }"
    done

    CT_DoLog EXTRA "Configuring gettext"

    # A bit ugly. D__USE_MINGW_ANSI_STDIO=1 has its own {v}asprintf functions
    # but gettext configure doesn't see this flag when it checks for that. An
    # alternative may be to use CC="${host}-gcc ${cflags}" but that didn't
    # work.
    # -O2 works around bug at http://savannah.gnu.org/bugs/?36443
    # gettext needs some fixing for MinGW-w64 it would seem.
    # -DLIBXML_STATIC needed to link with libxml (provided by gnulib) under
    # MinGW: without this flag, xmlFree is defined as `dllimport` by libxml
    # headers and hence fails to link.
    case "${host}" in
        *mingw*)
            case "${cflags}" in
                *D__USE_MINGW_ANSI_STDIO=1*)
                    extra_config+=( --disable-libasprintf )
                    ;;
            esac
            extra_config+=( --enable-threads=win32 )
            cflags=$cflags" -O2 -DLIBXML_STATIC"
        ;;
    esac

    if [ "${shared}" != "y" ]; then
        extra_config+=("--disable-shared")
    fi

    CT_DoExecLog CFG                                        \
    CFLAGS="${cflags}"                                      \
    LDFLAGS="${ldflags}"                                    \
    "${CT_SRC_DIR}/gettext-${CT_GETTEXT_VERSION}/configure" \
        --build=${CT_BUILD}                                 \
        --host="${host}"                                    \
        --prefix="${prefix}"                                \
        --enable-static                                     \
        --disable-java                                      \
        --disable-native-java                               \
        --disable-csharp                                    \
        --without-emacs                                     \
        --disable-openmp                                    \
        --with-included-libxml                              \
        --with-included-gettext                             \
        --with-included-glib                                \
        --with-included-libcroco                            \
        --with-included-libunistring                        \
        --with-libncurses-prefix="${prefix}"                \
        --with-libiconv-prefix="${prefix}"                  \
        --without-libpth-prefix                             \
        "${extra_config[@]}"

    CT_DoLog EXTRA "Building gettext"
    CT_DoExecLog ALL make ${JOBSFLAGS}

    CT_DoLog EXTRA "Installing gettext"
    CT_DoExecLog ALL make install
}

fi