blob: 14fce97ff0528f93b5026f159e60f5604e4c250c [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001require grub2.inc
2
3GRUBPLATFORM = "efi"
4
5DEPENDS_append_class-target = " grub-efi-native"
Brad Bishop316dfdd2018-06-25 12:45:53 -04006RDEPENDS_${PN}_class-target = "diffutils freetype grub-common virtual/grub-bootconf"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05007
8SRC_URI += " \
9 file://cfg \
10 "
11
12S = "${WORKDIR}/grub-${PV}"
13
14# Determine the target arch for the grub modules
15python __anonymous () {
16 import re
17 target = d.getVar('TARGET_ARCH')
Brad Bishop316dfdd2018-06-25 12:45:53 -040018 prefix = "" if d.getVar('EFI_PROVIDER') == "grub-efi" else "grub-efi-"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019 if target == "x86_64":
20 grubtarget = 'x86_64'
Brad Bishop316dfdd2018-06-25 12:45:53 -040021 grubimage = prefix + "bootx64.efi"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050022 elif re.match('i.86', target):
23 grubtarget = 'i386'
Brad Bishop316dfdd2018-06-25 12:45:53 -040024 grubimage = prefix + "bootia32.efi"
25 elif re.match('aarch64', target):
26 grubtarget = 'arm64'
27 grubimage = prefix + "bootaa64.efi"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028 elif re.match('arm', target):
29 grubtarget = 'arm'
30 grubimage = prefix + "bootarm.efi"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050031 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -040032 raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050033 d.setVar("GRUB_TARGET", grubtarget)
34 d.setVar("GRUB_IMAGE", grubimage)
Brad Bishop316dfdd2018-06-25 12:45:53 -040035 prefix = "grub-efi-" if prefix == "" else ""
36 d.setVar("GRUB_IMAGE_PREFIX", prefix)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050037}
38
39inherit deploy
40
41CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN="
42EXTRA_OECONF += "--enable-efiemu=no"
43
44# ldm.c:114:7: error: trampoline generated for nested function 'hook' [-Werror=trampolines]
45# and many other places in the grub code when compiled with some native gcc compilers (specifically, gentoo)
46CFLAGS_append_class-native = " -Wno-error=trampolines"
47
Brad Bishop316dfdd2018-06-25 12:45:53 -040048do_mkimage() {
49 cd ${B}
50 # Search for the grub.cfg on the local boot media by using the
51 # built in cfg file provided via this recipe
52 grub-mkimage -c ../cfg -p /EFI/BOOT -d ./grub-core/ \
53 -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \
54 ${GRUB_BUILDIN}
55}
56
57addtask mkimage before do_install after do_compile
58
59do_mkimage_class-native() {
60 :
61}
62
63do_install_append_class-target() {
64 install -d ${D}/boot
65 install -d ${D}/boot/EFI
66 install -d ${D}/boot/EFI/BOOT
67 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}/boot/EFI/BOOT/${GRUB_IMAGE}
68}
69
Brad Bishopd7bf8c12018-02-25 22:55:05 -050070do_install_class-native() {
71 install -d ${D}${bindir}
72 install -m 755 grub-mkimage ${D}${bindir}
73}
74
Brad Bishop316dfdd2018-06-25 12:45:53 -040075do_install_class-target() {
76 oe_runmake 'DESTDIR=${D}' -C grub-core install
77
Brad Bishopd7bf8c12018-02-25 22:55:05 -050078 # Remove build host references...
79 find "${D}" -name modinfo.sh -type f -exec \
80 sed -i \
81 -e 's,--sysroot=${STAGING_DIR_TARGET},,g' \
82 -e 's|${DEBUG_PREFIX_MAP}||g' \
83 -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
84 {} +
85}
86
87GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \
Brad Bishop316dfdd2018-06-25 12:45:53 -040088 efi_gop iso9660 configfile search loadenv test"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050089
90do_deploy() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040091 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR}
Brad Bishopd7bf8c12018-02-25 22:55:05 -050092}
93
94do_deploy_class-native() {
95 :
96}
97
98addtask deploy after do_install before do_build
99
Brad Bishop316dfdd2018-06-25 12:45:53 -0400100FILES_${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
101 ${datadir}/grub \
102 /boot/EFI/BOOT/${GRUB_IMAGE} \
103 "
104
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500105
106# 64-bit binaries are expected for the bootloader with an x32 userland
107INSANE_SKIP_${PN}_append_linux-gnux32 = " arch"
108INSANE_SKIP_${PN}-dbg_append_linux-gnux32 = " arch"
109INSANE_SKIP_${PN}_append_linux-muslx32 = " arch"
110INSANE_SKIP_${PN}-dbg_append_linux-muslx32 = " arch"
111
112BBCLASSEXTEND = "native"