History

kbuild: fix compilation of dtb specified on command-line without make rule

Since commit e7e2941300d2 ("kbuild: split device tree build rules into scripts/Makefile.dtbs"), it is no longer possible to compile a device tree blob that is not specified in a make rule like: dtb-$(CONFIG_FOO) += foo.dtb Before the mentioned commit, one could copy a dts file to e.g. arch/arm64/boot/dts/ (or a new subdirectory) and then convert it to a dtb file using: make ARCH=arm64 foo.dtb In this scenario, both 'dtb-y' and 'dtb-' are empty, and the inclusion of scripts/Makefile.dtbs relies on 'targets' to contain the MAKECMDGOALS. The value of 'targets', however, is only final later in the code. Move the conditional include of scripts/Makefile.dtbs down to where the value of 'targets' is final. Since Makefile.dtbs updates 'always-y' which is used as a prerequisite in the build rule, the build rule also needs to move down.

Thomas De Schampheleire committed 11 months ago

Commit b08fc4d1 parent 07fe35b1 file · +14 −12Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/Makefile.build+14−12
@@ -527,18 +527,6 @@ ifneq ($(userprogs),) · 526 unmodified lines
527include $(srctree)/scripts/Makefile.userprogs527include $(srctree)/scripts/Makefile.userprogs
528endif528endif
529 529
530ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),)
531include $(srctree)/scripts/Makefile.dtbs
532endif
533
534# Build
535# ---------------------------------------------------------------------------
536
537$(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
538 $(if $(KBUILD_MODULES), $(targets-for-modules)) \
539 $(subdir-ym) $(always-y)
540 @:
541
542# Single targets530# Single targets
543# ---------------------------------------------------------------------------531# ---------------------------------------------------------------------------
544 532
@@ -568,6 +556,20 @@ FORCE: · 23 unmodified lines
568targets += $(filter-out $(single-subdir-goals), $(MAKECMDGOALS))556targets += $(filter-out $(single-subdir-goals), $(MAKECMDGOALS))
569targets := $(filter-out $(PHONY), $(targets))557targets := $(filter-out $(PHONY), $(targets))
570 558
559# Now that targets is fully known, include dtb rules if needed
560ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),)
561include $(srctree)/scripts/Makefile.dtbs
562endif
563
564# Build
565# Needs to be after the include of Makefile.dtbs, which updates always-y
566# ---------------------------------------------------------------------------
567
568$(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
569 $(if $(KBUILD_MODULES), $(targets-for-modules)) \
570 $(subdir-ym) $(always-y)
571 @:
572
571# Read all saved command lines and dependencies for the $(targets) we573# Read all saved command lines and dependencies for the $(targets) we
572# may be building above, using $(if_changed{,_dep}). As an574# may be building above, using $(if_changed{,_dep}). As an
573# optimization, we don't need to read them if the target does not575# optimization, we don't need to read them if the target does not