# Maintainer: Felix Huettner <huettner94@gmx.de>

pkgname=whois
pkgver=5.5.23
pkgrel=1
pkgdesc="The whois client by Marco d'Itri"
arch=('i686' 'x86_64')
url="https://www.linux.it/~md/software/"
license=('GPL')
depends=('libxcrypt' 'libidn2' 'libiconv' 'libunistring')
makedepends=('perl' 'libxcrypt-devel' 'libidn2-devel' 'libiconv-devel' 'libunistring-devel' 'make' 'gcc')
backup=('etc/whois.conf')
source=("http://ftp.debian.org/debian/pool/main/w/whois/${pkgname}_${pkgver}.tar.xz"
        "whois-libiconv.patch")
sha256sums=('35c04e46bd8435f46e446a817728b5fae2f0a389033a9383e5e20bb6e8fba14a'
            '15635fe62da7eed833ad0b1c124fc8e4647f06c7e5b6b5b3314b32a663899ce6')

prepare() {
  mv "${pkgname}" "${pkgname}-${pkgver}"
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -i ${srcdir}/whois-libiconv.patch
}

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

  make prefix=/usr \
       CFLAGS="$CFLAGS $CPPFLAGS" \
       CONFIG_FILE=/etc/whois.conf \
       HAVE_LIBIDN2=1 \
       HAVE_ICONV=1
}

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

  make prefix=/usr BASEDIR="${pkgdir}" install-whois
  install -D -m644 whois.conf "${pkgdir}/etc/whois.conf"
}
