merged some improvements from the gentoo kvm-70 ebuild
[kvm-coreboot.git] / packages / grub2 / grub2.mk
blob98c340cd7ac6133766f21efb26a834fb60826397
1 GRUB2_REVISION=7e743dc7b9262c132488d7bb601ea48e4f730c60
2 GRUB2_URL=http://coreboot.org/viewmtn/revision/tar/$(GRUB2_REVISION)
3 GRUB2_TAR=grub2-$(GRUB2_REVISION).tar
5 GRUB2_DIR=$(BUILD_DIR)/grub2
6 GRUB2_SRC_DIR=$(GRUB2_DIR)/$(GRUB2_REVISION)
7 GRUB2_STAMP_DIR=$(GRUB2_DIR)/stamps
8 GRUB2_LOG_DIR=$(GRUB2_DIR)/logs
10 ifeq ($(CONFIG_VERBOSE),y)
11 GRUB2_CONFIG_LOG=/dev/stdout
12 GRUB2_BUILD_LOG=/dev/stdout
13 GRUB2_INSTALL_LOG=/dev/stdout
14 else
15 GRUB2_BUILD_LOG=$(GRUB2_LOG_DIR)/build.log
16 GRUB2_INSTALL_LOG=$(GRUB2_LOG_DIR)/install.log
17 GRUB2_CONFIG_LOG=$(GRUB2_LOG_DIR)/config.log
18 endif
20 GRUB2_CFG=$(PACKAGE_DIR)/grub2/conf/grub.cfg
21 GRUB2_MODULES=coreboot cat cmp iso9660 help lspci \
22 serial terminal lar terminfo memdisk ata ls \
23 configfile boot hexdump linux multiboot ext2
25 HAVE_RUBY:=$(call find-tool,ruby)
27 ifeq ($(HAVE_RUBY),n)
28 $(error To build GRUB2, you need to install 'ruby')
29 endif
31 $(SOURCE_DIR)/$(GRUB2_TAR):
32 @ mkdir -p $(SOURCE_DIR)
33 @ wget $(WGET_Q) -O $@ $(GRUB2_URL)
35 $(GRUB2_STAMP_DIR)/.unpacked: $(SOURCE_DIR)/$(GRUB2_TAR) | $(GRUB2_DIR) $(GRUB2_STAMP_DIR)
36 @ tar -C $(GRUB2_DIR) -xf $(SOURCE_DIR)/$(GRUB2_TAR)
37 @ touch $@
39 $(GRUB2_STAMP_DIR)/.configured: $(GRUB2_STAMP_DIR)/.unpacked | $(GRUB2_LOG_DIR)
40 @ echo "Configuring GRUB2..."
41 @ (cd $(GRUB2_SRC_DIR); sh ./autogen.sh > $(GRUB2_CONFIG_LOG) 2>&1)
42 @ (cd $(GRUB2_SRC_DIR); export LIBS= CC= LDFLAGS= CFLAGS=; ./configure --with-platform=linuxbios --prefix=$(STAGING_DIR) >> $(GRUB2_CONFIG_LOG) 2>&1)
43 @ touch $@
45 $(GRUB2_SRC_DIR)/grub-mkimage: $(GRUB2_STAMP_DIR)/.configured
46 @ echo "Building GRUB2..."
47 @ (cd $(GRUB2_SRC_DIR); make > $(GRUB2_CONFIG_LOG) 2>&1)
49 $(GRUB2_STAMP_DIR)/.installed: $(GRUB2_SRC_DIR)/grub-mkimage
50 @ chmod uga+x $(GRUB2_SRC_DIR)/mkinstalldirs
51 @ (cd $(GRUB2_SRC_DIR); make install > $(GRUB2_INSTALL_LOG) 2>&1)
52 @ touch $@
54 $(GRUB2_DIR)/grub2.elf: $(GRUB2_STAMP_DIR)/.installed
55 @ $(STAGING_DIR)/bin/grub-mkimage -o $@ $(GRUB2_MODULES)
57 $(GRUB2_STAMP_DIR)/.copied: $(GRUB2_DIR)/grub2.elf
58 @ mkdir -p $(shell dirname $(PAYLOAD_ELF))
59 @ cp $(GRUB2_DIR)/grub2.elf $(PAYLOAD_ELF)
60 @ touch $@
62 $(GRUB2_DIR) $(GRUB2_LOG_DIR) $(GRUB2_STAMP_DIR):
63 @ mkdir -p $@
65 grub2: $(GRUB2_STAMP_DIR)/.copied
67 grub2-clean:
68 @ rm -f $(GRUB2_DIR)/grub2.lar
69 @ rm -f $(GRUB2_DIR)/grub2.elf
70 @ rm -f $(GRUB2_STAMP_DIR)/.configured
71 @ rm -f $(GRUB2_STAMP_DIR)/.copied
72 @ rm -f $(GRUB2_STAMP_DIR)/.installed
73 ifneq ($(wildcard $(GRUB_SRC_DIR)/Makefile),)
74 @ $(MAKE) -C $(GRUB2_SRC_DIR) clean > /dev/null 2>&1
75 endif
77 grub2-distclean:
78 @ rm -rf $(GRUB2_DIR)/*