SUMMARY="Pascal wrapper for Qt5"
DESCRIPTION="libqt5pas is an interface between Lazarus and the Qt5 libraries.
Not all Qt5 functions are available, only those necessary for Lazarus \
functionality."
HOMEPAGE="https://wiki.freepascal.org/Qt5_Interface"
COPYRIGHT="2005-2013 Jan Van Hijfte
	2017 Željan Rikalo"
LICENSE="GNU LGPL v3"
REVISION="3"
SOURCE_URI="https://github.com/davidbannon/libqt5pas/archive/refs/tags/v$portVersion.tar.gz"
CHECKSUM_SHA256="a40c69f56dcce909417d63d5e1fa8a9f0ddaec9024de6e6f5a99043b99e2f151"
SOURCE_DIR="libqt5pas-$portVersion/cbindings"

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

libVersion="$portVersion"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	libqt5pas$secondaryArchSuffix = $portVersion
	lib:libQt5Pas$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libqt5Core$secondaryArchSuffix
	lib:libqt5Gui$secondaryArchSuffix
	lib:libqt5Network$secondaryArchSuffix
	lib:libqt5PrintSupport$secondaryArchSuffix
	lib:libqt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libqt5Core$secondaryArchSuffix
	devel:libqt5Gui$secondaryArchSuffix
	devel:libqt5Network$secondaryArchSuffix
	devel:libqt5PrintSupport$secondaryArchSuffix
	devel:libqt5Widgets$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix
	"

BUILD()
{
	qmake INSTALL_ROOT=$libDir
	make $jobArgs
}

INSTALL()
{
	#hack to fix the install path
	if [ "$targetArchitecture" = x86_64 ]; then
		sed -i "s|/boot/system/lib||" Makefile
	else
		sed -i "s|/boot/system/lib/x86||" Makefile
	fi

	make INSTALL_ROOT=$libDir install
	#clean up for INSTALL_ROOT
	rm -rf $libDir/boot
}
