SUMMARY="DB Browser for SQLite"
DESCRIPTION="DB Browser for SQLite is a high quality, visual, open source tool \
to create, design, and edit database files compatible with SQLite."
HOMEPAGE="https://sqlitebrowser.org/"
COPYRIGHT="2012-2020 Martin Kleusberg"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/sqlitebrowser/sqlitebrowser/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="c1f13a7caeab9c36908d7fd6e46718d5f2bb5d116882c5c6392e7c4b0f8dba0f"
SOURCE_FILENAME="sqlitebrowser-$portVersion.tar.gz"
ADDITIONAL_FILES="sqlitebrowser.rdef.in"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	sqlitebrowser$secondaryArchSuffix = $portVersion
	app:sqlitebrowser$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Test$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libqscintilla2_qt5$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Test$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libqscintilla2_qt5$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	"

BUILD()
{
	cmake -DCMAKE_INSTALL_PREFIX=$prefix .
	make $jobArgs
}

INSTALL()
{
	make $jobArgs install
	mkdir -p $appsDir
	mv $prefix/bin/sqlitebrowser $appsDir/SQLiteBrowser

	rm -rf $prefix/share

	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"

	sed \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/sqlitebrowser.rdef.in > sqlitebrowser.rdef
	addResourcesToBinaries sqlitebrowser.rdef $appsDir/SQLiteBrowser

	addAppDeskbarSymlink $appsDir/SQLiteBrowser SQLiteBrowser
}

TEST()
{
	make check
}
