SUMMARY="A fast C++ Verilog simulator"
DESCRIPTION="Verilator is the fastest free Verilog HDL simulator, and \
beats most commercial simulators. It compiles synthesizable Verilog (not \
test-bench code!), plus some PSL, SystemVerilog and Synthesis assertions \
into C++ or SystemC code. It is designed for large projects where fast \
simulation performance is of primary concern, and is especially well suited \
to generate executable models of CPUs for embedded software design teams."
HOMEPAGE="https://www.veripool.org/"
COPYRIGHT="2006-2018 Wilson Snyder"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://www.veripool.org/ftp/verilator-$portVersion.tgz"
CHECKSUM_SHA256="7dcb19711b8630ada59f0d3d7409faa9649e37bf4c53a0bbfcad32afb28b5975"
PATCHES="verilator-$portVersion.patchset"

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

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

PROVIDES="
	verilator$secondaryArchSuffix = $portVersion
	cmd:verilator = $portVersion
	cmd:verilator_bin = $portVersion
	cmd:verilator_bin_dbg = $portVersion
	cmd:verilator_coverage = $portVersion
	cmd:verilator_coverage_bin_dbg = $portVersion
	cmd:verilator_profcfunc = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

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

PATCH()
{
	sed -i 's,/usr/bin/perl,/usr/bin/env perl,g' test_regress/*.pl
	sed -i 's,/usr/bin/perl,/usr/bin/env perl,g' test_regress/t/*.pl
	chmod +x test_regress/*.pl
	chmod +x test_regress/t/*.pl
}

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

INSTALL()
{
	make install

	mkdir -p $developLibDir/pkgconfig $includeDir
	mv $dataDir/pkgconfig/* $developLibDir/pkgconfig/
	mv $dataDir/verilator/include/* $includeDir
	rmdir $dataDir/{pkgconfig,verilator/include}
}

TEST()
{
	make test
}
