# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# T2 SDE: package/.../seamonkey/seamonkey.conf
# Copyright (C) 2004 - 2014 The T2 SDE Project
# Copyright (C) 1998 - 2004 ROCK Linux Project
# 
# More information can be found in the files COPYING and README.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- T2-COPYRIGHT-NOTE-END ---

if [ $prefix_auto = 1 ] ; then
	prefix=$mozilla_prefix
	set_confopt
fi

hook_add preconf 8 "mkdir -p objdir; cd objdir; configscript=../configure"
var_remove makeopt ' ' '-f client.mk build'

# BK
mozilla_config() {
	cat >> .mozconfig <<-EOT
ac_add_options --enable-application=suite
ac_add_options --disable-accessibility
ac_add_options --with-system-bz2
ac_add_options --disable-updater
ac_add_options --disable-parental-controls
ac_add_options --enable-places
ac_add_options --disable-gnomevfs
ac_add_options --enable-system-sqlite
ac_add_options --enable-system-cairo
ac_add_options --enable-strip
ac_add_options --with-system-zlib
ac_add_options --enable-libxul
ac_add_options --enable-storage
ac_add_options --disable-tests
ac_add_options --with-default-mozilla-five-home=/usr/lib/seamonkey
ac_add_options --enable-jsd
ac_add_options --enable-default-toolkit=cairo-gtk2
ac_add_options --disable-crashreporter
ac_add_options --enable-gio
ac_add_options --enable-chrome-format=omni
ac_add_options --without-system-nspr
ac_add_options --without-system-nss
ac_add_options --disable-angle
ac_add_options --disable-debug
ac_add_options --disable-logging
ac_add_options --disable-gnomeui
ac_add_options --with-pthreads
ac_add_options --enable-system-pixman
ac_add_options --disable-profilesharing
ac_add_options --enable-crypto
ac_add_options --enable-mathml
ac_add_options --disable-ldap
ac_add_options --enable-install-strip
EOT

# BK unfortunately, this causes compile fail (after compiling for many hours!). v2.30
# ac_add_options --enable-shared-js

# BK
pkginstalled libnotify || echo "ac_add_options --disable-libnotify" >> .mozconfig
pkginstalled gconf || echo "ac_add_options --disable-gconf" >> .mozconfig
pkginstalled libffi && echo "ac_add_options --enable-system-ffi" >> .mozconfig
pkginstalled libvpx && echo "ac_add_options --with-system-libvpx" >> .mozconfig

# BK not sure about this. standard libjpeg causes seamonkey config error.
if pkginstalled libjpeg-turbo;then
 echo "ac_add_options --with-system-jpeg" >> .mozconfig
else
 echo "ac_add_options --without-system-jpeg" >> .mozconfig
fi

# BK necko-wifi thing needs dbus, needs explicit disable if no dbus:
if pkginstalled dbus; then
	#defaults anyway:
	echo "ac_add_options --enable-dbus" >> .mozconfig
	echo "ac_add_options --enable-necko-wifi" >> .mozconfig
else
	echo "ac_add_options --disable-dbus" >> .mozconfig
	echo "ac_add_options --disable-necko-wifi" >> .mozconfig
fi

pkginstalled hunspell && echo "ac_add_options --enable-system-hunspell" >> .mozconfig
# BK strange, need explicit disable here if no pulseaudio:
pkginstalled pulseaudio || echo "ac_add_options --disable-pulseaudio" >> .mozconfig

if pkginstalled gstreamer; then
	echo "ac_add_options --enable-gstreamer=1.0" >> .mozconfig
else
	echo "ac_add_options --disable-gstreamer" >> .mozconfig
fi

pkginstalled icu4c && echo "ac_add_options --with-system-icu" >> .mozconfig
cat .mozconfig
}
	
mozilla_postinstall() {
	echo "Copy all mozilla include files" \
	     "(required for building galeon, evolution, etc.) ..."
	mkdir -p $includedir/$pkg-$ver/xpcom
	cp -v mozilla/xpcom/base/nscore.h  $includedir/$pkg-$ver/xpcom/
	cp -v mozilla/xpcom/glue/nsDebug.h $includedir/$pkg-$ver/xpcom/
	cp -rL mozilla/dist/include/*      $includedir/$pkg-$ver/
	cp -rL mozilla/dist/public/*       $includedir/$pkg-$ver/

	echo "Creating /etc/profile.d/$pkg ..."
	cat <<- EOT > $root/etc/profile.d/$pkg
		export MOZILLA_FIVE_HOME=$MOZILLA_FIVE_HOME
	EOT

	echo "Creating library symlinks ..."
	cd $libdir
	for i in ldap50 nspr4 nss3 plc4 plds4 prldap50 smime3 softokn3 ssl3 ; do
		ln -sf $libdir/$pkg-$ver/lib${i}.so $libdir/lib${i}.so
	done
}

hook_add preconf  4 'mozilla_config'
hook_add postmake 8 'mozilla_postinstall'
