improve grub2
[buildroot.git] / target / x86 / grub2 / grub2.mk
blobf41c9110286a8e9adb1915024d864453493e04f7
1 GRUB2_SUPPORTED_ARCH=n
2 ifeq ($(ARCH),i386)
3 GRUB2_SUPPORTED_ARCH=y
4 endif
5 ifeq ($(ARCH),i486)
6 GRUB2_SUPPORTED_ARCH=y
7 endif
8 ifeq ($(ARCH),i586)
9 GRUB2_SUPPORTED_ARCH=y
10 endif
11 ifeq ($(ARCH),i686)
12 GRUB2_SUPPORTED_ARCH=y
13 endif
14 ifeq ($(ARCH),x86_64)
15 GRUB2_SUPPORTED_ARCH=y
16 endif
17 ifeq ($(GRUB2_SUPPORTED_ARCH),y)
18 #############################################################
20 # grub2
22 #############################################################
23 GRUB2_VER:=1.96+20080228
24 GRUB2_SOURCE:=grub2_$(GRUB2_VER).orig.tar.gz
25 GRUB2_PATCH:=grub2_$(GRUB2_VER)-1.diff.gz
26 GRUB2_SITE=$(BR2_DEBIAN_MIRROR)/debian/pool/main/g/grub2
27 GRUB2_PATCH_SITE:=$(BR2_DEBIAN_MIRROR)/debian/pool/main/g/grub2
28 GRUB2_CAT:=$(ZCAT)
29 GRUB2_DIR:=$(BUILD_DIR)/grub2-$(GRUB2_VER)
30 GRUB2_BUILDDIR:=$(GRUB2_DIR)/build/grub-pc
31 GRUB2_BINARY:=boot.img
32 GRUB2_TARGET_BINARY:=usr/lib/grub/$(ARCH)-pc/boot.img
33 GRUB2_SPLASHIMAGE=$(TOPDIR)/target/x86/grub/splash.xpm.gz
36 GRUB2_CFLAGS=-DSUPPORT_LOOPDEV
37 ifeq ($(BR2_LARGEFILE),)
38 GRUB2_CFLAGS+=-U_FILE_OFFSET_BITS
39 endif
42 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_SPLASH) += --enable-graphics
43 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_DISKLESS) += --enable-diskless
44 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_3c595) += --enable-3c595
45 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_3c90x) += --enable-3c90x
46 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_davicom) += --enable-davicom
47 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_e1000) += --enable-e1000
48 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_eepro100) += --enable-eepro100
49 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_epic100) += --enable-epic100
50 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_forcedeth) += --enable-forcedeth
51 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_natsemi) += --enable-natsemi
52 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_ns83820) += --enable-ns83820
53 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_ns8390) += --enable-ns8390
54 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_pcnet32) += --enable-pcnet32
55 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_pnic) += --enable-pnic
56 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_rtl8139) += --enable-rtl8139
57 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_r8169) += --enable-r8169
58 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_sis900) += --enable-sis900
59 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_tg3) += --enable-tg3
60 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_tulip) += --enable-tulip
61 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_tlan) += --enable-tlan
62 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_undi) += --enable-undi
63 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_via_rhine) += --enable-via-rhine
64 GRUB2_CONFIG-$(BR2_TARGET_GRUB2_w89c840) += --enable-w89c840
66 $(DL_DIR)/$(GRUB2_SOURCE):
67 $(WGET) -P $(DL_DIR) $(GRUB2_SITE)/$(GRUB2_SOURCE)
69 $(DL_DIR)/$(GRUB2_PATCH):
70 $(WGET) -P $(DL_DIR) $(GRUB2_PATCH_SITE)/$(GRUB2_PATCH)
72 $(GRUB2_DIR)/.unpacked: $(DL_DIR)/$(GRUB2_SOURCE) $(DL_DIR)/$(GRUB2_PATCH)
73 $(GRUB2_CAT) $(DL_DIR)/$(GRUB2_SOURCE) | tar -C $(BUILD_DIR) -xvf -
74 toolchain/patch-kernel.sh $(GRUB2_DIR) $(DL_DIR) $(GRUB2_PATCH)
75 for i in $(wildcard $(GRUB2_DIR)/debian/patches/*.diff); do \
76 cd $(GRUB2_DIR) && patch -p0 -i $$i; \
77 done
78 #for i in `grep -v "^#" $(GRUB2_DIR)/debian/patches/00list`; do \
79 # cat $(GRUB2_DIR)/debian/patches/$$i | patch -p1 -d $(GRUB2_DIR); \
80 #done
81 toolchain/patch-kernel.sh $(GRUB2_DIR) target/x86/grub2 grub\*.patch
82 (cd $(GRUB2_DIR) && ./autogen.sh)
83 touch $@
85 $(GRUB2_BUILDDIR)/.configured: $(GRUB2_DIR)/.unpacked
86 -rm -rf $(GRUB2_BUILDDIR)
87 $(INSTALL) -d $(@D)
88 (cd $(GRUB2_BUILDDIR); rm -rf config.cache; \
89 $(TARGET_CONFIGURE_OPTS) \
90 $(TARGET_CONFIGURE_ARGS) \
91 CPPFLAGS="$(GRUB2_CFLAGS)" \
92 grub_cv_i386_check_nested_functions=no \
93 $(GRUB2_DIR)/configure \
94 --target=$(GNU_TARGET_NAME) \
95 --host=$(GNU_TARGET_NAME) \
96 --build=$(GNU_HOST_NAME) \
97 --prefix=/ \
98 --mandir=/usr/man \
99 --infodir=/usr/info \
100 --disable-auto-linux-mem-opt \
101 $(DISABLE_LARGEFILE) \
102 $(GRUB2_CONFIG-y) \
103 --with-platform=pc \
105 touch $@
107 $(GRUB2_BUILDDIR)/$(GRUB2_BINARY): $(GRUB2_BUILDDIR)/.configured
108 $(MAKE) -C $(GRUB2_BUILDDIR)
110 $(GRUB2_BUILDDIR)/.installed: $(GRUB2_BUILDDIR)/$(GRUB2_BINARY)
111 $(MAKE) -C $(GRUB2_BUILDDIR) DESTDIR=$(TARGET_DIR)/usr install
112 test -d $(TARGET_DIR)/boot/grub2 || mkdir -p $(TARGET_DIR)/boot/grub2
113 #cp $(GRUB2_BUILDDIR)/stage1/stage1 $(GRUB2_BUILDDIR)/stage2/*1_5 $(GRUB2_BUILDDIR)/stage2/stage2 $(TARGET_DIR)/boot/grub2/
114 ifeq ($(BR2_TARGET_GRUB2_SPLASH),y)
115 test -f $(TARGET_DIR)/boot/grub2/$(GRUB2_SPLASHIMAGE) || \
116 cp $(GRUB2_SPLASHIMAGE) $(TARGET_DIR)/boot/grub2/
117 endif
118 touch $@
120 grub2: uclibc $(GRUB2_BUILDDIR)/.installed
122 grub2-source: $(DL_DIR)/$(GRUB2_SOURCE) $(DL_DIR)/$(GRUB2_PATCH)
124 grub2-clean:
125 $(MAKE) DESTDIR=$(TARGET_DIR)/usr CC=$(TARGET_CC) -C $(GRUB2_BUILDDIR) uninstall
126 -$(MAKE) -C $(GRUB2_BUILDDIR) clean
127 rm -f $(TARGET_DIR)/boot/grub2/$(GRUB2_SPLASHIMAGE) \
128 $(TARGET_DIR)/sbin/$(GRUB2_BINARY) \
129 $(TARGET_DIR)/boot/grub2/{stage{1,2},*1_5}
131 grub2-dirclean:
132 rm -rf $(GRUB2_BUILDDIR)
134 endif
136 #############################################################
138 # Toplevel Makefile options
140 #############################################################
141 ifeq ($(BR2_TARGET_GRUB2),y)
142 TARGETS+=grub2
143 endif