board/csky: fixup gdb instructions in readme.txt
[buildroot-gz.git] / boot / grub2 / grub2.mk
blobdc4e51ea8e24e6da9259e88cc65f7587f5f66fde
1 ################################################################################
3 # grub2
5 ################################################################################
7 GRUB2_VERSION = 2.00
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
22 GRUB2_TUPLE = i386-pc
23 GRUB2_TARGET = i386
24 GRUB2_PLATFORM = pc
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
30 GRUB2_TARGET = i386
31 GRUB2_PLATFORM = 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
37 GRUB2_TARGET = x86_64
38 GRUB2_PLATFORM = efi
39 endif
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
47 # tools.
49 # NOTE: TARGET_STRIP is overridden by BR2_STRIP_none, so always
50 # use the cross compile variant to ensure grub2 builds
52 GRUB2_CONF_ENV = \
53 $(HOST_CONFIGURE_OPTS) \
54 CPP="$(HOSTCC) -E" \
55 TARGET_CC="$(TARGET_CC)" \
56 TARGET_CFLAGS="$(TARGET_CFLAGS)" \
57 TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" \
58 TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
59 NM="$(TARGET_NM)" \
60 OBJCOPY="$(TARGET_OBJCOPY)" \
61 STRIP="$(TARGET_CROSS)strip"
63 GRUB2_CONF_OPTS = \
64 --target=$(GRUB2_TARGET) \
65 --with-platform=$(GRUB2_PLATFORM) \
66 --disable-grub-mkfont \
67 --enable-efiemu=no \
68 ac_cv_lib_lzma_lzma_code=no \
69 --enable-device-mapper=no \
70 --enable-libzfs=no \
71 --disable-werror
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
84 endef
85 endif
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) \
91 -O $(GRUB2_TUPLE) \
92 -o $(GRUB2_IMAGE) \
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)
99 endef
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
106 endef
107 GRUB2_POST_INSTALL_TARGET_HOOKS += GRUB2_EFI_STARTUP_NSH
108 endif
110 $(eval $(autotools-package))