SUMMARY="Visual database applications creator"
DESCRIPTION="KEXI is a visual database applications creator. It can be used for \
designing database applications, inserting and editing data, performing queries, \
and processing data. Forms can be created to provide a custom interface to your \
data. All database objects – tables, queries, forms, reports – are stored in the \
database, making it easy to share data and design.

KEXI is considered as a long awaited Open Source competitor for Microsoft Access, \
FileMaker and Oracle Forms. Its development is motivated by the lack of Rapid \
Application Development (RAD) tools for database systems that are sufficiently \
powerful, inexpensive, open standards driven and portable across many operating \
systems and hardware platforms."
HOMEPAGE="http://kexi-project.org/"
COPYRIGHT="KEXI Team"
LICENSE="GNU LGPL v2
	GNU GPL v2"
REVISION="1"
SOURCE_URI="https://download.kde.org/stable/kexi/src/kexi-$portVersion.tar.xz"
CHECKSUM_SHA256="7a813f9ea815a09c1e733d0e7dc879c64eee85f075389e87e6aab99cf0c1c1ff"
SOURCE_FILENAME="kexi-$portVersion.tar.xz"
PATCHES="kexi-$portVersion.patchset"
ADDITIONAL_FILES="kexi.rdef.in"

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

libVersion="3.2.0"

PROVIDES="
	kexi$secondaryArchSuffix = $portVersion
	lib:libkexicore3.2$secondaryArchSuffix = $libVersion
	lib:libkexidatatable3.2$secondaryArchSuffix = $libVersion
	lib:libkexidataviewcommon3.2$secondaryArchSuffix = $libVersion
	lib:libkexiextendedwidgets3.2$secondaryArchSuffix = $libVersion
	lib:libkexiformutils3.2$secondaryArchSuffix = $libVersion
	lib:libkexiguiutils3.2$secondaryArchSuffix = $libVersion
	lib:libkeximain3.2$secondaryArchSuffix = $libVersion
	lib:libkeximigrate3.2$secondaryArchSuffix = $libVersion
	lib:libkexirelationsview3.2$secondaryArchSuffix = $libVersion
	lib:libkexiundo3.2$secondaryArchSuffix = $libVersion
	lib:libkexiutils3.2$secondaryArchSuffix = $libVersion
	lib:libkformdesigner3.2$secondaryArchSuffix = $libVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	breeze_icons$secondaryArchSuffix
	lib:libKChart$secondaryArchSuffix
	lib:libKDb3$secondaryArchSuffix
	lib:libKF5Activities$secondaryArchSuffix
	lib:libKF5Archive$secondaryArchSuffix
	lib:libKF5Auth$secondaryArchSuffix
	lib:libKF5Bookmarks$secondaryArchSuffix
	lib:libKF5Codecs$secondaryArchSuffix
	lib:libKF5Completion$secondaryArchSuffix
	lib:libKF5ConfigCore$secondaryArchSuffix
	lib:libKF5ConfigGui$secondaryArchSuffix
	lib:libKF5ConfigWidgets$secondaryArchSuffix
	lib:libKF5CoreAddons$secondaryArchSuffix
	lib:libKF5Crash$secondaryArchSuffix
	lib:libKF5GuiAddons$secondaryArchSuffix
	lib:libKF5I18n$secondaryArchSuffix
	lib:libKF5IconThemes$secondaryArchSuffix
	lib:libKF5ItemModels$secondaryArchSuffix
	lib:libKF5ItemViews$secondaryArchSuffix
	lib:libKF5JobWidgets$secondaryArchSuffix
	lib:libKF5KIOCore$secondaryArchSuffix
	lib:libKF5KrossCore$secondaryArchSuffix
	lib:libKF5Parts$secondaryArchSuffix
	lib:libKF5Service$secondaryArchSuffix
	lib:libKF5Solid$secondaryArchSuffix
	lib:libKF5SonnetCore$secondaryArchSuffix
	lib:libKF5TextEditor$secondaryArchSuffix
	lib:libKF5TextWidgets$secondaryArchSuffix
	lib:libKF5WidgetsAddons$secondaryArchSuffix
	lib:libKF5WindowSystem$secondaryArchSuffix
	lib:libKF5XmlGui$secondaryArchSuffix
	lib:libKPropertyCore3$secondaryArchSuffix
	lib:libKPropertyWidgets3$secondaryArchSuffix
	lib:libKReport3$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5WebKitWidgets$secondaryArchSuffix
	lib:libsqlite3$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	extra_cmake_modules$secondaryArchSuffix >= 5.77
	breeze_icons$secondaryArchSuffix
	qthaikuplugins$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libKChart$secondaryArchSuffix
	devel:libKDb3$secondaryArchSuffix
	devel:libKF5Activities$secondaryArchSuffix
	devel:libKF5Archive$secondaryArchSuffix
	devel:libKF5Auth$secondaryArchSuffix
	devel:libKF5Bookmarks$secondaryArchSuffix
	devel:libKF5Codecs$secondaryArchSuffix
	devel:libKF5Completion$secondaryArchSuffix
	devel:libKF5ConfigCore$secondaryArchSuffix
	devel:libKF5ConfigGui$secondaryArchSuffix
	devel:libKF5ConfigWidgets$secondaryArchSuffix
	devel:libKF5CoreAddons$secondaryArchSuffix
	devel:libKF5Crash$secondaryArchSuffix
	devel:libKF5DBusAddons$secondaryArchSuffix
	devel:libKF5DesignerPlugin$secondaryArchSuffix
	devel:libKF5DocTools$secondaryArchSuffix
	devel:libKF5GuiAddons$secondaryArchSuffix
	devel:libKF5I18n$secondaryArchSuffix
	devel:libKF5IconThemes$secondaryArchSuffix
	devel:libKF5ItemModels$secondaryArchSuffix
	devel:libKF5ItemViews$secondaryArchSuffix
	devel:libKF5JobWidgets$secondaryArchSuffix
	devel:libKF5JSApi$secondaryArchSuffix
	devel:libKF5KIOCore$secondaryArchSuffix
	devel:libKF5KrossCore$secondaryArchSuffix
	devel:libKF5Parts$secondaryArchSuffix
	devel:libKF5Service$secondaryArchSuffix
	devel:libKF5Solid$secondaryArchSuffix
	devel:libKF5SonnetCore$secondaryArchSuffix
	devel:libKF5TextEditor$secondaryArchSuffix
	devel:libKF5TextWidgets$secondaryArchSuffix
	devel:libKF5WidgetsAddons$secondaryArchSuffix
	devel:libKF5WindowSystem$secondaryArchSuffix
	devel:libKF5XmlGui$secondaryArchSuffix
	devel:libKPropertyCore3$secondaryArchSuffix
	devel:libKReport3$secondaryArchSuffix
	devel:libmysqlclient$secondaryArchSuffix
	devel:libpq$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix >= 5.15
	devel:libQt5WebKitWidgets$secondaryArchSuffix
	devel:libsqlite3$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	cmd:python
	"

