Blame view

scripts/Makefile.clean 2.27 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  # SPDX-License-Identifier: GPL-2.0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
  # ==========================================================================
  # Cleaning up
  # ==========================================================================
  
  src := $(obj)
4f1933620   Paul Smith   kbuild: change kb...
7
  PHONY := __clean
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
  __clean:
371fdc77a   Masahiro Yamada   kbuild: collect s...
9
  include scripts/Kbuild.include
2315c6e42   Sam Ravnborg   kbuild: define cl...
10

2a6914703   Sam Ravnborg   kbuild: fix make ...
11
  # The filename Kbuild has precedence over Makefile
db8c1a7b2   Sam Ravnborg   kbuild: fix build...
12
13
  kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
  include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
16
  
  # Figure out what we need to build from the various variables
  # ==========================================================================
4ca76945b   Masahiro Yamada   kbuild: clean up ...
17
18
  subdir-ymn := $(sort $(subdir-y) $(subdir-m) $(subdir-) \
  		$(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m) $(obj-))))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
21
22
  
  # Add subdir path
  
  subdir-ymn	:= $(addprefix $(obj)/,$(subdir-ymn))
3156fd052   Robert P. J. Day   kbuild: fix some ...
23
  # build a list of files to remove, usually relative to the current
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
  # directory
faabed295   Masahiro Yamada   kbuild: introduce...
25
26
27
28
29
30
31
32
33
  __clean-files	:= \
  	$(clean-files) $(targets) $(hostprogs) $(userprogs) \
  	$(extra-y) $(extra-m) $(extra-) \
  	$(always-y) $(always-m) $(always-) \
  	$(hostprogs-always-y) $(hostprogs-always-m) $(hostprogs-always-) \
  	$(userprogs-always-y) $(userprogs-always-m) $(userprogs-always-)
  
  # deprecated
  __clean-files	+= $(always) $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34

ef8ff89b5   Michal Marek   kbuild: Really do...
35
  __clean-files   := $(filter-out $(no-clean-files), $(__clean-files))
a16c5f99a   Michal Marek   kbuild: Fix remov...
36
37
38
  # clean-files is given relative to the current directory, unless it
  # starts with $(objtree)/ (which means "./", so do not add "./" unless
  # you want to delete a file from the toplevel object directory).
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
39
40
  
  __clean-files   := $(wildcard                                               \
a16c5f99a   Michal Marek   kbuild: Fix remov...
41
42
  		   $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \
  		   $(filter $(objtree)/%, $(__clean-files)))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
  # ==========================================================================
1634f2bfd   Masahiro Yamada   kbuild: remove cl...
45
46
  quiet_cmd_clean = CLEAN   $(obj)
        cmd_clean = rm -rf $(__clean-files)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
48
49
  
  __clean: $(subdir-ymn)
  ifneq ($(strip $(__clean-files)),)
687ac1fa3   Masahiro Yamada   kbuild: remove un...
50
  	$(call cmd,clean)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
  endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
52
53
54
55
56
57
58
59
60
  	@:
  
  
  # ===========================================================================
  # Generic stuff
  # ===========================================================================
  
  # Descending
  # ---------------------------------------------------------------------------
4f1933620   Paul Smith   kbuild: change kb...
61
  PHONY += $(subdir-ymn)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
63
  $(subdir-ymn):
  	$(Q)$(MAKE) $(clean)=$@
4f1933620   Paul Smith   kbuild: change kb...
64
  .PHONY: $(PHONY)