# $Id: PKGBUILD 110131 2014-04-24 14:27:59Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Old Maintainer: Gustavo Alvarez <sl1pkn07@gmail.com>
# contributor: Cameron Banta <cbanta@gmail.com>

pkgbase=lua-alt-getopt
pkgname=(lua-alt-getopt lua51-alt-getopt)
pkgver=0.7.0
pkgrel=5
pkgdesc="Lua module for processing options similar to getopt_long(3) (5.1)"
license=('MIT')
arch=('any')
url="http://luaforge.net/projects/alt-getopt/"
depends=('lua' 'lua51')
makedepends=('bmake')
source=("http://mova.org/~cheusov/pub/lua_alt_getopt/lua-alt-getopt-${pkgver}.tar.gz"
        'LICENSE')
sha1sums=('431b590002f5fdced78e0745a9a283aefdd1dfa0'
          'e471a511997528dd080d2997580499c37d06111a')

build() {
  cp -r "${pkgname}-${pkgver}" build51
  cp -r "${pkgname}-${pkgver}" build52
  cd $srcdir/build51
  bmake LUAVER=5.1 PREFIX=/usr
  cd $srcdir/build52
  bmake LUAVER=5.2 PREFIX=/usr
}

package_lua51-alt-getopt() {
  cd $srcdir/build51
  install -Dm755 alt_getopt "${pkgdir}/usr/bin/alt_getopt5.1"
  install -Dm664 alt_getopt.lua "${pkgdir}/usr/share/lua/5.1/alt_getopt.lua"
  install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

package_lua-alt-getopt() {
  cd $srcdir/build52
  install -Dm755 alt_getopt "${pkgdir}/usr/bin/alt_getopt"
  install -Dm664 alt_getopt.lua "${pkgdir}/usr/share/lua/5.2/alt_getopt.lua"
  install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
