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

pkgname=mintty
pkgver=3.5.1
pkgrel=1
epoch=1
pkgdesc="Terminal emulator with native Windows look and feel"
arch=('i686' 'x86_64')
license=('GPL3')
depends=('sh')
makedepends=('gcc')
url="https://mintty.github.io"
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/mintty/mintty/archive/${pkgver}.tar.gz)
sha256sums=('cd51f1a042f363adaaf81205deda6b7bca8812bb4dc3502f7c4a1b12183d9dec')

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

}

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

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  mkdir -p ${pkgdir}/usr/{bin,share}
  mkdir -p ${pkgdir}/usr/share/man/man1
  mkdir -p ${pkgdir}/usr/share/licenses/${pkgname}
  mkdir -p ${pkgdir}/usr/share/${pkgname}/lang
  mkdir -p ${pkgdir}/usr/share/${pkgname}/themes
  mkdir -p ${pkgdir}/usr/share/${pkgname}/icon
  mkdir -p ${pkgdir}/usr/share/${pkgname}/sounds
  mkdir -p ${pkgdir}/usr/share/mintty/emojis

  install -m755 bin/mintty.exe ${pkgdir}/usr/bin/mintty.exe
  install -m755 tools/mintheme ${pkgdir}/usr/bin/
  install -m644 docs/mintty.1 ${pkgdir}/usr/share/man/man1/mintty.1

  install -m644 LICENSE* ${pkgdir}/usr/share/licenses/${pkgname}/

  install -m644 lang/messages.pot ${pkgdir}/usr/share/${pkgname}/lang/
  install -m644 lang/*.po ${pkgdir}/usr/share/${pkgname}/lang/

  install -m644 themes/* ${pkgdir}/usr/share/${pkgname}/themes/

  install -m644 tools/getemojis ${pkgdir}/usr/share/mintty/emojis

  install -m644 icon/wsl.ico ${pkgdir}//usr/share/${pkgname}/icon
  for i in 16 24 32 48 64 256
  do
    mkdir -p ${pkgdir}/usr/share/icons/hicolor/${i}x${i}/apps
    install -m644 icon/hi${i}-apps-mintty.png \
                 ${pkgdir}/usr/share/icons/hicolor/${i}x${i}/apps/mintty.png
  done
  install -m644 sounds/*.wav ${pkgdir}/usr/share/${pkgname}/sounds/
  install -m644 sounds/*.WAV ${pkgdir}/usr/share/${pkgname}/sounds/
  install -m644 sounds/*.md ${pkgdir}/usr/share/${pkgname}/sounds/
}
