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

EAPI=7

inherit toolchain-funcs

EGIT_COMMIT="7c27c6306160f630c3c4f4b4971deb657126d681"

HOMEPAGE="https://github.com/libbpf/libbpf"
DESCRIPTION="Stand-alone build of libbpf from the Linux kernel"
SRC_URI="https://github.com/${PN}/${PN}/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz"

LICENSE="GPL-2 LGPL-2.1 BSD-2"
SLOT="0/${PV}"
KEYWORDS="~amd64 ~x86"
IUSE="static-libs"

COMMON_DEPEND="virtual/libelf
	!<=dev-util/bcc-0.7.0"
DEPEND="${COMMON_DEPEND}
	sys-kernel/linux-headers"
RDEPEND="${COMMON_DEPEND}"

S="${WORKDIR}/${PN}-${EGIT_COMMIT}/src"

PATCHES=(
	"${FILESDIR}/libbpf-0.20190404-makefile.patch"
)

src_prepare() {
	# upstream doesn't provide a pkgconfig file, so
	# let's make one
	printf 'prefix=/usr\nexec_prefix=${prefix}\nlibdir=%s\n' \
			"/usr/$(get_libdir)" \
		> ${PN}.pc
	printf 'includedir=${prefix}/include\n\n' \
		>> ${PN}.pc

	printf 'Name: %s\nDescription: %s\nVersion: %s\nLibs: -lbpf %s\n' \
			"${PN}" \
			"${DESCRIPTION}" \
			"${PV}" \
			"$($(tc-getPKG_CONFIG) --libs libelf)" \
		>> ${PN}.pc

	default
}

src_compile() {
	emake \
		BUILD_SHARED=y \
		LIBSUBDIR="$(get_libdir)" \
		$(usex static-libs 'BUILD_STATIC=y' '' '' '') \
		CC="$(tc-getCC)"
}

src_install() {
	emake \
		BUILD_SHARED=y \
		LIBSUBDIR="$(get_libdir)" \
		DESTDIR="${D}" \
		$(usex static-libs 'BUILD_STATIC=y' '' '' '') \
		install

	insinto /usr/$(get_libdir)/pkgconfig
	doins ${PN}.pc
}