# Note: depends on zlib
# Note: depends on openssl
# Note: depends on Python2 (has to be built with zlib support/module)
# Note: depends on unzip
# Note: depends on zip
# Note: depends on gtk+2
# Note: depends on gtk+
# Note: depends on dbus
# Note: depends on dbus-glib
# Note: depends on sqlite
# Note: depends on alsa-lib
# Note: depends on curl (for the crashreporter)
# Note: depends on yasm
# Note: depends on libXt
# Note: depends on mesa
# Note: depends on gst-plugins-base0
# Note: depends on pulseaudio
# Note: depends on libXcomposite
# Note: depends on nspr
# Note: depends on nss
# Note: depends on libevent
# Note: depends on libvpx
# Note: depends on icu
# Note: depends on GConf
# Note: depends on autoconf-2.13
wget -c https://ftp.gnu.org/gnu/gnuzilla/52.6.0/icecat-52.6.0-gnu1.tar.bz2
tar -xjf icecat-52.6.0-gnu1.tar.bz2
cd icecat-52.6.0
# Clear out binary blobs
find . -name '*.exe' -or -name 'keyedobjects.nib' -or -name '*.bin' -or -name '*.sfx' -or -name '*.dll' -or -name '*Binary.plist' -or -name 'i54633.sug' -or -name 'i54633.good' -or -name 'crashd*' -or -name 'crashIn*' -or -name 'distribute-[0-9]*' -or -name '*.zip' -or -name '*.[oa]' -or -name '*.jar' -or -name '*.xpi' -or -name '*^headers^' -or -name '*.app' | while read file; do if [ -e "$file" ]; then rm -rf "$file"; touch "$file"; fi; done
rm -rf testing/mozbase/mozinstall/tests/Installer-Stubs testing/talos/talos/profiler/dump_syms_mac
# Disable features that call home if enabled by default
sed -i -e 's/true/false/' toolkit/components/telemetry/datareporting-prefs.js toolkit/components/telemetry/healthreport-prefs.js

mkdir -p builddir
cd builddir
../configure --prefix="/usr" --disable-tests --disable-updater --with-system-nspr --with-system-libevent --with-system-nss --with-system-zlib --with-system-bz2 --with-system-libvpx --with-system-icu --enable-system-pixman --enable-official-branding
# Note: you may want to set up a large chunk of swap space for this build unless you have an abundance of RAM
make
make install