1#
2# Copyright (C) 2012 OpenWrt.org
3#
4# This is free software, licensed under the GNU General Public License v2.
5# See /LICENSE for more information.
6#
7
8include $(TOPDIR)/rules.mk
9include $(INCLUDE_DIR)/kernel.mk
10
11PKG_NAME:=u-boot
12PKG_VERSION:=2014.10
13PKG_RELEASE:=1
14
15PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
16PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
17PKG_SOURCE_URL:= \
18	http://mirror2.openwrt.org/sources \
19	ftp://ftp.denx.de/pub/u-boot
20
21PKG_MD5SUM:=3ddcaee2f05b7c464778112ec83664b5
22
23PKG_LICENSE:=GPL-2.0 GPL-2.0+
24PKG_LICENSE_FILES:=Licenses/README
25
26include $(INCLUDE_DIR)/package.mk
27
28define uboot/Default
29  TITLE:=
30  CONFIG:=
31  IMAGE:=
32endef
33
34define uboot/ox820
35  TITLE:=U-Boot for the Oxford/PLX NAS7820
36endef
37
38UBOOTS:=ox820
39
40define Package/uboot/template
41define Package/uboot-oxnas-$(1)
42  SECTION:=boot
43  CATEGORY:=Boot Loaders
44  DEPENDS:=@TARGET_oxnas
45  TITLE:=$(2)
46  URL:=http://www.denx.de/wiki/U-Boot
47  VARIANT:=$(1)
48  MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
49endef
50endef
51
52define BuildUBootPackage
53	$(eval $(uboot/Default))
54	$(eval $(uboot/$(1)))
55	$(call Package/uboot/template,$(1),$(TITLE))
56endef
57
58ifdef BUILD_VARIANT
59$(eval $(call uboot/$(BUILD_VARIANT)))
60UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
61UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
62endif
63
64define Build/Prepare
65	$(call Build/Prepare/Default)
66	$(CP) ./files/* $(PKG_BUILD_DIR)
67	find $(PKG_BUILD_DIR) -name .svn | $(XARGS) rm -rf
68endef
69
70define Build/Configure
71	$(MAKE) -C $(PKG_BUILD_DIR) \
72		$(UBOOT_CONFIG)_config
73endef
74
75define Build/Compile
76	$(MAKE) -C $(PKG_BUILD_DIR) \
77		u-boot.bin \
78		CROSS_COMPILE=$(TARGET_CROSS)
79endef
80
81define Package/uboot/install/default
82	$(INSTALL_DIR) $(BIN_DIR)
83	$(CP) $(PKG_BUILD_DIR)/u-boot.bin \
84		$(BIN_DIR)/openwrt-$(BOARD)-$(1)-u-boot.bin
85	$(CP) $(PKG_BUILD_DIR)/u-boot.bin \
86		$(KERNEL_BUILD_DIR)/u-boot.bin
87endef
88
89define Package/uboot/install/template
90define Package/uboot-oxnas-$(1)/install
91	$(call Package/uboot/install/default,$(2))
92endef
93endef
94
95$(foreach u,$(UBOOTS), \
96	$(eval $(call Package/uboot/install/template,$(u),$(u))) \
97)
98
99$(foreach u,$(UBOOTS), \
100	$(eval $(call BuildUBootPackage,$(u))) \
101	$(eval $(call BuildPackage,uboot-oxnas-$(u))) \
102)
103