# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Ray Donnelly <mingw.android@gmail.com>

pkgname=which
pkgver=2.23
pkgrel=4
pkgdesc="A utility to show the full path of commands"
arch=('i686' 'x86_64')
url="https://savannah.gnu.org/projects/which/"
msys2_references=(
  "anitya: 5127"
)
license=('GPL3')
source=("https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.gz"
        msys2-allow-windows-mixed-absolute-paths.patch)
depends=('sh')
makedepends=('autotools' 'gcc')
#options=('debug' '!strip')
sha256sums=('a2c558226fc4d9e4ce331bd2fd3c3f17f955115d2c00e447618a4ef9978a2a73'
            'adf32a958c3cb212e20bc95b716a988a02eac3f297007db201e56d29434be8c3')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/msys2-allow-windows-mixed-absolute-paths.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}
}
