build: allow calling append-dtb from image build commands
authorFelix Fietkau <nbd@nbd.name>
Thu, 2 Nov 2017 12:28:26 +0000 (13:28 +0100)
committerFelix Fietkau <nbd@nbd.name>
Thu, 2 Nov 2017 15:01:18 +0000 (16:01 +0100)
mpc85xx uses this for firmware image files, since the dtb data is not
directly part of the kernel image. This causes build failures in the
image builder.

Fix this by adding a separate build step that runs this call earlier,
reusing the generated file for any calls from kernel or image build
commands.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
include/image-commands.mk
include/image.mk

index aaece705d20b13e0335689eb98e095a6607a7005..1ec5252972c3a012c9bef782133fedb41af78b58 100644 (file)
@@ -102,8 +102,7 @@ define Build/tplink-safeloader
 endef
 
 define Build/append-dtb
-       $(call Image/BuildDTB,$(if $(DEVICE_DTS_DIR),$(DEVICE_DTS_DIR),$(DTS_DIR))/$(DEVICE_DTS).dts,$@.dtb)
-       cat $@.dtb >> $@
+       cat $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb >> $@
 endef
 
 define Build/install-dtb
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))