summaryrefslogtreecommitdiff
path: root/exlibs/mozilla.exlib
blob: 2055d21c0c8c7891d35fb70e7bfffd534b970a34 (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
# 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
    edo mkdir -p "${WORK}"
}

mozilla_src_prepare() {
    default

    edo 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 "${ECONF_SOURCE}"/config/autoconf.mk.in

    # The Firefox 3.6.2 build introduced broken makefiles that have yet to be
    # fixed. Affected makefiles attempt to call the "hg parent" command;
    # however, there is no such command. They meant "hg parents", instead.
    # Of course, they shouldn't be calling "hg" at all as the tarball does not
    # ship a working ".hg/" repository.
    #
    # This fix removes all references to "hg" from affected makefiles, and
    # should probably be submitted as an upstream patch.
    for BROKEN_MAKEFILE in \
        "${ECONF_SOURCE}/toolkit/mozapps/installer/package-name.mk" \
        "${ECONF_SOURCE}/browser/app/Makefile.in" \
        "${ECONF_SOURCE}/browser/locales/Makefile.in" \
        "${ECONF_SOURCE}/xpcom/analysis/Makefile.in" \
        ; do
        edo sed -e 's:$(shell hg .*)::' -i "${BROKEN_MAKEFILE}"
    done
}

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 x 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"
    else
        for x in ${CFLAGS}; do
            case ${x} in
                -O|-O1)      param_optimize="--enable-optimize=-O1"  ;;
                -O2|-O3|-Os) param_optimize="--enable-optimize=${x}" ;;
            esac
        done
        [[ -z ${param_optimize} ]] && 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
}