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

pkgname=wget
pkgver=1.24.5
pkgrel=1
pkgdesc="A network utility to retrieve files from the Web"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/wget/"
license=('GPL3')
depends=('gcc-libs' 'libiconv' 'libidn2' 'libintl' 'libgpgme' 'libpcre2_8' 'libpsl' 'libuuid' 'libgnutls' 'zlib')
makedepends=('autoconf-archive' 'gettext-devel' 'libidn2-devel' 'libgpgme-devel' 'libuuid-devel'
             'libpsl-devel' 'libgnutls-devel' 'pcre2-devel' 'zlib-devel' 'python' 'libunistring-devel' 'autotools' 'gcc')
checkdepends=('perl-HTTP-Daemon' 'perl-IO-Socket-SSL')
optdepends=('ca-certificates: HTTPS downloads')
backup=('etc/wgetrc')
source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.lz{,.sig})
sha256sums=('57a107151e4ef94fdf94affecfac598963f372f13293ed9c74032105390b36ee'
            'SKIP')
validpgpkeys=('7845120B07CBD8D6ECE5FF2B2A1743EDA91A35B6') # Tim Rühsen <tim.ruehsen@gmx.de>

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

  autoreconf -fiv
  cat >> doc/sample.wgetrc <<EOF

# default root certs location
ca_certificate=/usr/ssl/certs/ca-bundle.crt
EOF
}

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

  local CYGWIN_CHOST="${CHOST/-msys/-cygwin}"
  ./configure --build=${CYGWIN_CHOST} \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --with-ssl=gnutls \
    --with-libpsl \
    --without-libiconv-prefix \
    --without-libintl-prefix \
    --without-libpth-prefix \
    --without-libgnutls-prefix \
    --without-metalink

  make
}

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

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
}
