SUMMARY="Module that contains unsupported Qt 5 APIs"
DESCRIPTION="Qt is a cross-platform application framework that is widely \
used for developing software with a graphical user interface, and also used \
for developing non-GUI programs such as command-line tools and consoles for \
servers."
HOMEPAGE="https://qt.io/"
COPYRIGHT="2015-2021 The Qt Company Ltd."
LICENSE="GNU LGPL v2.1
	GNU LGPL v3
	GNU FDL v1"
REVISION="1"
SOURCE_URI="https://download.qt.io/official_releases/qt/${portVersion%.*}/$portVersion/submodules/qt5compat-everywhere-src-$portVersion.tar.xz"
CHECKSUM_SHA256="a5bb33d9df1d99e5afc21b0d0a36b79aa98829e2b1bee03c811ad69b79276bad"
SOURCE_DIR="qt5compat-everywhere-src-$portVersion"

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

PROVIDES="
	qt6_5compat$secondaryArchSuffix = $portVersion compat >= 6
	lib:libQt6Core5Compat$secondaryArchSuffix = $portVersion compat >= 6
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libicudata$secondaryArchSuffix >= 66
	lib:libicui18n$secondaryArchSuffix >= 66
	lib:libicuuc$secondaryArchSuffix >= 66
	lib:libQt6Core$secondaryArchSuffix
	lib:libQt6Gui$secondaryArchSuffix
	lib:libQt6Qml$secondaryArchSuffix
	lib:libQt6QmlModels$secondaryArchSuffix
	lib:libQt6Quick$secondaryArchSuffix
	lib:libQt6ShaderTools$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	qt6_5compat${secondaryArchSuffix}_devel = $portVersion compat >= 6
	devel:libQt6Core5Compat$secondaryArchSuffix = $portVersion compat >= 6
	"
REQUIRES_devel="
	qt6_5compat$secondaryArchSuffix == $portVersion base
	qt6_base${secondaryArchSuffix}_devel
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	qt6_tools${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libicuuc$secondaryArchSuffix >= 66
	devel:libQt6Core$secondaryArchSuffix
	devel:libQt6Gui$secondaryArchSuffix
	devel:libQt6Qml$secondaryArchSuffix
	devel:libQt6QmlModels$secondaryArchSuffix
	devel:libQt6Quick$secondaryArchSuffix
	devel:libQt6ShaderTools$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:cmake
	cmd:find
	cmd:g++$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:ninja
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	cmd:python3.7
	cmd:sed
	cmd:xargs
	"

BUILD()
{
	export DISABLE_ASLR=1

	cmake -B build -S $sourceDir -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_CXX_FLAGS=-fPIC

	find -name cmake_install.cmake -exec sed -i "s|set(CMAKE_INSTALL_PREFIX.*|set(CMAKE_INSTALL_PREFIX \"$prefix\")|" {} \;

	ninja -C build $jobArgs
}

INSTALL()
{
	ninja -C build install

	packageEntries devel \
		$libDir/cmake
}
