ramips: rename PSG1218 to match label
[openwrt/openwrt.git] / include / u-boot.mk
1 PKG_NAME ?= u-boot
2
3 ifndef PKG_SOURCE_PROTO
4 PKG_SOURCE = $(PKG_NAME)-$(PKG_VERSION).tar.bz2
5 PKG_SOURCE_URL = \
6 http://sources.lede-project.org \
7 ftp://ftp.denx.de/pub/u-boot
8 endif
9
10 PKG_BUILD_DIR = $(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
11
12 PKG_TARGETS := bin
13 PKG_FLAGS:=nonshared
14
15 PKG_LICENSE:=GPL-2.0 GPL-2.0+
16 PKG_LICENSE_FILES:=Licenses/README
17
18 PKG_BUILD_PARALLEL:=1
19
20 export GCC_HONOUR_COPTS=s
21
22 define Package/u-boot/install/default
23 $(CP) $(patsubst %,$(PKG_BUILD_DIR)/%,$(UBOOT_IMAGE)) $(1)/
24 endef
25
26 Package/u-boot/install = $(Package/u-boot/install/default)
27
28 define U-Boot/Init
29 BUILD_TARGET:=
30 BUILD_SUBTARGET:=
31 BUILD_DEVICES:=
32 NAME:=
33 DEPENDS:=
34 HIDDEN:=
35 DEFAULT:=
36 VARIANT:=$(1)
37 UBOOT_CONFIG:=$(1)
38 UBOOT_IMAGE:=u-boot.bin
39 endef
40
41 TARGET_DEP = TARGET_$(BUILD_TARGET)$(if $(BUILD_SUBTARGET),_$(BUILD_SUBTARGET))
42
43 UBOOT_MAKE_FLAGS = \
44 HOSTCC="$(HOSTCC)" \
45 HOSTCFLAGS='$(HOST_CFLAGS) $$$$(HOSTCPPFLAGS)' \
46 HOSTLDFLAGS=""
47
48 define Build/U-Boot/Target
49 $(eval $(call U-Boot/Init,$(1)))
50 $(eval $(call U-Boot/Default,$(1)))
51 $(eval $(call U-Boot/$(1),$(1)))
52
53 define Package/u-boot-$(1)
54 SECTION:=boot
55 CATEGORY:=Boot Loaders
56 TITLE:=U-Boot for $(NAME)
57 VARIANT:=$(VARIANT)
58 DEPENDS:=@!IN_SDK $(DEPENDS)
59 HIDDEN:=$(HIDDEN)
60 ifneq ($(BUILD_TARGET),)
61 DEPENDS += @$(TARGET_DEP)
62 ifneq ($(BUILD_DEVICES),)
63 DEFAULT := y if ($(TARGET_DEP)_Default \
64 $(patsubst %,|| $(TARGET_DEP)_DEVICE_%,$(BUILD_DEVICES)) \
65 $(patsubst %,|| $(patsubst TARGET_%,TARGET_DEVICE_%,$(TARGET_DEP))_DEVICE_%,$(BUILD_DEVICES)))
66 endif
67 endif
68 $(if $(DEFAULT),DEFAULT:=$(DEFAULT))
69 URL:=http://www.denx.de/wiki/U-Boot
70 endef
71
72 define Package/u-boot-$(1)/install
73 $$(Package/u-boot/install)
74 endef
75 endef
76
77 define Build/Configure/U-Boot
78 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(UBOOT_CONFIGURE_VARS) $(UBOOT_CONFIG)_config
79 endef
80
81 DTC=$(wildcard $(LINUX_DIR)/scripts/dtc/dtc)
82
83 define Build/Compile/U-Boot
84 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
85 CROSS_COMPILE=$(TARGET_CROSS) \
86 $(if $(DTC),DTC="$(DTC)") \
87 $(UBOOT_MAKE_FLAGS)
88 endef
89
90 define BuildPackage/U-Boot/Defaults
91 Build/Configure/Default = $$$$(Build/Configure/U-Boot)
92 Build/Compile/Default = $$$$(Build/Compile/U-Boot)
93 endef
94
95 define BuildPackage/U-Boot
96 $(eval $(call BuildPackage/U-Boot/Defaults))
97 $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
98 $(eval $(call Build/U-Boot/Target,$(type)))
99 )
100 $(eval $(call Build/DefaultTargets))
101 $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
102 $(call BuildPackage,u-boot-$(type))
103 )
104 endef