SUMMARY="A library for processing UTF-8 encoded Unicode strings"
DESCRIPTION="utf8proc is a small, clean C library that provides Unicode \
normalization, case-folding, and other operations for data in the UTF-8 \
encoding, supporting Unicode version 13."
HOMEPAGE="https://julialang.org/utf8proc/"
COPYRIGHT="2006-2020 Public Software Group
	2014-2020 Steven G. Johnson, Jiahao Chen, Tony Kelman, Jonas Fonseca, \
	and other contributors listed in the git history"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/JuliaStrings/utf8proc/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="d4e8dfc898cfd062493cb7f42d95d70ccdd3a4cd4d90bec0c71b47cca688f1be"
SOURCE_FILENAME="utf8proc-$portVersion.tar.gz"
SOURCE_DIR="utf8proc-$portVersion"
PATCHES="libutf8proc2-2.4.0.patchset"

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

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

PROVIDES="
	libutf8proc2$secondaryArchSuffix = $portVersion
	lib:libutf8proc$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libutf8proc2${secondaryArchSuffix}_devel = $portVersion
	devel:libutf8proc$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libutf8proc2$secondaryArchSuffix == $portVersion base
	"
CONFLICTS_devel="
	libutf8proc${secondaryArchSuffix}_devel
	"

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

defineDebugInfoPackage libutf8proc2$secondaryArchSuffix \
	$libDir/libutf8proc.so.$libVersion

BUILD()
{
	mkdir -p build_haiku && cd build_haiku
	cmake .. \
		-DBUILD_SHARED_LIBS=ON \
		$cmakeDirArgs
}

INSTALL()
{
	cd build_haiku
	make install
	prepareInstalledDevelLib libutf8proc

	mkdir -p $developLibDir/pkgconfig
	cat > $developLibDir/pkgconfig/libutf8proc.pc << EOF
prefix=${prefix}
exec_prefix=${prefix}
libdir=${libDir}
includedir=${includeDir}

Name: libutf8proc
Description: UTF8 processing
Version: $portVersion
Libs: -L${developLibDir} -lutf8proc
Cflags: -I${includeDir} -DUTF8PROC_EXPORTS
EOF

	packageEntries devel $developDir
}

TEST()
{
	cd build_haiku
	make check # test cases not supported yet with cmake
}
