SUMMARY="Multi-platform cross assembler for 6502/6510/65816 CPU"
DESCRIPTION="ACME is a free cross assembler that can produce code for the following processors: \
6502, 6510 (including illegal opcodes), 65c02 and 65816.
ACME supports the standard assembler stuff like global/local/anonymous labels, \
offset assembly, conditional assembly and looping assembly. \
It can include other source files as well as binaries while assembling. \
Calculations can be done in integer or float mode."
HOMEPAGE="http://sourceforge.net/p/acme-crossass/"
COPYRIGHT="2012-2020 Marco Baye"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://sourceforge.net/code-snapshots/svn/a/ac/acme-crossass/code-0/acme-crossass-code-0-r208-trunk.zip"
CHECKSUM_SHA256="67d45b4f5622e89a9196f354b99261917b4e5b59c8c679fd2723c92dfd89565b"
SOURCE_DIR="acme-crossass-code-0-r208-trunk"

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

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

PROVIDES="
	acme$secondaryArchSuffix = $portVersion
	cmd:acme$commandSuffix = $portVersion
	cmd:toacme$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

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

TEST_REQUIRES="
	cmd:test
	"

PATCH()
{
	sed -i "s|/usr/local/bin|$commandBinDir|g" src/Makefile
	sed -i "s|/usr/local/bin|$commandBinDir|g" contrib/toacme/src/Makefile
}

BUILD()
{
	make -C src $jobArgs all
	make -C contrib/toacme/src $jobArgs all
}


INSTALL()
{
	make -C src install
	make -C contrib/toacme/src install

	# copy documentation
	mkdir -p $docDir/acme
	mkdir -p $docDir/toacme

	cp -rd docs/* $docDir/acme
	cp -rd contrib/toacme/docs/* $docDir/toacme
	cp -rd examples $docDir/

	# copy the ACME_Lib
	mkdir -p $dataDir
	cp -rd ACME_Lib $dataDir
}

TEST()
{
	sed -i "s| acme| $sourceDir/src/acme|g" examples/Makefile

	ACME=$sourceDir/ACME_Lib make -C examples $jobArgs

	declare -a testfiles=("ddrv128.prg" "ddrv64.prg" "macedit.o" "trigono.o")
	for i in "${testfiles[@]}"
	do
		test -f examples/${i}
	done
}
