1 # ==========================================================================
3 # ==========================================================================
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
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
-))
41 subdir
-ymn
:= $(addprefix
$(obj
)/,$(subdir
-ymn
))
43 # build a list
of files to remove
, usually relative to the current
46 __clean
-files
:= $(extra
-y
) $(always
) \
47 $(targets
) $(clean
-files
) \
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
)),)
77 ifneq
($(strip
$(__clean
-dirs
)),)
80 ifneq
($(strip
$(clean
-rule
)),)
86 # ===========================================================================
88 # ===========================================================================
91 # ---------------------------------------------------------------------------
93 PHONY
+= $(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
.