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

EAPI=7

LLVM_MAX_SLOT=14
inherit llvm toolchain-funcs

DESCRIPTION="C semantic parser"
HOMEPAGE="https://sparse.wiki.kernel.org/index.php/Main_Page"

if [[ ${PV} == "9999" ]] ; then
	inherit git-r3
	EGIT_REPO_URI="https://git.kernel.org/pub/scm/devel/${PN}/${PN}.git"
else
	SRC_URI="https://www.kernel.org/pub/software/devel/${PN}/dist/${P}.tar.xz"
	KEYWORDS="~amd64 ~arm ~hppa ~ppc ~ppc64 ~s390 ~sparc ~x86"
fi

LICENSE="MIT"
SLOT="0"
IUSE="gtk llvm sqlite test xml"
RESTRICT="!test? ( test )"

RDEPEND="gtk? ( x11-libs/gtk+:3 )
	llvm? ( <sys-devel/llvm-$((${LLVM_MAX_SLOT} + 1)):= )
	sqlite? ( dev-db/sqlite:= )
	xml? ( dev-libs/libxml2 )"
DEPEND="${RDEPEND}"
BDEPEND="gtk? ( virtual/pkgconfig )
	xml? ( virtual/pkgconfig )"

llvm_check_deps() {
	has_version "sys-devel/llvm:${LLVM_SLOT}" && \
		has_version -r "sys-devel/llvm:${LLVM_SLOT}"
}

pkg_setup() {
	use llvm && llvm_pkg_setup
}

_emake() {
	# Makefile does not allow for an easy override of flags.
	# Collect them here and override default phases.
	emake \
		CC="$(tc-getCC)" \
		LD="$(tc-getCC)" \
		AR="$(tc-getAR)" \
		CFLAGS="${CFLAGS}" \
		PKG_CONFIG="$(tc-getPKG_CONFIG)" \
		HAVE_GTK=$(usex gtk) \
		HAVE_LLVM=$(usex llvm) \
		HAVE_SQLITE=$(usex sqlite) \
		HAVE_LIBXML=$(usex xml) \
		V=1 \
		PREFIX="${EPREFIX}/usr" \
		"$@"
}

src_compile() {
	_emake
}

src_test() {
	_emake check
}

src_install() {
	_emake DESTDIR="${D}" install

	dodoc FAQ README
}