few updates from RMerlin sources
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / scripts / Makefile.clean
blob027b61e837e37d2b562e5f4e35ae2f97a3843cb0
1 # ==========================================================================
2 # Cleaning up
3 # ==========================================================================
5 src := $(obj)
7 PHONY := __clean
8 __clean:
10 # Read auto.conf if it exists, otherwise ignore
11 -include include/config/auto.conf
13 # Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
14 # Usage:
15 # $(Q)$(MAKE) $(clean)=dir
16 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
18 # The filename Kbuild has precedence over Makefile
19 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
20 include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
22 # Figure out what we need to build from the various variables
23 # ==========================================================================
25 __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
26 subdir-y += $(__subdir-y)
27 __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
28 subdir-m += $(__subdir-m)
29 __subdir-n := $(patsubst %/,%,$(filter %/, $(obj-n)))
30 subdir-n += $(__subdir-n)
31 __subdir- := $(patsubst %/,%,$(filter %/, $(obj-)))
32 subdir- += $(__subdir-)
34 # Subdirectories we need to descend into
36 subdir-ym := $(sort $(subdir-y) $(subdir-m))
37 subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-))
39 # Add subdir path
41 subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
43 # build a list of files to remove, usually relative to the current
44 # directory
46 __clean-files := $(extra-y) $(always) \
47 $(targets) $(clean-files) \
48 $(host-progs) \
49 $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
51 # as clean-files is given relative to the current directory, this adds
52 # a $(obj) prefix, except for absolute paths
54 __clean-files := $(wildcard \
55 $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \
56 $(filter /%, $(__clean-files)))
58 # as clean-dirs is given relative to the current directory, this adds
59 # a $(obj) prefix, except for absolute paths
61 __clean-dirs := $(wildcard \
62 $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs))) \
63 $(filter /%, $(clean-dirs)))
65 # ==========================================================================
67 quiet_cmd_clean = CLEAN $(obj)
68 cmd_clean = rm -f $(__clean-files)
69 quiet_cmd_cleandir = CLEAN $(__clean-dirs)
70 cmd_cleandir = rm -rf $(__clean-dirs)
73 __clean: $(subdir-ymn)
74 ifneq ($(strip $(__clean-files)),)
75 +$(call cmd,clean)
76 endif
77 ifneq ($(strip $(__clean-dirs)),)
78 +$(call cmd,cleandir)
79 endif
80 ifneq ($(strip $(clean-rule)),)
81 +$(clean-rule)
82 endif
86 # ===========================================================================
87 # Generic stuff
88 # ===========================================================================
90 # Descending
91 # ---------------------------------------------------------------------------
93 PHONY += $(subdir-ymn)
94 $(subdir-ymn):
95 $(Q)$(MAKE) $(clean)=$@
97 # If quiet is set, only print short version of command
99 cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
102 # Declare the contents of the .PHONY variable as phony. We keep that
103 # information in a variable se we can use it in if_changed and friends.
105 .PHONY: $(PHONY)