SUMMARY="Display TUI widgets for shell scripts"
DESCRIPTION="Dialog is an application used in shell scripts which displays \
text user interface widgets. It uses the curses or ncurses library."
HOMEPAGE="https://invisible-island.net/dialog/"
COPYRIGHT="1999-2014 Thomas E. Dickey"
LICENSE="GNU LGPL v2"
SOURCE_URI="ftp://ftp.invisible-island.net/dialog/dialog-${portVersion/_/-}.tgz"
CHECKSUM_SHA256="2ff1ba74c632b9d13a0d0d2c942295dd4e8909694eeeded7908a467d0bcd4756"
SOURCE_DIR="dialog-${portVersion/_/-}"
REVISION="2"
PATCHES="dialog-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	dialog$secondaryArchSuffix = $portVersion
	lib:libdialog$secondaryArchSuffix = 14.0.0 compat >= 14
	"
if [ -z "$secondaryArchSuffix" ]; then
	PROVIDES="$PROVIDES
	cmd:dialog = $portVersion
	"
fi

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	"
PROVIDES_devel="
	dialog${secondaryArchSuffix}_devel = $portVersion
	cmd:dialog_config$secondaryArchSuffix = $portVersion
	devel:libdialog$secondaryArchSuffix = 14.0.0 compat >= 14
	"
REQUIRES_devel="
	dialog$secondaryArchSuffix == $portVersion base
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libncurses$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"
BUILD()
{
	runConfigure --omit-dirs "docDir" ./configure --with-shared \
		--with-ncursesw --with-libtool
	make
}
INSTALL()
{
	make install-full

	rm $libDir/libdialog.la

	prepareInstalledDevelLib libdialog

	# devel package
	packageEntries devel \
		$binDir/dialog-config \
		$developDir \
		$manDir/man3

	# Remove stuff we don't need in the secondary architecture base package.
	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $binDir $manDir
	fi

}
