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

EAPI=8

EGIT_REPO_URI="https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git"
inherit git-r3 linux-info

DESCRIPTION="A lightweight tool for hosting KVM guests"
HOMEPAGE="https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git/"

LICENSE="GPL-2"
SLOT="0"
IUSE=""

DEPEND="riscv? ( sys-apps/dtc )"
BDEPEND="${DEPEND}"
RDEPEND="${DEPEND}"

function ctarget() {
	CTARGET="${ARCH}"
	use amd64 && CTARGET='x86_64'
	echo $CTARGET
}

CONFIG_CHECK="
	SERIAL_8250 SERIAL_8250_CONSOLE
	VIRTIO VIRTIO_PCI
	VIRTIO_RING VIRTIO_PCI
	VIRTIO_BLK VIRTIO_NET
	~VIRTIO_BALLOON
	~VIRTIO_CONSOLE
	~HW_RANDOM_VIRTIO
	~FB_VESA
"

pkg_pretend() {
	if use kernel_linux ; then
		if kernel_is lt 2 6 25; then
			eerror "This version of KVM requires a host kernel of 2.6.25 or higher."
		fi
		if use riscv && kernel_is lt 5 16; then
			ewarn "RISC-V KVM official support landed in kernel 5.16,"
			ewarn "and requires the hypervisor extension."
		fi

		if ! linux_config_exists; then
			eerror "Unable to check your kernel for KVM support"
		else
			check_extra_config
		fi
	fi
}

src_prepare() {
	default
	sed -e 's/^CFLAGS\t:=/CFLAGS := $(CFLAGS)/' \
		-e 's/^LDFLAGS\t:=/LDFLAGS := $(LDFLAGS)/' -i Makefile
}

src_compile() {
	V=1 ARCH=$(ctarget) emake
}

src_install() {
	dobin lkvm vm || die
	dodoc README Documentation/virtio-console.txt || die
	doman Documentation/${PN}.1
}