1# checks for left-over files in the (usually uninstalled) tree, ie. for
2# stuff that best be deleted to avoid problems like having old plugin binaries
3# lying around.
4#
5# set CRUFT_FILES and/or CRUFT_DIRS in your Makefile.am when you include this
6
7check-cruft:
8	@cruft_files=""; cruft_dirs=""; \
9	for f in $(CRUFT_FILES); do \
10	  if test -e $$f; then \
11	    cruft_files="$$cruft_files $$f"; \
12	  fi \
13	done; \
14	for d in $(CRUFT_DIRS); do \
15	  if test -e $$d; then \
16	    cruft_dirs="$$cruft_dirs $$d"; \
17	  fi \
18	done; \
19	if test "x$$cruft_files$$cruft_dirs" != x; then \
20	  echo; \
21	  echo "**** CRUFT ALERT *****"; \
22	  echo; \
23	  echo "The following files and directories may not be needed any "; \
24	  echo "longer (usually because a plugin has been merged into     "; \
25	  echo "another plugin, moved to a different module, or been      "; \
26	  echo "renamed), and you probably want to clean them up if you   "; \
27	  echo "don't have local changes:                                 "; \
28	  echo; \
29	  for f in $$cruft_files; do echo "file $$f"; done; \
30	  echo; \
31	  for d in $$cruft_dirs; do echo "directory $$d"; done; \
32	  echo; \
33	  echo "'make clean-cruft' will remove these for you."; \
34	  echo; \
35	fi
36
37clean-cruft-dirs:
38	@for d in $(CRUFT_DIRS); do \
39	  if test -e $$d; then \
40	    rm -r "$$d" && echo "Removed directory $$d"; \
41	  fi \
42	done
43
44clean-cruft-files:
45	@for f in $(CRUFT_FILES); do \
46	  if test -e $$f; then \
47	    rm "$$f" && echo "Removed file $$f"; \
48	  fi \
49	done
50
51clean-cruft: clean-cruft-dirs clean-cruft-files
52
53# also might want to add this to your Makefile.am:
54#
55# all-local: check-cruft
56
57