# Depends on: autoconf2-13 gtk2 gtk3 unzip yasm zip icu libevent libvpx nspr nss pulseaudio sqlite dbus-glib gconf gstreamer-plugins-base startup-notification

description="Browser suite, the Open Source sibling of Netscape"
url="https://www.seamonkey-project.org/"
packager="tnut <tnut@nutyx.org>"

name=seamonkey
version=2.49.4
release=2

source=( https://ftp.mozilla.org/pub/$name/releases/$version/source/$name-$version.source.tar.xz )

build()  {

cd $name-$version
cat > mozconfig << "EOF"
# If you have a multicore machine, all cores will be used by default.
# If desired, you can reduce the number of cores used, e.g. to 1, by
# uncommenting the next line and setting a valid number of CPU cores.
#mk_add_options MOZ_MAKE_FLAGS="-j1"

# If you have installed DBus-Glib comment out this line:
# ac_add_options --disable-dbus

# If you have installed dbus-glib, and you have installed (or will install)
# wireless-tools, and you wish to use geolocation web services, comment out
# this line
ac_add_options --disable-necko-wifi

# Uncomment these lines if you have installed optional dependencies:
#ac_add_options --enable-system-hunspell
ac_add_options --enable-startup-notification

# Uncomment the following option if you have not installed PulseAudio
#ac_add_options --disable-pulseaudio
# and uncomment this if you installed alsa-lib instead of PulseAudio
#ac_add_options --enable-alsa

# Comment out following option if you have gconf installed
ac_add_options --disable-gconf

# Comment out following options if you have not installed
# recommended dependencies:
ac_add_options --enable-system-sqlite
ac_add_options --with-system-libevent
ac_add_options --with-system-libvpx
ac_add_options --with-system-nspr
ac_add_options --with-system-nss
ac_add_options --with-system-icu



# The BLFS editors recommend not changing anything below this line:
ac_add_options --prefix=/usr
ac_add_options --enable-application=suite

ac_add_options --disable-crashreporter
ac_add_options --disable-updater
ac_add_options --disable-tests

ac_add_options --enable-optimize="-O2"
ac_add_options --enable-strip
ac_add_options --enable-install-strip

ac_add_options --enable-gio
ac_add_options --enable-official-branding
ac_add_options --enable-safe-browsing
ac_add_options --enable-url-classifier

# From firefox-40 (and the corresponding version of seamonkey),
# using system cairo caused seamonkey to crash
# frequently when it was doing background rendering in a tab.
# This appears to again work in seamonkey-2.49.2
ac_add_options --enable-system-cairo
ac_add_options --enable-system-ffi
ac_add_options --enable-system-pixman

ac_add_options --with-pthreads

ac_add_options --with-system-bz2
ac_add_options --with-system-jpeg
ac_add_options --with-system-png
ac_add_options --with-system-zlib
EOF

CFLAGS_HOLD=$CFLAGS
CXXFLAGS_HOLD=$CXXFLAGS
EXTRA_FLAGS=" -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2"
export CFLAGS+=$EXTRA_FLAGS
export CXXFLAGS+=$EXTRA_FLAGS
unset EXTRA_FLAGS

SHELL=/bin/sh make -f client.mk

SHELL=/bin/sh make -f client.mk DESTDIR=$PKG install INSTALL_SDK=

chown -R 0:0 $PKG/usr/lib/$name-$version

mkdir -p $PKG/usr/share/man/man1
cp -v $(find -name seamonkey.1 | head -n1) $PKG/usr/share/man/man1

install -Dm644 suite/branding/nightly/icons/gtk/seamonkey.png \
$PKG/usr/share/pixmaps/seamonkey.png

install -Dm644 mozilla/toolkit/mozapps/installer/linux/rpm/mozilla.desktop \
$PKG/usr/share/applications/seamonkey.desktop

sed -i 's/@MOZ_APP_DISPLAYNAME@/SeaMonkey internet suite/' \
$PKG/usr/share/applications/seamonkey.desktop

sed -i 's/@MOZ_APP_NAME@/seamonkey/' \
$PKG/usr/share/applications/seamonkey.desktop

}
