SUMMARY="Small but very powerful text-based mail client"
DESCRIPTION="A text-based email client for Unix-like systems. \
The Mutt slogan is All mail clients suck. This one just sucks less."
HOMEPAGE="http://www.mutt.org/"
COPYRIGHT="1996-2016 Michael R. Elkins
	1996-2002 Brandon Long
	1997-2009 Thomas Roessler
	1998-2005 Werner Koch
	1999-2014 Brendan Cully
	1999-2002 Tommi Komulainen
	2000-2004 Edmund Grimley Evans
	2006-2009 Rocco Rutte
	2014-2018 Kevin J. McCarthy"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://bitbucket.org/mutt/mutt/downloads/mutt-$portVersion.tar.gz"
CHECKSUM_SHA256="47972a0152b81b9f67ff322a0a6682b914c15545bfdeac6bcc2f2c0bf9361844"
PATCHES="mutt-$portVersion.patchset"

ARCHITECTURES="all ?x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

commandBinDir=$binDir
commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandBinDir=$prefix/bin
	commandSuffix=
fi

PROVIDES="
	mutt$secondaryArchSuffix = $portVersion
	cmd:flea$commandSuffix = $portVersion
	cmd:mutt$commandSuffix = $portVersion
	cmd:muttbug$commandSuffix = $portVersion
	cmd:pgpewrap$commandSuffix = $portVersion
	cmd:mutt_pgpring$commandSuffix = $portVersion
	cmd:smime_keys$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:gpg$secondaryArchSuffix
	lib:libaspell$secondaryArchSuffix
	lib:libassuan$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libgettextpo$secondaryArchSuffix
	lib:libgnutls$secondaryArchSuffix
	lib:libgpgme$secondaryArchSuffix
	lib:libgpg_error$secondaryArchSuffix
	lib:libgsasl$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libidn$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
#	lib:libsasl2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:libaspell$secondaryArchSuffix
	devel:libassuan$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libgettextlib$secondaryArchSuffix
	devel:libgnutls$secondaryArchSuffix
	devel:libgpgme$secondaryArchSuffix
	devel:libgpg_error$secondaryArchSuffix
	devel:libgsasl$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libidn$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
#	devel:libsasl2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:autoreconf
	cmd:awk
	cmd:bison
	cmd:gawk
	cmd:gcc$secondaryArchSuffix
	cmd:gpg$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:m4
	"

GLOBAL_WRITABLE_FILES="
	settings/Muttrc keep-old
	settings/Muttrc.dist keep-old
	settings/mime.types keep-old
	settings/mime.types.dist keep-old
	"

defineDebugInfoPackage mutt$secondaryArchSuffix \
	$commandBinDir/mutt \
	$commandBinDir/pgpewrap \
	$commandBinDir/mutt_pgpring

BUILD()
{
	export CFLAGS="-D_BSD_SOURCE"
	export LDFLAGS="-lnetwork -lbsd"

	libtoolize --force --copy --install
	autoreconf -vfi

	runConfigure --omit-dirs "binDir" configure \
		--enable-compressed \
		--enable-gpgme \
		--enable-imap \
		--enable-pop \
		--enable-smtp \
		--enable-sidebar \
		--disable-warnings \
		--with-gnutls \
		--with-idn \
		--with-regex \
		--with-ssl \
		--with-mailpath=`finddir B_USER_DIRECTORY`/mail/mutt \
		--bindir=$commandBinDir

	make $jobArgs
}

INSTALL()
{
	make install
}
