# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer:
pkgname=recode
pkgver=3.6
pkgrel=1
pkgdesc="Charset converter tool and library"
url="https://github.com/pinard/Recode"
arch="all"
license="GPL-2.0-or-later"
depends=""
depends_dev=""
makedepends="$depends_dev libtool automake autoconf texinfo flex bison"
install=""
subpackages="$pkgname-dev $pkgname-doc"
source="Recode-$pkgver.tar.gz::https://github.com/pinard/Recode/archive/v$pkgver.tar.gz
	recode-automake.patch
	recode-bool-bitfield.patch
	recode-flex-m4.patch
	recode-format-security.patch
	0001-avoid-gnu-error-3.patch
	"

_builddir="$srcdir"/Recode-$pkgver
prepare() {
	local i
	cd "$_builddir"
	update_config_sub || return 1
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
	rm -f acinclude.m4 m4/libtool.m4
	autoreconf -vif
}

build() {
	cd "$_builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--disable-nls \
		--disable-static \
		--without-included-gettext \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1
	rm "$pkgdir"/usr/lib/charset.alias
}

md5sums="977d5e836dc6540b120d00ecdf14d25d  Recode-3.6.tar.gz
0c9269360d3671e8bc865a16a6243fdd  recode-automake.patch
b2b69d392dbb6ba45b77873d3a3b6ce6  recode-bool-bitfield.patch
ed5fa897383f1a8f3b15236d2487d3bc  recode-flex-m4.patch
3ab25ae6bba23ddce1c85ed2af251e03  recode-format-security.patch
0534962f3ee5018046c5504982624d0d  0001-avoid-gnu-error-3.patch"
sha256sums="1f0c859350a5fb3c555a7b80080e3238bbf2f0dc50f4009af0a407b3e2865503  Recode-3.6.tar.gz
dbe524a4bed3901549294089f05fd05b83cf4517541139622e00fc041de952d5  recode-automake.patch
d48b94231ab9b866dc1abf73de55a5535c8c754751a038fdaf75f3082593a06b  recode-bool-bitfield.patch
b3364355bee4f2ea0939ec0a9d924ab6efa923967daf5ea064fdb1750aef6990  recode-flex-m4.patch
715731dbf03afbf5be8226a808da75b96180f825d31bba74ed8b9851283e042a  recode-format-security.patch
94172af72807ed15c8ef9acde2297ba571e78327a7599e62afb5c7b76df2f530  0001-avoid-gnu-error-3.patch"
sha512sums="0d2ea3e340811ce1172d1a934af20030fb69a940cc86ab6f1bb90a2f81869b91c7f7d2ce503b527d47228140604c465d08661f4f39ae5bdcb28beef1388c3a17  Recode-3.6.tar.gz
628e3cfddc30c5c4cae5de0a67d9f2539f334a096e8dfaf2aaec04449e1c1f49ab1701a7998d9029506e2935e169fa07c7fbb418c97cbc48497a906f8dc304c8  recode-automake.patch
b10aa58b2da7a3991d9894bde775ce3ae18d3ab5b6db7941824e0dba871cb30c3c530d32dedfd9be1c7fdd874f956819341c53ae946962441b3b84e1dbebee33  recode-bool-bitfield.patch
edb4f9a380744ffdabb5775a2d2cfaaa04f491b2fafa7c47f32197394e03607d48c00dcf19a24b486665bd510428a3ba4e4030e3ebd7f832bb453865c69bd868  recode-flex-m4.patch
093314da6eb2666dcf7a8268366204669aa82df4e5455f28982595a60025d0ccadc989f08868c7ff4d4f49f3298395ce228fa848aed0dcb470063d07ea1dfae1  recode-format-security.patch
f14c90429c98e39f101e86fbc090eaae88e25c6d912865416d19d53ff50a1a5ba77d73e31861cd3be3c70b5dd12d2770f211ed338b67ee0747bfc6c35b1358a9  0001-avoid-gnu-error-3.patch"
