package/grub: play it safe, cross compile everywhere
[openwrt/svn-archive/archive.git] / package / grub / Makefile
1 #
2 # Copyright (C) 2006-2009 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9 include $(INCLUDE_DIR)/kernel.mk
10
11 PKG_NAME:=grub
12 PKG_VERSION:=0.97
13 PKG_RELEASE:=2
14
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
16 PKG_SOURCE_URL:=ftp://alpha.gnu.org/gnu/grub
17 PKG_MD5SUM:=cd3f3eb54446be6003156158d51f4884
18
19 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/grub-$(PKG_VERSION)
20 PKG_TARGETS:=bin
21
22 include $(INCLUDE_DIR)/package.mk
23
24 export grub_cv_prog_objcopy_absolute=yes
25
26 define Package/grub
27 SECTION:=boot
28 DEPENDS:=@TARGET_x86
29 CATEGORY:=Boot Loaders
30 TITLE:=GRand Unified Bootloader
31 URL:=http://www.gnu.org/software/grub/
32 endef
33
34 CONFIGURE_FLAGS:= \
35 --target=$(GNU_TARGET_NAME) \
36 --host=$(GNU_TARGET_NAME) \
37 --build=$(GNU_HOST_NAME)
38
39 ifneq ($(HOST_OS),Darwin)
40 define Build/Configure
41 (cd $(PKG_BUILD_DIR); \
42 LDFLAGS="-static" \
43 ./configure \
44 $(CONFIGURE_FLAGS) \
45 --program-prefix="" \
46 --program-suffix="" \
47 --prefix=/usr \
48 --exec-prefix=/usr \
49 --bindir=/usr/bin \
50 --sbindir=/usr/sbin \
51 --libexecdir=/usr/lib \
52 --sysconfdir=/etc \
53 --datadir=/usr/share \
54 --localstatedir=/var \
55 --mandir=/usr/man \
56 --infodir=/usr/info \
57 $(DISABLE_NLS) \
58 --disable-auto-linux-mem-opt \
59 )
60 endef
61
62 #
63 # ./configure detects whether the host compiler supports
64 # -fno-stack-protector but only sets STAGE2_CFLAGS accordingly
65 #
66 define Build/Compile
67 $(MAKE) -C $(PKG_BUILD_DIR) \
68 GRUB_CFLAGS="\$$$$(STAGE2_CFLAGS)" \
69 STAGE1_CFLAGS="\$$$$(STAGE2_CFLAGS)"
70 endef
71
72 define Build/InstallDev
73 $(MAKE) -C $(PKG_BUILD_DIR) \
74 DESTDIR="$(STAGING_DIR_HOST)" \
75 install
76 mv $(STAGING_DIR_HOST)/usr/sbin/grub $(STAGING_DIR_HOST)/bin
77 endef
78 endif
79
80 $(eval $(call BuildPackage,grub))