# Maintainer: Luke R. <g4jc@openmailbox.org> GPG: rsa4096/3EAE8697
# Contributor: Marti Raudsepp <marti@juffo.org>
# Contributor: mutantmonkey <aur@mutantmonkey.in>
# Contributor: grawity

pkgname=tcpcrypt
pkgver=0.5
pkgrel=2
pkgdesc="Transparent user space implementation for the tcpcrypt TCP extensions"
arch=('i686' 'x86_64' 'armv7h')
url="http://tcpcrypt.org/"
license=('BSD')
depends=('libnetfilter_queue' 'openssl' 'iptables')
makedepends=('gcc' 'autoconf' 'automake' 'openssl')
provides=('tcpcrypt')
conflicts=('tcpcrypt')
source=("$pkgname-$pkgver.tar.gz::https://github.com/scslab/tcpcrypt/archive/v$pkgver.tar.gz"
        'tcpcrypt.service'
        'tcpcrypt.sysusers'
        'tcpcrypt.tmpfiles')
sha256sums=('251213be8bfd0b9224f4d8d7a79fe1b8961a180f5a278f128376a66364a38ea3'
            'be617bf7d3f8050ca3c1ad0c1681634c1d101f5eb75d33776d8a414afb8d6526'
            '69fe5592f393e2d0e196d189bda98f8737652a992b827cfbd1fcd6a221db893d'
            '6ed9beaf9998bc3bfdd7c17d253c8b910833240b5d3a0d5daec8cd2f3cdac44b')

prepare() {
  cd "$srcdir"/$pkgname-$pkgver
  mkdir -p m4

  sed -i 's:AC_PROG_LIBTOOL:LT_INIT:' configure.ac
  ./bootstrap.sh
}

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

  ./configure --prefix=/usr
  make
}

package() {
  cd "$srcdir"/$pkgname-$pkgver

  make DESTDIR="$pkgdir" install

  install -Dm644 "$srcdir"/$pkgname-$pkgver/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  install -Dm644 "$srcdir"/tcpcrypt.service "$pkgdir"/usr/lib/systemd/system/tcpcrypt.service
  install -Dm644 "$srcdir"/tcpcrypt.sysusers "$pkgdir"/usr/lib/sysusers.d/tcpcrypt.conf
  install -Dm644 "$srcdir"/tcpcrypt.tmpfiles "$pkgdir"/usr/lib/tmpfiles.d/tcpcrypt.conf
}
