From f4726c1d270189d13ba9f2491dd35776d28126d5 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Mon, 8 Jul 2024 21:04:41 +0300 Subject: [PATCH] Makefile: add target `distclean` --- Makefile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9d661d2..339998b 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,20 @@ define rmfiles_if_exist done endef +define rmdirs + @for dir in $1; do \ + if [ -d "$$dir" ]; then \ + if [ -z "$$(find "$$dir" -mindepth 1 -maxdepth 1 -print -quit)" ]; \ + then \ + echo "Removing empty directory $$dir"; \ + else \ + echo "Removing non-empty directory $$dir"; \ + fi; \ + rm -r $$dir; \ + fi; \ + done +endef + define rmdirs_if_empty @for dir in $1; do \ if [ -d "$$dir" ]; then \ @@ -67,4 +81,7 @@ clean: $(call rmfiles_if_exist,$(EXECPATH) $(DEP) $(OBJ)) $(call rmdirs_if_empty,$(BINDIR) $(OBJDIR)) -.PHONY: all clean +distclean: + $(call rmdirs,$(BINDIR) $(OBJDIR)) + +.PHONY: all clean distclean