]> git.hungrycats.org Git - linux/blob
e7c392fd5788
[linux] /
1 # ==========================================================================
2 # Cleaning up
3 # ==========================================================================
4
5 src := $(obj)
6
7 .PHONY: __clean
8 __clean:
9
10 include $(obj)/Makefile
11
12 # Figure out what we need to build from the various variables
13 # ==========================================================================
14
15 __subdir-y      := $(patsubst %/,%,$(filter %/, $(obj-y)))
16 subdir-y        += $(__subdir-y)
17 __subdir-m      := $(patsubst %/,%,$(filter %/, $(obj-m)))
18 subdir-m        += $(__subdir-m)
19 __subdir-n      := $(patsubst %/,%,$(filter %/, $(obj-n)))
20 subdir-n        += $(__subdir-n)
21 __subdir-       := $(patsubst %/,%,$(filter %/, $(obj-)))
22 subdir-         += $(__subdir-)
23
24 # Subdirectories we need to descend into
25
26 subdir-ym       := $(sort $(subdir-y) $(subdir-m))
27 subdir-ymn      := $(sort $(subdir-ym) $(subdir-n) $(subdir-))
28
29 # Add subdir path
30
31 EXTRA_TARGETS   := $(addprefix $(obj)/,$(EXTRA_TARGETS))
32 clean-files     := $(addprefix $(obj)/,$(clean-files))
33 host-progs      := $(addprefix $(obj)/,$(host-progs))
34 subdir-ymn      := $(addprefix $(obj)/,$(subdir-ymn))
35
36 # ==========================================================================
37
38 __clean-files := $(wildcard $(EXTRA_TARGETS) $(host-progs) $(clean-files))
39
40 quiet_cmd_clean = CLEAN   $(obj)
41       cmd_clean = rm -f $(__clean-files); $(clean-rule)
42
43 __clean: $(subdir-ymn)
44 ifneq ($(strip $(__clean-files) $(clean-rule)),)
45         +$(call cmd,clean)
46 else
47         @:
48 endif
49
50 # ===========================================================================
51 # Generic stuff
52 # ===========================================================================
53
54 # Descending
55 # ---------------------------------------------------------------------------
56
57 .PHONY: $(subdir-ymn)
58 $(subdir-ymn):
59         $(Q)$(MAKE) -f scripts/Makefile.clean obj=$@
60
61 # If quiet is set, only print short version of command
62
63 cmd = @$(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))' &&) $(cmd_$(1))