| 1 |  | # Copyright 1999-2023 Gentoo Authors | 
  |  | 1 | # Copyright 1999-2024 Gentoo Authors | 
  | 2 | 2 | # Distributed under the terms of the GNU General Public License v2 | 
  | 3 | 3 |  | 
  | 4 |  | EAPI="7" | 
  |  | 4 | EAPI=8 | 
  | 5 | 5 |  | 
  | 6 |  | PYTHON_COMPAT=( python3_{9,10,11} ) | 
  |  | 6 | PYTHON_COMPAT=( python3_{10..12} ) | 
  | 7 | 7 |  | 
  | 8 | 8 | inherit toolchain-funcs python-any-r1 | 
  | 9 | 9 |  | 
| ... | ... |  | 
  | 12 | 12 | # git clone git://git.seabios.org/seabios.git && cd seabios | 
  | 13 | 13 | # git archive --output seabios-${PV}.tar.gz --prefix seabios-${PV}/ rel-${PV} | 
  | 14 | 14 |  | 
  | 15 |  | # To generate binary tarball you can run the following from fork tree: | 
  | 16 |  | # cd .../seabios-1.14.0-r2/image/usr/share | 
  | 17 |  | # $ tar cJf seabios-1.14.0-r2-bin.tar.xz *.bin | 
  | 18 |  |  | 
  | 19 | 15 | if [[ ${PV} == *9999* || -n "${EGIT_COMMIT}" ]] ; then | 
  | 20 | 16 | 	EGIT_REPO_URI="git://git.seabios.org/seabios.git" | 
  | 21 | 17 | 	inherit git-r3 | 
  | 22 | 18 | else | 
  | 23 |  | 	KEYWORDS="~alpha amd64 ~arm arm64 ~hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86" | 
  | 24 |  |  | 
  | 25 |  | 	SRC_URI=" | 
  | 26 |  | 		!binary? ( https://www.seabios.org/downloads/${P}.tar.gz ) | 
  | 27 |  | 		binary? ( https://dev.gentoo.org/~sam/distfiles/${P}-r2-bin.tar.xz )" | 
  |  | 19 | 	SRC_URI="https://www.seabios.org/downloads/${P}.tar.gz" | 
  |  | 20 | 	KEYWORDS="~alpha amd64 arm64 ~loong ~m68k ~mips ~ppc ppc64 x86" | 
  | 28 | 21 | fi | 
  | 29 | 22 |  | 
  | 30 | 23 | DESCRIPTION="Open Source implementation of a 16-bit x86 BIOS" | 
| ... | ... |  | 
  | 32 | 25 |  | 
  | 33 | 26 | LICENSE="LGPL-3 GPL-3" | 
  | 34 | 27 | SLOT="0" | 
  | 35 |  | IUSE="+binary debug +seavgabios" | 
  | 36 |  |  | 
  | 37 |  | REQUIRED_USE="debug? ( !binary )" | 
  |  | 28 | IUSE="debug +seavgabios" | 
  | 38 | 29 |  | 
  | 39 |  | SOURCE_DEPEND=" | 
  |  | 30 | BDEPEND=" | 
  | 40 | 31 | 	>=sys-power/iasl-20060912 | 
  | 41 | 32 | 	${PYTHON_DEPS}" | 
  | 42 |  | DEPEND=" | 
  | 43 |  | 	!binary? ( | 
  | 44 |  | 		${SOURCE_DEPEND} | 
  | 45 |  | 	)" | 
  | 46 |  | RDEPEND="" | 
  |  | 33 | RDEPEND="!sys-firmware/seabios-bin" | 
  | 47 | 34 |  | 
  | 48 | 35 | choose_target_chost() { | 
  | 49 | 36 | 	if [[ -n "${CC}" ]]; then | 
| ... | ... |  | 
  | 65 | 52 | } | 
  | 66 | 53 |  | 
  | 67 | 54 | pkg_pretend() { | 
  | 68 |  | 	if ! use binary; then | 
  | 69 |  | 		ewarn "You have decided to compile your own SeaBIOS. This is not" | 
  | 70 |  | 		ewarn "supported by upstream unless you use their recommended" | 
  | 71 |  | 		ewarn "toolchain (which you are not)." | 
  |  | 55 | 	ewarn "You have decided to compile your own SeaBIOS. This is not" | 
  |  | 56 | 	ewarn "supported by upstream unless you use their recommended" | 
  |  | 57 | 	ewarn "toolchain (which you are not)." | 
  |  | 58 | 	elog | 
  |  | 59 | 	ewarn "If you are intending to use this build with QEMU, realize" | 
  |  | 60 | 	ewarn "you will not receive any support if you have compiled your" | 
  |  | 61 | 	ewarn "own SeaBIOS. Virtual machines subtly fail based on changes" | 
  |  | 62 | 	ewarn "in SeaBIOS." | 
  |  | 63 | 	if [[ -z "$(choose_target_chost)" ]]; then | 
  | 72 | 64 | 		elog | 
  | 73 |  | 		ewarn "If you are intending to use this build with QEMU, realize" | 
  | 74 |  | 		ewarn "you will not receive any support if you have compiled your" | 
  | 75 |  | 		ewarn "own SeaBIOS. Virtual machines subtly fail based on changes" | 
  | 76 |  | 		ewarn "in SeaBIOS." | 
  | 77 |  | 		if [[ -z "$(choose_target_chost)" ]]; then | 
  | 78 |  | 			elog | 
  | 79 |  | 			eerror "Before you can compile ${PN}[-binary], you need to install a x86 cross-compiler" | 
  | 80 |  | 			eerror "Run the following commands:" | 
  | 81 |  | 			eerror "  emerge crossdev" | 
  | 82 |  | 			eerror "  crossdev --stable -t x86_64-pc-linux-gnu" | 
  | 83 |  | 			die "cross-compiler is needed" | 
  | 84 |  | 		fi | 
  |  | 65 | 		eerror "Before you can compile ${PN}, you need to install a x86 cross-compiler" | 
  |  | 66 | 		eerror "Run the following commands:" | 
  |  | 67 | 		eerror "  emerge crossdev" | 
  |  | 68 | 		eerror "  crossdev --stable -t x86_64-pc-linux-gnu" | 
  |  | 69 | 		die "cross-compiler is needed" | 
  | 85 | 70 | 	fi | 
  | 86 | 71 | } | 
  | 87 | 72 |  | 
  | 88 |  | pkg_setup() { | 
  | 89 |  | 	use binary || python-any-r1_pkg_setup | 
  | 90 |  | } | 
  | 91 |  |  | 
  | 92 |  | src_unpack() { | 
  | 93 |  | 	default | 
  | 94 |  |  | 
  | 95 |  | 	# This simplifies the logic between binary & source builds. | 
  | 96 |  | 	mkdir -p "${S}" | 
  | 97 |  | } | 
  | 98 |  |  | 
  | 99 | 73 | src_prepare() { | 
  | 100 | 74 | 	default | 
  | 101 | 75 |  | 
  | 102 |  | 	if ! use binary; then | 
  | 103 |  | 		eapply "${FILESDIR}"/${PN}-1.14.0-binutils-2.36.patch | 
  | 104 |  | 	fi | 
  | 105 |  |  | 
  | 106 | 76 | 	# Ensure precompiled iasl files are never used | 
  | 107 | 77 | 	find "${WORKDIR}" -name '*.hex' -delete || die | 
  | 108 | 78 | } | 
  | 109 | 79 |  | 
  | 110 | 80 | src_configure() { | 
  | 111 |  | 	use binary && return | 
  | 112 |  |  | 
  | 113 | 81 | 	tc-ld-disable-gold #438058 | 
  | 114 | 82 |  | 
  | 115 | 83 | 	if use debug ; then | 
| ... | ... |  | 
  | 136 | 104 | } | 
  | 137 | 105 |  | 
  | 138 | 106 | src_compile() { | 
  | 139 |  | 	use binary && return | 
  | 140 |  |  | 
  | 141 | 107 | 	local TARGET_CHOST=$(choose_target_chost) | 
  | 142 | 108 |  | 
  | 143 |  | 	cp "${FILESDIR}/seabios/config.seabios-128k" .config || die | 
  | 144 |  | 	_emake oldnoconfig | 
  | 145 |  | 	CHOST="${TARGET_CHOST}" _emake iasl | 
  | 146 |  | 	CHOST="${TARGET_CHOST}" _emake out/bios.bin | 
  | 147 |  | 	mv out/bios.bin ../bios.bin || die | 
  | 148 |  |  | 
  | 149 | 109 | 	cp "${FILESDIR}/seabios/config.seabios-256k" .config || die | 
  | 150 | 110 | 	_emake oldnoconfig | 
  | 151 | 111 | 	CHOST="${TARGET_CHOST}" _emake iasl | 
| ... | ... |  | 
  | 173 | 133 |  | 
  | 174 | 134 | src_install() { | 
  | 175 | 135 | 	insinto /usr/share/seabios | 
  | 176 |  | 	doins ../bios.bin | 
  | 177 | 136 | 	doins ../bios-256k.bin | 
  | 178 | 137 |  | 
  | 179 | 138 | 	if use seavgabios ; then |