SUMMARY="Polygon and line clipping and offsetting library"
DESCRIPTION="The Clipper library performs clipping and offsetting for \
both lines and polygons. All four boolean clipping operations are supported - \
intersection, union, difference and exclusive-or. Polygons can be of any shape \
including self-intersecting polygons."
HOMEPAGE="https://sourceforge.net/projects/polyclipping/"
COPYRIGHT="2010-2019 Angus Johnson"
LICENSE="Boost v1.0"
REVISION="1"
SOURCE_URI="http://downloads.sourceforge.net/polyclipping/clipper_ver${portVersion}.zip"
CHECKSUM_SHA256="a14320d82194807c4480ce59c98aa71cd4175a5156645c4e2b3edd330b930627"
SOURCE_DIR=""

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

libVersion="$portVersion"
libVersionCompat="$libVersion compat >= ${libVersion%.*}"

PROVIDES="
	polyclipping$secondaryArchSuffix = $portVersion
	lib:libpolyclipping$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"
PROVIDES_devel="
	polyclipping${secondaryArchSuffix}_devel = $portVersion
	devel:libpolyclipping$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	polyclipping$secondaryArchSuffix == $portVersion base
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

defineDebugInfoPackage polyclipping$secondaryArchSuffix \
	"$libDir"/libpolyclipping.so.22

PATCH()
{
	cd cpp
	sed -i 's,${CMAKE_INSTALL_PREFIX}/include',$includeDir, CMakeLists.txt
	sed -i 's,${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}',$libDir, CMakeLists.txt
	sed -i 's,${CMAKE_INSTALL_PREFIX}/share/pkgconfig',$developLibDir/pkgconfig, \
		CMakeLists.txt
}

BUILD()
{
	mkdir -p build && cd "$_"
	cmake ../cpp \
		-DCMAKE_INSTALL_PREFIX:PATH="$prefix" \
		$cmakeDirArgs
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLib libpolyclipping
	fixPkgconfig

	packageEntries devel $developDir
}
