From 5a5d10b67d21c24560ea35a9fda7827946e90404 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Mon, 8 Jul 2024 20:58:22 +0300 Subject: [PATCH] Makefile: remove multiple directories in one call --- Makefile | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 7b7ce81..9d661d2 100644 --- a/Makefile +++ b/Makefile @@ -51,18 +51,20 @@ define rmfiles_if_exist done endef -define rmdir_if_empty - @if [ -d "$1" ]; then \ - if [ -z "$$(find "$1" -mindepth 1 -maxdepth 1 -print -quit)" ]; then \ - echo "Removing empty directory $1"; \ - rm -r $1; \ +define rmdirs_if_empty + @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"; \ + rm -r $$dir; \ + fi; \ fi; \ - fi + done endef clean: $(call rmfiles_if_exist,$(EXECPATH) $(DEP) $(OBJ)) - $(call rmdir_if_empty,$(BINDIR)) - $(call rmdir_if_empty,$(OBJDIR)) + $(call rmdirs_if_empty,$(BINDIR) $(OBJDIR)) .PHONY: all clean