1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 if [[ ${PV} == 9999 ]]; then
11 if [[ -n ${GRUB_AUTOGEN} || -n ${GRUB_BOOTSTRAP} ]]; then
12 PYTHON_COMPAT=( python{2_7,3_{5,6,7}} )
16 if [[ -n ${GRUB_AUTORECONF} ]]; then
21 inherit bash-completion-r1 flag-o-matic multibuild pax-utils toolchain-funcs
23 if [[ ${PV} != 9999 ]]; then
24 if [[ ${PV} == *_alpha* || ${PV} == *_beta* || ${PV} == *_rc* ]]; then
25 # The quote style is to work with <=bash-4.2 and >=bash-4.3 #503860
27 SRC_URI="mirror://gnu-alpha/${PN}/${MY_P}.tar.xz"
30 SRC_URI="mirror://gnu/${PN}/${P}.tar.xz"
33 KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86"
36 EGIT_REPO_URI="https://git.savannah.gnu.org/git/grub.git"
40 "${FILESDIR}"/gfxpayload.patch
41 "${FILESDIR}"/grub-2.02_beta2-KERNEL_GLOBS.patch
44 DEJAVU=dejavu-sans-ttf-2.37
45 UNIFONT=unifont-12.0.01
46 SRC_URI+=" fonts? ( mirror://gnu/unifont/${UNIFONT}/${UNIFONT}.pcf.gz )
47 themes? ( mirror://sourceforge/dejavu/${DEJAVU}.zip )"
49 DESCRIPTION="GNU GRUB boot loader"
50 HOMEPAGE="https://www.gnu.org/software/grub/"
52 # Includes licenses for dejavu and unifont
53 LICENSE="GPL-3 fonts? ( GPL-2-with-font-exception ) themes? ( BitstreamVera )"
55 IUSE="device-mapper doc efiemu +fonts mount nls static sdl test +themes truetype libzfs"
57 GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot qemu qemu-mips pc uboot xen xen-32 )
58 IUSE+=" ${GRUB_ALL_PLATFORMS[@]/#/grub_platforms_}"
61 grub_platforms_coreboot? ( fonts )
62 grub_platforms_qemu? ( fonts )
63 grub_platforms_ieee1275? ( fonts )
64 grub_platforms_loongson? ( fonts )
93 truetype? ( virtual/pkgconfig )
97 >=sys-libs/ncurses-5.2-r5:0=
98 sdl? ( media-libs/libsdl )
99 device-mapper? ( >=sys-fs/lvm2-2.02.45 )
100 libzfs? ( sys-fs/zfs )
101 mount? ( sys-fs/fuse:0 )
102 truetype? ( media-libs/freetype:2= )
103 ppc? ( >=sys-apps/ibm-powerpc-utils-1.3.5 )
104 ppc64? ( >=sys-apps/ibm-powerpc-utils-1.3.5 )
105 grub_platforms_xen? ( app-emulation/xen-tools:= )
106 grub_platforms_xen-32? ( app-emulation/xen-tools:= )
108 DEPEND="${COMMON_DEPEND}
110 app-arch/xz-utils[static-libs(+)]
112 app-arch/bzip2[static-libs(+)]
113 media-libs/freetype[static-libs(+)]
114 sys-libs/zlib[static-libs(+)]
119 RDEPEND="${COMMON_DEPEND}
121 grub_platforms_efi-32? ( sys-boot/efibootmgr )
122 grub_platforms_efi-64? ( sys-boot/efibootmgr )
124 !sys-boot/grub:0 !sys-boot/grub-static
125 nls? ( sys-devel/gettext )
128 RESTRICT="strip !test? ( test )"
130 QA_EXECSTACK="usr/bin/grub*-emu* usr/lib/grub/*"
131 QA_WX_LOAD="usr/lib/grub/*"
132 QA_MULTILIB_PATHS="usr/lib/grub/.*"
135 if [[ ${PV} == 9999 ]]; then
137 pushd "${P}" >/dev/null || die
138 local GNULIB_URI="https://git.savannah.gnu.org/git/gnulib.git"
139 local GNULIB_REVISION=$(source bootstrap.conf >/dev/null; echo "${GNULIB_REVISION}")
140 git-r3_fetch "${GNULIB_URI}" "${GNULIB_REVISION}"
141 git-r3_checkout "${GNULIB_URI}" gnulib
142 popd >/dev/null || die
150 sed -i -e /autoreconf/d autogen.sh || die
152 # Nothing in Gentoo packages 'american-english' in the exact path
153 # wanted for the test, but all that is needed is a compressible text
154 # file, and we do have 'words' from miscfiles in the same path.
156 -e '/CFILESSRC.*=/s,american-english,words,' \
157 tests/util/grub-fs-tester.in \
160 if [[ -n ${GRUB_AUTOGEN} || -n ${GRUB_BOOTSTRAP} ]]; then
164 if [[ -n ${GRUB_BOOTSTRAP} ]]; then
166 AUTOPOINT=: AUTORECONF=: ./bootstrap || die
167 elif [[ -n ${GRUB_AUTOGEN} ]]; then
171 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')
226 ln -rs "${WORKDIR}/${UNIFONT}.pcf" unifont.pcf || die
230 ln -rs "${WORKDIR}/${DEJAVU}/ttf/DejaVuSans.ttf" DejaVuSans.ttf || die
233 local ECONF_SOURCE="${S}"
234 econf "${myeconfargs[@]}"
239 replace-flags -O3 -O2
241 # We don't want to leak flags onto boot code.
242 export HOST_CCASFLAGS=${CCASFLAGS}
243 export HOST_CFLAGS=${CFLAGS}
244 export HOST_CPPFLAGS=${CPPFLAGS}
245 export HOST_LDFLAGS=${LDFLAGS}
246 unset CCASFLAGS CFLAGS CPPFLAGS LDFLAGS
248 use static && HOST_LDFLAGS+=" -static"
250 tc-ld-disable-gold #439082 #466536 #526348
251 export TARGET_LDFLAGS="${TARGET_LDFLAGS} ${LDFLAGS}"
254 tc-export CC NM OBJCOPY RANLIB STRIP
255 tc-export BUILD_CC # Bug 485592
257 MULTIBUILD_VARIANTS=()
259 for p in "${GRUB_ALL_PLATFORMS[@]}"; do
260 use "grub_platforms_${p}" && MULTIBUILD_VARIANTS+=( "${p}" )
262 [[ ${#MULTIBUILD_VARIANTS[@]} -eq 0 ]] && MULTIBUILD_VARIANTS=( guessed )
263 grub_do grub_configure
267 # Sandbox bug 404013.
268 use libzfs && addpredict /etc/dfs:/dev/zfs
271 use doc && grub_do_once emake -C docs html
275 # The qemu dependency is a bit complex.
276 # You will need to adjust QEMU_SOFTMMU_TARGETS to match the cpu/platform.
281 grub_do emake install DESTDIR="${D}" bashcompletiondir="$(get_bashcompdir)"
282 use doc && grub_do_once emake -C docs install-html DESTDIR="${D}"
287 newins "${FILESDIR}"/grub.default-3 grub
291 elog "For information on how to configure GRUB2 please refer to the guide:"
292 elog " https://wiki.gentoo.org/wiki/GRUB2_Quick_Start"
294 if has_version 'sys-boot/grub:0'; then
295 elog "A migration guide for GRUB Legacy users is available:"
296 elog " https://wiki.gentoo.org/wiki/GRUB2_Migration"
299 if [[ -z ${REPLACING_VERSIONS} ]]; then
301 elog "You may consider installing the following optional packages:"
302 optfeature "Detect other operating systems (grub-mkconfig)" sys-boot/os-prober
303 optfeature "Create rescue media (grub-mkrescue)" dev-libs/libisoburn
304 optfeature "Enable RAID device detection" sys-fs/mdadm