SUMMARY="Google's C++ argument parsing library"
DESCRIPTION="The gflags package contains a C++ library that implements \
commandline flags processing. It includes built-in support for standard \
types such as string and the ability to define flags in the source file in \
which they are used."
HOMEPAGE="https://gflags.github.io/gflags/"
COPYRIGHT="2006 Google Inc."
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://github.com/gflags/gflags/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf"

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

PROVIDES="
	gflags$secondaryArchSuffix = $portVersion
	cmd:gflags_completions.sh
	lib:libgflags$secondaryArchSuffix = $portVersion compat >= 2.2
	lib:libgflags_nothreads$secondaryArchSuffix = $portVersion compat >= 2.2
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	gflags${secondaryArchSuffix}_devel = $portVersion
	devel:libgflags$secondaryArchSuffix = $portVersion compat >= 2.2
	devel:libgflags_nothreads$secondaryArchSuffix = $portVersion compat >= 2.2
	"
REQUIRES_devel="
	gflags$secondaryArchSuffix == $portVersion base
	"

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

BUILD()
{
	mkdir -p build && cd build

	cmake -G "Unix Makefiles" .. \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DCMAKE_BUILD_TYPE=Release \
		-DLIBRARY_INSTALL_DIR:PATH=$libDir \
		-DBUILD_SHARED_LIBS:BOOL=ON \
		-DBUILD_gflags_LIB:BOOL=ON

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	mkdir -p $includeDir
	mv $prefix/include/* $includeDir/
	rmdir $prefix/include

	prepareInstalledDevelLibs libgflags libgflags_nothreads
	fixPkgconfig

	sed -i 's,\/include,/'${relativeIncludeDir}',g' \
		$libDir/cmake/gflags/gflags-config.cmake

	packageEntries devel \
		$developDir \
		$libDir/cmake
}
