Makefile.clean 1.86 KB
Newer Older
1 2 3
# ==========================================================================
# Cleaning up
# ==========================================================================
4 5 6 7 8 9 10 11

src := $(obj)

.PHONY: __clean
__clean:

include $(obj)/Makefile

12 13 14
# Figure out what we need to build from the various variables
# ==========================================================================

15 16 17 18 19 20 21 22 23
__subdir-y	:= $(patsubst %/,%,$(filter %/, $(obj-y)))
subdir-y	+= $(__subdir-y)
__subdir-m	:= $(patsubst %/,%,$(filter %/, $(obj-m)))
subdir-m	+= $(__subdir-m)
__subdir-n	:= $(patsubst %/,%,$(filter %/, $(obj-n)))
subdir-n	+= $(__subdir-n)
__subdir-	:= $(patsubst %/,%,$(filter %/, $(obj-)))
subdir-		+= $(__subdir-)

24 25
# Subdirectories we need to descend into

26 27 28
subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
subdir-ymn      := $(sort $(subdir-ym) $(subdir-n) $(subdir-))

29 30
# Add subdir path

31 32 33 34 35
EXTRA_TARGETS	:= $(addprefix $(obj)/,$(EXTRA_TARGETS))
clean-files	:= $(addprefix $(obj)/,$(clean-files))
host-progs	:= $(addprefix $(obj)/,$(host-progs))
subdir-ymn	:= $(addprefix $(obj)/,$(subdir-ymn))

36 37
# ==========================================================================

38 39
__clean-files := $(wildcard $(EXTRA_TARGETS) $(host-progs) $(clean-files))

40 41
quiet_cmd_clean = CLEAN   $(obj)
      cmd_clean = rm -f $(__clean-files); $(clean-rule)
42

43 44
__clean: $(subdir-ymn)
ifneq ($(strip $(__clean-files) $(clean-rule)),)
45
	+$(call cmd,clean)
46
else
47
	@:
48 49
endif

50 51 52 53 54 55
# ===========================================================================
# Generic stuff
# ===========================================================================

# Descending
# ---------------------------------------------------------------------------
56

57
.PHONY: $(subdir-ymn)
58
$(subdir-ymn):
59
	$(Q)$(MAKE) -f scripts/Makefile.clean obj=$@
60

61 62 63
# If quiet is set, only print short version of command

cmd = @$(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))' &&) $(cmd_$(1))