build: allow calling append-dtb from image build commands
[openwrt/openwrt.git] / include / image.mk
index fc6bf06e96be11170fbba18ed1c3f2c5610f93a9..9ab139cba679e2609eaf8ac24d05ac932eea5edc 100644 (file)
@@ -435,7 +435,23 @@ define Device/Build/compile
 
 endef
 
+ifndef IB
+define Device/Build/dtb
+  $(KDIR)/image-$(1).dtb: FORCE
+       $(call Image/BuildDTB,$(2)/$(1).dts,$$@)
+
+  $(3): $(KDIR)/image-$(1).dtb
+endef
+endif
+
 define Device/Build/kernel
+  $$(eval $$(foreach dts,$$(DEVICE_DTS), \
+       $$(call Device/Build/dtb,$$(dts), \
+               $$(if $$(DEVICE_DTS_DIR),$$(DEVICE_DTS_DIR),$$(DTS_DIR)),\
+               $$(KDIR_KERNEL_IMAGE) $(KDIR)/$$(KERNEL_INITRAMFS_NAME) \
+       ) \
+  ))
+
   $(KDIR)/$$(KERNEL_NAME):: image_prepare
   $$(_TARGET): $$(if $$(KERNEL_INSTALL),$(BIN_DIR)/$$(KERNEL_IMAGE))
   $(call Device/Export,$$(KDIR_KERNEL_IMAGE),$(1))