# Contributor: Kiyoshi Aman <kiyoshi.aman@gmail.com>
# Maintainer: Kiyoshi Aman <kiyoshi.aman@gmail.com>
pkgname=libotr3
pkgver=3.2.1
pkgrel=4
pkgdesc="Off The Record Messaging, an encryption library for secure IM conversations"
url="http://otr.cypherpunks.ca/"
arch="all"
license="LGPL-2.0-or-later"
depends=
depends_dev="libgcrypt-dev"
makedepends="$depends_dev"
install=""
replaces="libotr"
subpackages="$pkgname-dev $pkgname-doc:doc $pkgname-tools:tools"
source="http://www.cypherpunks.ca/otr/libotr-$pkgver.tar.gz"

_builddir="$srcdir/libotr-$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
}

build() {
	cd "$_builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		|| return 1
	make || return 1
}

package() {
        cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1
}

tools() {
    license="GPL"
    depends="$pkgname"
    cd "$_builddir"
    mkdir -p "$subpkgdir"/usr/
    mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

doc() {
    default_doc
    depends="$pkgname"
    cd "$_builddir"
    install -Dm0644 Protocol-v2.html "$subpkgdir"/usr/share/doc/$pkgname/Protocol-v2.html
    install -Dm0644 README           "$subpkgdir"/usr/share/doc/$pkgname/README
}

md5sums="974acf937d2ce0ee89b27a9815c17a3f  libotr-3.2.1.tar.gz"
sha256sums="d428eaa584984baa09450cca07742e0ac8fc62401f3a1c556e3025023369cdf4  libotr-3.2.1.tar.gz"
sha512sums="7dfac85cb7dd1a95481330ecf3bfe54477a9de7e20370919386e8aa9553e374a2d3587d7b4bb654d1a30bd1c47e41c577f7b78f4007c5cb97f2f6a2c63078899  libotr-3.2.1.tar.gz"
