# Contributor: Marc Vertes <mvertes@free.fr>
# Maintainer: Marc Vertes <mvertes@free.fr>
pkgname=seamonkey
pkgver=2.46
pkgrel=6
pkgdesc="all-in-one internet application suite"
url="http://www.seamonkey-project.org"
arch="x86_64"
license="MPL"
depends=""
makedepends="unzip zip gtk+2.0-dev yasm alsa-lib-dev libxt-dev linux-headers
	hunspell-dev nspr-dev nss-dev jpeg-dev bzip2-dev zlib-dev libpng-dev
	libevent-dev libvpx-dev sqlite-dev libffi-dev pixman-dev python2-dev
	startup-notification-dev icu-dev m4 libxcomposite-dev paxmark autoconf2.13
	nss-static
	"
install=""
subpackages=""
source=" https://archive.mozilla.org/pub/mozilla.org/seamonkey/releases/$pkgver/source/seamonkey-$pkgver.source.tar.xz
	mozconfig

	fix-aouth.patch
	fix-hunspell.patch
	fix-libgen.patch
	fix-linux-syscall.patch
	fix-mallinfo.patch
	fix-platform-linux.patch
	fix-siginfo_t.patch
	fix-stabs.patch
	fix-sysctl.patch
	fix-system-headers.patch
	firefox-gcc-6.0.patch
	"

builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	cp ../../mozconfig .mozconfig
	export MOZ_MAKE_FLAGS="$MAKEFLAGS"
	export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/lib/seamonkey-$pkgver"
	# Needed for mozilla/python/mach/mach/mixin/process.py
	export SHELL="/bin/ash"
	# Disable null pointer gcc6 optimization in gcc6 (rhbz#1328045)
	MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -fno-delete-null-pointer-checks"
	unset MAKEFLAGS CPPFLAGS

	make -f client.mk build || return 1
}

package() {
	cd "$builddir"
	paxmark -msp */dist/bin/xpcshell || return 1
	make -f client.mk DESTDIR="$pkgdir" INSTALL_SDK= install || return 1
	paxmark -msp "$pkgdir/usr/lib/seamonkey-$pkgver/seamonkey" \
		"$pkgdir/usr/lib/seamonkey-$pkgver/seamonkey-bin" \
		"$pkgdir/usr/lib/seamonkey-$pkgver/plugin-container" || return 1

	rm -rf "$pkgdir/usr/lib/seamonkey-$pkgver/dictionaries" \
		"$pkgdir/usr/lib/seamonkey-$pkgver/hypenation"
	ln -s /usr/share/hunspell \
		"$pkgdir/usr/lib/seamonkey-$pkgver/dictionaries"
	ln -s /usr/share/hyphen \
		"$pkgdir/usr/lib/seamonkey-$pkgver/hyphenation"
	install -Dm644 suite/branding/nightly/icons/gtk/seamonkey.png \
		"$pkgdir/usr/share/pixmaps/seamonkey.png"
	install -Dm644 mozilla/toolkit/mozapps/installer/linux/rpm/mozilla.desktop \
		"$pkgdir/usr/share/applications/seamonkey.desktop"
	sed -i 's/@MOZ_APP_DISPLAYNAME@/SeaMonkey internet suite/' \
		"$pkgdir/usr/share/applications/seamonkey.desktop"
	sed -i 's/@MOZ_APP_NAME@/seamonkey/' \
		"$pkgdir/usr/share/applications/seamonkey.desktop"
	rm -f "$pkgdir/usr/lib/pkgconfig/seamonkey-nss.pc"
	rm -f "$pkgdir/usr/lib/pkgconfig/seamonkey-nspr.pc"
}

sha512sums="b70a40ad6797c82458436ce8e15d461bec982916a3ad5949610f2830647872f3b54a63fb62b17780c33e74c067054b590d0a5ebd0e836854a10e60feee692491  seamonkey-2.46.source.tar.xz
24cf618f0bd28cf0aef645db311cb62962f655e29c72b299095731a845361aac8d041e526f0407014ee2dd6825bc4399b74ba8f9e09120a9f4becc7d5eb6f372  mozconfig
c3b3b5a32f8672a42c051c03c31761414ce52c4a32258f1c7417af7de891e4b5f620ef2762034a18f84e5c7235559d920963aff0f28c2c1f4ae697a38d49b89c  fix-aouth.patch
ea58a2cf58e7d1d99a2346a6977fcb2acff8052e304f9f0d66e24241d77fe352610537c4d2a886b9085b970368dbe46e5011acc210bebcdf22a88a4b5be960b1  fix-hunspell.patch
f148a9212b9d1bf62ce99e3ea69233fcdd74ffb0948ab53d17ec417539b4f9533409b2e9c487e3789b76cdfca92da074b9ea0f82452f56f72eced9cfbcd078f1  fix-libgen.patch
fe377b6c0acbbb569f363cde2de8c640837237120bcbc3099cb9d9691f5b576cd76c531b0019e45385f696d7be60bb97141e39f2de742cb6d1a138fbcf217cc5  fix-linux-syscall.patch
fd6b68082843a17a97a09953f24f74e72090acbcd245e8564ffe41ed5cb0a7afbf3dfc653a6e33a5f0bb0218ec11430f92acedc0c98a32c17dd2a053c3eef855  fix-mallinfo.patch
25bb4f99a2d831a8604444a1071ca946c14b9fe416929660ce6f9d196b3cecbd84b8706a8a16f2653db0d722a8f033fac9dc2f295bf5b59e7f39024d89221d01  fix-platform-linux.patch
285e9330810b0f57ebba3d15cb371543840a7c6b8a2656d6d6b3ad7e8d2ec840b34bcb75b92c3747b5a1b42625fbde3a5d1bbec7052ce47fe5455e5076ec6268  fix-siginfo_t.patch
4a7fae85299969618d729021ed79ab312650419dd849800c4e93c2b78a063a91f4003e2ee66c74abefa28b881376cf78f52e99e5ae3c08b85ba11eeae73a5034  fix-stabs.patch
43e800bdb15a11c21f71d0552ae2e92ad97574eb324f7be75cc92ed98332201386f9c9846d3e5f27b4e71452ffac71ab5b82ffdc2091d6c4830b9cb792bbdde4  fix-sysctl.patch
d65900a74901d0455266342e4efbb655d67c62b52e69f482c33c3da3e24af900a3186f1398b88cccd9e822395480cd4ec4ce0d6053978003911457cacc36f767  fix-system-headers.patch
664983718ba4ed2588850f499cc7da94f2b35d384b6655b1e5ec118e45e8cbd108aa2b9e04cc4b902f4ddba2e1be2cffb056643e053761bfc6da92c942f30305  firefox-gcc-6.0.patch"