1 # Template file for 'firefox'
3 # THIS PKG MUST BE SYNCHRONIZED WITH "srcpkgs/firefox-i18n".
9 short_desc="Mozilla Firefox web browser"
10 maintainer="Duncaen <duncaen@voidlinux.org>"
11 license="MPL-2.0, GPL-2.0-or-later, LGPL-2.1-or-later"
12 homepage="https://www.mozilla.org/firefox/"
13 distfiles="${MOZILLA_SITE}/firefox/releases/${version/beta/b}/source/firefox-${version/beta/b}.source.tar.xz"
14 checksum=f134a5420200bb03ab460f9d2867507c0edb222ce73faf4064cdbea02a0aca1b
18 hostmakedepends="autoconf213 unzip zip pkg-config perl python3 yasm rust
19 cargo llvm${_llvmver} clang${_llvmver} lld${_llvmver} nodejs cbindgen nasm which tar"
20 makedepends="nss-devel libjpeg-turbo-devel gtk+3-devel icu-devel
21 pixman-devel libevent-devel libnotify-devel libvpx-devel libwebp-devel
22 libXrender-devel libXcomposite-devel libSM-devel libXt-devel rust-std
23 libXdamage-devel freetype-devel
24 $(vopt_if alsa alsa-lib-devel) $(vopt_if dbus dbus-glib-devel)
25 $(vopt_if pulseaudio pulseaudio-devel) $(vopt_if xscreensaver libXScrnSaver-devel)
26 $(vopt_if sndio sndio-devel) $(vopt_if jack jack-devel)"
27 depends="nss>=3.72 nspr>=4.32 desktop-file-utils hicolor-icon-theme"
28 conflicts="firefox-esr>=0"
30 build_options="alsa jack dbus pulseaudio xscreensaver sndio wayland lto clang"
31 build_options_default="alsa jack dbus pulseaudio xscreensaver sndio wayland clang"
33 desc_option_lto="Enable Link Time Optimization"
34 desc_option_clang="Build with clang"
36 case $XBPS_TARGET_MACHINE in
37 armv[56]*) broken="required NEON extensions are not supported on armv6" ;;
39 ppc*) broken="xptcall bitrot" ;;
42 # we need this because cargo verifies checksums of all files in vendor
43 # crates when it builds and gives us no way to override or update the
44 # file sanely... so just clear out the file list
45 _clear_vendor_checksums() {
46 sed -i 's/\("files":{\)[^}]*/\1/' third_party/rust/$1/.cargo-checksum.json
50 case "$XBPS_TARGET_MACHINE" in
52 cp "${FILESDIR}/stab.h" toolkit/crashreporter/google-breakpad/src/
56 # Mozilla API keys (see https://location.services.mozilla.com/api)
57 # Note: This is for Void Linux use ONLY.
58 echo -n "cd894504-7a2a-4263-abff-ff73ee89ffca" > mozilla-api-key
62 : # _clear_vendor_checksums num-traits
66 if [ "$build_option_clang" ]; then
70 if [ "$CROSS_BUILD" ]; then
73 local gcc_version=$(gcc -dumpversion)
74 local clang_version=$(clang -dumpversion)
76 cat <<-! >"wrapper/${XBPS_TARGET_MACHINE}-clang"
79 --target="${XBPS_CROSS_TRIPLET}" \
80 --sysroot="${XBPS_CROSS_BASE}" \
81 --gcc-toolchain=/usr \
82 -isystem "${XBPS_CROSS_BASE}/usr/include" \
86 cat <<-! >"wrapper/${XBPS_TARGET_MACHINE}-clang++"
89 --target="${XBPS_CROSS_TRIPLET}" \
90 --sysroot="${XBPS_CROSS_BASE}" \
91 --gcc-toolchain=/usr \
92 -isystem "${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}" \
93 -isystem "${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/${XBPS_CROSS_TRIPLET}" \
94 -isystem "${XBPS_CROSS_BASE}/usr/include/c++/${gcc_version%.*}/backward" \
95 -isystem "${XBPS_CROSS_BASE}/usr/include" \
101 export PATH="${wrksrc}/wrapper:$PATH"
102 export CC=${XBPS_TARGET_MACHINE}-clang
103 export CXX=${XBPS_TARGET_MACHINE}-clang++
109 export HOST_CXX=clang++
114 export CXXFLAGS="-O2"
115 export HOST_CFLAGS=""
116 export HOST_CXXFLAGS=""
117 export LDFLAGS="-Wl,-rpath=/usr/lib/firefox"
118 # export LDFLAGS+="-Wl,--threads=${XBPS_MAKEJOBS}"
121 if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
122 echo "ac_add_options --disable-jemalloc"
127 case "$XBPS_TARGET_MACHINE" in
128 x86_64*|i686*|arm*|aarch64*) echo "ac_add_options --disable-elf-hack" ;;
133 # it seems mozilla has started catching up with google's webrtc
134 # and this newly involves introducing several megabytes of generated
135 # json junk that we just cannot maintain in-tree, additionally they
136 # have indicated that they will be re-generating these frequently
138 # it is unacceptable to keep a 7MB patch downstream, so disable it
140 # https://phabricator.services.mozilla.com/D134738
142 case "$XBPS_TARGET_MACHINE" in
143 armv7l*) echo "ac_add_options --disable-webrtc" ;;
146 # third_party/libwebrtc/common_audio/wav_file.cc:93:2: error:
147 # #error "Need to convert samples to big-endian when reading from WAV file"
148 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
149 echo "ac_add_options --disable-webrtc"
154 ac_add_options --prefix=/usr
155 ac_add_options --libdir=/usr/lib
156 ac_add_options --host=${XBPS_TRIPLET}
157 ac_add_options --target=${XBPS_CROSS_TRIPLET:-${XBPS_TRIPLET}}
158 ac_add_options --enable-linker=$(vopt_if clang lld bfd)
159 $(vopt_if lto 'ac_add_options --enable-lto=cross')
160 $(vopt_if clang 'ac_add_options --with-libclang-path=/usr/lib')
162 ac_add_options --enable-official-branding
163 ac_add_options --enable-application=browser
164 ac_add_options --enable-release
165 ac_add_options --enable-hardening
166 ac_add_options --enable-optimize="\${CFLAGS}"
167 ac_add_options --enable-path-remapping=c,rust
168 ac_add_options --disable-tests
169 ac_add_options --disable-crashreporter
170 ac_add_options --disable-updater
171 ac_add_options --disable-install-strip
172 ac_add_options --disable-strip
173 ac_add_options --disable-profiling
178 # XXX: wasi currently not ready
179 # ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
180 ac_add_options --without-wasm-sandboxed-libraries
182 ac_add_options --with-mozilla-api-keyfile="${wrksrc}/mozilla-api-key"
184 ac_add_options --enable-system-pixman
185 ac_add_options --with-system-ffi
186 ac_add_options --with-system-icu
187 ac_add_options --with-system-jpeg
188 ac_add_options --with-system-libevent
189 ac_add_options --with-system-libvpx
190 ac_add_options --with-system-nspr
191 ac_add_options --with-system-nss
192 ac_add_options --with-system-webp
193 ac_add_options --with-system-zlib
194 # XXX: the system's libpng doesn't have APNG support
195 ac_add_options --without-system-png
197 ac_add_options --with-unsigned-addon-scopes=app,system
198 ac_add_options --allow-addon-sideload
200 ac_add_options $(vopt_enable dbus)
201 ac_add_options $(vopt_enable dbus necko-wifi)
202 ac_add_options --disable-audio-backends
203 ac_add_options $(vopt_enable alsa)
204 ac_add_options $(vopt_enable jack)
205 ac_add_options $(vopt_enable pulseaudio)
206 ac_add_options $(vopt_enable sndio)
207 ac_add_options --enable-default-toolkit=$(vopt_if wayland 'cairo-gtk3-wayland' 'cairo-gtk3')
209 MOZ_APP_REMOTINGNAME=Firefox
212 # work around large debug symbols on 32-bit hosts
213 if [ "$XBPS_WORDSIZE" = "32" ]; then
214 echo "ac_add_options --disable-debug-symbols" >>.mozconfig
215 echo "ac_add_options --disable-debug" >>.mozconfig
216 export LDFLAGS+=" -Wl,--no-keep-memory"
219 if [ "$SOURCE_DATE_EPOCH" ]; then
220 export MOZ_BUILD_DATE=$(date --date "@$SOURCE_DATE_EPOCH" "+%Y%m%d%H%M%S")
223 export MOZ_MAKE_FLAGS="${makejobs}"
225 export MOZBUILD_STATE_PATH="${wrksrc}/mozbuild"
226 export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
233 export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
234 export MOZBUILD_STATE_PATH="${wrksrc}/mozbuild"
235 DESTDIR="$DESTDIR" ./mach install
237 vinstall "${FILESDIR}/vendor.js" 644 usr/lib/firefox/browser/defaults/preferences
238 vinstall "${FILESDIR}/firefox.desktop" 644 usr/share/applications
240 for i in 16x16 22x22 24x24 32x32 48x48 128x128 256x256; do
241 vinstall ${wrksrc}/browser/branding/official/default${i%x*}.png 644 \
242 usr/share/icons/hicolor/${i}/apps firefox.png
245 # We don't want the development stuff
246 rm -rf ${DESTDIR}/usr/{include,lib/firefox-devel,share/idl}
248 # https://bugzilla.mozilla.org/show_bug.cgi?id=658850
249 ln -sf firefox ${DESTDIR}/usr/lib/firefox/firefox-bin
251 vbin ${FILESDIR}/firefox-wayland