SUMMARY="Multi pass optimizing macro assembler for the 65xx series of processors"
DESCRIPTION="64tass is cross assembler targeting the 65xx series of micro processors \
which features the familiar syntax of Omicron TASS and TASM."
HOMEPAGE="https://sourceforge.net/projects/tass64/"
COPYRIGHT="2013-2020 Soci/Singular
	1997-2001 Benjamin Sittler"
LICENSE="GNU LGPL v2.1
	my_getopt"
REVISION="1"
SOURCE_URI="https://github.com/irmen/64tass/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="c9222531a711cf7f23fe0294dd953c2a7cda37f84070fdaeaf8c83a7284cc582"
SOURCE_DIR="64tass-$portVersion"

ARCHITECTURES="all !x86_gcc2 ?arm ?ppc ?sparc"
SECONDARY_ARCHITECTURES="x86"

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

portVersionCompat="$portVersion compat >= ${portVersion%%.*}"

PROVIDES="
	64tass$secondaryArchSuffix = $portVersionCompat
	cmd:64tass$commandSuffix = $portVersionCompat"
REQUIRES="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:gzip
	cmd:make
	cmd:which
	"

PATCH()
{
	sed -i "s|\$(exec_prefix)/bin|$commandBinDir|g" Makefile
	sed -i "s|\$(prefix)/share|$dataRootDir|g" Makefile
	sed -i "s|\$(datarootdir)/man|$manDir|g" Makefile
	sed -i "s|\$(datarootdir)/doc/\$(TARGET)|$docDir|g" Makefile
	sed -i "s|/usr/bin/install|`which install`|g" Makefile
	sed -i "s|\sLICENSE-L\{0,1\}GPL-2.[0-1]||g;s|\sLICENSE-my_getopt||g" Makefile
}

BUILD()
{
	make $jobArgs
}

INSTALL()
{
	make install $jobArgs

	# vim syntax
	# TODO: better version checking, still ok until
	# we are on the 8.2 branch or we repackage vim itself
	mkdir -p $dataDir/vim/vim82/syntax
	cp -r syntax/vim/syntax/*.vim $dataDir/vim/vim82/syntax
}
