Magellan Linux

Contents of /tags/mkinitrd-6_5_0/klibc/scripts/Makefile.clean

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1345 - (show annotations) (download)
Fri Jun 3 21:22:00 2011 UTC (13 years ago) by niro
File size: 3007 byte(s)
tagged 'mkinitrd-6_5_0'
1 # ==========================================================================
2 # Cleaning up
3 # ==========================================================================
4
5 src := $(obj)
6
7 .PHONY: __clean
8 __clean:
9
10 # Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
11 # Usage:
12 # $(Q)$(MAKE) $(clean)=dir
13 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
14
15 # The filename Kbuild has precedence over Makefile
16 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
17 include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
18
19 # Figure out what we need to build from the various variables
20 # ==========================================================================
21
22 subdirs := $(subdir-y) $(subdir-m) $(subdir-n) $(subdir-)
23 subdirs += $(patsubst %/,%,$(filter %/, $(obj-y)))
24 subdirs += $(patsubst %/,%,$(filter %/, $(obj-m)))
25 subdirs += $(patsubst %/,%,$(filter %/, $(obj-n)))
26 subdirs += $(patsubst %/,%,$(filter %/, $(obj-)))
27
28 subdirs += $(patsubst %/,%,$(filter %/, $(klib-y)))
29 subdirs += $(patsubst %/,%,$(filter %/, $(klib-)))
30
31 # Subdirectories we need to descend into
32 subdirs := $(addprefix $(obj)/,$(sort $(subdirs)))
33
34
35 # build a list of files to remove, usually releative to the current
36 # directory
37
38 __clean-files := $(extra-y) $(EXTRA_TARGETS) $(always) \
39 $(targets) $(clean-files) \
40 $(host-progs) \
41 $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
42 klib.list
43
44 # as clean-files is given relative to the current directory, this adds
45 # a $(obj) prefix, except for absolute paths
46
47 __clean-files := $(wildcard \
48 $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \
49 $(filter /%, $(__clean-files)))
50
51 # as clean-dirs is given relative to the current directory, this adds
52 # a $(obj) prefix, except for absolute paths
53
54 __clean-dirs := $(wildcard \
55 $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs))) \
56 $(filter /%, $(clean-dirs)))
57
58 # ==========================================================================
59
60 quiet_cmd_clean = CLEAN $(obj)
61 cmd_clean = rm -f $(__clean-files)
62 quiet_cmd_cleandir = CLEAN $(__clean-dirs)
63 cmd_cleandir = rm -rf $(__clean-dirs)
64
65
66 __clean: $(subdirs)
67 ifneq ($(strip $(__clean-files)),)
68 +$(call cmd,clean)
69 endif
70 ifneq ($(strip $(__clean-dirs)),)
71 +$(call cmd,cleandir)
72 endif
73 ifneq ($(strip $(clean-rule)),)
74 +$(clean-rule)
75 endif
76 @:
77
78
79 # ===========================================================================
80 # Generic stuff
81 # ===========================================================================
82
83 # Descending
84 # ---------------------------------------------------------------------------
85
86 .PHONY: $(subdirs)
87 $(subdirs):
88 $(Q)$(MAKE) $(clean)=$@
89
90 # If quiet is set, only print short version of command
91
92 cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))