SUMMARY="An implementation of the ACPI specification"
DESCRIPTION="The ACPI Component Architecture (ACPICA) project provides an \
operating system (OS)-independent reference implementation of the Advanced \
Configuration and Power Interface Specification (ACPI)."
HOMEPAGE="https://acpica.org/"
COPYRIGHT="2000-2021 Intel Corp."
LICENSE="Intel (ACPICA)
	GNU GPL v2
	BSD (2-clause)"
REVISION="1"
SOURCE_URI="https://acpica.org/sites/acpica/files/acpica-unix-$portVersion.tar.gz"
CHECKSUM_SHA256="b49237a2c3df58b57310612ec3a6ebee69e1a525b5efeec7152faf32a03b7068"
SOURCE_DIR="acpica-unix-$portVersion"
SOURCE_URI_2="https://acpica.org/sites/acpica/files/acpitests-unix-$portVersion.tar.gz"
CHECKSUM_SHA256_2="d70dfc85f32f9c2e2e838a4fc94afd23d418971454b2ad11e9250a4409f8ae75"
SOURCE_DIR_2="acpitests-unix-$portVersion"

ARCHITECTURES="all !x86_gcc2"
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
fi

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandBinDir=$prefix/bin
fi

PROVIDES="
	iasl$secondaryArchSuffix = $portVersion
	cmd:acpibin = $portVersion
	cmd:acpidump = $portVersion
	cmd:acpiexamples = $portVersion
	cmd:acpiexec = $portVersion
	cmd:acpihelp = $portVersion
	cmd:acpinames = $portVersion
	cmd:acpisrc = $portVersion
	cmd:acpixtract = $portVersion
	cmd:iasl = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

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

TEST_REQUIRES="
	cmd:awk
	cmd:find
	"

PATCH()
{
	sed -i 's/-lrt//g' generate/unix/acpiexec/Makefile
}

BUILD()
{
	make PREFIX=$prefix $jobArgs
}

INSTALL()
{
	make PREFIX="$prefix" INSTALLDIR="$commandBinDir" install
}

TEST()
{
	export ASL="$sourceDir"/generate/unix/bin/iasl
	cd "$sourceDir2"/tests/aslts
	make install

	export acpiexec="$sourceDir"/generate/unix/bin/acpiexec
	export acpibin="$sourceDir"/generate/unix/bin/acpibin
	export ASLTSDIR="$sourceDir2"/tests/aslts
	PATH="$sourceDir/generate/unix/bin:$PATH"
	cd "$ASLTSDIR"/bin
	./Do 1
}
