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

pkgname=tcsh
pkgver=6.22.04
pkgrel=1
epoch=
pkgdesc="C shell with file name completion and command line editing"
arch=("i686" "x86_64")
url="https://www.tcsh.org/"
license=('BSD')
groups=()
depends=('gcc-libs' 'libcrypt' 'libiconv' 'ncurses')
makedepends=('gcc' 'libcrypt-devel' 'libiconv-devel' 'ncurses-devel')
provides=('csh')
conflicts=('csh')
install=tcsh.install
source=("ftp://ftp.astron.com/pub/${pkgname}/${pkgname}-${pkgver}.tar.gz"
        "msys-platform.patch")
sha256sums=('eb16356243218c32f39e07258d72bf8b21e62ce94bb0e8a95e318b151397e231'
            '69d1f10818adf9ebb09369a5eb3500c289f518c5e54f51d93439c7a6ac90af6b')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  cp -f config/cygwin config/msys
  patch -p1 -i ${srcdir}/msys-platform.patch
  autoreconf -ivf
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./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
}
