# Depends on python2
# Depends on dbus-glib
# Depends on yasm
# Depends on alsa-lib

# 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

# https://bugzilla.mozilla.org/show_bug.cgi?id=1130446:
wget https://bugzilla.mozilla.org/attachment.cgi?id=8560524&action=diff
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 firefox-31.4.0esr-build
cd firefox-31.4.0esr-build

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

# --disable-debug-symbols is used to be able to build firefox 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
make install

cd ..
rm -rf mozilla-esr31
#rm firefox-31.4.0esr.source.tar.bz2

exit 0
