1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
9 if [[ -n ${GRUB_AUTOGEN} ]]; then
10 PYTHON_COMPAT=( python{2_7,3_{5,6,7}} )
14 if [[ -n ${GRUB_AUTORECONF} ]]; then
19 inherit bash-completion-r1 flag-o-matic multibuild pax-utils toolchain-funcs
21 if [[ ${PV} != 9999 ]]; then
22 if [[ ${PV} == *_alpha* || ${PV} == *_beta* || ${PV} == *_rc* ]]; then
23 # The quote style is to work with <=bash-4.2 and >=bash-4.3 #503860
25 SRC_URI="mirror://gnu-alpha/${PN}/${MY_P}.tar.xz"
28 SRC_URI="mirror://gnu/${PN}/${P}.tar.xz"
31 KEYWORDS="amd64 ~arm ~arm64 ppc ppc64 x86"
34 EGIT_REPO_URI="git://git.sv.gnu.org/grub.git
35 http://git.savannah.gnu.org/r/grub.git"
39 "${FILESDIR}"/gfxpayload.patch
40 "${FILESDIR}"/grub-2.02_beta2-KERNEL_GLOBS.patch
41 "${FILESDIR}"/2.02-multiple-early-initrd.patch
42 "${FILESDIR}"/2.02-freetype-capitalise-variables.patch
43 "${FILESDIR}"/2.02-freetype-pkg-config.patch
44 "${FILESDIR}"/2.02-xfs-sparse-inodes.patch
45 "${FILESDIR}"/2.02-X86_64_PLT32.patch
46 "${FILESDIR}"/2.02-gcc8.patch
47 "${FILESDIR}"/2.02-efi-tsc-pmtimer.patch
50 DEJAVU=dejavu-sans-ttf-2.37
51 UNIFONT=unifont-9.0.06
52 SRC_URI+=" fonts? ( mirror://gnu/unifont/${UNIFONT}/${UNIFONT}.pcf.gz )
53 themes? ( mirror://sourceforge/dejavu/${DEJAVU}.zip )"
55 DESCRIPTION="GNU GRUB boot loader"
56 HOMEPAGE="https://www.gnu.org/software/grub/"
58 # Includes licenses for dejavu and unifont
59 LICENSE="GPL-3 fonts? ( GPL-2-with-font-exception ) themes? ( BitstreamVera )"
61 IUSE="device-mapper doc efiemu +fonts mount multislot nls static sdl test +themes truetype libzfs"
63 GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot qemu qemu-mips pc uboot xen xen-32 )
64 IUSE+=" ${GRUB_ALL_PLATFORMS[@]/#/grub_platforms_}"
67 grub_platforms_coreboot? ( fonts )
68 grub_platforms_qemu? ( fonts )
69 grub_platforms_ieee1275? ( fonts )
70 grub_platforms_loongson? ( fonts )
73 # os-prober: Used on runtime to detect other OSes
74 # xorriso (dev-libs/libisoburn): Used on runtime for mkrescue
77 >=sys-libs/ncurses-5.2-r5:0=
78 sdl? ( media-libs/libsdl )
79 device-mapper? ( >=sys-fs/lvm2-2.02.45 )
80 libzfs? ( sys-fs/zfs )
81 mount? ( sys-fs/fuse:0 )
82 truetype? ( media-libs/freetype:2= )
83 ppc? ( >=sys-apps/ibm-powerpc-utils-1.3.5 )
84 ppc64? ( >=sys-apps/ibm-powerpc-utils-1.3.5 )
86 DEPEND="${COMMON_DEPEND}
97 grub_platforms_xen? ( app-emulation/xen-tools:= )
98 grub_platforms_xen-32? ( app-emulation/xen-tools:= )
100 app-arch/xz-utils[static-libs(+)]
102 app-arch/bzip2[static-libs(+)]
103 media-libs/freetype[static-libs(+)]
104 sys-libs/zlib[static-libs(+)]
116 sys-fs/squashfs-tools
120 media-libs/freetype:2
123 truetype? ( virtual/pkgconfig )
125 RDEPEND="${COMMON_DEPEND}
127 grub_platforms_efi-32? ( sys-boot/efibootmgr )
128 grub_platforms_efi-64? ( sys-boot/efibootmgr )
130 !multislot? ( !sys-boot/grub:0 !sys-boot/grub-static )
131 nls? ( sys-devel/gettext )
134 RESTRICT="strip !test? ( test )"
136 QA_EXECSTACK="usr/bin/grub*-emu* usr/lib/grub/*"
137 QA_WX_LOAD="usr/lib/grub/*"
138 QA_MULTILIB_PATHS="usr/lib/grub/.*"
141 if [[ ${PV} == 9999 ]]; then
150 sed -i -e /autoreconf/d autogen.sh || die
152 if use multislot; then
153 # fix texinfo file name, bug 416035
154 sed -i -e 's/^\* GRUB:/* GRUB2:/' -e 's/(grub)/(grub2)/' docs/grub.texi || die
157 # Nothing in Gentoo packages 'american-english' in the exact path
158 # wanted for the test, but all that is needed is a compressible text
159 # file, and we do have 'words' from miscfiles in the same path.
161 -e '/CFILESSRC.*=/s,american-english,words,' \
162 tests/util/grub-fs-tester.in \
165 if [[ -n ${GRUB_AUTOGEN} ]]; then
167 bash autogen.sh || die
170 if [[ -n ${GRUB_AUTORECONF} ]]; then
177 multibuild_foreach_variant run_in_build_dir "$@"
181 multibuild_for_best_variant run_in_build_dir "$@"
187 case ${MULTIBUILD_VARIANT} in
188 efi*) platform=efi ;;
189 xen*) platform=xen ;;
191 *) platform=${MULTIBUILD_VARIANT} ;;
194 case ${MULTIBUILD_VARIANT} in
196 if [[ ${CTARGET:-${CHOST}} == x86_64* ]]; then
200 if [[ ${CTARGET:-${CHOST}} == i?86* ]]; then
202 local -x TARGET_CFLAGS="-Os -march=x86-64 ${TARGET_CFLAGS}"
203 local -x TARGET_CPPFLAGS="-march=x86-64 ${TARGET_CPPFLAGS}"
210 --libdir="${EPREFIX}"/usr/lib
211 --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html
212 $(use_enable device-mapper)
213 $(use_enable mount grub-mount)
215 $(use_enable themes grub-themes)
216 $(use_enable truetype grub-mkfont)
218 $(use_enable sdl grub-emu-sdl)
219 ${platform:+--with-platform=}${platform}
221 # Let configure detect this where supported
222 $(usex efiemu '' '--disable-efiemu')
225 if use multislot; then
226 myeconfargs+=( --program-transform-name="s,grub,grub2," )
229 # Set up font symlinks
230 ln -s "${WORKDIR}/${UNIFONT}.pcf" unifont.pcf || die
232 ln -s "${WORKDIR}/${DEJAVU}/ttf/DejaVuSans.ttf" DejaVuSans.ttf || die
235 local ECONF_SOURCE="${S}"
236 econf "${myeconfargs[@]}"
241 replace-flags -O3 -O2
243 # We don't want to leak flags onto boot code.
244 export HOST_CCASFLAGS=${CCASFLAGS}
245 export HOST_CFLAGS=${CFLAGS}
246 export HOST_CPPFLAGS=${CPPFLAGS}
247 export HOST_LDFLAGS=${LDFLAGS}
248 unset CCASFLAGS CFLAGS CPPFLAGS LDFLAGS
250 use static && HOST_LDFLAGS+=" -static"
252 tc-ld-disable-gold #439082 #466536 #526348
253 export TARGET_LDFLAGS="${TARGET_LDFLAGS} ${LDFLAGS}"
256 tc-export CC NM OBJCOPY RANLIB STRIP
257 tc-export BUILD_CC # Bug 485592
259 MULTIBUILD_VARIANTS=()
261 for p in "${GRUB_ALL_PLATFORMS[@]}"; do
262 use "grub_platforms_${p}" && MULTIBUILD_VARIANTS+=( "${p}" )
264 [[ ${#MULTIBUILD_VARIANTS[@]} -eq 0 ]] && MULTIBUILD_VARIANTS=( guessed )
265 grub_do grub_configure
269 # Sandbox bug 404013.
270 use libzfs && addpredict /etc/dfs:/dev/zfs
273 use doc && grub_do_once emake -C docs html
277 # The qemu dependency is a bit complex.
278 # You will need to adjust QEMU_SOFTMMU_TARGETS to match the cpu/platform.
283 grub_do emake install DESTDIR="${D}" bashcompletiondir="$(get_bashcompdir)"
284 use doc && grub_do_once emake -C docs install-html DESTDIR="${D}"
288 if use multislot; then
289 mv "${ED%/}"/usr/share/info/grub{,2}.info || die
293 newins "${FILESDIR}"/grub.default-3 grub
297 elog "For information on how to configure GRUB2 please refer to the guide:"
298 elog " https://wiki.gentoo.org/wiki/GRUB2_Quick_Start"
300 if has_version 'sys-boot/grub:0'; then
301 elog "A migration guide for GRUB Legacy users is available:"
302 elog " https://wiki.gentoo.org/wiki/GRUB2_Migration"
305 if [[ -z ${REPLACING_VERSIONS} ]]; then
307 elog "You may consider installing the following optional packages:"
308 optfeature "Detect other operating systems (grub-mkconfig)" sys-boot/os-prober
309 optfeature "Create rescue media (grub-mkrescue)" dev-libs/libisoburn
310 optfeature "Enable RAID device detection" sys-fs/mdadm