# $Id$
# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Contributor: Daenyth <Daenyth+Arch [at] gmail [dot] com>
# Contributor: Jeff Mickey <jeff@archlinux.org>
# Contributor: sh__

# ALARM: jdoe0
# --enable-aligned flag is required to work correctly on armv5

pkgname=libtorrent
pkgver=0.13.7
pkgrel=1
pkgdesc='BitTorrent library with a focus on high performance and good code'
url='http://rakshasa.github.io/rtorrent/'
arch=('x86_64')
license=('GPL')
depends=('openssl')
source=("https://github.com/rakshasa/rtorrent/releases/download/v0.9.${pkgver##*.}/${pkgname}-${pkgver}.tar.gz"
        'https://github.com/rakshasa/libtorrent/commit/4607bbf7.patch')
sha256sums=('c738f60f4d7b6879cd2745fb4310bf24c9287219c1fd619706a9d5499ca7ecc1'
            '88238b777b2d5c01d0ed3d0093554475c004db51193db88f91d41b9a4db50bb8')

prepare() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	patch -p1 -i ../4607bbf7.patch
	./autogen.sh
}

build() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	export CXXFLAGS+=' -fno-strict-aliasing'

	[[ $CARCH == 'arm' ]] && CONFIG='--enable-aligned'

	./configure \
		--prefix=/usr \
		--disable-debug $CONFIG

	make
}

package() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	make DESTDIR="${pkgdir}" install
}