Greatly improve Makefile
- Only recompile the tests that have changed (Using macros and auto-generated targets! Eat that, automake!) - Compute file size and gziped size and display them - Use the `.PHONY` directive where relevant - Hide some minor commands and write out others clearer
This commit is contained in:
parent
b67b5d77a0
commit
316d53e25b
1 changed files with 21 additions and 12 deletions
33
Makefile
33
Makefile
|
@ -1,20 +1,29 @@
|
|||
.PHONY: all clean check-size
|
||||
SASSC=sass
|
||||
SASSC_ARGS=--style compressed
|
||||
PANDOC=pandoc
|
||||
PANDOC_ARGS=--css=../styling.css -V lang=en -V highlighting-css= --mathjax \
|
||||
--smart --to=html5
|
||||
TEST_MD=$(wildcard test_md/*.md)
|
||||
TEST_HTML=$(patsubst test_md/%.md,test_html/%.html,$(TEST_MD))
|
||||
|
||||
all: clean compile test
|
||||
all: styling.css $(TEST_HTML) check-size
|
||||
|
||||
compile:
|
||||
$(SASSC) -t compressed styling.sass styling.css
|
||||
styling.css: styling.sass
|
||||
$(SASSC) $(SASSC_ARGS) styling.sass styling.css
|
||||
|
||||
test: compile
|
||||
mkdir -p test_html
|
||||
$(foreach i,$(TEST_MD),\
|
||||
$(PANDOC) $(i) -o $(patsubst test_md/%.md,test_html/%.html,$(i)) \
|
||||
--standalone -t html5 --mathjax --smart -V highlighting-css= \
|
||||
-V lang=en -c ../styling.css ;\
|
||||
)
|
||||
check-size: styling.css
|
||||
@echo "raw size: $(shell stat -c%s styling.css) bytes"
|
||||
@echo "gziped size:" \
|
||||
"$(shell gzip -c styling.css | wc -c | awk '{print $1;}') bytes"
|
||||
|
||||
define TEST_TARGET
|
||||
$(patsubst test_md/%.md,test_html/%.html,$(1)): $(1)
|
||||
@mkdir -p test_html
|
||||
$(PANDOC) $(PANDOC_ARGS) $$< -o $$@
|
||||
endef
|
||||
|
||||
$(foreach i,$(TEST_MD),$(eval $(call TEST_TARGET,$(i))))
|
||||
|
||||
clean:
|
||||
rm -rf test_html
|
||||
rm -f styling.css
|
||||
rm -rf styling.css test_html
|
||||
|
|
Loading…
Reference in a new issue