Skip to content

Commit

Permalink
kbuild: unify clean-dirs rule for in-kernel and external module
Browse files Browse the repository at this point in the history
Factor out the duplicated code for in-kernel and external module
cleaning.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
  • Loading branch information
Masahiro Yamada committed Aug 21, 2019
1 parent c99f391 commit 76cd306
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \
$(drivers-) $(net-) $(libs-) $(virt-))))

build-dirs := $(vmlinux-dirs)
clean-dirs := $(vmlinux-alldirs)

init-y := $(patsubst %/, %/built-in.a, $(init-y))
core-y := $(patsubst %/, %/built-in.a, $(core-y))
Expand Down Expand Up @@ -1388,11 +1389,8 @@ DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
#
clean: rm-dirs := $(CLEAN_DIRS)
clean: rm-files := $(CLEAN_FILES)
clean-dirs := $(addprefix _clean_, $(vmlinux-alldirs))

PHONY += $(clean-dirs) clean archclean vmlinuxclean
$(clean-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
PHONY += archclean vmlinuxclean

vmlinuxclean:
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
Expand Down Expand Up @@ -1629,12 +1627,7 @@ PHONY += _emodinst_post
_emodinst_post: _emodinst_
$(call cmd,depmod)

clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))

PHONY += $(clean-dirs) clean
$(clean-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)

clean-dirs := $(KBUILD_EXTMOD)
clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers

PHONY += /
Expand Down Expand Up @@ -1664,6 +1657,11 @@ descend: $(build-dirs)
$(build-dirs): prepare
$(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1

clean-dirs := $(addprefix _clean_, $(clean-dirs))
PHONY += $(clean-dirs) clean
$(clean-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)

clean: $(clean-dirs)
$(call cmd,rmdirs)
$(call cmd,rmfiles)
Expand Down

0 comments on commit 76cd306

Please sign in to comment.