# 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 http://ftpmirror.gnu.org/gnuzilla/31.4.0/icecat-31.4.0.tar.bz2

# 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 icecat-31.4.0-bug1130446.patch

tar xf icecat-31.4.0.tar.bz2

cd icecat-31.4.0
patch -p1 < ../icecat-31.4.0-bug1130446.patch
cd ..

mkdir icecat-31.4.0-build
cd icecat-31.4.0-build

../icecat-31.4.0/configure \
    --prefix=/usr \
    --enable-application=browser \
    --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.

make
make install

cd ..
exit 0
