summaryrefslogtreecommitdiff
blob: 0eb273b8fadb0f2a8b89aab3c456072f7b20ff98 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=4

inherit eutils toolchain-funcs

DESCRIPTION="Lightweight text-mode editor"
HOMEPAGE="http://fte.sourceforge.net"
SRC_URI="
	mirror://sourceforge/fte/${P}-src.zip
	mirror://sourceforge/fte/${P}-common.zip"

LICENSE="|| ( GPL-2 Artistic )"
SLOT="0"
KEYWORDS="~alpha amd64 ppc -sparc x86 ~amd64-linux ~x86-linux ~ppc-macos"
IUSE="gpm slang X"

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

RDEPEND="
	>=sys-libs/ncurses-5.2
	X? (
		x11-libs/libXdmcp
		x11-libs/libXau
		x11-libs/libX11
		x11-libs/libXpm
	)
	gpm? ( >=sys-libs/gpm-1.20 )"
DEPEND="${RDEPEND}
	slang? ( >=sys-libs/slang-2.1.3 )
	app-arch/unzip"

set_targets() {
	export TARGETS=""
	use slang && TARGETS="${TARGETS} sfte"
	use X && TARGETS="${TARGETS} xfte"

	[[ ${CHOST} == *-linux-gnu* ]] \
		&& TARGETS="${TARGETS} vfte" \
		|| TARGETS="${TARGETS} nfte"
}

src_prepare() {
	epatch \
		"${FILESDIR}"/fte-gcc34 \
		"${FILESDIR}"/${PN}-new_keyword.patch \
		"${FILESDIR}"/${PN}-slang.patch \
		"${FILESDIR}"/${PN}-interix.patch \
		"${FILESDIR}"/${PN}-cpp14.patch # bug #595048

	[[ -e /usr/include/linux/keyboard.h ]] && \
		sed /usr/include/linux/keyboard.h -e '/wait.h/d' > src/hacked_keyboard.h

	sed \
		-e "s:<linux/keyboard.h>:\"hacked_keyboard.h\":" \
		-i src/con_linux.cpp || die "sed keyboard"
	sed \
		-e 's:^OPTIMIZE:#&:g' \
		-e '/^LDFLAGS/s:=:+=:g' \
		-e 's:= g++:= $(CXX):g' \
		-i src/fte-unix.mak || die "sed CFLAGS, LDFLAGS, CC"
	ecvs_clean
}

src_configure() {
	set_targets
	sed \
		-e "s:@targets@:${TARGETS}:" \
		-e '/^XINCDIR  =/c\XINCDIR  =' \
		-e '/^XLIBDIR  =/c\XLIBDIR  = -lstdc++' \
		-e '/^SINCDIR   =/c\SINCDIR = -I'"${EPREFIX}"'/usr/include/slang' \
		-i src/fte-unix.mak || die "sed targets"

	if ! use gpm; then
		sed \
			-e "s:#define USE_GPM://#define USE_GPM:" \
			-i src/con_linux.cpp || die "sed USE_GPM"
		sed \
			-e "s:-lgpm::" \
			-i src/fte-unix.mak || die "sed -lgpm"
	fi
}

src_compile() {
	local os="-DLINUX" # by now the default in makefile
	[[ ${CHOST} == *-interix* ]] && os=

	DEFFLAGS="PREFIX='${EPREFIX}'/usr CONFIGDIR='${EPREFIX}'/usr/share/fte \
		DEFAULT_FTE_CONFIG=../config/main.fte UOS=${os}"

	set_targets
	emake CXX=$(tc-getCXX) OPTIMIZE="${CXXFLAGS}" ${DEFFLAGS} TARGETS="${TARGETS}" all
}

src_install() {
	local files

	keepdir /etc/fte

	into /usr

	set_targets
	files="${TARGETS} cfte"

	for i in ${files}; do
		dobin src/$i
	done

	dobin "${FILESDIR}"/fte

	dodoc CHANGES BUGS HISTORY README TODO
	dohtml doc/*

	insinto /usr/share/fte
	doins -r config/*
}

pkg_postinst() {
	ebegin "Compiling configuration"
	cd "${EPREFIX}"/usr/share/fte || die "missing configuration dir"
	"${EPREFIX}"/usr/bin/cfte main.fte "${EPREFIX}"/etc/fte/system.fterc
	eend $?
}