diff options
author | Ulrich Müller <ulm@gentoo.org> | 2020-02-06 14:04:23 +0100 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2020-02-06 14:04:23 +0100 |
commit | a08319d85e0e3054aaa8048b4d51fc534533e23e (patch) | |
tree | 05114a6380984e974ae9e74686dafad53f990876 /Makefile | |
parent | offline.css: Add vertical margin to header and footer. (diff) | |
download | devmanual-a08319d85e0e3054aaa8048b4d51fc534533e23e.tar.gz devmanual-a08319d85e0e3054aaa8048b4d51fc534533e23e.tar.bz2 devmanual-a08319d85e0e3054aaa8048b4d51fc534533e23e.zip |
Makefile: New target "delete-old".
This will delete any orphaned html and image files that could be
left over after the corresponding source file was moved or removed.
Such files are also not covered by "clean", so add the new target as
prerequisite.
Run a single "find" pass to get a list of all files in ALL_FILES and
subsequently extract the necessary subsets from it. The list of all
files is needed anyway for deletion of orphans, which are not included
in HTMLS or IMAGES.
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -1,16 +1,16 @@ -# These "find" commands match text.xml and *.svg files, respectively, -# but only after excluding the .git directory from the search for -# performance and overall sanity reasons. -XMLS := $(shell find . -name .git -prune -o -type f -name 'text.xml' -print) -SVGS := $(shell find . -name .git -prune -o -type f -name '*.svg' -print) +# Run a single "find" pass to get a list of all files (with the .git +# directory excluded), then filter out what we need. +ALL_FILES := $(shell find . -name .git -prune -o -type f -print) +XMLS := $(filter %/text.xml,$(ALL_FILES)) +SVGS := $(filter %.svg,$(ALL_FILES)) HTMLS := $(subst text.xml,index.html,$(XMLS)) -ECLASS_HTMLS := $(wildcard eclass-reference/*/index.html) +ECLASS_HTMLS := $(filter ./eclass-reference/%/index.html,$(ALL_FILES)) IMAGES := $(patsubst %.svg,%.png,$(SVGS)) # Nonzero value disables external assets for offline browsing. OFFLINE = 0 -all: prereq validate build documents.js +all: prereq validate delete-old build documents.js prereq: @type rsvg-convert >/dev/null 2>&1 || \ @@ -70,7 +70,14 @@ tidy: $(HTMLS) $(ECLASS_HTMLS) test $${status} -eq 0 && echo "tidy validation successful"; \ exit $${status} -clean: - rm -f $(HTMLS) $(IMAGES) _documents.js documents.js +# Delete any orphaned html and image files that could be left over +# after the corresponding source file was moved or removed. +delete-old: + @-rm -f $(filter-out $(HTMLS) $(ECLASS_HTMLS) $(IMAGES), \ + $(filter %/index.html %.png,$(ALL_FILES))) + @find . ! -path './.git*' -type d -empty -delete -.PHONY: all prereq validate build tidy clean +clean: delete-old + @rm -f $(HTMLS) $(IMAGES) _documents.js documents.js + +.PHONY: all prereq validate build tidy delete-old clean |