From 3abb10e9107226e2e9353913abef691b37e84377 Mon Sep 17 00:00:00 2001 From: Jeff Donahue Date: Sat, 29 Mar 2014 17:47:58 -0700 Subject: [PATCH] create superclean Makefile target to delete all files with generated extensions --- Makefile | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a432c87..ac91df7 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,8 @@ PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library)) # Define build targets ############################## .PHONY: all init test clean linecount lint tools examples py mat distribute \ - py$(PROJECT) mat$(PROJECT) proto runtest + py$(PROJECT) mat$(PROJECT) proto runtest \ + superclean supercleanlist supercleanfiles all: init $(NAME) $(STATIC_NAME) tools examples @echo $(CXX_OBJS) @@ -260,6 +261,40 @@ clean: @- $(RM) -rf $(BUILD_DIR) @- $(RM) -rf $(DISTRIBUTE_DIR) +# make superclean recursively* deletes all files ending with an extension +# suggesting that Caffe built them. This may be useful if you've built older +# versions of Caffe that do not place all generated files in a location known +# to make clean. +# +# make supercleanlist will list the files to be deleted by make superclean. +# +# * Recursive with the exception that symbolic links are never followed, per the +# default behavior of 'find'. +SUPERCLEAN_EXTS := .so .a .o .bin .testbin .pb.cc .pb.h _pb2.py .cuo + +supercleanfiles: + $(eval SUPERCLEAN_FILES := \ + $(strip $(foreach ext,$(SUPERCLEAN_EXTS), \ + $(shell find . -name '*$(ext)')))) + +supercleanlist: supercleanfiles + @ \ + if [ -z "$(SUPERCLEAN_FILES)" ]; then \ + echo "No generated files found."; \ + else \ + echo $(SUPERCLEAN_FILES); \ + fi + +superclean: clean supercleanfiles + @ \ + if [ -z "$(SUPERCLEAN_FILES)" ]; then \ + echo "No generated files found."; \ + else \ + echo "Deleting the following generated files:"; \ + echo $(SUPERCLEAN_FILES); \ + $(RM) $(SUPERCLEAN_FILES); \ + fi + distribute: all mkdir $(DISTRIBUTE_DIR) # add include -- 2.7.4