pkgname=lynx
pkgver=2.9.2
_relver=${pkgver}
pkgrel=1
pkgdesc="A text browser for the World Wide Web"
url="https://lynx.invisible-island.net/"
msys2_pgp_keys_url="https://invisible-island.net/public/public.html"
msys2_references=(
  "cpe: cpe:/a:lynx:lynx"
  "cpe: cpe:/a:lynx_project:lynx"
  "cpe: cpe:/a:university_of_kansas:lynx"
)
arch=('i686' 'x86_64')
license=('GPL')
depends=('openssl' 'libidn' 'ncurses' 'libintl')
makedepends=('gcc' 'autotools' 'openssl-devel' 'libidn-devel' 'ncurses-devel' 'gettext-devel')
backup=('etc/lynx.cfg')
source=("https://invisible-mirror.net/archives/lynx/tarballs/${pkgname}${_relver}.tar.bz2"{,.asc})
sha256sums=('7374b89936d991669e101f4e97f2c9592036e1e8cdaa7bafc259a77ab6fb07ce'
            'SKIP')
validpgpkeys=('19882D92DDA4C400C22C0D56CC2AF4472167BE03')

prepare() {
  cd "${srcdir}/${pkgname}${_relver}"

}

build() {
  cd "${srcdir}/${pkgname}${_relver}"

  local CYGWIN_CHOST="${CHOST/-msys/-cygwin}"
  ./configure \
    --build=${CYGWIN_CHOST} \
    --prefix=/usr \
    --sysconfdir=/etc \
    --with-ssl=/usr \
    --enable-nls \
    --enable-ipv6 \
    --mandir=/usr/share/man
  make
}

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

  # FS#20404 - points to local help
  sed -i -e "s|^HELPFILE.*$|HELPFILE:file:///usr/share/doc/lynx/lynx_help/lynx_help_main.html|" "${pkgdir}/etc/lynx.cfg"

  install -d "${pkgdir}/usr/share/doc/lynx"
  cp -rf lynx_help "${pkgdir}/usr/share/doc/lynx"
}
