# Contributor: ScrumpyJack <scrumpyjack@st.ilet.to>
# Maintainer: ScrumpyJack <scrumpyjack@st.ilet.to>
pkgname=w3m
_pkgver=0.5.3+git20180125
pkgver=${_pkgver/+git/.}
pkgrel=1
pkgdesc='Text-based Web browser, as well as pager'
url='https://github.com/tats/w3m'
license='MIT UCD'
arch='all'
makedepends="imlib2-dev libressl-dev gc-dev ncurses-dev linux-headers"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/tats/$pkgname/archive/v$_pkgver.tar.gz
	https.patch"
builddir="$srcdir/$pkgname-${_pkgver/+/-}"

# secfixes:
#   0.5.3.20180125-r0:
#     - CVE-2018-6196
#     - CVE-2018-6197
#     - CVE-2018-6198

build() {
	cd "$builddir"
	./configure \
		--prefix=/usr \
		--libexecdir=/usr/lib \
		--enable-image=fb \
		--with-ssl \
		--disable-nntp \
		--disable-dict \
		--disable-help-cgi \
		--with-imagelib=imlib2 \
		--with-termlib=ncurses \
		--disable-w3mmailer \
		--disable-mouse
	make -j1
}

check() {
	cd "$builddir"
	./w3m -version
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install

	install -d "$pkgdir"/usr/share/doc/"$pkgname"
	install -d "$pkgdir"/usr/share/licenses/"$pkgname"
	local i; for i in doc/*; do
		install -m644 "$i" "$pkgdir"/usr/share/doc/"$pkgname"
	done
	ln -s /usr/share/doc/"$pkgname"/README \
		"$pkgdir"/usr/share/licenses/"$pkgname"
}

sha512sums="61b8498b927569937c509460e291eeba6eb302d34ccd6e1bf4d1eb07ac73a3ac5a477161727d310324625be04b907f8c3e970382d08c9fa0846b371699f04e14  w3m-0.5.3.20180125.tar.gz
3844b3a079524ad403da7fe03461210a433ff1cd562862c4df55c3be250ccba0c34eb61bcc8df1973d70e2ef034edaf1804bb2fa682b01723322f108f523932a  https.patch"
