summaryrefslogtreecommitdiff
blob: 3ba6d2c8d2a6a61fc3be3c055db17ebc8fa6cded (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
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

NEED_EMACS=25.1
inherit edo elisp toolchain-funcs

DESCRIPTION="A high-level Emacs Lisp RDBMS front-end"
HOMEPAGE="https://github.com/magit/emacsql"

if [[ ${PV} == *9999* ]]; then
	inherit git-r3

	EGIT_REPO_URI="https://github.com/magit/${PN}.git"
else
	SRC_URI="
		https://github.com/magit/${PN}/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz
	"
	KEYWORDS="~amd64"
fi

LICENSE="Unlicense"
SLOT="0"
# TODO(arsen): postgres-pg using app-emacs/pg (unpackaged as of yet)
IUSE="+sqlite postgres mysql"

DEPEND="
	sqlite? ( dev-db/sqlite:3 )
"
RDEPEND="
	${DEPEND}
	postgres? ( dev-db/postgresql )
	mysql? ( virtual/mysql )
"
BDEPEND="virtual/pkgconfig"

PATCHES=(
	"${FILESDIR}/${PN}-3.1.1-fix-utf8-bom-writing.patch"
)

SITEFILE="50${PN}-gentoo.el"

src_prepare() {
	default

	# Not packaged.
	rm emacsql-pg.el || die

	local -A backends=(
		[sqlite]=sqlite
		[postgres]=psql
		[mysql]=mysql
	)

	for useflag in "${!backends[@]}"; do
		if ! use "${useflag}"; then
			rm emacsql-"${backends[${useflag}]}".el || die
		fi
	done
}

src_compile() {
	if use sqlite; then
		edo $(tc-getCC) -fPIC -Wall -Wextra \
			$($(tc-getPKG_CONFIG) --cflags --libs sqlite3) \
			${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -o emacsql-sqlite \
			sqlite/emacsql.c
	fi
	elisp_src_compile
}

src_install() {
	elisp_src_install

	if use sqlite; then
		exeinto "${SITELISP}"/emacsql/sqlite
		doexe emacsql-sqlite
	fi
}