# $Id: PKGBUILD 127436 2015-02-09 21:13:00Z arodseth $
# Maintainer: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Sébastien Luttringer
# Contributor: Lucas Hermann Negri <kkndrox@gmail.com>

pkgbase=lua-bitop
pkgname=(lua-bitop lua51-bitop)
pkgver=1.0.2
pkgrel=5
pkgdesc='C extension adding bitwise operations on numbers'
arch=('x86_64' 'i686')
url='http://bitop.luajit.org/'
makedepends=('lua' 'lua51')
source=("http://bitop.luajit.org/download/LuaBitOp-$pkgver.tar.gz")
md5sums=('d0c1080fe0c844e8477279668e2d0d06')
license=('MIT')

build() {
  cp -a "LuaBitOp-$pkgver" "LuaBitOp51-$pkgver"

  msg2 'Building with lua 5.2'
  cd "LuaBitOp-$pkgver"
  make INCLUDES=' -I/usr/include' LUA='lua'

  msg2 'Building with lua 5.1'
  cd "../LuaBitOp51-$pkgver"
  make INCLUDES=' -I/usr/include/lua5.1' LUA='lua5.1'
}

package_lua-bitop() {
  depends=('lua')

  cd "LuaBitOp-$pkgver"
  install -Dm 644 bit.so "$pkgdir/usr/lib/lua/5.2/bit.so"
  install -dm 755 "$pkgdir/usr/share/licenses/$pkgname"
  ln -s '../lua/LICENSE' "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

package_lua51-bitop() {
  depends=('lua51')
  conflicts=('luabitop')
  replaces=('luabitop')

  cd "LuaBitOp51-$pkgver"
  install -Dm 644 bit.so "$pkgdir/usr/lib/lua/5.1/bit.so"
  install -dm 755 "$pkgdir/usr/share/licenses/$pkgname"
  ln -s '../lua51/LICENSE' "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim:set ts=2 sw=2 et:
