@@ -41,6 +41,20 @@ include $(srctree)/scripts/Makefile.compiler
4141include $(kbuild-file)
4242include $(srctree)/scripts/Makefile.lib
4343
44+ # Do not include hostprogs rules unless needed.
45+ # $(sort ...) is used here to remove duplicated words and excessive spaces.
46+ hostprogs := $(sort $(hostprogs))
47+ ifneq ($(hostprogs),)
48+ include $(srctree)/scripts/Makefile.host
49+ endif
50+
51+ # Do not include userprogs rules unless needed.
52+ # $(sort ...) is used here to remove duplicated words and excessive spaces.
53+ userprogs := $(sort $(userprogs))
54+ ifneq ($(userprogs),)
55+ include $(srctree)/scripts/Makefile.userprogs
56+ endif
57+
4458ifndef obj
4559$(warning kbuild: Makefile.build is included improperly)
4660endif
5771# subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
5872subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
5973subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
74+ subdir-dtbslist := $(sort $(filter %/dtbs-list, $(dtb-y)))
6075
6176targets-for-builtin := $(extra-y)
6277
@@ -273,15 +288,10 @@ rust_common_cmd = \
273288# would not match each other.
274289
275290quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
276- cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $< $(cmd_objtool)
277-
278- define rule_rustc_o_rs
279- $(call cmd_and_fixdep,rustc_o_rs)
280- $(call cmd,gen_objtooldep)
281- endef
291+ cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $<
282292
283293$(obj)/%.o: $(obj)/%.rs FORCE
284- +$(call if_changed_rule ,rustc_o_rs)
294+ +$(call if_changed_dep ,rustc_o_rs)
285295
286296quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
287297 cmd_rustc_rsi_rs = \
@@ -353,7 +363,7 @@ $(obj)/%.o: $(obj)/%.S FORCE
353363
354364targets += $(filter-out $(subdir-builtin), $(real-obj-y))
355365targets += $(filter-out $(subdir-modorder), $(real-obj-m))
356- targets += $(lib-y) $(always-y)
366+ targets += $(real-dtb-y) $( lib-y) $(always-y)
357367
358368# Linker scripts preprocessor (.lds.S -> .lds)
359369# ---------------------------------------------------------------------------
@@ -379,6 +389,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
379389# To build objects in subdirs, we need to descend into the directories
380390$(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
381391$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
392+ $(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj)/% ;
382393
383394#
384395# Rule to compile a set of .o files into one .a file (without symbol table)
@@ -394,8 +405,12 @@ quiet_cmd_ar_builtin = AR $@
394405$(obj)/built-in.a: $(real-obj-y) FORCE
395406 $(call if_changed,ar_builtin)
396407
397- # This is a list of build artifacts from the current Makefile and its
398- # sub-directories. The timestamp should be updated when any of the member files.
408+ #
409+ # Rule to create modules.order and dtbs-list
410+ #
411+ # This is a list of build artifacts (module or dtb) from the current Makefile
412+ # and its sub-directories. The timestamp should be updated when any of the
413+ # member files.
399414
400415cmd_gen_order = { $(foreach m, $(real-prereqs), \
401416 $(if $(filter %/$(notdir $@), $m), cat $m, echo $m);) :; } \
@@ -404,6 +419,9 @@ cmd_gen_order = { $(foreach m, $(real-prereqs), \
404419$(obj)/modules.order: $(obj-m) FORCE
405420 $(call if_changed,gen_order)
406421
422+ $(obj)/dtbs-list: $(dtb-y) $(dtbo-y) FORCE
423+ $(call if_changed,gen_order)
424+
407425#
408426# Rule to compile a set of .o files into one .a file (with symbol table)
409427#
@@ -432,22 +450,23 @@ intermediate_targets = $(foreach sfx, $(2), \
432450 $(patsubst %$(strip $(1)),%$(sfx), \
433451 $(filter %$(strip $(1)), $(targets))))
434452# %.asn1.o <- %.asn1.[ch] <- %.asn1
435- targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h)
453+ # %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
454+ # %.dtbo.o <- %.dtbo.S <- %.dtbo <- %.dtso
455+ # %.lex.o <- %.lex.c <- %.l
456+ # %.tab.o <- %.tab.[ch] <- %.y
457+ targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
458+ $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \
459+ $(call intermediate_targets, .dtbo.o, .dtbo.S .dtbo) \
460+ $(call intermediate_targets, .lex.o, .lex.c) \
461+ $(call intermediate_targets, .tab.o, .tab.c .tab.h)
436462
437- # Include additional build rules when necessary
463+ # Build
438464# ---------------------------------------------------------------------------
439465
440- # $(sort ...) is used here to remove duplicated words and excessive spaces.
441- hostprogs := $(sort $(hostprogs))
442- ifneq ($(hostprogs),)
443- include $(srctree)/scripts/Makefile.host
444- endif
445-
446- # $(sort ...) is used here to remove duplicated words and excessive spaces.
447- userprogs := $(sort $(userprogs))
448- ifneq ($(userprogs),)
449- include $(srctree)/scripts/Makefile.userprogs
450- endif
466+ $(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
467+ $(if $(KBUILD_MODULES), $(targets-for-modules)) \
468+ $(subdir-ym) $(always-y)
469+ @:
451470
452471# Single targets
453472# ---------------------------------------------------------------------------
@@ -478,20 +497,6 @@ FORCE:
478497targets += $(filter-out $(single-subdir-goals), $(MAKECMDGOALS))
479498targets := $(filter-out $(PHONY), $(targets))
480499
481- # Now that targets is fully known, include dtb rules if needed
482- ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),)
483- include $(srctree)/scripts/Makefile.dtbs
484- endif
485-
486- # Build
487- # Needs to be after the include of Makefile.dtbs, which updates always-y
488- # ---------------------------------------------------------------------------
489-
490- $(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
491- $(if $(KBUILD_MODULES), $(targets-for-modules)) \
492- $(subdir-ym) $(always-y)
493- @:
494-
495500# Read all saved command lines and dependencies for the $(targets) we
496501# may be building above, using $(if_changed{,_dep}). As an
497502# optimization, we don't need to read them if the target does not
0 commit comments