Update ignore list for new source file patterns.
[fontstandard.git] / Makefile
1 #!/usr/bin/make -f
2
3 CODEPOINT := \\([0-9a-fA-F]{2,5})
4
5 .DELETE_ON_ERROR:
6 .SECONDARY:
7 .PHONY: all clean superclean
8
9 FORMATS := ttf woff
10 FONTSTANDARD := $(addprefix fontstandard.,$(FORMATS))
11
12 FAVERSION ?= v4.2.0
13 URL := https://github.com/FortAwesome/Font-Awesome/raw/$(FAVERSION)
14
15 SUBVERSION := 1
16 VERSION := $(shell echo $(FAVERSION) | sed -E 's/[^0-9]//g').$(SUBVERSION)
17 FONTAWESOME := FontAwesome_$(VERSION).otf
18 VARIABLES := variables_$(VERSION).less
19
20 all: $(FONTSTANDARD)
21
22 FONTFORGE ?= fontforge
23 CONVERT.ttf.woff := echo 'Open($$1); Generate($$2)' | $(FONTFORGE)
24
25 fontstandard.ttf: $(FONTAWESOME) fontstandard.fontforge
26 $(FONTFORGE) $< $@ < fontstandard.fontforge
27
28 %.woff: %.ttf
29 $(CONVERT.ttf.woff) $< $@
30
31 $(FONTAWESOME):
32 wget -O $@ $(URL)/fonts/FontAwesome.otf
33
34 $(VARIABLES):
35 wget -O $@ $(URL)/less/variables.less
36
37 %.fontforge: $(VARIABLES) %.remove.txt %.preamble.txt %.remap.txt
38 echo 'Open($$1); Reencode("unicode4");' > $@
39 sed -E 's/__VERSION__/$(VERSION)/' < $*.preamble.txt >> $@
40 grep -E "@fa-var-("$$(grep -v '^#' $*.remove.txt \
41 | paste -sd '|' -)")[-a-z]*:" $(VARIABLES) \
42 | sed -E 's/.*$(CODEPOINT).*/SelectMore(0u\1);/g' >> $@
43 echo 'DetachAndRemoveGlyphs();' >> $@
44
45 grep -v '^#' $*.remap.txt | while read -r dst src rest; do \
46 (grep -E -m 1 "@fa-var-$${src}:" $(VARIABLES) \
47 || echo "$${src} not found." >&2) \
48 | sed -E 's/.*$(CODEPOINT).*/Select(0u\1); CopyReference(); Select(0u'$${dst}'); Paste();/g' >> $@ \
49 ; done
50
51 echo 'Generate($$2)' >> $@
52
53 clean:
54 $(RM) fontstandard.fontforge
55 $(RM) $(FONTSTANDARD)
56
57 superclean: clean
58 $(RM) $(FONTAWESOME)
59 $(RM) $(VARIABLES)