perl: missing minor v5.14 features
[sheet.git] / Makefile
1 all: sitemap.xml style plan.plp UPDATE data cache
2
3 .PHONY: force # applied to download after 2 hours
4 download := $(shell [ -z $$(find data/download -mmin -120) ] && (touch data/download && echo force))
5
6 # atomically create file by command
7 cmdsave = @echo "$1" $2 \>$@; mispipe "$1 $2" 'ifne sponge $@'
8 # download git checkout
9 gitsave = @if cd $@ 2>/dev/null; \
10         then echo git pull $@; git pull -q --ff-only || true; \
11         else echo git clone $1 $@; git clone -q --progress $1 $@; fi
12
13 sitemap.xml: tools/mksitemap
14         $(call cmdsave,$<)
15
16 style: light.css sc.css
17 %.css: style/%.scss $(wildcard style/_*.scss)
18         $(call cmdsave,sassc -t compressed $< | perl -pE 's/\}+\K/\n/g')
19
20 plan.plp: TODO
21         kramdown $< >$@
22
23 UPDATE: $(download)
24         $(call cmdsave,git log -1 --date=short --pretty='%ad    %s')
25
26 cache: $(patsubst %.inc.pl,data/%.json,$(wildcard charset-*.inc.pl) $(wildcard keyboard/altgr/*.inc.pl) writing-latn.inc.pl)
27 word: word/put.min.js data/wordlist.en.json data/wordlist.nl.json data/wordlist.ru.json data/wordpairs.json
28
29 word/put.js: $(download)
30         tools/wget-ifmodified https://github.com/kriszyp/put-selector/raw/master/put.js $@
31 word/%.min.js: word/%.js
32         uglifyjs -m '' $< -o $@
33
34 data: data/digraphs.json data/unicode-cover.inc.pl data/countries.inc.pl data/browser data/termcol-xcolor.inc.pl data/digraphs-xorg.json data/unicode-sampler word keyboard/symbols/unigraph
35
36 data/DerivedAge.txt: $(download)
37         tools/wget-ifmodified http://www.unicode.org/Public/UNIDATA/$(@F) $@
38
39 data/unicode-age.inc.pl: tools/mkcharver data/DerivedAge.txt
40         $(call cmdsave,$^)
41
42 data/rfc1345.txt: $(download)
43         tools/wget-ifmodified http://www.ietf.org/rfc/$(@F) $@
44
45 data/digraphs-rfc.inc.pl: tools/mkdigraphs-rfc data/rfc1345.txt
46         $(call cmdsave,$^)
47
48 data/digraphs-shiar.inc.pl: tools/mkdigraphs-shiar shiar.inc.txt
49         $(call cmdsave,$^)
50
51 data/xorg-compose: $(download)
52         tools/wget-ifmodified http://gitlab.freedesktop.org/xorg/lib/libx11/-/raw/master/nls/en_US.UTF-8/Compose.pre $@
53 data/keysymdef.h: $(download)
54         tools/wget-ifmodified http://gitlab.freedesktop.org/xorg/proto/xorgproto/-/raw/master/include/X11/$(@F) $@
55 data/keysymdef.json: tools/mkxkeysymdef data/keysymdef.h
56         $(call cmdsave,$^)
57 data/digraphs-xorg.json: tools/mkdigraphs-xorg data/xorg-compose data/keysymdef.json
58         $(call cmdsave,$^)
59
60 keyboard/symbols/%: tools/mkxkbsymbols data/keyboard/altgr/%.eng.json
61         $(call cmdsave,$^)
62
63 data/digraphs-vim.inc.pl: tools/mkdigraphs-vim
64         $(call cmdsave,$<)
65
66 data/digraphs-plan9.txt:
67         tools/wget-ifmodified https://9fans.github.io/usr/local/plan9/lib/keyboard $@
68 data/digraphs-plan9.inc.pl: tools/mkdigraphs-plan9 data/digraphs-plan9.txt
69         $(call cmdsave,$^)
70
71 data/digraphs.json: tools/mkdigraphlist data/digraphs-rfc.inc.pl data/digraphs-vim.inc.pl data/digraphs-shiar.inc.pl data/unicode-char.inc.pl
72         $(call cmdsave,$<)
73
74 data/unicode-char.inc.pl: tools/mkcharinfo data/digraphs-rfc.inc.pl data/digraphs-shiar.inc.pl data/unicode-age.inc.pl unicode-table.inc.pl
75         $(call cmdsave,$<)
76
77 data/font/%.inc.pl: tools/mkttfinfo data/font/%.ttf #TODO ttc
78         $(call cmdsave,$^) || true
79
80 data/unicode-sampler: $(download)
81         $(call gitsave,git://git.shiar.nl/unicode-sampler)
82
83 data/xcolors/themes: data/xcolors
84 data/xcolors: $(download)
85         $(call gitsave,https://github.com/tlatsas/xcolors)
86
87 data/termcol-xcolor.inc.pl: tools/mktermcol-xcolor data/xcolors/themes
88         $(call cmdsave,$^/*)
89
90 data/camels.pexels-4321178.jpg:
91         tools/wget-ifmodified https://images.pexels.com/photos/4321178/pexels-photo-4321178.jpeg $@
92 data/camels.jpg: data/camels.pexels-4321178.jpg
93         tools/mkimgthumb --jpg 800x400 'data/camels.smaller:-area:0x225.jpg' .
94
95 data/wordlist.version.txt: force
96         @[ -e $@ ] || date -Is >$@
97         tools/lastword $@ || true
98
99 data/wordlist.%.inc.pl: tools/mkwordlist data/wordlist.version.txt
100         $(call cmdsave,$< $*)
101 data/word%.json: data/word%.inc.pl
102         $(call cmdsave,tools/mkjson $<)
103 data/%.json: %.inc.pl
104         $(call cmdsave,tools/mkjson $<)
105
106 data/wordpairs.inc.pl: data/wordlist.version.txt
107         tools/wordpairs >$@
108
109 .SECONDARY: data/font/%.ttf
110 data/font/%.ttf:
111         find /usr/share/fonts/truetype/ ~/.fonts/ -iname "$(@F)" | head -1 | xargs -i ln -sf {} $@
112 data/font/%.win2k.ttf:
113         find /usr/share/fonts/truetype/msttcorefonts/ -iname "$(*F).ttf" | head -1 | xargs -i ln -sf {} $@
114 data/font/dv%.ttf:
115         find /usr/share/fonts/truetype/dejavu/ -iname "DejaVu*$(*F).ttf" | head -1 | xargs -i ln -sf {} $@
116 data/font/droid%.ttf:
117         find /usr/share/fonts/truetype/droid/ -iname "Droid*$(*F).ttf" | head -1 | xargs -i ln -sf {} $@
118 data/font/droidserif.ttf:
119         ln -sf /usr/share/fonts/truetype/droid/DroidSerif-Regular.ttf $@
120 data/font/free%.ttf:
121         find /usr/share/fonts/truetype/freefont/ -iname "$(@F)" | head -1 | xargs -i ln -sf {} $@
122 data/font/roboto.ttf:
123         ln -sf /usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Regular.ttf $@
124 data/font/noto%.ttf:
125         find /usr/share/fonts/truetype/noto/ -iname "Noto$(*F)-Regular.ttf" | head -1 | xargs -i ln -sf {} $@
126
127 data/font: tools/mkttfinfo
128         mkdir -p $@
129         $(MAKE) data/font/all
130         touch $@
131
132 data/font/all: data/font/all-win2k data/font/all-dejavu data/font/all-google data/font/all-other
133 data/font/all-win2k: data/font/verdana.win2k.inc.pl data/font/times.win2k.inc.pl data/font/arial.win2k.inc.pl data/font/cour.win2k.inc.pl data/font/comic.win2k.inc.pl data/font/georgia.win2k.inc.pl data/font/arialuni.inc.pl
134 data/font/all-dejavu: data/font/dvsans.inc.pl data/font/dvserif.inc.pl data/font/dvmono.inc.pl
135 data/font/all-google: data/font/droidsans.inc.pl data/font/droidserif.inc.pl data/font/droidmono.inc.pl data/font/roboto.inc.pl data/font/notosans.inc.pl data/font/notoserif.inc.pl
136 data/font/all-other: data/font/unifont.inc.pl data/font/code2000.inc.pl data/font/freesans.inc.pl data/font/freeserif.inc.pl
137
138 #data/font/unifont.inc.pl: tools/mkttfinfo
139 #       $< unifont.ttf $@
140 #       $< --headless unifont_upper.ttf >>$@
141
142 data/unicode-cover.inc.pl: tools/mkfontinfo data/font # $(wildcard data/font/*.inc.pl)
143         $(call cmdsave,$<)
144
145 data/countryInfo.txt: $(download)
146         tools/wget-ifmodified http://download.geonames.org/export/dump/$(@F) $@
147
148 data/countries.inc.pl: tools/mkcountries-geonames data/countryInfo.txt
149         $(call cmdsave,$^)
150
151 data/browser: data/browser/support.inc.pl data/browser/usage-wm.inc.pl
152
153 data/browser/caniuse/fulldata-json/data-2.0.json: data/browser/caniuse
154 data/browser/caniuse/data.json: data/browser/caniuse
155 data/browser/caniuse: $(download)
156         $(call gitsave,https://github.com/Fyrd/caniuse.git)
157
158 data/browser/support.inc.pl: tools/mkcaniuse data/browser/caniuse/fulldata-json/data-2.0.json
159         $(call cmdsave,$^)
160
161 data/browser/usage-wm.tsv: $(download)
162         tools/wget-ifmodified https://analytics.wikimedia.org/datasets/periodic/reports/metrics/browser/all_sites_by_browser_family_and_major_percent.tsv $@
163
164 data/browser/usage-wm.inc.pl: tools/mkusage-wikimedia data/browser/usage-wm.tsv
165         $(call cmdsave,$^)
166
167 clean:
168         -rm data/digraphs.json
169         -rm data/unicode-char.inc.pl
170         -rm data/unicode-age.inc.pl
171         -rm -rf data/font/
172         -rm data/unicode-cover.inc.pl
173         -rm data/browser/support.inc.pl
174         -rm data/browser/usage-wm.inc.pl
175