package: uboot-sunxi: various changes
[openwrt-working-2016/.git] / package / boot / uboot-sunxi / Makefile
1 #
2 # Copyright (C) 2013-2016 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:=u-boot
12 PKG_VERSION:=2016.03
13 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
14 PKG_SOURCE_URL:= \
15         http://mirror2.openwrt.org/sources \
16         ftp://ftp.denx.de/pub/u-boot
17
18 PKG_MD5SUM:=973c1d896be751321cc3aafa564f64b2
19
20 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
21
22 PKG_LICENSE:=GPL-2.0 GPL-2.0+
23 PKG_LICENSE_FILES:=Licenses/README
24
25 include $(INCLUDE_DIR)/package.mk
26
27 define uboot/Default
28   TITLE:=
29   CONFIG:=
30   IMAGE:=
31 endef
32
33 define uboot/A10-OLinuXino-Lime
34   TITLE:=U-Boot for the A10 OLinuXino LIME
35 endef
36
37 define uboot/A13-OLinuXino
38   TITLE:=U-Boot for the A13 OlinuXino
39 endef
40
41 define uboot/A20-OLinuXino-Lime
42   TITLE:=U-Boot for the A20 OLinuXino LIME
43 endef
44
45 define uboot/A20-OLinuXino_MICRO
46   TITLE:=U-Boot for A20 OLinuXino MICRO
47 endef
48
49 define uboot/Bananapi
50   TITLE:=U-Boot for Bananapi
51 endef
52
53 define uboot/Bananapro
54   TITLE:=U-Boot for Bananapro
55 endef
56
57 define uboot/Cubieboard
58   TITLE:=U-Boot for Cubieboard
59 endef
60
61 define uboot/Cubieboard2
62   TITLE:=U-Boot for Cubieboard2
63 endef
64
65 define uboot/Cubietruck
66   TITLE:=U-Boot for Cubietruck
67 endef
68
69 define uboot/Hummingbird_A31
70   TITLE:=U-Boot for the Hummingbird A31 board
71 endef
72
73 define uboot/Mele_M9
74   TITLE:=U-Boot for the Mele M9 (A31)
75 endef
76
77 define uboot/OLIMEX_A13_SOM
78   TITLE:=U-Boot for the Olimex A13 SOM
79 endef
80
81 define uboot/Linksprite_pcDuino
82   TITLE:=U-Boot for Linksprite pcDuino
83 endef  
84
85 define uboot/Linksprite_pcDuino3
86   TITLE:=U-Boot for Linksprite pcDuino3
87 endef  
88
89 define uboot/Lamobo_R1
90   TITLE:=U-Boot for Lamobo R1
91 endef
92
93 define uboot/pangolin
94   TITLE:=U-Boot for Theobroma A31-yQ7 devboard
95 endef
96
97 define uboot/orangepi_plus
98   TITLE:=U-Boot for Orange Pi Plus (H3)
99 endef
100
101 UBOOTS:= \
102         A10-OLinuXino-Lime \
103         A13-OLinuXino \
104         A20-OLinuXino-Lime \
105         A20-OLinuXino_MICRO \
106         Bananapi \
107         Bananapro \
108         Cubieboard \
109         Cubieboard2 \
110         Cubietruck \
111         Hummingbird_A31 \
112         Mele_M9 \
113         OLIMEX_A13_SOM \
114         Linksprite_pcDuino \
115         Linksprite_pcDuino3 \
116         Lamobo_R1 \
117         orangepi_plus \
118         pangolin
119
120 define Package/uboot/template
121 define Package/uboot-sunxi-$(1)
122   SECTION:=boot
123   CATEGORY:=Boot Loaders
124   DEPENDS:=@TARGET_sunxi
125   TITLE:=$(2)
126   URL:=http://www.denx.de/wiki/U-Boot
127   VARIANT:=$(1)
128   MAINTAINER:=Zoltan HERPAI <wigyori@uid0.hu>
129 endef
130 endef
131
132 define BuildUBootPackage
133         $(eval $(uboot/Default))
134         $(eval $(uboot/$(1)))
135         $(call Package/uboot/template,$(1),$(TITLE))
136 endef
137
138 ifdef BUILD_VARIANT
139 $(eval $(call uboot/$(BUILD_VARIANT)))
140 UBOOT_CONFIG:=$(if $(CONFIG),$(CONFIG),$(BUILD_VARIANT))
141 UBOOT_IMAGE:=$(if $(IMAGE),$(IMAGE),openwrt-$(BOARD)-$(BUILD_VARIANT)-u-boot.bin)
142 endif
143
144 # check if any specialized uEnv bootconfig is required
145 ifeq ($(UBOOT_CONFIG),pangolin)
146         UENV:=pangolin
147 else
148         UENV:=default
149 endif
150
151 define Build/Configure
152         $(MAKE) -C $(PKG_BUILD_DIR) \
153                 USE_PRIVATE_LIBGCC=yes $(UBOOT_CONFIG)_defconfig
154 endef
155
156 define Build/Compile
157         $(MAKE) -C $(PKG_BUILD_DIR) \
158                 CROSS_COMPILE=$(TARGET_CROSS) \
159                 DTCDIR=$(LINUX_DIR)/scripts/dtc/
160 endef
161
162 define Package/uboot/install/default
163         $(CP) $(PKG_BUILD_DIR)/u-boot.bin \
164                 $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-u-boot.bin
165         $(CP) $(PKG_BUILD_DIR)/spl/sunxi-spl.bin \
166                 $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-spl.bin
167         $(CP) $(PKG_BUILD_DIR)/u-boot-sunxi-with-spl.bin \
168                 $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-u-boot-with-spl.bin
169         $(CP) uEnv-$(UENV).txt \
170                 $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-uEnv.txt
171         mkimage -C none -A arm -T script -d $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-uEnv.txt \
172                 $(KERNEL_BUILD_DIR)/uboot-$(BOARD)-$(1)-boot.scr
173 endef
174
175 define Package/uboot/install/template
176 define Package/uboot-sunxi-$(1)/install
177         $(call Package/uboot/install/default,$(2))
178 endef
179 endef
180
181 $(foreach u,$(UBOOTS), \
182         $(eval $(call Package/uboot/install/template,$(u),$(u))) \
183 )
184
185 $(foreach u,$(UBOOTS), \
186         $(eval $(call BuildUBootPackage,$(u))) \
187         $(eval $(call BuildPackage,uboot-sunxi-$(u))) \
188 )