summaryrefslogtreecommitdiff
blob: 0e4e9fd91365ed64dd938eec225360384a553bf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit autotools

GITID="06cc8a637efd9097af4f138b1b7c755120ffaa88"
DESCRIPTION="HTML to ASCII converter programmed to handle incorrect html"
HOMEPAGE="https://bhaak.net/vilistextum/"
SRC_URI="https://github.com/bhaak/vilistextum/archive/${GITID}.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}/${PN}-${GITID}"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 ppc sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris"
IUSE="unicode"

# Known test failures nobody cares about
RESTRICT="test"

DEPEND="virtual/libiconv"

PATCHES=(
	"${FILESDIR}"/${PN}-2.8.0-prefix.patch
	"${FILESDIR}"/${PN}-2.8.0.20200411-blockquote.patch
	"${FILESDIR}"/${PN}-2.8.0-towlower.patch
	"${FILESDIR}"/${PN}-2.8.0.20200411-list-alignment.patch
	"${FILESDIR}"/${P}-static.patch
)

src_prepare() {
	default
	eautoreconf

	# wcscasecmp needs extensions, which aren't enabled
	export ac_cv_func_wcscasecmp=no
}

get_locale() {
	locale -a | grep -i "$1\.utf.*8\$"
}

find_locale() {
	local l t

	# we basically prefer to find en_US.UTF-8, but it may not always be
	# available, in which case it is better not to hardcode to use it
	l=$(get_locale en_US)
	if [[ -z ${l} ]] ; then
		for t in "en_GB" "en_.*" ".*" ; do
			l=$(get_locale ${t})
			if [[ -n ${l} ]] ; then
				l=${l%%$'\n'*}
				break;
			fi
		done
	fi
	[[ -z ${l} ]] && die "Failed to find a unicode locale"
	echo "${l}"
}

src_configure() {
	# need hardwired locale simply because locale -a | grep -i utf-8 | head -n1
	# isn't always returning the most sensical (and working) locale
	econf \
		$(use_enable unicode multibyte) \
		$(use_with unicode unicode-locale $(find_locale))
}

src_test() {
	if $(locale -a | grep -iq "en_US\.utf.*8"); then
		emake -j1 check
	else
		ewarn "If you like to run the test,"
		ewarn "please make sure en_US.UTF-8 is installed."
		die "en_US.UTF-8 locale is missing"
	fi
}

src_install() {
	default
	doman doc/${PN}.1
	dodoc doc/changes.xhtml doc/htmlmail.xhtml
}