Skip to content

Commit

Permalink
kbuild: refactor tagets caluculation for KBUILD_{BUILTIN,KBUILD_MODULES}
Browse files Browse the repository at this point in the history
Remove lib-target, builtin-target, modorder-target, and modtargets.

Instead, add targets-for-builtin and targets-for-modules.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
Masahiro Yamada committed Jun 1, 2020
1 parent 0a8820e commit f3908ab
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions scripts/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,24 @@ endif
subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
subdir-modorder := $(sort $(filter %/modules.order, $(modorder)))

targets-for-builtin := $(extra-y)

ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
lib-target := $(obj)/lib.a
targets-for-builtin += $(obj)/lib.a
endif

ifdef need-builtin
builtin-target := $(obj)/built-in.a
targets-for-builtin += $(obj)/built-in.a
endif

targets-for-modules := $(obj-m)
targets-for-modules += $(patsubst %.o, %.mod, $(obj-m))

ifdef need-modorder
modorder-target := $(obj)/modules.order
targets-for-modules += $(obj)/modules.order
endif

mod-targets := $(patsubst %.o, %.mod, $(obj-m))
targets += $(targets-for-builtin) $(targets-for-modules)

# Linus' kernel sanity checking tool
ifeq ($(KBUILD_CHECKSRC),1)
Expand Down Expand Up @@ -284,8 +289,6 @@ cmd_mod = { \
$(obj)/%.mod: $(obj)/%.o FORCE
$(call if_changed,mod)

targets += $(mod-targets)

quiet_cmd_cc_lst_c = MKLST $@
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
$(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
Expand Down Expand Up @@ -359,7 +362,7 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
$(call if_changed_rule,as_o_S)

targets += $(filter-out $(subdir-builtin), $(real-obj-y)) $(real-obj-m) $(lib-y)
targets += $(extra-y) $(always-y) $(MAKECMDGOALS)
targets += $(always-y) $(MAKECMDGOALS)

# Linker scripts preprocessor (.lds.S -> .lds)
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -396,8 +399,6 @@ quiet_cmd_ar_builtin = AR $@
$(obj)/built-in.a: $(real-obj-y) FORCE
$(call if_changed,ar_builtin)

targets += $(builtin-target)

#
# Rule to create modules.order file
#
Expand All @@ -414,8 +415,6 @@ $(obj)/modules.order: $(subdir-modorder) FORCE
$(obj)/lib.a: $(lib-y) FORCE
$(call if_changed,ar)

targets += $(lib-target)

# NOTE:
# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
# module is turned into a multi object module, $^ will contain header file
Expand Down Expand Up @@ -478,8 +477,8 @@ endif

else

__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
$(if $(KBUILD_MODULES),$(obj-m) $(mod-targets) $(modorder-target)) \
__build: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
$(if $(KBUILD_MODULES), $(targets-for-modules)) \
$(subdir-ym) $(always-y)
@:

Expand Down

0 comments on commit f3908ab

Please sign in to comment.