summaryrefslogtreecommitdiff
path: root/makefiles/gmake/clean.mk
diff options
context:
space:
mode:
Diffstat (limited to 'makefiles/gmake/clean.mk')
-rw-r--r--makefiles/gmake/clean.mk38
1 files changed, 38 insertions, 0 deletions
diff --git a/makefiles/gmake/clean.mk b/makefiles/gmake/clean.mk
new file mode 100644
index 0000000..d416905
--- /dev/null
+++ b/makefiles/gmake/clean.mk
@@ -0,0 +1,38 @@
+# cleans up directories
+#
+# requires:
+# - SUBDIRS: for recursive cleaning
+# - local_clean, local_distclean targets in local GNUmakefile
+# - all artifacts to clean:
+# - BINS, TEST_BINS, TEST_CPP_BINS, CPP_BINS
+# - OBJS, CPPOBJS, BIN_OBJS, TEST_BIN_OBJS, CPP_BIN_OBJS, TEST_CPP_BIN_OBJS
+# - CMODULES, CPPMODULES
+#
+# provides:
+# - target: clean
+# - target: distclean
+
+.PHONY: clean_recursive clean local_clean
+
+clean_recursive:
+ @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \
+ (set -e; $(MAKE) -C $$d clean || exit 1); done)
+
+clean: clean_recursive local_clean
+ -@rm -f *.bak 2>/dev/null
+ -@rm -f *~ 2>/dev/null
+ -@rm -f *.d port/*.d 2>/dev/null
+ -@rm -f $(BINS) $(CPP_BINS) $(TEST_BINS) $(TEST_CPP_BINS) 2>/dev/null
+ -@rm -f $(OBJS) $(CPP_OBJS) $(BIN_OBJS) $(TEST_BIN_OBJS) $(CPP_BIN_OBJS) $(TEST_CPP_BIN_OBJS) 2>/dev/null
+ -@rm -f exec/*
+ -@rm -f *.core
+ -@rm -f $(CMODULES) $(CPPMODULES)
+ -@rm -f $(CMODULES .o=.d) $(CPPMODULES .o=.d)
+
+.PHONY: distclean_recursive distclean local_distclean
+
+distclean_recursive:
+ @test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \
+ (set -e; $(MAKE) -C $$d distclean || exit 1); done)
+
+distclean: distclean_recursive local_distclean clean