# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=xmlrpc-c
pkgver=1.39.11
pkgrel=0
pkgdesc="This library provides a modular implementation of XML-RPC for C and C++"
url="http://xmlrpc-c.sourceforge.net/"
arch="all"
license="BSD and MIT"
depends=
depends_dev="libxml2-dev"
makedepends="libtool curl-dev libxml2-dev zlib-dev"
subpackages="$pkgname-dev $pkgname-doc $pkgname-client
	$pkgname-client++:clientxx xmlrpc-c++:cxx $pkgname-abyss"
source="$pkgname-$pkgver.tar.gz::https://sourceforge.net/projects/xmlrpc-c/files/Xmlrpc-c%20Super%20Stable/$pkgver/xmlrpc-c-$pkgver.tgz/download
	host-os-uclibc.patch"

builddir="$srcdir"/$pkgname-$pkgver

build() {
	cd "$builddir"
	update_config_sub || return 1
	export CXXFLAGS="$CXXFLAGS -std=gnu++98"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--enable-libxml2-backend \
		--disable-cgi-server \
		--disable-libwww-client \
		--disable-wininet-client \
		|| return 1
	make -j1 AR=ar RANLIB=ranlib || return 1
}

package() {
	cd "$builddir"
	make -j1 DESTDIR="$pkgdir" AR=ar RANLIB=ranlib install || return 1
	install -m 644 -D doc/COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}

client() {
	pkgdesc="C client libraries for xmlrpc-c"
	replaces="$pkgname"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libxmlrpc_client.so.* "$subpkgdir"/usr/lib/
}

clientxx() {
	replaces="libxml-c++"
	pkgdesc="C++ client libraries for xmlrpc-c"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libxmlrpc_client++.so.* "$subpkgdir"/usr/lib/
}

cxx() {
	pkgdesc="This library provides a modular implementation of XML-RPC for C++"
	replaces="$pkgname"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*++* \
		"$pkgdir"/usr/lib/libxmlrpc_packetsocket.so.* \
		"$pkgdir"/usr/lib/libxmlrpc_cpp.so.* \
		"$subpkgdir"/usr/lib/
}

abyss() {
	pkgdesc="Abyss server libraries for C++"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*abyss* \
		"$subpkgdir"/usr/lib/
}

md5sums="503651550379ed72f7c6923a4c3551bd  xmlrpc-c-1.39.11.tar.gz
d3bee91077d3c7e1c0b80f6d7eeb2e63  host-os-uclibc.patch"
sha256sums="2e56cdcdd5c5fa564bcdc7a56bca108a88f5b78b34ccc85558366efabdc8b8e8  xmlrpc-c-1.39.11.tar.gz
0aae483973387c710ddc6103be36287cfe507eaa2e998805e6aa858be8eeaaa5  host-os-uclibc.patch"
sha512sums="13e7ddf5264436671437c0bcd698380baca35c4469f592edf79cb4cafda254fe8207ecb992ee728ed20ec70457a20bd0cf8e180ce5cf0561a38a21f1e588f584  xmlrpc-c-1.39.11.tar.gz
30b57c5ffd65ea9781a56d1b4535e53c9d51c16e00d269992b239f1ff611fe3a510eb72b4d6ee96100706161d40738bbdf109580c745bfc9899d540ca6b3f1e5  host-os-uclibc.patch"
