pkgbase=libssh
pkgname=('libssh' 'libssh-devel')
pkgver=0.9.6
pkgrel=1
pkgdesc='Library for accessing ssh client services through C libraries'
url='https://www.libssh.org/'
license=('LGPL')
arch=('i686' 'x86_64')
depends=('zlib' 'libopenssl')
makedepends=('cmake' 'python' 'openssl-devel')
source=("https://www.libssh.org/files/${pkgver%.*}/$pkgname-$pkgver.tar.xz"{,.asc}
        0001-Work-around-internal-compiler-error.patch)
sha256sums=('86bcf885bd9b80466fe0e05453c58b877df61afa8ba947a58c356d7f0fab829b'
            'SKIP'
            'f34ae4dcc7770b36bdc76f71096ccd95e86a800a7bbfb2e44f2217fe9fa3ea36')
validpgpkeys=('8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D') # Andreas Schneider <asn@cryptomilk.org>

prepare() {
  mkdir -p build

  cd $pkgname-$pkgver
  patch -p1 -i "${srcdir}/0001-Work-around-internal-compiler-error.patch"
}

build() {
  cd build
  cmake ../$pkgname-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DWITH_GSSAPI=OFF \
    -DUNIT_TESTING=OFF
  make
  make DESTDIR="$srcdir/dest" install
}

package_libssh() {
  mkdir -p $pkgdir/usr/bin
  cp -rf $srcdir/dest/usr/bin/* $pkgdir/usr/bin/
}

package_libssh-devel() {
  mkdir -p $pkgdir/usr/include
  cp -rf $srcdir/dest/usr/include/* $pkgdir/usr/include/

  mkdir -p $pkgdir/usr/lib
  cp -rf $srcdir/dest/usr/lib/* $pkgdir/usr/lib/
}
