# Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ EAPI="5" WANT_AUTOCONF="2.1" PYTHON_COMPAT=( python2_7 ) PYTHON_REQ_USE='threads,sqlite' SRC_URI="http://ftpmirror.gnu.org/gnuzilla/${PV}/${P}-gnu1.tar.bz2" # original firefox 38.2.0 used mozconfig-v6.38 eclass inherit check-reqs flag-o-matic toolchain-funcs eutils multilib pax-utils autotools python-any-r1 DESCRIPTION="Icecat Web Browser" HOMEPAGE="https://www.gnu.org/software/gnuzilla/" KEYWORDS="~alpha amd64 ~arm hppa ~ia64 ppc ppc64 x86 ~amd64-linux ~x86-linux" SLOT="0" LICENSE="MPL-2.0 GPL-2 LGPL-2.1" IUSE="custom-cflags custom-optimization egl hardened +minimal neon pgo selinux test debug tests gstreamer gstreamer-0 pulseaudio startup-notification system-cairo system-icu system-jpeg system-sqlite system-libvpx" ASM_DEPEND=">=dev-lang/yasm-1.1" # Mesa 7.10 needed for WebGL + bugfixes RDEPEND=" >=dev-libs/nss-3.19.2 >=dev-libs/nspr-4.10.8 selinux? ( sec-policy/selinux-mozilla ) dev-libs/atk dev-libs/expat >=dev-libs/libevent-1.4.7 >=x11-libs/cairo-1.10[X] >=x11-libs/gtk+-2.18:2 x11-libs/gdk-pixbuf >=x11-libs/pango-1.22.0 >=media-libs/libpng-1.6.16:0=[apng] >=media-libs/mesa-10.2:* media-libs/fontconfig >=media-libs/freetype-2.4.10 kernel_linux? ( media-libs/alsa-lib ) pulseaudio? ( media-sound/pulseaudio ) virtual/freedesktop-icon-theme startup-notification? ( >=x11-libs/startup-notification-0.8 ) >=dev-libs/glib-2.26:2 >=sys-libs/zlib-1.2.3 >=virtual/libffi-3.0.10 gstreamer? ( >=media-libs/gstreamer-1.4.5:1.0 >=media-libs/gst-plugins-base-1.4.5:1.0 >=media-libs/gst-plugins-good-1.4.5:1.0 >=media-plugins/gst-plugins-libav-1.4.5:1.0 ) gstreamer-0? ( media-plugins/gst-plugins-meta:0.10[ffmpeg] ) x11-libs/libX11 x11-libs/libXcomposite x11-libs/libXdamage x11-libs/libXext x11-libs/libXfixes x11-libs/libXrender x11-libs/libXt system-cairo? ( >=x11-libs/cairo-1.12[X] >=x11-libs/pixman-0.19.2 ) system-icu? ( >=dev-libs/icu-51.1:= ) system-jpeg? ( >=media-libs/libjpeg-turbo-1.2.1 ) system-sqlite? ( >=dev-db/sqlite-3.8.8.2:3[secure-delete,debug=] ) system-libvpx? ( >=media-libs/libvpx-1.3.0[postproc] ) " DEPEND="${RDEPEND} app-arch/zip app-arch/unzip >=sys-devel/binutils-2.16.1 pgo? ( >=sys-devel/gcc-4.5 ) amd64? ( ${ASM_DEPEND} virtual/opengl ) x86? ( ${ASM_DEPEND} virtual/opengl ) virtual/pkgconfig ${PYTHON_DEPS}" QA_PRESTRIPPED="usr/$(get_libdir)/${PN}/icecat" BUILD_OBJ_DIR="${S}/pkgbuild-${ARCH}" pkg_setup() { # Ensure we use C locale when building export LANG="C" export LC_ALL="C" export LC_MESSAGES="C" export LC_CTYPE="C" # Ensure that we have a sane build enviroment export MOZILLA_CLIENT=1 export BUILD_OPT=1 export NO_STATIC_LIB=1 export USE_PTHREADS=1 export ALDFLAGS=${LDFLAGS} # ensure MOZCONFIG is not defined eval unset MOZCONFIG # nested configure scripts in mozilla products generate unrecognized options # false positives when toplevel configure passes downwards. export QA_CONFIGURE_OPTIONS=".*" if [[ $(gcc-major-version) -eq 3 ]]; then ewarn "Unsupported compiler detected, DO NOT file bugs for" ewarn "outdated compilers. Bugs opened with gcc-3 will be closed" ewarn "invalid." fi python-any-r1_pkg_setup # Avoid PGO profiling problems due to enviroment leakage # These should *always* be cleaned up anyway unset DBUS_SESSION_BUS_ADDRESS \ DISPLAY \ ORBIT_SOCKETDIR \ SESSION_MANAGER \ XDG_SESSION_COOKIE \ XAUTHORITY if use pgo; then einfo ewarn "You will do a double build for profile guided optimization." ewarn "This will result in your build taking at least twice as long as before." fi } pkg_pretend() { # Ensure we have enough disk space to compile if use pgo || use debug || use test ; then CHECKREQS_DISK_BUILD="8G" else CHECKREQS_DISK_BUILD="4G" fi check-reqs_pkg_setup } src_unpack() { unpack ${A} } src_prepare() { cd "${S}" epatch "${FILESDIR}"/2000_"${PN}"_gentoo-install-dirs.patch epatch "${FILESDIR}"/5002_"${PN}"_application-handlers.patch epatch "${FILESDIR}"/6001_"${PN}"_alpha-defines.patch epatch "${FILESDIR}"/7000_"${PN}"_drop-Wl-build-id-v4.patch epatch "${FILESDIR}"/7003_"${PN}"_freebsd-jscpucfg.patch epatch "${FILESDIR}"/7004_"${PN}"_freebsd-libexecinfo-v3.patch epatch "${FILESDIR}"/8001_"${PN}"_hppa-js-configure.patch epatch "${FILESDIR}"/8003_"${PN}"_gmp-clearkey-sprintf.patch epatch "${FILESDIR}"/8010_"${PN}"_bug114311-freetype26.patch # Allow user to apply any additional patches without modifing ebuild epatch_user # Enable gnomebreakpad if use debug ; then sed -i -e "s:GNOME_DISABLE_CRASH_DIALOG=1:GNOME_DISABLE_CRASH_DIALOG=0:g" \ "${S}"/build/unix/run-icecat.sh || die "sed failed!" fi # Ensure that our plugins dir is enabled as default sed -i -e "s:/usr/lib/mozilla/plugins:/usr/lib/nsbrowser/plugins:" \ "${S}"/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 32bit!" sed -i -e "s:/usr/lib64/mozilla/plugins:/usr/lib64/nsbrowser/plugins:" \ "${S}"/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 64bit!" # Fix sandbox violations during make clean, bug 372817 sed -e "s:\(/no-such-file\):${T}\1:g" \ -i "${S}"/config/rules.mk \ -i "${S}"/nsprpub/configure{.in,} \ || die # Don't exit with error when some libs are missing which we have in # system. sed '/^MOZ_PKG_FATAL_WARNINGS/s@= 1@= 0@' \ -i "${S}"/browser/installer/Makefile.in || die # Don't error out when there's no files to be removed: sed 's@\(xargs rm\)$@\1 -f@' \ -i "${S}"/toolkit/mozapps/installer/packager.mk || die eautoreconf # Must run autoconf in js/src cd "${S}"/js/src || die eautoconf # Need to update jemalloc's configure cd "${S}"/memory/jemalloc/src || die WANT_AUTOCONF= eautoconf } src_configure() { MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}" MEXTENSIONS="default" export MOZ_SRTP=0 export MOZ_SRTP=0 export NECKO_WIFI=0 export NECKO_WIFI_DBUS=0 export MOZ_PEERCONNECTION=0 export MOZ_TELEMETRY_REPORTING=0 #################################### # # CFLAGS setup and ARCH support # #################################### # Set optimization level if [[ ${ARCH} == hppa ]]; then echo "ac_add_options --enable-optimize=-O0" >>.mozconfig elif [[ ${ARCH} == x86 ]]; then echo "ac_add_options --enable-optimize=-O2" >>.mozconfig elif use custom-optimization || [[ ${ARCH} =~ (alpha|ia64) ]]; then # Set optimization level based on CFLAGS if is-flag -O0; then echo "ac_add_options --enable-optimize=-O0" >>.mozconfig elif [[ ${ARCH} == ppc ]] && has_version '>=sys-libs/glibc-2.8'; then echo "ac_add_options --enable-optimize=-O1" >>.mozconfig elif is-flag -O3; then echo "ac_add_options --enable-optimize=-O3" >>.mozconfig elif is-flag -O1; then echo "ac_add_options --enable-optimize=-O1" >>.mozconfig elif is-flag -Os; then echo "ac_add_options --enable-optimize=-Os" >>.mozconfig else echo "ac_add_options --enable-optimize=-O2" >>.mozconfig fi else # Enable Mozilla's default echo "ac_add_options --enable-optimize" >>.mozconfig fi # Strip optimization so it does not end up in compile string filter-flags '-O*' # Strip over-aggressive CFLAGS use custom-cflags || strip-flags # Additional ARCH support case "${ARCH}" in alpha) # Historically we have needed to add -fPIC manually for 64-bit. # Additionally, alpha should *always* build with -mieee for correct math # operation append-flags -fPIC -mieee ;; ia64) # Historically we have needed to add this manually for 64-bit append-flags -fPIC ;; ppc64) append-flags -fPIC -mminimal-toc ;; esac # Go a little faster; use less RAM append-flags "$MAKEEDIT_FLAGS" #################################### # # mozconfig setup # #################################### echo "ac_add_options --disable-pedantic" >>.mozconfig echo "ac_add_options --disable-updater" >>.mozconfig echo "ac_add_options --disable-strip" >>.mozconfig echo "ac_add_options --disable-install-strip" >>.mozconfig echo "ac_add_options --disable-installer" >>.mozconfig echo "ac_add_options --disable-strip-libs" >>.mozconfig # Here is a strange one... if is-flag '-mcpu=ultrasparc*' || is-flag '-mtune=ultrasparc*'; then echo "ac_add_options --enable-js-ultrasparc" >>.mozconfig fi # Currently --enable-elf-dynstr-gc only works for x86, # thanks to Jason Wever for the fix. if use x86 && [[ ${enable_optimize} != -O0 ]]; then echo "ac_add_options --enable-elf-dynstr-gc" >> .mozconfig fi # jemalloc won't build with older glibc if ! has_version ">=sys-libs/glibc-2.4"; then echo "ac_add_options --disable-jemalloc" >> .mozconfig else echo "export MOZ_JEMALLOC3=1" >> "${S}"/.mozconfig || die echo "ac_add_options --enable-jemalloc" >>.mozconfig echo "ac_add_options --enable-replace-malloc" >>.mozconfig fi #################################### # # other setup # #################################### echo "ac_add_options --disable-webrtc" >> .mozconfig echo "ac_add_options --with-system-zlib" >>.mozconfig echo "ac_add_options --enable-pango" >>.mozconfig echo "ac_add_options --enable-svg" >>.mozconfig echo "ac_add_options --with-system-bz2" >>.mozconfig echo "ac_add_options --enable-default-toolkit=cairo-gtk2" >>.mozconfig echo "ac_add_options --disable-dbus" >>.mozconfig echo "ac_add_options --disable-necko-wifi" >>.mozconfig echo "ac_add_options --disable-android-apz" >>.mozconfig echo "ac_add_options --enable-profiling" >>.mozconfig if use debug; then echo "ac_add_options --enable-debug" >>.mozconfig echo "ac_add_options --enable-debug-symbols" >>.mozconfig fi if use tests; then echo "ac_add_options --enable-tests" >>.mozconfig else echo "ac_add_options --disable-tests" >>.mozconfig fi if use startup-notification; then echo "ac_add_options --enable-startup-notification" >>.mozconfig fi # for webm echo "ac_add_options --enable-ogg" >>.mozconfig echo "ac_add_options --enable-wave" >>.mozconfig # system defaults echo "ac_add_options --with-system-nspr --with-nspr-prefix=${EPREFIX}/usr" >>.mozconfig echo "ac_add_options --with-system-nss --with-nss-prefix=${EPREFIX}/usr" >>.mozconfig echo "ac_add_options --x-includes=${EPREFIX}/usr/include --x-libraries=${EPREFIX}/usr/$(get_libdir)" >>.mozconfig echo "ac_add_options --with-system-libevent=${EPREFIX}/usr" >>.mozconfig echo "ac_add_options --prefix=${EPREFIX}/usr" >>.mozconfig echo "ac_add_options --libdir=${EPREFIX}/usr/$(get_libdir)" >>.mozconfig echo "ac_add_options --disable-system-hunspell" >>.mozconfig echo "ac_add_options --disable-gnomevfs" >>.mozconfig echo "ac_add_options --disable-gnomeui" >>.mozconfig echo "ac_add_options --enable-gio" >>.mozconfig echo "ac_add_options --disable-crashreporter" >>.mozconfig echo "ac_add_options --with-system-png" >>.mozconfig echo "ac_add_options --enable-system-ffi" >>.mozconfig echo "ac_add_options --disable-gold" >>.mozconfig echo "ac_add_options --disable-gconf" >>.mozconfig echo "ac_add_options --target=${CTARGET:-${CHOST}}" >>.mozconfig echo "ac_add_options --build=${CTARGET:-${CHOST}}" >>.mozconfig if use gstreamer; then echo "ac_add_options --enable-gstreamer=1.0" >>.mozconfig elif use gstreamer-0 ; then echo "ac_add_options --enable-gstreamer=0.10" >>.mozconfig else echo "ac_add_options --disable-gstreamer" >>.mozconfig fi if use pulseaudio; then echo "ac_add_options --enable-pulseaudio" >>.mozconfig else echo "ac_add_options --disable-pulseaudio" >>.mozconfig fi if use system-cairo; then echo "ac_add_options --enable-system-cairo" >>.mozconfig echo "ac_add_options --enable-system-pixman" >>.mozconfig fi if use system-sqlite; then echo "ac_add_options --enable-system-sqlite" >>.mozconfig fi if use system-jpeg; then echo "ac_add_options --with-system-jpeg" >>.mozconfig fi if use system-icu; then echo "ac_add_options --with-system-icu" >>.mozconfig echo "ac_add_options --enable-intl-api" >>.mozconfig fi if use system-libvpx; then echo "ac_add_options --with-system-libvpx" >>.mozconfig else sed -i -e "s|softfp|hard|" \ "${S}"/media/libvpx/moz.build fi # It doesn't compile on alpha without this LDFLAGS use alpha && append-ldflags "-Wl,--no-relax" # Add full relro support for hardened use hardened && append-ldflags "-Wl,-z,relro,-z,now" if use neon ; then echo "ac_add_options --with-fpu=neon" >>.mozconfig echo "ac_add_options --with-thumb=yes" >>.mozconfig echo "ac_add_options --with-thumb-interwork=no" >>.mozconfig fi if [[ ${CHOST} == armv* ]] ; then echo "ac_add_options --with-float-abi=hard" >>.mozconfig echo "ac_add_options --enable-skia" >>.mozconfig fi if use egl; then echo "ac_add_options --with-gl-provider=EGL" >>.mozconfig fi echo "ac_add_options --enable-extensions=${MEXTENSIONS}" >>.mozconfig echo "ac_add_options --disable-mailnews" >>.mozconfig # Other ff-specific settings echo "ac_add_options --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}" >>.mozconfig # Allow for a proper pgo build if use pgo; then echo "mk_add_options PROFILE_GEN_SCRIPT='\$(PYTHON) \$(OBJDIR)/_profile/pgo/profileserver.py'" >> "${S}"/.mozconfig fi echo "mk_add_options MOZ_OBJDIR=${BUILD_OBJ_DIR}" >> "${S}"/.mozconfig #################################### # # Finalize and report settings # #################################### declare ac opt hash reason echo echo "==========================================================" echo "Building ${PF} with the following configuration" grep ^ac_add_options .mozconfig | while read ac opt; do [[ -z ${hash} || ${hash} == \# ]] \ || die "error reading mozconfig: ${ac} ${opt}" printf " %-30s %s\n" "${opt}" done echo "==========================================================" echo if [[ $(gcc-major-version) -lt 4 ]]; then append-cxxflags -fno-stack-protector fi # workaround for funky/broken upstream configure... emake -f client.mk configure } src_compile() { if use pgo; then addpredict /root addpredict /etc/gconf # Icecat tries to use dri stuff when it's run, see bug 380283 shopt -s nullglob cards=$(echo -n /dev/dri/card* | sed 's/ /:/g') if test -z "${cards}"; then cards=$(echo -n /dev/ati/card* /dev/nvidiactl* | sed 's/ /:/g') if test -n "${cards}"; then # Binary drivers seem to cause access violations anyway, so # let's use indirect rendering so that the device files aren't # touched at all. See bug 394715. export LIBGL_ALWAYS_INDIRECT=1 fi fi shopt -u nullglob addpredict "${cards}" CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \ MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL}" \ Xemake -f client.mk profiledbuild || die "Xemake failed" else CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \ MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL}" \ emake -f client.mk realbuild fi } src_install() { LIBDIR="$(get_libdir)" MOZILLA_FIVE_HOME="${LIBDIR}/${PN}" BUILDDIR="" DICTPATH="\"${EPREFIX}/usr/share/myspell\"" cd "${BUILD_OBJ_DIR}" || die # Pax mark xpcshell for hardened support, only used for startupcache creation. pax-mark m "${BUILD_OBJ_DIR}"/dist/bin/xpcshell MOZ_MAKE_FLAGS="${MAKEOPTS}" \ emake DESTDIR="${BUILD_OBJ_DIR}/image" install # Required in order to use plugins and even run icecat on hardened. pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/{icecat,icecat-bin,plugin-container} if use minimal; then rm -fr "${ED}/${PN}${EPREFIX}/usr/include" || echo "warning: failed to remove include dir." rm -fr "${ED}/${PN}${EPREFIX}/usr/share" || echo "warning: failed to remove share dir." rm -fr "${ED}/${PN}${MOZILLA_FIVE_HOME}-devel" || echo "warning: failed to remove devel dir." fi # revdep-rebuild entry insinto /etc/revdep-rebuild echo "SEARCH_DIRS_MASK=${MOZILLA_FIVE_HOME}" >> ${T}/10${PN} doins "${T}"/10${PN} || die }