# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=yajl
pkgver=2.1.0
pkgrel=0
pkgdesc="Yet Another JSON Library (YAJL)"
url="http://lloyd.github.com/yajl/"
arch="all"
license="BSD"
depends=""
makedepends="cmake"
install=""
subpackages="$pkgname-dev $pkgname-tools"
source="http://dev.alpinelinux.org/archive/yajl/yajl-$pkgver.tar.gz"

_builddir="$srcdir"/yajl-$pkgver

# How to create archive from git:
#
#  abuild snapshot
#

_gitrepo=yajl.git
_giturl="git://github.com/lloyd/$_gitrepo"
_gittag=$pkgver

snapshot() {
	local _tarball=$pkgname-$pkgver.tar.gz
	msg "Creating $_tarball.."
	mkdir -p "$srcdir"
	cd "${SRCDEST:-$srcdir}"
	if ! [ -d "$_gitrepo" ]; then
		git clone --bare  $_giturl || return 1
	else
		git --git-dir=$_gitrepo fetch || return 1
        fi

        git --git-dir=$_gitrepo archive --prefix=$pkgname-$pkgver/ \
		-o "$SRCDEST"/$_tarball $_gittag || return 1

	msg "Uploading $_tarball"
        scp "$SRCDEST"/$_tarball dev.alpinelinux.org:/archive/$pkgname/
}

prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	cmake -DCMAKE_INSTALL_PREFIX="/usr" . || return 1
	make
}

package() {
	cd "$_builddir"
	make install DESTDIR="$pkgdir" || return 1
	mv "$pkgdir"/usr/share/pkgconfig "$pkgdir"/usr/lib/
}

tools() {
	pkgdesc="JSON tools based on Yajl"
	mkdir -p "$subpkgdir"/usr/
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}


md5sums="f4a2bfee856245a66a25ceea14658be4  yajl-2.1.0.tar.gz"
sha256sums="b03bb1283e6b86dfff2aac86d3a92dee3969c03ddd59217cacf8b4aa191ffa49  yajl-2.1.0.tar.gz"
sha512sums="857101d8b99be22bde3c21ec1921ffcbbcd14735ff420728855e064631e6c4c4ceaec40b0e5c8b6d8cba1b36fe1ace0738f8e917e2f992107559b17ddf73de50  yajl-2.1.0.tar.gz"
