# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=which
pkgver=2.21
pkgrel=1
pkgdesc="A utility to show the full path of commands"
arch=('i686' 'x86_64')
url="http://www.xs4all.nl/~carlo17/which"
license=('GPL3')
groups=('base')
source=("http://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz"
        am-1.14.all.patch)
depends=('msys2-runtime' 'sh')
install=which.install
md5sums=('097ff1a324ae02e0a3b0369f07a7544a'
         '9315cae265dd34eaf7aae9a23ac1840e')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/am-1.14.all.patch
}

build() {
  [[ -d ${srcdir}/build-${CHOST} ]] && rm -rf ${srcdir}/build-${CHOST}
  mkdir ${srcdir}/build-${CHOST} && cd ${srcdir}/build-${CHOST}

  ../${pkgname}-${pkgver}/configure \
    --prefix=/usr \
    --build=${CHOST} \
    --host=${CHOST} \
    --target=${CHOST}

  make
}

package() {
  cd ${srcdir}/build-${CHOST}
  make install DESTDIR=${pkgdir}
}
