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

pkgname=wget
pkgver=1.21.2
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')
groups=('base-devel')
depends=('gcc-libs' 'libiconv' 'libidn2' 'libintl' 'libgpgme' 'libpcre2_8' 'libpsl' 'libuuid' 'openssl' 'zlib')
makedepends=('autoconf-archive' 'gettext-devel' 'libidn2-devel' 'libgpgme-devel' 'libuuid-devel'
             'libpsl-devel' 'openssl-devel' 'pcre2-devel' 'zlib-devel' 'python' 'libunistring-devel')
checkdepends=('perl-HTTP-Daemon' 'perl-IO-Socket-SSL')
optdepends=('ca-certificates: HTTPS downloads')
backup=('etc/wgetrc')
install=wget.install
source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.lz{,.sig}
        1.13.4-sysconfdir.patch
        wget-1.14-msys2.patch
        fix-gettext-version.patch)
sha256sums=('1727a330a86acacb3e57615ce268f5f29978bf7adec4abe6a30d370207bc91b3'
            'SKIP'
            'c397093e82b50bcc6a4112a14b22d7426e67ce853d0dae65170aec6d7def4de8'
            '9d15f08be39c537acd175304c5e3116f3b8111b3cbf4ca300efce5b9e0832371'
            '47c50fc5157ab878da8d40e8e07d8aa778a2a6e8f625260bca646796f32501f7')
validpgpkeys=('7845120B07CBD8D6ECE5FF2B2A1743EDA91A35B6') # Tim Rühsen <tim.ruehsen@gmx.de>

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  #patch -p2 -i "${srcdir}/1.13.4-sysconfdir.patch"
  patch -p1 -i "${srcdir}/wget-1.14-msys2.patch"
  #patch -p1 -i "${srcdir}/fix-gettext-version.patch"

  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}"
  ./configure --build=${CHOST} \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --with-ssl=openssl \
    --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
}
