SUMMARY="Libraries to support Unicode and globalization"
SUMMARY_devel="The ICU development files"
DESCRIPTION="International Components for Unicode (ICU) is a mature, widely \
used set of C/C++ and Java libraries providing Unicode and Globalization \
support for software applications. ICU is widely portable and gives \
applications the same results on all platforms and between C/C++ and Java \
software.
ICU is released under a nonrestrictive open source license that is suitable \
for use with both commercial software and with other open source or free \
software.

Here are a few highlights of the services provided by ICU:

* Code Page Conversion: Convert text data to or from Unicode and nearly any \
other character set or encoding. ICU's conversion tables are based on charset \
data collected by IBM over the course of many decades, and is the most \
complete available anywhere.
* Collation: Compare strings according to the conventions and standards of a \
particular language, region or country. ICU's collation is based on the \
Unicode Collation Algorithm plus locale-specific comparison rules from the \
Common Locale Data Repository, a comprehensive source for this type of data.
* Formatting: Format numbers, dates, times and currency amounts according the \
conventions of a chosen locale. This includes translating month and day names \
into the selected language, choosing appropriate abbreviations, ordering \
fields correctly, etc. This data also comes from the Common Locale Data \
Repository.
* Time Calculations: Multiple types of calendars are provided beyond the \
traditional Gregorian calendar. A thorough set of timezone calculation APIs \
are provided.
* Unicode Support: ICU closely tracks the Unicode standard, providing easy \
access to all of the many Unicode character properties, Unicode Normalization, \
Case Folding and other fundamental operations as specified by the Unicode \
Standard.
* Regular Expression: ICU's regular expressions fully support Unicode while \
providing very competitive performance.
* Bidi: support for handling text containing a mixture of left to right \
(English) and right to left (Arabic or Hebrew) data.
* Text Boundaries: Locate the positions of words, sentences, paragraphs within \
a range of text, or identify locations that would be suitable for line \
wrapping when displaying the text."
HOMEPAGE="http://www.icu-project.org"
COPYRIGHT="1995-2020 IBM Corporation and others."
LICENSE="ICU"
REVISION="1"
SOURCE_URI="https://github.com/unicode-org/icu/releases/download/release-67-1/icu4c-67_1-src.tgz"
SOURCE_URI_2="https://github.com/unicode-org/icu/releases/download/release-67-1/icu4c-67_1-data.zip#noarchive"
#SOURCE_URI_3="http://www.iana.org/time-zones/repository/releases/tzdata2019c.tar.gz#noarchive"
CHECKSUM_SHA256="94a80cd6f251a53bd2a997f6f1b5ac6653fe791dfab66e1eb0227740fb86d5dc"
CHECKSUM_SHA256_2="7c16a59cc8c06128b7ecc1dc4fc056b36b17349312829b17408b9e67b05c4a7e"
SOURCE_DIR="icu"
PATCHES="icu66-66.1.patchset"

ARCHITECTURES="!all ?x86 arm sparc arm64 riscv64"
# leave inactive until full testing can be done
SECONDARY_ARCHITECTURES="!x86"

PROVIDES="
	icu67$secondaryArchSuffix = $portVersion compat >= 67
	lib:libicudata$secondaryArchSuffix = $portVersion compat >= 67
	lib:libicui18n$secondaryArchSuffix = $portVersion compat >= 67
	lib:libicuio$secondaryArchSuffix = $portVersion compat >= 67
	lib:libicutest$secondaryArchSuffix = $portVersion compat >= 67
	lib:libicutu$secondaryArchSuffix = $portVersion compat >= 67
	lib:libicuuc$secondaryArchSuffix = $portVersion compat >= 67
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	icu67${secondaryArchSuffix}_devel = $portVersion
	cmd:icu_config${secondaryArchSuffix} = $portVersion compat >= 67
	devel:libicudata${secondaryArchSuffix} = $portVersion compat >= 67
	devel:libicui18n${secondaryArchSuffix} = $portVersion compat >= 67
	devel:libicuio${secondaryArchSuffix} = $portVersion compat >= 67
	devel:libicutest${secondaryArchSuffix} = $portVersion compat >= 67
	devel:libicutu${secondaryArchSuffix} = $portVersion compat >= 67
	devel:libicuuc${secondaryArchSuffix} = $portVersion compat >= 67
	"
REQUIRES_devel="
	icu67${secondaryArchSuffix} == $portVersion base
	"

if [ -z "$secondaryArchSuffix" ]; then
	SUMMARY_tools="The ICU support tools"
	PROVIDES_tools="
		icu67_tools = $portVersion
		cmd:derb
		cmd:escapesrc
		cmd:genbrk
		cmd:genccode
		cmd:gencfu
		cmd:gencmn
		cmd:gencnval
		cmd:gendict
		cmd:gennorm2
		cmd:genrb
		cmd:gensprep
		cmd:icuinfo
		cmd:icupkg
		cmd:makeconv
		cmd:pkgdata
		"
	REQUIRES_tools="
		icu == $portVersion base
		haiku
		"
fi

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python3
	cmd:sed
	cmd:unzip
	cmd:tar
	cmd:gunzip
	"

BUILD()
{
	cd source

	# Created during build and prevent rebuilds.
	#rm -rf tools/tzcode/vanguard
	#cp ../../../sources-3/tzdata*.tar.gz tools/tzcode/

	unzip -oq ../../../sources-2/icu4c-*-data.zip
	rm -f data/in/icudt??l.dat
	autoconf
	runConfigure ./configure \
		--disable-samples --disable-extras --with-data-packaging=archive
	make $jobArgs
}

INSTALL()
{
	cd source
	make install


	prepareInstalledDevelLibs \
		libicudata \
		libicui18n \
		libicuio \
		libicutest \
		libicutu \
		libicuuc
	fixPkgconfig

	# Update icu-config to point to the develop/lib dir
	fixDevelopLibDirReferences \
		$binDir/icu-config

	# devel package
	packageEntries devel \
		$developDir \
		$libDir/icu \
		$binDir/icu-config \
		$manDir/man1/icu-config.1

	# tools package
	if [ -z "$secondaryArchSuffix" ]; then
		packageEntries tools \
			$binDir \
			$manDir
	else
		rm -r $binDir $manDir
	fi
}

TEST()
{
	cd source
	make check
}
