SUMMARY="Paint software for editing illustrations and images"
DESCRIPTION="AzPainter is a full color painting software for Linux.

It’s a lightweight tool with tablet pressure support, and provides basic \
functions such as selection, layers, filters.

The software uses an original graphic toollkit called Mlib. It’s extremely lightweight.

Features include:
* Extremely fast and frugal on system resources.
* Optimized user interface designed for efficient painting and drawing workflow.
* Support for 16-bit color images with transparency (RGBA)
* Automatic brush size adjustment that’s dependent on tablet pen pressure.
* Many artistic filters.
* Good range of selection tools.
* Support for many third-party image formats including PSD, PNG, JPG and more."
HOMEPAGE="http://azsky2.html.xdomain.jp/"
COPYRIGHT="2013-2022 Azel"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://gitlab.com/azelpg/azpainter/-/archive/v$portVersion/azpainter-v$portVersion.tar.gz"
CHECKSUM_SHA256="98037b35642ed4f3e6c622951868ed13c242ba8a30755b4da823a0be77df7f55"
SOURCE_DIR="azpainter-v$portVersion"
PATCHES="
	azpainter-$portVersion.patchset
	disable_cursors.patch
	"
ADDITIONAL_FILES="azpainter.rdef.in"

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

PROVIDES="
	azpainter$secondaryArchSuffix = $portVersion
	app:AzPainter = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libwebp$secondaryArchSuffix
	lib:libX11$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfontconfig$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libwebp$secondaryArchSuffix
	devel:libX11$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:which
	"

BUILD()
{
	./configure --prefix=$prefix \
		--bindir=$appsDir \
		--datarootdir=$dataDir \
		--datadir=$dataDir \
		--docdir=$docDir

	make $jobArgs
}

INSTALL()
{
	make install

	mv $appsDir/azpainter $appsDir/AzPainter
	rm -rf $dataDir/{mime,icons,applications}

	local APP_SIGNATURE="application/x-vnd.azpainter"
	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/azpainter.rdef.in > azpainter.rdef

	addResourcesToBinaries azpainter.rdef $appsDir/AzPainter

	addAppDeskbarSymlink $appsDir/AzPainter
}
