1 |
commit: a08319d85e0e3054aaa8048b4d51fc534533e23e |
2 |
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Feb 6 13:04:23 2020 +0000 |
4 |
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Feb 6 13:04:23 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=a08319d8 |
7 |
|
8 |
Makefile: New target "delete-old". |
9 |
|
10 |
This will delete any orphaned html and image files that could be |
11 |
left over after the corresponding source file was moved or removed. |
12 |
Such files are also not covered by "clean", so add the new target as |
13 |
prerequisite. |
14 |
|
15 |
Run a single "find" pass to get a list of all files in ALL_FILES and |
16 |
subsequently extract the necessary subsets from it. The list of all |
17 |
files is needed anyway for deletion of orphans, which are not included |
18 |
in HTMLS or IMAGES. |
19 |
|
20 |
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> |
21 |
|
22 |
Makefile | 27 +++++++++++++++++---------- |
23 |
1 file changed, 17 insertions(+), 10 deletions(-) |
24 |
|
25 |
diff --git a/Makefile b/Makefile |
26 |
index ef2c735..d379bd3 100644 |
27 |
--- a/Makefile |
28 |
+++ b/Makefile |
29 |
@@ -1,16 +1,16 @@ |
30 |
-# These "find" commands match text.xml and *.svg files, respectively, |
31 |
-# but only after excluding the .git directory from the search for |
32 |
-# performance and overall sanity reasons. |
33 |
-XMLS := $(shell find . -name .git -prune -o -type f -name 'text.xml' -print) |
34 |
-SVGS := $(shell find . -name .git -prune -o -type f -name '*.svg' -print) |
35 |
+# Run a single "find" pass to get a list of all files (with the .git |
36 |
+# directory excluded), then filter out what we need. |
37 |
+ALL_FILES := $(shell find . -name .git -prune -o -type f -print) |
38 |
+XMLS := $(filter %/text.xml,$(ALL_FILES)) |
39 |
+SVGS := $(filter %.svg,$(ALL_FILES)) |
40 |
HTMLS := $(subst text.xml,index.html,$(XMLS)) |
41 |
-ECLASS_HTMLS := $(wildcard eclass-reference/*/index.html) |
42 |
+ECLASS_HTMLS := $(filter ./eclass-reference/%/index.html,$(ALL_FILES)) |
43 |
IMAGES := $(patsubst %.svg,%.png,$(SVGS)) |
44 |
|
45 |
# Nonzero value disables external assets for offline browsing. |
46 |
OFFLINE = 0 |
47 |
|
48 |
-all: prereq validate build documents.js |
49 |
+all: prereq validate delete-old build documents.js |
50 |
|
51 |
prereq: |
52 |
@type rsvg-convert >/dev/null 2>&1 || \ |
53 |
@@ -70,7 +70,14 @@ tidy: $(HTMLS) $(ECLASS_HTMLS) |
54 |
test $${status} -eq 0 && echo "tidy validation successful"; \ |
55 |
exit $${status} |
56 |
|
57 |
-clean: |
58 |
- rm -f $(HTMLS) $(IMAGES) _documents.js documents.js |
59 |
+# Delete any orphaned html and image files that could be left over |
60 |
+# after the corresponding source file was moved or removed. |
61 |
+delete-old: |
62 |
+ @-rm -f $(filter-out $(HTMLS) $(ECLASS_HTMLS) $(IMAGES), \ |
63 |
+ $(filter %/index.html %.png,$(ALL_FILES))) |
64 |
+ @find . ! -path './.git*' -type d -empty -delete |
65 |
|
66 |
-.PHONY: all prereq validate build tidy clean |
67 |
+clean: delete-old |
68 |
+ @rm -f $(HTMLS) $(IMAGES) _documents.js documents.js |
69 |
+ |
70 |
+.PHONY: all prereq validate build tidy delete-old clean |