From 4c1d5a5d2dad51a90d2617cd9f4187e6eb8f4159 Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Wed, 26 Dec 2018 11:06:54 +0530 Subject: [PATCH] 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 --- Makefile | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 33f4de6..3464565 100644 --- a/Makefile +++ b/Makefile @@ -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 /*.o") + $(V)find $(build_dir) -type f -name "*.o" -exec rm -rf {} + + $(if $(V), @echo " RM /*.a") + $(V)find $(build_dir) -type f -name "*.a" -exec rm -rf {} + + $(if $(V), @echo " RM /*.elf") + $(V)find $(build_dir) -type f -name "*.elf" -exec rm -rf {} + + $(if $(V), @echo " RM /*.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 /*.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 ") $(V)rm -rf $(build_dir) endif ifeq ($(install_dir),$(CURDIR)/install) - $(if $(V), @echo " RM $(install_dir)") + $(if $(V), @echo " RM ") $(V)rm -rf $(install_dir) endif