aboutsummaryrefslogtreecommitdiff
blob: 15abb065dd890db1b24883155b8328cf52e7354d (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
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

LUA_COMPAT=( lua5-1 luajit )

inherit lua-single toolchain-funcs flag-o-matic

DESCRIPTION="Spreadsheet Calculator Improvised -- An ncurses spreadsheet program for terminal"
HOMEPAGE="https://github.com/andmarti1424/sc-im"
SRC_URI="https://github.com/andmarti1424/sc-im/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD-4"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="X plots wayland xls xlsx lua ods tmux"
REQUIRED_USE="lua? ( ${LUA_REQUIRED_USE} )"

PATCHES=(
	"${FILESDIR}/${P}-prefix.patch"
	"${FILESDIR}/${P}-automagic.patch"
	"${FILESDIR}/${P}-clipboard.patch"
)

DEPEND="
	sys-libs/ncurses

	lua? (
		${LUA_DEPS}
	)
	ods? (
		dev-libs/libxml2
		dev-libs/libzip
	)
	plots? ( sci-visualization/gnuplot )
	tmux? ( app-misc/tmux )
	wayland? ( gui-apps/wl-clipboard )
	X? ( x11-misc/xclip )
	xls? (
		dev-libs/libxls
	)
	xlsx? (
		dev-libs/libxlsxwriter
		dev-libs/libxml2
		dev-libs/libzip
	)
"
RDEPEND="${DEPEND}"
BDEPEND="virtual/pkgconfig"
S="${WORKDIR}/${P}/src"

pkg_setup() {
	CONFLICTING=$(usex tmux "tmux " "")$(usex wayland "wayland " "")$(usex X "X" "")
	if ( use tmux && ( use wayland || use X ) ) ; then
		elog "Conflicting flags for clipboard support are set: ${CONFLICTING}"
		elog "tmux support has been preferred."
	elif ( use wayland && use X ) ; then
		elog "Conflicting flags for clipboard support are set: ${CONFLICTING}"
		elog "Wayland support has been preferred."
	fi

	# Run lua setup
	lua-single_pkg_setup
}

src_configure() {
	tc-export CC

	PKGCONF=$(tc-getPKG_CONFIG)

	if use tmux ; then
		append-cflags '-DDEFAULT_COPY_TO_CLIPBOARD_CMD=\""tmux load-buffer"\"'
		append-cflags '-DDEFAULT_PASTE_FROM_CLIPBOARD_CMD=\""tmux show-buffer"\"'
	elif use wayland ; then
		append-cflags '-DDEFAULT_COPY_TO_CLIPBOARD_CMD=\""wl-copy <"\"'
		append-cflags '-DDEFAULT_PASTE_FROM_CLIPBOARD_CMD=\""wl-paste"\"'
	elif use X ; then
		append-cflags '-DDEFAULT_COPY_TO_CLIPBOARD_CMD=\""xclip -i -selection clipboard <"\"'
		append-cflags '-DDEFAULT_PASTE_FROM_CLIPBOARD_CMD=\""xclip -o -selection clipboard"\"'
	fi

	use plots && append-cflags -DGNUPLOT
	if use xls; then
		append-cflags -DXLS $(${PKGCONF} --cflags libxls)
		LDLIBS+=" $(${PKGCONF} --libs libxls)"
	fi
	if use xlsx || use ods ; then
		append-cflags -DODS -DXLSX $(${PKGCONF} --cflags libxml-2.0 libzip)
		LDLIBS+=" -DODS -DXLSX $(${PKGCONF} --libs libxml-2.0 libzip)"
	fi
	if use xlsx ; then
		append-cflags -DXLSX_EXPORT $(${PKGCONF} --cflags xlsxwriter)
		LDLIBS+=" -DXLSX_EXPORT $(${PKGCONF} --libs xlsxwriter)"
	fi
	if use lua ; then
		append-cflags -DXLUA $(${PKGCONF} --cflags lua)
		LDLIBS+=" -DXLUA $(${PKGCONF} --libs lua) -rdynamic"
	fi
	append-cflags $(${PKGCONF} --cflags ncursesw) || append-cflags $(${PKGCONF} --cflags ncurses)
	LDLIBS+=" $(${PKGCONF} --libs ncursesw)" || LDLIBS+=" $(${PKGCONF} --libs ncurses)"
	export LDLIBS
}