Commit c99f3918 authored by Masahiro Yamada's avatar Masahiro Yamada

kbuild: unify vmlinux-dirs and module-dirs rules

The in-kernel build and external module build have similar code
for descending into sub-directories.

Factor out the code into the common place.
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
parent 2042b548
...@@ -1016,6 +1016,8 @@ vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ ...@@ -1016,6 +1016,8 @@ vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \
$(patsubst %/,%,$(filter %/, $(init-) $(core-) \ $(patsubst %/,%,$(filter %/, $(init-) $(core-) \
$(drivers-) $(net-) $(libs-) $(virt-)))) $(drivers-) $(net-) $(libs-) $(virt-))))
build-dirs := $(vmlinux-dirs)
init-y := $(patsubst %/, %/built-in.a, $(init-y)) init-y := $(patsubst %/, %/built-in.a, $(init-y))
core-y := $(patsubst %/, %/built-in.a, $(core-y)) core-y := $(patsubst %/, %/built-in.a, $(core-y))
drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y))
...@@ -1038,7 +1040,7 @@ vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) ...@@ -1038,7 +1040,7 @@ vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
# Recurse until adjust_autoksyms.sh is satisfied # Recurse until adjust_autoksyms.sh is satisfied
PHONY += autoksyms_recursive PHONY += autoksyms_recursive
ifdef CONFIG_TRIM_UNUSED_KSYMS ifdef CONFIG_TRIM_UNUSED_KSYMS
autoksyms_recursive: $(vmlinux-deps) modules.order autoksyms_recursive: descend modules.order
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
"$(MAKE) -f $(srctree)/Makefile vmlinux" "$(MAKE) -f $(srctree)/Makefile vmlinux"
endif endif
...@@ -1070,17 +1072,7 @@ targets := vmlinux ...@@ -1070,17 +1072,7 @@ targets := vmlinux
# The actual objects are generated when descending, # The actual objects are generated when descending,
# make sure no implicit rule kicks in # make sure no implicit rule kicks in
$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; $(sort $(vmlinux-deps)): descend ;
# Handle descending into subdirectories listed in $(vmlinux-dirs)
# Preset locale variables to speed up the build process. Limit locale
# tweaks to this spot to avoid wrong language settings when running
# make menuconfig etc.
# Error messages still appears in the original language
PHONY += $(vmlinux-dirs)
$(vmlinux-dirs): prepare
$(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1
filechk_kernel.release = \ filechk_kernel.release = \
echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
...@@ -1302,13 +1294,13 @@ modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules.builtin ...@@ -1302,13 +1294,13 @@ modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules.builtin
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh
modules.order: $(vmlinux-dirs) modules.order: descend
$(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@ $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
modbuiltin-dirs := $(addprefix _modbuiltin_, $(vmlinux-dirs)) modbuiltin-dirs := $(addprefix _modbuiltin_, $(build-dirs))
modules.builtin: $(modbuiltin-dirs) modules.builtin: $(modbuiltin-dirs)
$(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@ $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
PHONY += $(modbuiltin-dirs) PHONY += $(modbuiltin-dirs)
# tristate.conf is not included from this Makefile. Add it as a prerequisite # tristate.conf is not included from this Makefile. Add it as a prerequisite
...@@ -1618,12 +1610,9 @@ $(objtree)/Module.symvers: ...@@ -1618,12 +1610,9 @@ $(objtree)/Module.symvers:
echo " is missing; modules will have no dependencies and modversions."; \ echo " is missing; modules will have no dependencies and modversions."; \
echo ) echo )
module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) build-dirs := $(KBUILD_EXTMOD)
PHONY += $(module-dirs) modules PHONY += modules
$(module-dirs): prepare modules: descend $(objtree)/Module.symvers
$(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) need-modorder=1
modules: $(module-dirs) $(objtree)/Module.symvers
@$(kecho) ' Building modules, stage 2.'; @$(kecho) ' Building modules, stage 2.';
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
...@@ -1665,6 +1654,16 @@ help: ...@@ -1665,6 +1654,16 @@ help:
PHONY += prepare PHONY += prepare
endif # KBUILD_EXTMOD endif # KBUILD_EXTMOD
# Handle descending into subdirectories listed in $(build-dirs)
# Preset locale variables to speed up the build process. Limit locale
# tweaks to this spot to avoid wrong language settings when running
# make menuconfig etc.
# Error messages still appears in the original language
PHONY += descend $(build-dirs)
descend: $(build-dirs)
$(build-dirs): prepare
$(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1
clean: $(clean-dirs) clean: $(clean-dirs)
$(call cmd,rmdirs) $(call cmd,rmdirs)
$(call cmd,rmfiles) $(call cmd,rmfiles)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment