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=sass
|
||||||
|
SASSC_ARGS=--style compressed
|
||||||
PANDOC=pandoc
|
PANDOC=pandoc
|
||||||
|
PANDOC_ARGS=--css=../styling.css -V lang=en -V highlighting-css= --mathjax \
|
||||||
|
--smart --to=html5
|
||||||
TEST_MD=$(wildcard test_md/*.md)
|
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:
|
styling.css: styling.sass
|
||||||
$(SASSC) -t compressed styling.sass styling.css
|
$(SASSC) $(SASSC_ARGS) styling.sass styling.css
|
||||||
|
|
||||||
test: compile
|
check-size: styling.css
|
||||||
mkdir -p test_html
|
@echo "raw size: $(shell stat -c%s styling.css) bytes"
|
||||||
$(foreach i,$(TEST_MD),\
|
@echo "gziped size:" \
|
||||||
$(PANDOC) $(i) -o $(patsubst test_md/%.md,test_html/%.html,$(i)) \
|
"$(shell gzip -c styling.css | wc -c | awk '{print $1;}') bytes"
|
||||||
--standalone -t html5 --mathjax --smart -V highlighting-css= \
|
|
||||||
-V lang=en -c ../styling.css ;\
|
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:
|
clean:
|
||||||
rm -rf test_html
|
rm -rf styling.css test_html
|
||||||
rm -f styling.css
|
|
||||||
|
|
Loading…
Reference in a new issue