summaryrefslogtreecommitdiff
path: root/exlibs/mozilla.exlib
blob: 85c4174a0a424a9eb5731952fca2945613503ff4 (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
# Copyright 2008 Bernd Steinhauser <berniyh@exherbo.org>
# Distributed under the terms of the GNU General Public License v2

require flag-o-matic multilib

export_exlib_phases src_unpack src_prepare src_configure

# Mozilla checkout project
myexparam co_project

# Provide "debug" option and common implementation
myexparam -b provide_debug=true

# nspr and nss versions. Values should be standard exheres version specs
# enclosed in double quotes (e.g. "[>=4.8]", "[=3.12.3]"). If unspecified, the
# latest available versions will be used.
myexparam supported_nspr=
myexparam supported_nss=

exparam -v MOZ_CO_PROJECT co_project
exparam -v supported_nspr supported_nspr
exparam -v supported_nss supported_nss

exparam -b provide_debug && MYOPTIONS="debug"

DEPENDENCIES="
    build+run:
        dev-libs/nspr${supported_nspr}
        dev-libs/nss${supported_nss}
"

WORK="${WORKBASE}"/build/${MOZ_CO_PROJECT}

export BUILD_OFFICIAL=1
export MOZILLA_OFFICIAL=1

mozilla_src_unpack() {
    default
    mkdir -p "${WORK}" || die "creating ${WORK} failed"
}

mozilla_src_prepare() {
    default

    sed \
        -e "/^installdir/ c installdir = /usr/$(get_libdir)/${PN}" \
        -e "/^includedir/ c includedir = /usr/include/${PN}" \
        -e "/^idldir/ c idldir = /usr/share/idl/${PN}" \
        -e "/^sdkdir/ c sdkdir = /usr/$(get_libdir)/${PN}-devel" \
        -i "${WORKBASE}"/mozilla*/config/autoconf.mk.in \
        || die "sed autoconf.mk.in failed"
}

mozilla_src_configure() {
    illegal_in_global_scope

    export PKG_SKIP_STRIP=1
    export MOZ_CO_PROJECT
    export MOZ_OBJDIR=@TOPSRCDIR@/../build

    # Workaround for gcc hidden symbol errors affecting Mozilla products
    # ("ld: final link failed: Nonrepresentable section on output"). See
    # Mozilla bug #293438 and also:
    #     http://benjamin.smedbergs.us/blog/2005-10-27/gcc-40-workaround/
    export ac_cv_visibility_pragma=no

    local param_optimize

    # Override the default optimization levels of Mozilla projects with the
    # value specified by -O from the user's CFLAGS/CXXFLAGS (if -O isn't given
    # gcc defaults to '-O0'). Optimization must be disabled when the 'debug'
    # option is set.
    if exparam -b provide_debug && option debug ; then
        param_optimize="--disable-optimize"
    elif is-flagq -O || is-flag -O1 ; then
        param_optimize="--enable-optimize=-O1"
    elif is-flagq -O2 ; then
        param_optimize="--enable-optimize=-O2"
    elif is-flagq -O3 ; then
        param_optimize="--enable-optimize=-O3"
    elif is-flagq -Os ; then
        param_optimize="--enable-optimize=-Os"
    else
        param_optimize="--enable-optimize=-O0"
    fi

    # Now filter -O from CFLAGS/CXXFLAGS to avoid a duplicate in the resulting
    # compile string.
    filter-flags '-O*'

    local param_debug
    exparam -b provide_debug && param_debug="
        $(option_enable debug)
        $(option_enable debug tests)
    "

    econf \
        "${MOZILLA_SRC_CONFIGURE_PARAMS[@]}" \
        $(for s in "${MOZILLA_SRC_CONFIGURE_OPTION_ENABLES[@]}" ; do
            option_enable ${s}
        done) \
        $(for s in "${MOZILLA_SRC_CONFIGURE_OPTION_WITHS[@]}" ; do
            option_with ${s}
        done) \
        --disable-strip \
        --enable-application=${MOZ_CO_PROJECT} \
        ${param_debug} \
        ${param_optimize} \
        --with-default-mozilla-five-home=/usr/$(get_libdir)/${PN} \
        --with-distribution-id=org.exherbo \
        --with-system-nspr \
        --with-system-nss
}