SUMMARY="Aozora Bunko text viewer"
DESCRIPTION="Aobook is a viewer for Aozora Bunko which is a digital library \
of Japanese-language literature."
HOMEPAGE="https://osdn.net/projects/aobook/"
COPYRIGHT="2014-2018 Azel"
LICENSE="BSD (3-clause)"
REVISION="2"
SOURCE_URI="https://github.com/hanya/aobook-haiku/archive/v${portVersion/_/-}.tar.gz"
CHECKSUM_SHA256="f840a98b0f0c1f3fa31ae19498bc9051106e068b9af95eb4065643693f7f1e07"
SOURCE_FILENAME="aobook-haiku-${portVersion/_/-}.tar.gz"
SOURCE_DIR="aobook-haiku-${portVersion/_/-}"

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

USER_SETTINGS_FILES="
	settings/aobook directory
	"

PROVIDES="
	aobook$secondaryArchSuffix = $portVersion
	app:Aobook = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$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:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	makefile_engine
	cmd:g++$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:sed
	"

BUILD()
{
	make -C mlib -f Makefile.haiku $jobArgs OBJ_DIR=objects
	make -C src -f Makefile.haiku -j1 OBJ_DIR=objects \
		default catalogs bindcatalogs
}

INSTALL()
{
	mkdir -p $appsDir
	cp -af src/objects/aobook $appsDir/Aobook

	mkdir -p $dataDir/aobook/doc
	cp -af doc/manual.html $dataDir/aobook/doc

	addAppDeskbarSymlink $appsDir/Aobook

	mkdir -p $dataDir/locale/catalogs/x-vnd.azsky.aobook
	cp src/objects/x-vnd.azsky.aobook/* \
		$dataDir/locale/catalogs/x-vnd.azsky.aobook
}
