Skip to content

Commit f4d4ffc

Browse files
Jason Cooperglikely
authored andcommitted
kbuild: dtbs_install: new make target
Unlike other build products in the Linux kernel, there is no 'make *install' mechanism to put devicetree blobs in a standard place. This commit adds a new 'dtbs_install' make target which copies all of the dtbs into the INSTALL_DTBS_PATH directory. INSTALL_DTBS_PATH can be set before calling make to change the default install directory. If not set then it defaults to: $INSTALL_PATH/dtbs/$KERNELRELEASE. This is done to keep dtbs from different kernel versions separate until things have settled down. Once the dtbs are stable, and not so strongly linked to the kernel version, the devicetree files will most likely move to their own repo. Users will need to upgrade install scripts at that time. v7: (reworked by Grant Likely) - Moved rules from arch/arm/Makefile to arch/arm/boot/dts/Makefile so that each dtb install could have a separate target and be reported as part of the make output. - Fixed dependency problem to ensure $KERNELRELEASE is calculated before attempting to install - Removed option to call external script. Copying the files should be sufficient and a build system can post-process the install directory. Despite the fact an external script is used for installing the kernel, I don't think that is a pattern that should be encouraged. I would rather see buildroot type tools post process the install directory to rename or move dtb files after installing to a staging directory. - Plus it is easy to add a hook after the fact without blocking the rest of this feature. - Move the helper targets into scripts/Makefile.lib with the rest of the common dtb rules Signed-off-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Grant Likely <grant.likely@linaro.org> Cc: Michal Marek <mmarek@suse.cz> Cc: Russell King <linux@arm.linux.org.uk> Cc: Rob Herring <robh+dt@kernel.org>
1 parent c8a4c63 commit f4d4ffc

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

‎Makefile‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,13 @@ export KBUILD_IMAGE ?= vmlinux
726726
# images. Default is /boot, but you can set it to other values
727727
export INSTALL_PATH ?= /boot
728728

729+
#
730+
# INSTALL_DTBS_PATH specifies a prefix for relocations required by build roots.
731+
# Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed as
732+
# an argument if needed. Otherwise it defaults to the kernel install path
733+
#
734+
export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE)
735+
729736
#
730737
# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
731738
# relocations required by build roots. This is not defined in the

‎arch/arm/Makefile‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ $(INSTALL_TARGETS):
310310
%.dtb: | scripts
311311
$(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) $(boot)/dts/$@
312312

313-
PHONY += dtbs
314-
dtbs: scripts
315-
$(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) dtbs
313+
PHONY += dtbs dtbs_install
314+
dtbs dtbs_install: prepare scripts
315+
$(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) $@
316316

317317
# We use MRPROPER_FILES and CLEAN_FILES now
318318
archclean:
@@ -331,6 +331,7 @@ define archhelp
331331
echo ' bootpImage - Combined zImage and initial RAM disk'
332332
echo ' (supply initrd image via make variable INITRD=<path>)'
333333
echo '* dtbs - Build device tree blobs for enabled boards'
334+
echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
334335
echo ' install - Install uncompressed kernel'
335336
echo ' zinstall - Install compressed kernel'
336337
echo ' uinstall - Install U-Boot wrapped compressed kernel'

‎arch/arm/boot/dts/Makefile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ dtb-$(CONFIG_ARCH_ZYNQ) += zynq-zc702.dtb \
321321
zynq-zc706.dtb \
322322
zynq-zed.dtb
323323

324-
targets += dtbs
324+
targets += dtbs dtbs_install
325325
targets += $(dtb-y)
326326
endif
327327

@@ -331,3 +331,5 @@ dtbs: $(addprefix $(obj)/, $(dtb-y))
331331
$(Q)rm -f $(obj)/../*.dtb
332332

333333
clean-files := *.dtb
334+
335+
dtbs_install: $(addsuffix _dtbinst_, $(dtb-y))

‎scripts/Makefile.lib‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,18 @@ $(obj)/%.dtb: $(src)/%.dts FORCE
273273

274274
dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
275275

276+
# Helper targets for Installing DTBs into the boot directory
277+
quiet_cmd_dtb_install = INSTALL $<
278+
cmd_dtb_install = cp $< $(2)
279+
280+
_dtbinst_pre_:
281+
$(Q)if [ -d $(INSTALL_DTBS_PATH).old ]; then rm -rf $(INSTALL_DTBS_PATH).old; fi
282+
$(Q)if [ -d $(INSTALL_DTBS_PATH) ]; then mv $(INSTALL_DTBS_PATH) $(INSTALL_DTBS_PATH).old; fi
283+
$(Q)mkdir -p $(INSTALL_DTBS_PATH)
284+
285+
%.dtb_dtbinst_: $(obj)/%.dtb _dtbinst_pre_
286+
$(call cmd,dtb_install,$(INSTALL_DTBS_PATH))
287+
276288
# Bzip2
277289
# ---------------------------------------------------------------------------
278290

0 commit comments

Comments
 (0)