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