SUMMARY="Simple Kana to Kanji Conversion"
DESCRIPTION="SKK is an input method without morphological analysis."
HOMEPAGE="https://github.com/codefirst/aquaskk"
COPYRIGHT="2002-2005 phonohawk
	2005-2013 AquaSKK Project
	2014-2018 codefirst"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/hanya/aquaskk/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="1b558787dea61444a46a1c2e4f369451f158d9b93a3387818f5d4cde8e5a5726"
SOURCE_DIR="aquaskk-$portVersion"

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

PROVIDES="
	aquaskk$secondaryArchSuffix
	addon:aquaskk
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:python2
	lib:libpython2.7
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:gyp
	cmd:ninja
	cmd:python2
	cmd:xres
	"
if [ "$targetArchitecture" = x86_gcc2 ]; then
BUILD_PREREQUIRES+="
	cmd:g++
	"
fi

BUILD()
{
	cd platform/haiku/src

	$portPackageLinksDir/cmd~python2/bin/python2 build.py gyp \
		--platform=Haiku --arch=$targetArchitecture

	$portPackageLinksDir/cmd~python2/bin/python2 build.py build \
		-c Release \
		method/method.gyp:aquaskk \
		preference/preference.gyp:preference
}

INSTALL()
{
	APlatDir=platform/haiku
	AOutDir=$APlatDir/src/out_haiku/Release
	AIconDir=data/icons
	AConfigDir=data/config
	AHaikuConfigDir=$APlatDir/data/config
	DataDir=$dataDir/aquaskk
	IconDir=$DataDir/icons
	CatalogDir=$dataDir/locale/catalogs
if [ "$targetArchitecture" = x86_gcc2 ]; then
	InputMethodDir=$addOnsDir/../input_server/methods
else
	InputMethodDir=$addOnsDir/input_server/methods
fi
	mkdir -p $DataDir
	mkdir -p $IconDir
	mkdir -p $CatalogDir/x-vnd.AquaSKK-InputMethod
	mkdir -p $CatalogDir/x-vnd.AquaSKK-Preference
	mkdir -p $InputMethodDir

	cp $AOutDir/aquaskk $InputMethodDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	cp $AOutDir/aquaskk_task $DataDir
fi
	cp $AOutDir/aquaskk_preference $DataDir

	cp $APlatDir/src/preference/dict_downloader.py $DataDir

	cp $AConfigDir/{act.conf,act.rule,azik_us.rule} $DataDir
	cp $AConfigDir/{azik.rule,comma.rule,kana-rule.conf} $DataDir
	cp $AConfigDir/{old-kana.rule,period.rule,yakumono-ippai.rule} $DataDir

	cp $AHaikuConfigDir/{azik.conf,keymap.conf,sub-rule.json} $DataDir
	cp $AHaikuConfigDir/{DictionarySet.json,UserDefaults.json} $DataDir

	cp $AIconDir/{AquaSKK-Ascii.png,AquaSKK-Hirakana.png} $IconDir
	cp $AIconDir/{AquaSKK-Jisx0201Kana.png,AquaSKK-Jisx0208Latin.png} $IconDir
	cp $AIconDir/AquaSKK-Katakana.png $IconDir

	cp $AOutDir/x-vnd.AquaSKK-InputMethod/* \
		$CatalogDir/x-vnd.AquaSKK-InputMethod
	cp $AOutDir/x-vnd.AquaSKK-Preference/* \
		$CatalogDir/x-vnd.AquaSKK-Preference
}
