# Maintainer: Masanori Shirayama <mashir43@gmail.com>

pkgname=tcsh
pkgver=6.24.16
pkgrel=1
epoch=
pkgdesc="C shell with file name completion and command line editing"
arch=("i686" "x86_64")
url="https://www.tcsh.org/"
msys2_repository_url="https://github.com/tcsh-org/tcsh"
msys2_references=(
  "anitya: 4945"
)
license=('BSD')
groups=()
depends=('gcc-libs' 'libxcrypt' 'libiconv' 'ncurses')
makedepends=('gcc' 'libxcrypt-devel' 'libiconv-devel' 'ncurses-devel' 'autotools')
provides=('csh')
conflicts=('csh')
install=tcsh.install
source=("https://astron.com/pub/tcsh/tcsh-${pkgver}.tar.gz"{,.asc})
sha256sums=('4208cf4630fb64d91d81987f854f9570a5a0e8a001a92827def37d0ed8f37364'
            'SKIP')
validpgpkeys=('AD87109763D8D8C2C94CBA8065C26E471F45B123') # Kimmo Suominen

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  autoreconf -ivf
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  export MSYSTEM=CYGWIN
  ./configure \
    --prefix=/usr \
    --build=${CHOST} \
    --host=${CHOST} \
    --target=${CHOST}

  make
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make -k check || true
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install

  install -Dm644 ./Copyright ${pkgdir}/usr/share/licenses/tcsh/Copyright

  cd "${pkgdir}/usr/bin"
  cp -p tcsh.exe csh.exe
}
