# Depends on python2
# Depends on unzip
# Depends on zip
# Depends on gtk
# Depends on gtk-unix-print
# Depends on glib
# Depends on gobject
# Depends on gdk-x11
# Depends on libogg
# Depends on libvorbis
# Depends on gstreamer (>=0.10.25)
# Depends on gst-plugins-base 0.10

# Exit on error:
set -e

# Be verbose:
set -v

wget \
    https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/31.4.0esr/source/firefox-31.4.0esr.source.tar.bz2 \
    --no-check-certificate


# https://bugzilla.mozilla.org/show_bug.cgi?id=1130446:
wget \
    https://bug1130446.bugzilla.mozilla.org/attachment.cgi?id=8560524 \
    --no-check-certificate

mv attachment.cgi?id=8560524 firefox-31.4.0esr-bug1130446.patch

tar xf firefox-31.4.0esr.source.tar.bz2

cd mozilla-esr31
patch -p1 < ../firefox-31.4.0esr-bug1130446.patch
cd ..

mkdir xulrunner-31.4.0esr-build
cd xulrunner-31.4.0esr-build

../mozilla-esr31/configure \
    --prefix=/usr \
    --enable-application=xulrunner \
    --disable-pulseaudio \
    --disable-tests \
    --disable-crashreporter \
    --disable-updater \
    --disable-parental-controls \
    --disable-debug-symbols

# --disable-debug-symbols is used to be able to build Icecat with "only"
# 2 GB of RAM, otherwise, the build fails.

#    --disable-webgl \
#    --disable-jsd \
#    --disable-opus \
#    --disable-wmf \
#    --disable-wave \
#    --disable-necko-wifi \
#    --disable-gconf \
#    --disable-dbus \
#    --disable-websms-backend \
#    --disable-gamepad \
#    --disable-accessibility \

make 2>&1 | tee make.log

make install

cd ..
exit 0
