[PATCH] I2C: i2c-algo-pca -- gracefully handle a busy bus
[linux-2.6/next.git] / scripts / Makefile.clean
blobff3e87dbf387412448f8f1d1359120a997636234
1 # ==========================================================================
2 # Cleaning up
3 # ==========================================================================
5 src := $(obj)
7 .PHONY: __clean
8 __clean:
10 include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
12 # Figure out what we need to build from the various variables
13 # ==========================================================================
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-)
24 # Subdirectories we need to descend into
26 subdir-ym := $(sort $(subdir-y) $(subdir-m))
27 subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-))
29 # Add subdir path
31 subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
33 # build a list of files to remove, usually releative to the current
34 # directory
36 __clean-files := $(extra-y) $(EXTRA_TARGETS) $(always) \
37 $(targets) $(clean-files) \
38 $(host-progs) \
39 $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
41 # as clean-files is given relative to the current directory, this adds
42 # a $(obj) prefix, except for absolute paths
44 __clean-files := $(wildcard \
45 $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \
46 $(filter /%, $(__clean-files)))
48 # as clean-dirs is given relative to the current directory, this adds
49 # a $(obj) prefix, except for absolute paths
51 __clean-dirs := $(wildcard \
52 $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs))) \
53 $(filter /%, $(clean-dirs)))
55 # ==========================================================================
57 quiet_cmd_clean = CLEAN $(obj)
58 cmd_clean = rm -f $(__clean-files)
59 quiet_cmd_cleandir = CLEAN $(__clean-dirs)
60 cmd_cleandir = rm -rf $(__clean-dirs)
63 __clean: $(subdir-ymn)
64 ifneq ($(strip $(__clean-files)),)
65 +$(call cmd,clean)
66 endif
67 ifneq ($(strip $(__clean-dirs)),)
68 +$(call cmd,cleandir)
69 endif
70 ifneq ($(strip $(clean-rule)),)
71 +$(clean-rule)
72 endif
76 # ===========================================================================
77 # Generic stuff
78 # ===========================================================================
80 # Descending
81 # ---------------------------------------------------------------------------
83 .PHONY: $(subdir-ymn)
84 $(subdir-ymn):
85 $(Q)$(MAKE) $(clean)=$@
87 # If quiet is set, only print short version of command
89 cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
91 # Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
92 # Usage:
93 # $(Q)$(MAKE) $(clean)=dir
94 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj