1 ################################################################################
5 ################################################################################
8 GRUB2_SITE
= $(BR2_GNU_MIRROR
)/grub
9 GRUB2_SOURCE
= grub-
$(GRUB2_VERSION
).
tar.xz
10 GRUB2_LICENSE
= GPLv3
+
11 GRUB2_LICENSE_FILES
= COPYING
12 GRUB2_DEPENDENCIES
= host-bison host-flex
14 GRUB2_BUILTIN_MODULES
= $(call qstrip
,$(BR2_TARGET_GRUB2_BUILTIN_MODULES
))
15 GRUB2_BUILTIN_CONFIG
= $(call qstrip
,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG
))
16 GRUB2_BOOT_PARTITION
= $(call qstrip
,$(BR2_TARGET_GRUB2_BOOT_PARTITION
))
18 ifeq ($(BR2_TARGET_GRUB2_I386_PC
),y
)
19 GRUB2_IMAGE
= $(BINARIES_DIR
)/grub.img
20 GRUB2_CFG
= $(TARGET_DIR
)/boot
/grub
/grub.cfg
21 GRUB2_PREFIX
= ($(GRUB2_BOOT_PARTITION
))/boot
/grub
25 else ifeq ($(BR2_TARGET_GRUB2_I386_EFI
),y
)
26 GRUB2_IMAGE
= $(BINARIES_DIR
)/efi-part
/EFI
/BOOT
/bootia32.efi
27 GRUB2_CFG
= $(BINARIES_DIR
)/efi-part
/EFI
/BOOT
/grub.cfg
28 GRUB2_PREFIX
= /EFI
/BOOT
29 GRUB2_TUPLE
= i386-efi
32 else ifeq ($(BR2_TARGET_GRUB2_X86_64_EFI
),y
)
33 GRUB2_IMAGE
= $(BINARIES_DIR
)/efi-part
/EFI
/BOOT
/bootx64.efi
34 GRUB2_CFG
= $(BINARIES_DIR
)/efi-part
/EFI
/BOOT
/grub.cfg
35 GRUB2_PREFIX
= /EFI
/BOOT
36 GRUB2_TUPLE
= x86_64-efi
41 # Grub2 is kind of special: it considers CC, LD and so on to be the
42 # tools to build the native tools (i.e to be executed on the build
43 # machine), and uses TARGET_CC, TARGET_CFLAGS, TARGET_CPPFLAGS,
44 # TARGET_LDFLAGS to build the bootloader itself. However, to add to
45 # the confusion, it also uses NM, OBJCOPY and STRIP to build the
46 # bootloader itself; none of these are used to build the native
49 # NOTE: TARGET_STRIP is overridden by BR2_STRIP_none, so always
50 # use the cross compile variant to ensure grub2 builds
53 $(HOST_CONFIGURE_OPTS
) \
55 TARGET_CC
="$(TARGET_CC)" \
56 TARGET_CFLAGS
="$(TARGET_CFLAGS)" \
57 TARGET_CPPFLAGS
="$(TARGET_CPPFLAGS)" \
58 TARGET_LDFLAGS
="$(TARGET_LDFLAGS)" \
60 OBJCOPY
="$(TARGET_OBJCOPY)" \
61 STRIP
="$(TARGET_CROSS)strip"
64 --target
=$(GRUB2_TARGET
) \
65 --with-platform
=$(GRUB2_PLATFORM
) \
66 --disable-grub-mkfont \
68 ac_cv_lib_lzma_lzma_code
=no \
69 --enable-device-mapper
=no \
73 # We don't want all the native tools and Grub2 modules to be installed
74 # in the target. So we in fact install everything into the host
75 # directory, and the image generation process (below) will use the
76 # grub-mkimage tool and Grub2 modules from the host directory.
78 GRUB2_INSTALL_TARGET_OPTS
= DESTDIR
=$(HOST_DIR
) install
80 ifeq ($(BR2_TARGET_GRUB2_I386_PC
),y
)
81 define GRUB2_IMAGE_INSTALL_ELTORITO
82 cat
$(HOST_DIR
)/usr
/lib
/grub
/$(GRUB2_TUPLE
)/cdboot.img
$(GRUB2_IMAGE
) > \
83 $(BINARIES_DIR
)/grub-eltorito.img
87 define GRUB2_IMAGE_INSTALLATION
88 mkdir
-p
$(dir $(GRUB2_IMAGE
))
89 $(HOST_DIR
)/usr
/bin
/grub-mkimage \
90 -d
$(HOST_DIR
)/usr
/lib
/grub
/$(GRUB2_TUPLE
) \
93 -p
"$(GRUB2_PREFIX)" \
94 $(if
$(GRUB2_BUILTIN_CONFIG
),-c
$(GRUB2_BUILTIN_CONFIG
)) \
95 $(GRUB2_BUILTIN_MODULES
)
96 mkdir
-p
$(dir $(GRUB2_CFG
))
97 $(INSTALL
) -D
-m
0644 boot
/grub2
/grub.cfg
$(GRUB2_CFG
)
98 $(GRUB2_IMAGE_INSTALL_ELTORITO
)
100 GRUB2_POST_INSTALL_TARGET_HOOKS
+= GRUB2_IMAGE_INSTALLATION
102 ifeq ($(GRUB2_PLATFORM
),efi
)
103 define GRUB2_EFI_STARTUP_NSH
104 echo
$(notdir $(GRUB2_IMAGE
)) > \
105 $(BINARIES_DIR
)/efi-part
/startup.nsh
107 GRUB2_POST_INSTALL_TARGET_HOOKS
+= GRUB2_EFI_STARTUP_NSH
110 $(eval
$(autotools-package
))