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

pkgname=mksh
_ver=59c
# use a pacman compatible version scheme
pkgver=${_ver/[a-z]/.${_ver//[0-9.]/}}
pkgrel=1
pkgdesc="The MirBSD Korn Shell"
arch=("i686" "x86_64")
url="https://www.mirbsd.org/mksh.htm"
license=('ISC')
depends=('gcc-libs')
makedepends=('gcc')
provides=('ksh')
conflicts=('ksh')
install=mksh.install
source=("https://www.mirbsd.org/MirOS/dist/mir/${pkgname}/${pkgname}-R${_ver}.tgz"
        "https://www.mirbsd.org/TaC-mksh.txt")
sha256sums=('77ae1665a337f1c48c61d6b961db3e52119b38e58884d1c89684af31f87bc506'
            '8a53fe4d643fb7341e6c94653d63d3d813d8d849fc1d9dfe5dc49ab2fb48aee9')

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

  ./Build.sh
}

check() {
  cd "${srcdir}/${pkgname}"
  ./test.sh || true
}

package() {
  cd "${srcdir}/${pkgname}"

  mkdir -p "${pkgdir}/usr/share/licenses/mksh"

  install -Dm755 mksh.exe "${pkgdir}/usr/bin/mksh.exe"
  install -Dm755 mksh.exe "${pkgdir}/usr/bin/ksh.exe"
  install -Dm644 dot.mkshrc "${pkgdir}/etc/skel/.mkshrc"
  install -Dm644 mksh.1 "${pkgdir}/usr/share/man/man1/mksh.1"

  cd "${srcdir}"
  install -Dm644 TaC-mksh.txt "${pkgdir}/usr/share/licenses/mksh/TaC-mksh.txt"
}
