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

pkgbase=libcrypt
pkgname=('libcrypt' 'libcrypt-devel')
pkgver=2.1
pkgrel=3
pkgdesc="Encryption/Decryption utility and library"
arch=('i686' 'x86_64')
license=('custom')
url="https://cygwin.com/"
makedepends=('gcc' 'git' 'make')
source=(${pkgbase}-${pkgver}::git+https://sourceware.org/git/cygwin-apps/crypt.git#tag=crypt-${pkgver//./_}-release
        msysize.patch)
sha256sums=('SKIP'
            'f0646267208c94d96cf07b6f90296b7c7211b7daa64cb85c6a80128ac3f6ebff')

prepare() {
  cd ${srcdir}/${pkgbase}-${pkgver}

  patch -p1 -i ${srcdir}/msysize.patch
}

build() {
  cd "${srcdir}/${pkgbase}-${pkgver}"
  make CC=gcc AR=ar CFLAGS="${CFLAGS}"

  make DESTDIR=${srcdir}/dest install
}

package_libcrypt() {
  pkgdesc="Encryption/Decryption library"
  groups=('libraries')
  depends=('gcc-libs')
  mkdir -p ${pkgdir}/usr/bin

  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/
}

package_libcrypt-devel() {
  pkgdesc="Libcrypt headers and libraries"
  groups=('development')
  depends=("libcrypt=${pkgver}")
  options=('staticlibs')

  mkdir -p ${pkgdir}/usr

  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
