# Contributor: Sergey Lukin <sergej.lukin@gmail.com>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=icu
pkgver=71.1
pkgrel=4
pkgdesc="International Components for Unicode library"
url="https://icu.unicode.org/"
arch="all"
license="MIT ICU Unicode-TOU"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="python3 py3-yaml"
checkdepends="diffutils"
install="$pkgname-data-en.post-install"
subpackages="
	$pkgname-static
	$pkgname-dev
	$pkgname-doc
	$pkgname-libs
	$pkgname-data-en:_data_en:noarch
	$pkgname-data-full:_data_full:noarch
	"
source="https://github.com/unicode-org/icu/releases/download/release-${pkgver//./-}/icu4c-${pkgver//./_}-src.tgz
	https://github.com/unicode-org/icu/releases/download/release-${pkgver//./-}/icu4c-${pkgver//./_}-data.zip
	https://github.com/unicode-org/icu/releases/download/release-${pkgver//./-}/icu4c-${pkgver//./_}-data-bin-b.zip
	https://github.com/unicode-org/icu/releases/download/release-${pkgver//./-}/icu4c-${pkgver//./_}-data-bin-l.zip
	001-fix-heap-buffer-overflow.patch
	skip-flawed-tests.patch
	data-filter-en.yml
	"

prepare() {
	default_prepare

	rm -rf data
	mv "$srcdir"/data .
}

build() {
	_yaml2json "$srcdir"/data-filter-en.yml > data-filter-en.json
	export ICU_DATA_FILTER_FILE="./data-filter-en.json"

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--with-data-packaging=archive \
		--disable-samples \
		--enable-static \
		--mandir=/usr/share/man
	make
}

package() {
	make -j1 DESTDIR="$pkgdir" install

	chmod +x "$pkgdir"/usr/bin/icu-config

	install -Dm644 "$srcdir"/icu/license.html -t "$pkgdir"/usr/share/licenses/icu/
}

sha512sums="
1fd2a20aef48369d1f06e2bb74584877b8ad0eb529320b976264ec2db87420bae242715795f372dbc513ea80047bc49077a064e78205cd5e8b33d746fd2a2912  icu4c-71_1-src.tgz
05eb134a963a541a280e49e4d0aca07e480fef14daa0108c8fb9add18c150c9d34c8cbc46386c07909d511f7777eb3ea9f494001f191b84a7de0be8047da8b56  icu4c-71_1-data.zip
b031e520d41cc313012a0a9d9c4eed51aee9e04213b810bcec32e18d0964f4f26448b989879a9d8901d29024da08ce2ac89c8c6d321c85d78f6414b5edebc1a4  001-fix-heap-buffer-overflow.patch
de2cd008406d133cc838388f5a109560d29323e0a4c8c6306f712a536b6d90846d44bc5f691514621653f33a2929c0d84fa9c54d61d5ddf4606243df63c7e139  skip-flawed-tests.patch
"
