summaryrefslogtreecommitdiff
blob: ded9e0a3c4c4e26301fc6d0e759d434c4468214d (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit versionator toolchain-funcs

MY_PV=$(replace_version_separator 2 '_')

DESCRIPTION="A vi/ex clone"
HOMEPAGE="http://elvis.the-little-red-haired-girl.org"
SRC_URI="ftp://ftp.cs.pdx.edu/pub/elvis/${PN}-${MY_PV}.tar.gz"

LICENSE="Artistic"
SLOT="0"
KEYWORDS="amd64 ppc ppc64 ~riscv x86 ~ppc-macos ~sparc-solaris"
IUSE="X doc"

RDEPEND="
	sys-libs/ncurses:0=
	app-eselect/eselect-vi
	X? (
		>=x11-libs/libX11-1.0.0
		>=x11-libs/libXt-1.0.0
		>=x11-libs/libXpm-3.5.4.2
		>=x11-libs/libXft-2.1.8.2
	)"

DEPEND="
	${RDEPEND}
	X? ( x11-base/xorg-proto )
	virtual/pkgconfig"

S="${WORKDIR}/${PN}-${MY_PV}"

PATCHES=(
	"${FILESDIR}"/ft2.3-symbol-collision-fix.patch
	"${FILESDIR}"/${P}-glibc-2.10.patch
	"${FILESDIR}"/${P}-interix.patch
)

src_configure() {
	export CC="$(tc-getCC)"
	./configure \
		--libs="$($(tc-getPKG_CONFIG) --libs ncurses)" \
		--prefix="${EPREFIX}"/usr \
		--bindir="${EPREFIX}"/usr/bin \
		--datadir="${EPREFIX}"/usr/share/elvis \
		--docdir="${EPREFIX}"/usr/share/doc/${PF} \
		$(use_with X x) \
		|| die

	# Some Makefile fixups (must happen after configure)
	# Use our CFLAGS
	sed -e "s#^CFLAGS=\(.*\)#CFLAGS=\1 ${CFLAGS}#g;" -i Makefile || \
		die "sed 1 failed"

	# We'll install the man-pages ourselves
	sed -i -e '/^	sh instman.sh/d' Makefile || die "sed 2 failed"

	# Don't try to write to /etc
	sed -i -e 's,/etc/elvis,${ED}/etc/elvis,g' Makefile || die "sed 3 failed"

	# Use LDFLAGS
	sed -i -e "s#\$(CC) \$(CFLAGS)#\$(CC) \$(CFLAGS) ${LDFLAGS}#" Makefile || \
		die "sed 4 failed"
}

src_install() {
	dodir /usr/bin
	dodir /usr/share/man/man1
	dodir /usr/share/elvis
	dodir /usr/share/doc/${PF}
	dodir /etc

	local docdir="${ED}/usr/share/doc/${PF}"
	if ! use doc; then
		docdir="${T}/doc-discard"
	fi

	emake install \
		PREFIX="${ED}"/usr \
		BINDIR="${ED}"/usr/bin \
		DATADIR="${ED}"/usr/share/elvis \
		DOCDIR="${docdir}"

	# Install the man-pages
	mv doc/elvis.man doc/elvis.1 || die
	mv doc/elvtags.man doc/elvtags.1 || die
	mv doc/ref.man doc/ref.1 || die
	doman doc/*.1

	# Fixup some READMEs
	sed -i -e "s,${ED},,g" "${ED}"/etc/elvis/README \
		|| die 'sed /etc/elvis/README failed'
	sed -i -e "s,${ED},,g" "${ED}"/usr/share/elvis/README \
		|| die 'sed /usr/share/elvis/README failed'
}

pkg_postinst() {
	einfo "Setting /usr/bin/vi symlink"
	eselect vi set "${PN}"
}

pkg_postrm() {
	einfo "Updating /usr/bin/vi symlink"
	eselect vi update
}