# Maintainer: Johannes Schindelin <johannes.schindelin@gmx.de>

pkgname=w3m
_basever=0.5.3
_gitdate=20180125
pkgver=${_basever}+${_gitdate}
pkgrel=1
pkgdesc="w3m is a pager with WWW capability (net-utils)"
arch=('i686' 'x86_64')
url="https://w3m.sourceforge.io/"
license=('BSD')
groups=('net-utils')
depends=('libgc' 'libiconv' 'libintl' 'openssl' 'zlib' 'ncurses')
makedepends=('libgc-devel' 'libiconv-devel' 'gettext-devel' 'openssl-devel' 'zlib-devel' 'libtool' 'ncurses-devel')
source=(#"https://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.gz"
        https://github.com/tats/w3m/archive/v${_basever}+git${_gitdate}.tar.gz
        '0001-w3m-0.5.3-bdwgc72-1.patch'
        '0002-MSys-Make-sure-that-setmode-is-declared.patch')
sha256sums=('c75068ef06963c9e3fd387e8695a203c6edda2f467b5f2f754835afb75eb36f3'
            'c464f681443552b50967ab0a9680c414d3c84afa1bb8a8966fa17ee5f0efd3d9'
            '06271c4c614112cfa9b7aeb1013f265d4abdf353d264261e1861a482b3f1d396')

prepare() {
  cd ${srcdir}/${pkgname}-${_basever}-git${_gitdate}

  cp /usr/share/libtool/build-aux/config.{guess,sub} ./
  #patch -p1 <${srcdir}/0001-w3m-0.5.3-bdwgc72-1.patch
  patch -p1 <${srcdir}/0002-MSys-Make-sure-that-setmode-is-declared.patch
}

build() {
  cd ${srcdir}/${pkgname}-${_basever}-git${_gitdate}

  ./configure \
    --prefix=/usr \
    --with-editor=/usr/bin/vim \
    --with-mailer=/usr/bin/mutt \
    --with-browser=/usr/bin/elinks
  make
}

package() {
  cd ${srcdir}/${pkgname}-${_basever}-git${_gitdate}

  make DESTDIR=${pkgdir} install

  mkdir -p "${pkgdir}/usr/share/licenses/${pkgname}"
  cp -f doc/README "${pkgdir}/usr/share/licenses/${pkgname}"
}
