summaryrefslogtreecommitdiff
path: root/Makefile
blob: cb23a87aa18875cb125a9c1228f5c998e09e326a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
suffix = .xhtml
link_suffix = $(suffix)
version = $(shell git rev-parse --short HEAD)

versioned_jpg = 's/.*/.jpg?&/'
versioned_png = 's/.*/.png?&/'

#versioned_jpg='s/.*/.&.jpg/'
#versioned_png='s/.*/.&.png/'

version_args = --stringparam versioned_jpg $(shell echo $(version) | sed $(versioned_jpg)) --stringparam versioned_png $(shell echo $(version) | sed $(versioned_png))

xsltproc=xsltproc --stringparam stylesheet "$(shell cat style.min.css)" --stringparam version $(version) $(version_args)
svg2png=rsvg-convert -f png
fix_doctype=sed 's/ SYSTEM "about:legacy-compat"//'

to_html=$(fix_doctype) | xsltproc xsl/convert-xhtml-to-html.xsl - | $(fix_doctype) | sed -e 's/<br><\/br>/<br>/g' -e 's/<\/img>//g' -e 's/<\/link>//g' -e 's/<\/meta>//g' -e 's/<html xmlns="http:\/\/www.w3.org\/1999\/xhtml"/<html/'

#html_minify=./node_modules/.bin/html-minifier  --html5 --remove-optional-tags --use-short-doctype --remove-attribute-quotes
html_minify=sed -f minify_html.sed

pages=$(shell xsltproc xsl/main_filenames.xsl main.xml)

pages_gen=$(pages:%.xml=%$(suffix))
pages_gen_html=$(pages:%.xml=%.html)

common_depend=main.xml $(wildcard xsl/*.xsl) Makefile checkmark.svg style.min.css minify_html.sed

DEFAULT_VERBOSITY=0

# verbosity stuff
V_XSLT = $(v_xslt_$(V))
v_xslt_ = $(v_xslt_$(DEFAULT_VERBOSITY))
v_xslt_0 = @echo "  XSLT  " $@;

V_GEN = $(v_gen_$(V))
v_gen_ = $(v_gen_$(DEFAULT_VERBOSITY))
v_gen_0 = @echo "  GEN   " $@;

V_CSS = $(v_css_$(V))
v_css_ = $(v_css_$(DEFAULT_VERBOSITY))
v_css_0 = @echo "  CSS   " $@;


.PHONY: all html
all: $(pages_gen) checkmark.png style.min.css

html: $(pages_gen_html)

%.png: %.svg
	$(V_GEN) $(svg2png) $< > $@

%$(suffix): %.xml %.xsl $(common_depend)
	$(V_XSLT) $(xsltproc) --stringparam suffix $(link_suffix) $< | $(fix_doctype) | perl -pe 'chomp if eof' > $@

%$(suffix): %.xml $(common_depend)
	$(V_XSLT) $(xsltproc) --stringparam suffix $(link_suffix) $< | $(fix_doctype) | perl -pe 'chomp if eof' > $@

%.html: %.xml %.xsl $(common_depend)
	$(V_XSLT) $(xsltproc) --stringparam suffix .html $< | $(to_html) | $(html_minify) | perl -pe 'chomp if eof' > $@

%.html: %.xml $(common_depend)
	$(V_XSLT) $(xsltproc) --stringparam suffix .html $< | $(to_html) | $(html_minify) | perl -pe 'chomp if eof' > $@

style.min.css: style.css font.css
	$(V_CSS) node_modules/.bin/postcss -u postcss-import -u postcss-css-variables style.css | node_modules/.bin/cleancss > style.min.css

clean:
	rm -f $(pages_gen) checkmark.png
	rm -f $(pages_gen_html)