top: Improve 'clean' and 'distclean' makefile targets

This improves 'clean' and 'distclean' makefile target as follows:
1. Remove only .o, .a, .elf, and .bin files for 'clean'
2. Remove .dep in-addition to what 'clean' does for 'distclean'
3. Remove default build and install directory for 'distclean'

Signed-off-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
Anup Patel 2018-12-26 11:06:54 +05:30 committed by Anup Patel
parent a4ce793121
commit 4c1d5a5d2d

View file

@ -284,20 +284,27 @@ install_firmwares: $(build_dir)/$(platform_subdir)/lib/libplatsbi.a $(build_dir)
# Rule for "make clean"
.PHONY: clean
clean:
ifeq ($(build_dir),$(CURDIR)/build)
$(V)mkdir -p $(build_dir)
$(if $(V), @echo " CLEAN $(build_dir)")
$(V)find $(build_dir) -regex ".*\.\(o\|a\|elf\|bin\)" -type f -exec rm -rf {} +
endif
$(if $(V), @echo " RM <build_directory>/*.o")
$(V)find $(build_dir) -type f -name "*.o" -exec rm -rf {} +
$(if $(V), @echo " RM <build_directory>/*.a")
$(V)find $(build_dir) -type f -name "*.a" -exec rm -rf {} +
$(if $(V), @echo " RM <build_directory>/*.elf")
$(V)find $(build_dir) -type f -name "*.elf" -exec rm -rf {} +
$(if $(V), @echo " RM <build_directory>/*.bin")
$(V)find $(build_dir) -type f -name "*.bin" -exec rm -rf {} +
# Rule for "make distclean"
.PHONY: distclean
distclean:
distclean: clean
$(V)mkdir -p $(build_dir)
$(if $(V), @echo " RM <build_directory>/*.dep")
$(V)find $(build_dir) -type f -name "*.dep" -exec rm -rf {} +
ifeq ($(build_dir),$(CURDIR)/build)
$(if $(V), @echo " RM $(build_dir)")
$(if $(V), @echo " RM <build_directory>")
$(V)rm -rf $(build_dir)
endif
ifeq ($(install_dir),$(CURDIR)/install)
$(if $(V), @echo " RM $(install_dir)")
$(if $(V), @echo " RM <install_directory>")
$(V)rm -rf $(install_dir)
endif