BUILD()
{
	mkdir -p build
	cd build

	cmake .. \
		-DCMAKE_INSTALL_PREFIX=$appsDir/Calligra \
		-DCMAKE_INSTALL_BINDIR=$appsDir/Calligra \
		-DCMAKE_INSTALL_LIBDIR=$libDir \
		-DCMAKE_INSTALL_DATAROOTDIR=$dataDir \
		-DECM_MKSPECS_INSTALL_DIR=$dataDir/Qt5/mkspecs \
		-DECM_DIR=/system/data/cmake/Modules/ECM/cmake \
		-DKDE_INSTALL_PLUGINDIR=$addOnsDir/Qt5 \
		-DKDE_INSTALL_DATAROOTDIR=$dataDir \
		-DICONV_INCLUDE_DIR=/system/$relativeIncludeDir \
		-DKEXI_AUTORISE_TABBED_TOOLBAR=OFF \
		-DKEXI_USE_KFILEWIDGET=OFF \
		-DKEXI_SCRIPTS_SUPPORT=ON

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mv $appsDir/Calligra/kexi-3.2 $appsDir/Calligra/Kexi

	mkdir -p "$dataDir/deskbar/menu/Applications/Calligra"

	local APP_SIGNATURE="application/x-vnd.kexi"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/kexi.rdef.in > $sourceDir/build/kexi.rdef

	addResourcesToBinaries $sourceDir/build/kexi.rdef $appsDir/Calligra/Kexi
	addAppDeskbarSymlink $appsDir/Calligra/Kexi "Calligra/Kexi"
}

TEST()
{
	cd build
	make test
}
