1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 if [[ ${PV} == 9999 ]]; then
8 PYTHON_COMPAT=( python{2_7,3_3,3_4,3_5} )
9 inherit autotools python-any-r1
12 inherit autotools bash-completion-r1 flag-o-matic multibuild pax-utils toolchain-funcs versionator
14 if [[ ${PV} != 9999 ]]; then
15 if [[ ${PV} == *_alpha* || ${PV} == *_beta* || ${PV} == *_rc* ]]; then
16 # The quote style is to work with <=bash-4.2 and >=bash-4.3 #503860
18 SRC_URI="mirror://gnu-alpha/${PN}/${MY_P}.tar.xz"
21 SRC_URI="mirror://gnu/${PN}/${P}.tar.xz
22 mirror://gentoo/${P}.tar.xz
23 https://dev.gentoo.org/~floppym/dist/${P}.tar.xz"
26 KEYWORDS="~amd64 ~x86"
29 EGIT_REPO_URI="git://git.sv.gnu.org/grub.git
30 http://git.savannah.gnu.org/r/grub.git"
34 "${FILESDIR}"/gfxpayload.patch
35 "${FILESDIR}"/grub-2.02_beta2-KERNEL_GLOBS.patch
38 DEJAVU=dejavu-sans-ttf-2.35
39 UNIFONT=unifont-8.0.01
40 SRC_URI+=" fonts? ( mirror://gnu/unifont/${UNIFONT}/${UNIFONT}.pcf.gz )
41 themes? ( mirror://sourceforge/dejavu/${DEJAVU}.zip )"
43 DESCRIPTION="GNU GRUB boot loader"
44 HOMEPAGE="https://www.gnu.org/software/grub/"
46 # Includes licenses for dejavu and unifont
47 LICENSE="GPL-3 fonts? ( GPL-2-with-font-exception ) themes? ( BitstreamVera )"
49 IUSE="debug device-mapper doc efiemu +fonts mount +multislot nls static sdl test +themes truetype libzfs"
51 GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot qemu qemu-mips pc uboot xen )
52 IUSE+=" ${GRUB_ALL_PLATFORMS[@]/#/grub_platforms_}"
55 grub_platforms_coreboot? ( fonts )
56 grub_platforms_qemu? ( fonts )
57 grub_platforms_ieee1275? ( fonts )
58 grub_platforms_loongson? ( fonts )
61 # os-prober: Used on runtime to detect other OSes
62 # xorriso (dev-libs/libisoburn): Used on runtime for mkrescue
65 >=sys-libs/ncurses-5.2-r5:0=
67 sdl? ( media-libs/libsdl )
69 device-mapper? ( >=sys-fs/lvm2-2.02.45 )
70 libzfs? ( sys-fs/zfs )
71 mount? ( sys-fs/fuse )
72 truetype? ( media-libs/freetype:2= )
73 ppc? ( sys-apps/ibm-powerpc-utils sys-apps/powerpc-utils )
74 ppc64? ( sys-apps/ibm-powerpc-utils sys-apps/powerpc-utils )
83 fonts? ( media-libs/freetype:2 )
84 grub_platforms_xen? ( app-emulation/xen-tools:= )
86 app-arch/xz-utils[static-libs(+)]
88 app-arch/bzip2[static-libs(+)]
89 media-libs/freetype[static-libs(+)]
90 sys-libs/zlib[static-libs(+)]
104 grub_platforms_efi-32? ( sys-boot/efibootmgr )
105 grub_platforms_efi-64? ( sys-boot/efibootmgr )
107 !multislot? ( !sys-boot/grub:0 )
108 nls? ( sys-devel/gettext )
111 DEPEND+=" !!=media-libs/freetype-2.5.4"
113 STRIP_MASK="*/grub/*/*.{mod,img}"
118 usr/lib*/grub/*/*.mod
119 usr/lib*/grub/*/*.module
120 usr/lib*/grub/*/kernel.exec
121 usr/lib*/grub/*/kernel.img
125 usr/lib*/grub/*/kernel.exec
126 usr/lib*/grub/*/kernel.img
127 usr/lib*/grub/*/*.image
131 usr/lib.*/grub/.*/kernel.img
135 if [[ ${PV} == 9999 ]]; then
144 sed -i -e /autoreconf/d autogen.sh || die
146 if use multislot; then
147 # fix texinfo file name, bug 416035
148 sed -i -e 's/^\* GRUB:/* GRUB2:/' -e 's/(grub)/(grub2)/' docs/grub.texi || die
151 if [[ ${PV} == 9999 ]]; then
153 bash autogen.sh || die
160 multibuild_foreach_variant run_in_build_dir "$@"
164 multibuild_for_best_variant run_in_build_dir "$@"
170 case ${MULTIBUILD_VARIANT} in
173 if [[ ${CTARGET:-${CHOST}} == x86_64* ]]; then
174 local CTARGET=${CTARGET:-i386}
178 if [[ ${CTARGET:-${CHOST}} == i?86* ]]; then
179 local CTARGET=${CTARGET:-x86_64}
180 local TARGET_CFLAGS="-Os -march=x86-64 ${TARGET_CFLAGS}"
181 local TARGET_CPPFLAGS="-march=x86-64 ${TARGET_CPPFLAGS}"
182 export TARGET_CFLAGS TARGET_CPPFLAGS
185 *) platform=${MULTIBUILD_VARIANT} ;;
191 --libdir="${EPREFIX}"/usr/lib
192 --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html
193 $(use_enable debug mm-debug)
194 $(use_enable device-mapper)
195 $(use_enable mount grub-mount)
197 $(use_enable themes grub-themes)
198 $(use_enable truetype grub-mkfont)
200 $(use sdl && use_enable debug grub-emu-sdl)
201 ${platform:+--with-platform=}${platform}
203 # Let configure detect this where supported
204 $(usex efiemu '' '--disable-efiemu')
207 if use multislot; then
208 myeconfargs+=( --program-transform-name="s,grub,grub2," )
211 # Set up font symlinks
212 ln -s "${WORKDIR}/${UNIFONT}.pcf" unifont.pcf || die
214 ln -s "${WORKDIR}/${DEJAVU}/ttf/DejaVuSans.ttf" DejaVuSans.ttf || die
217 ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
220 grub_get_platforms() {
221 MULTIBUILD_VARIANTS=()
223 for platform in "${GRUB_ALL_PLATFORMS[@]}"; do
224 if use "grub_platforms_${platform}"; then
225 MULTIBUILD_VARIANTS+=( "${platform}" )
228 if (( ${#MULTIBUILD_VARIANTS[@]} == 0 )); then
229 MULTIBUILD_VARIANTS=( guessed )
235 replace-flags -O3 -O2
237 # We don't want to leak flags onto boot code.
238 export HOST_CCASFLAGS=${CCASFLAGS}
239 export HOST_CFLAGS=${CFLAGS}
240 export HOST_CPPFLAGS=${CPPFLAGS}
241 export HOST_LDFLAGS=${LDFLAGS}
242 unset CCASFLAGS CFLAGS CPPFLAGS LDFLAGS
244 use static && HOST_LDFLAGS+=" -static"
246 tc-ld-disable-gold #439082 #466536 #526348
247 export TARGET_LDFLAGS="${TARGET_LDFLAGS} ${LDFLAGS}"
250 tc-export CC NM OBJCOPY RANLIB STRIP
251 tc-export BUILD_CC # Bug 485592
253 # Portage will take care of cleaning up GRUB_PLATFORMS
255 grub_do grub_configure
259 # Sandbox bug 404013.
260 use libzfs && addpredict /etc/dfs:/dev/zfs
263 use doc && grub_do_once emake -C docs html
267 # The qemu dependency is a bit complex.
268 # You will need to adjust QEMU_SOFTMMU_TARGETS to match the cpu/platform.
273 grub_do emake install DESTDIR="${D}" bashcompletiondir="$(get_bashcompdir)"
274 use doc && grub_do_once emake -C docs install-html DESTDIR="${D}"
278 if use multislot; then
279 mv "${ED%/}"/usr/share/info/grub{,2}.info || die
283 newins "${FILESDIR}"/grub.default-3 grub
287 elog "For information on how to configure GRUB2 please refer to the guide:"
288 elog " https://wiki.gentoo.org/wiki/GRUB2_Quick_Start"
290 if has_version 'sys-boot/grub:0'; then
291 elog "A migration guide for GRUB Legacy users is available:"
292 elog " https://wiki.gentoo.org/wiki/GRUB2_Migration"
295 if [[ -z ${REPLACING_VERSIONS} ]]; then
297 elog "You may consider installing the following optional packages:"
298 optfeature "Detect other operating systems (grub-mkconfig)" sys-boot/os-prober
299 optfeature "Create rescue media (grub-mkrescue)" dev-libs/libisoburn
300 optfeature "Enable RAID device detection" sys-fs/mdadm