aboutsummaryrefslogtreecommitdiffstats
path: root/include/u-boot.mk
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2017-01-22 19:33:21 +0100
committerFelix Fietkau <nbd@nbd.name>2017-01-24 16:21:24 +0100
commit31b16a3c7dd8fb379c7756d3366cc1b490491435 (patch)
treef8802eaa911e0a5c5b90918645aa9ccfb39839e0 /include/u-boot.mk
parent3d1b2b22d6d27f9da64d159743fd77ee7265eee9 (diff)
downloadupstream-31b16a3c7dd8fb379c7756d3366cc1b490491435.tar.gz
upstream-31b16a3c7dd8fb379c7756d3366cc1b490491435.tar.bz2
upstream-31b16a3c7dd8fb379c7756d3366cc1b490491435.zip
build: add generic build template for u-boot packages
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'include/u-boot.mk')
-rw-r--r--include/u-boot.mk96
1 files changed, 96 insertions, 0 deletions
diff --git a/include/u-boot.mk b/include/u-boot.mk
new file mode 100644
index 0000000000..4993eb6a06
--- /dev/null
+++ b/include/u-boot.mk
@@ -0,0 +1,96 @@
+PKG_NAME ?= u-boot
+
+ifndef PKG_SOURCE_PROTO
+PKG_SOURCE = $(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL = \
+ http://sources.lede-project.org \
+ ftp://ftp.denx.de/pub/u-boot
+endif
+
+PKG_BUILD_DIR = $(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_TARGETS := bin
+PKG_FLAGS:=nonshared
+
+PKG_LICENSE:=GPL-2.0 GPL-2.0+
+PKG_LICENSE_FILES:=Licenses/README
+
+PKG_BUILD_PARALLEL:=1
+
+export GCC_HONOUR_COPTS=s
+
+define Package/u-boot/install/default
+ $(CP) $(patsubst %,$(PKG_BUILD_DIR)/%,$(UBOOT_IMAGE)) $(1)/
+endef
+
+Package/u-boot/install = $(Package/u-boot/install/default)
+
+define U-Boot/Init
+ BUILD_TARGET:=
+ BUILD_SUBTARGET:=
+ BUILD_DEVICES:=
+ NAME:=
+ DEPENDS:=
+ HIDDEN:=
+ VARIANT:=$(1)
+ UBOOT_CONFIG:=$(1)
+ UBOOT_IMAGE:=u-boot.bin
+endef
+
+TARGET_DEP = TARGET_$(BUILD_TARGET)$(if $(BUILD_SUBTARGET),_$(BUILD_SUBTARGET))
+
+define Build/U-Boot/Target
+ $(eval $(call U-Boot/Init,$(1)))
+ $(eval $(call U-Boot/Default,$(1)))
+ $(eval $(call U-Boot/$(1),$(1)))
+
+ define Package/u-boot-$(1)
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ TITLE:=U-Boot for $(NAME)
+ VARIANT:=$(VARIANT)
+ DEPENDS:=@!IN_SDK $(DEPENDS)
+ HIDDEN:=$(HIDDEN)
+ ifneq ($(BUILD_TARGET),)
+ DEPENDS += @$(TARGET_DEP)
+ ifneq ($(BUILD_DEVICES),)
+ DEFAULT := y if ($(TARGET_DEP)_Default \
+ $(patsubst %,|| $(TARGET_DEP)_DEVICE_%,$(BUILD_DEVICES)) \
+ $(patsubst %,|| $(patsubst TARGET_%,TARGET_DEVICE_%,$(TARGET_DEP))_DEVICE_%,$(BUILD_DEVICES)))
+ endif
+ endif
+ URL:=http://www.denx.de/wiki/U-Boot
+ endef
+
+ define Package/u-boot-$(1)/install
+ $$(Package/u-boot/install)
+ endef
+endef
+
+define Build/Configure/U-Boot
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(UBOOT_CONFIGURE_VARS) $(UBOOT_CONFIG)_config
+endef
+
+DTC=$(wildcard $(LINUX_DIR)/scripts/dtc/dtc)
+
+define Build/Compile/U-Boot
+ +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+ CROSS_COMPILE=$(TARGET_CROSS) \
+ $(if $(DTC),DTC="$(DTC)")
+endef
+
+define BuildPackage/U-Boot/Defaults
+ Build/Configure/Default = $$$$(Build/Configure/U-Boot)
+ Build/Compile/Default = $$$$(Build/Compile/U-Boot)
+endef
+
+define BuildPackage/U-Boot
+ $(eval $(call BuildPackage/U-Boot/Defaults))
+ $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
+ $(eval $(call Build/U-Boot/Target,$(type)))
+ )
+ $(eval $(call Build/DefaultTargets))
+ $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
+ $(call BuildPackage,u-boot-$(type))
+ )
+endef