SUMMARY="The NASM assembler"
DESCRIPTION="The Netwide Assembler, NASM, is an 80x86 and x86-64 assembler \
designed for portability and modularity. It supports a range of object file \
formats, including Linux and *BSD a.out, ELF, COFF, Mach-O, Microsoft 16-bit \
OBJ, Win32 and Win64. It will also output plain binary files. Its syntax is \
designed to be simple and easy to understand, similar to Intel's but less \
complex. It supports all currently known x86 architectural extensions, and \
has strong support for macros."
HOMEPAGE="https://www.nasm.us/"
COPYRIGHT="1996-2018 The NASM Authors"
LICENSE="BSD (2-clause)"
REVISION="2"
SOURCE_URI="https://www.nasm.us/pub/nasm/releasebuilds/$portVersion/nasm-$portVersion.tar.bz2"
CHECKSUM_SHA256="34fd26c70a277a9fdd54cb5ecf389badedaf48047b269d1008fbc819b24e80bc"
PATCHES="nasm-$portVersion.patchset"

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

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

PROVIDES="
	nasm$secondaryArchSuffix = $portVersion compat >= 1
	cmd:nasm$commandSuffix = $portVersion compat >= 1
	cmd:ndisasm$commandSuffix = $portVersion compat >= 1
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"
if [ "$targetArchitecture" = x86_gcc2 ]; then
	REPLACES="
		nasm
		"
fi

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

TEST_REQUIRES="
	cmd:perl
	"

defineDebugInfoPackage nasm$secondaryArchSuffix \
	$commandBinDir/nasm \
	$commandBinDir/ndisasm

BUILD()
{
	runConfigure --omit-dirs "binDir" ./configure \
		--bindir="$commandBinDir"
	make $jobArgs PERL=true
}

INSTALL()
{
	make install PERL=true
}

TEST()
{
	make test
}
