SUMMARY="A static analysis tool for C/C++ code"
DESCRIPTION="Cppcheck provides unique code analysis to detect bugs and focuses on \
detecting undefined behaviour and dangerous coding constructs. The goal is \
to detect only real errors in the code (i.e. have very few false positives).

Features:
* Unique code analysis that detect various kinds of bugs in your code.
* Both command line interface and graphical user interface are available.
* Cppcheck has a strong focus on detecting undefined behaviour."
HOMEPAGE="http://cppcheck.sourceforge.net/"
COPYRIGHT="2007-2018 Cppcheck team"
LICENSE="GNU GPL v3"
REVISION="3"
SOURCE_URI="https://github.com/danmar/cppcheck/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="ea7ac1cd2f5c00ecffd596fd0f7281cba44308e565a634fae02b77ecd927c153"
SOURCE_FILENAME="cppcheck-$portVersion.tar.gz"
PATCHES="cppcheck-$portVersion.patchset"

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

GLOBAL_WRITABLE_FILES="
	settings/cppcheck/avr.cfg keep-old
	settings/cppcheck/boost.cfg keep-old
	settings/cppcheck/bsd.cfg keep-old
	settings/cppcheck/cppcheck-lib.cfg keep-old
	settings/cppcheck/embedded_sql.cfg keep-old
	settings/cppcheck/gnu.cfg keep-old
	settings/cppcheck/googletest.cfg keep-old
	settings/cppcheck/gtk.cfg keep-old
	settings/cppcheck/microsoft_sal.cfg keep-old
	settings/cppcheck/motif.cfg keep-old
	settings/cppcheck/posix.cfg keep-old
	settings/cppcheck/python.cfg keep-old
	settings/cppcheck/qt.cfg keep-old
	settings/cppcheck/ruby.cfg keep-old
	settings/cppcheck/sdl.cfg keep-old
	settings/cppcheck/sfml.cfg keep-old
	settings/cppcheck/std.cfg keep-old
	settings/cppcheck/tinyxml2.cfg keep-old
	settings/cppcheck/windows.cfg keep-old
	settings/cppcheck/wxwidgets.cfg keep-old
	settings/cppcheck/zlib.cfg keep-old
	"

PROVIDES="
	cppcheck$secondaryArchSuffix = $portVersion
	cmd:cppcheck$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libpcre$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage cppcheck$secondaryArchSuffix \
	$binDir/cppcheck

BUILD()
{
	mkdir -p build
	cd build
	cmake .. \
		-DUSE_CLANG=OFF \
		-DBUILD_SHARED_LIBS=ON \
		-DBUILD_TESTS=ON \
		-DHAVE_RULES=ON \
		-DCFGDIR=$settingsDir/cppcheck \
		$cmakeDirArgs

	make $jobArgs
}

INSTALL()
{
	cd build
	make install
}

TEST()
{
	cd build
	make test
}
