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

EAPI=8

inherit toolchain-funcs

DESCRIPTION="A selection from coreboot/utils useful in general"
HOMEPAGE="https://www.coreboot.org/"
SRC_URI="https://coreboot.org/releases/coreboot-${PV}.tar.xz"

LICENSE="GPL-2+ GPL-2"
SLOT="0"
KEYWORDS="~amd64"

DEPEND="sys-apps/pciutils
	sys-libs/zlib"
RDEPEND="${DEPEND}"
BDEPEND=""

S="${WORKDIR}/coreboot-${PV}"
PATCHES=(
	"${FILESDIR}"/${PN}-4.18-musl.patch
	"${FILESDIR}"/${PN}-4.18-flags.patch
)

# selection from README.md that seem useful outside coreboot
coreboot_utils=(
	#cbfstool  has textrels and is not really necessary outside coreboot
	cbmem
	ifdtool
	intelmetool
	inteltool
	me_cleaner
	nvramtool
	pmh7tool
	superiotool
)

src_prepare() {
	default
	# drop some CFLAGS that hurt compilation on modern toolchains or
	# force optimisation
	# can't do this in one sed, because it all happens back-to-back
	for e in '-O[01234567s]' '-g' '-Werror' '-ansi' '-pendantic' ; do
		sed -i -e 's/\( \|=\)'"${e}"'\( \|$\)/\1/g' util/*/Makefile{.inc,} \
			|| die
	done
}

src_compile() {
	tc-export CC
	export HOSTCFLAGS="${CFLAGS}"
	for tool in ${coreboot_utils[*]} ; do
		[[ -f util/${tool}/Makefile ]] || continue
		emake -C util/${tool} V=1
	done
}

src_install() {
	exeinto /usr/sbin
	for tool in ${coreboot_utils[*]} ; do
		[[ -e util/${tool}/${tool} ]]    && doexe util/${tool}/${tool}
		[[ -e util/${tool}/${tool}.py ]] && doexe util/${tool}/${tool}.py
		[[ -e util/${tool}/${tool}.8 ]]  && doman util/${tool}/${tool}.8
		[[ -d util/${tool}/man ]]        && doman util/${tool}/man/*.[12345678]
	done
}