tools: preserve make errors, ignore empty output
[sheet.git] / Makefile
index cf8618b..85fc990 100644 (file)
--- a/Makefile
+++ b/Makefile
-all: unicode-char.inc.pl unicode-cover.inc.pl countries.inc.pl data/browser/support.inc.pl
+all: sitemap.xml data/digraphs.inc.pl data/unicode-cover.inc.pl data/countries.inc.pl data/browser data/termcol-xcolor.inc.pl
+more: all data/digraphs-xorg.inc.pl
 
-download: data/DerivedAge.txt data/rfc1345.txt data/countryInfo.txt data/caniuse.json
+download: data/DerivedAge.txt data/rfc1345.txt data/xorg-compose data/countryInfo.txt data/browser/caniuse data/browser/usage-wm.tsv data/xcolors data/unicode-sampler
 .PHONY: download
 
+# atomically create file by command
+cmdsave = @echo $1 $2 \>$@; mispipe '$1 $2' 'ifne sponge $@'
+# download git checkout
+gitsave = @if cd $@ 2>/dev/null; \
+       then echo git pull $@; git pull -q --ff-only || true; \
+       else echo git clone $1 $@; git clone -q --progress $1 $@; fi
+
+sitemap.xml: tools/mksitemap
+       $(call cmdsave,$<)
+
 data/DerivedAge.txt:
        tools/wget-ifmodified http://www.unicode.org/Public/UNIDATA/$(@F) $@
 
-unicode-age.inc.pl: data/DerivedAge.txt
-       tools/mkcharver $< >$@
+data/unicode-age.inc.pl: tools/mkcharver data/DerivedAge.txt
+       $(call cmdsave,$^)
 
 data/rfc1345.txt:
        tools/wget-ifmodified http://www.ietf.org/rfc/$(@F) $@
 
-digraphs.inc.pl: data/rfc1345.txt shiar.inc.txt
-       tools/mkdigraphlist $< >$@
+data/digraphs-rfc.inc.pl: tools/mkdigraphs-rfc data/rfc1345.txt
+       $(call cmdsave,$^)
+
+data/digraphs-shiar.inc.pl: tools/mkdigraphs-shiar shiar.inc.txt
+       $(call cmdsave,$^)
+
+data/xorg-compose:
+       tools/wget-ifmodified http://cgit.freedesktop.org/xorg/lib/libX11/plain/nls/en_US.UTF-8/Compose.pre $@
+
+data/digraphs-xorg.inc.pl: tools/mkdigraphs-xorg data/xorg-compose
+       $(call cmdsave,$^)
+
+data/digraphs-vim.inc.pl: tools/mkdigraphs-vim
+       $(call cmdsave,$<)
+
+data/digraphs.inc.pl: tools/mkdigraphlist data/digraphs-rfc.inc.pl data/digraphs-vim.inc.pl data/digraphs-shiar.inc.pl data/unicode-char.inc.pl
+       $(call cmdsave,$<)
+
+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
+       $(call cmdsave,$<)
+
+data/font/%.inc.pl: tools/mkttfinfo data/font/%.ttf
+       $(call cmdsave,$^) || true
+
+data/unicode-sampler:
+       $(call gitsave,git://git.shiar.nl/unicode-sampler)
 
-unicode-char.inc.pl: digraphs.inc.pl unicode-age.inc.pl
-       tools/mkcharinfo >$@
+data/xcolors/themes: data/xcolors
+data/xcolors:
+       $(call gitsave,https://github.com/tlatsas/xcolors)
 
-ttfsupport:
-       mkdir -p ttfsupport
-       tools/convert-allfonts
+data/termcol-xcolor.inc.pl: tools/mktermcol-xcolor data/xcolors/themes
+       $(call cmdsave,$^/*)
 
-unicode-cover.inc.pl: ttfsupport tools/mkfontinfo
-       tools/mkfontinfo >$@
+.SECONDARY:
+data/font/%.ttf:
+       find /usr/share/fonts/truetype/ ~/.fonts/ -iname "$(@F)" | head -1 | xargs -i ln -sf {} $@
+data/font/%.win2k.ttf:
+       find /usr/share/fonts/truetype/msttcorefonts/ -iname "$(*F).ttf" | head -1 | xargs -i ln -sf {} $@
+data/font/dv%.ttf:
+       find /usr/share/fonts/truetype/dejavu/ -iname "DejaVu*$(*F).ttf" | head -1 | xargs -i ln -sf {} $@
+data/font/droid%.ttf:
+       find /usr/share/fonts/truetype/droid/ -iname "Droid*$(*F).ttf" | head -1 | xargs -i ln -sf {} $@
+data/font/droidserif.ttf:
+       ln -sf /usr/share/fonts/truetype/droid/DroidSerif-Regular.ttf $@
+data/font/free%.ttf:
+       find /usr/share/fonts/truetype/freefont/ -iname "$(@F)" | head -1 | xargs -i ln -sf {} $@
+data/font/roboto.ttf:
+       ln -sf /usr/share/fonts/truetype/roboto/Roboto-Regular.ttf $@
+data/font/noto%.ttf:
+       find /usr/share/fonts/truetype/noto/ -iname "Noto$(*F)-Regular.ttf" | head -1 | xargs -i ln -sf {} $@
+
+data/font: tools/mkttfinfo
+       mkdir -p $@
+       $(MAKE) data/font/all
+       touch $@
+
+data/font/all: data/font/all-win2k data/font/all-dejavu data/font/all-google data/font/all-other
+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
+data/font/all-dejavu: data/font/dvsans.inc.pl data/font/dvserif.inc.pl data/font/dvmono.inc.pl
+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
+data/font/all-other: data/font/unifont.inc.pl data/font/code2000.inc.pl data/font/freesans.inc.pl data/font/freeserif.inc.pl
+
+#data/font/unifont.inc.pl: tools/mkttfinfo
+#      $< unifont.ttf $@
+#      $< --headless unifont_upper.ttf >>$@
+
+data/unicode-cover.inc.pl: tools/mkfontinfo data/font $(patsubst data/font/%.ttf,data/font/%.inc.pl,$(wildcard data/font/*.ttf))
+       $(call cmdsave,$<)
 
 data/countryInfo.txt:
        tools/wget-ifmodified http://download.geonames.org/export/dump/$(@F) $@
 
-countries.inc.pl: data/countryInfo.txt
-       tools/mkcountries-geonames $< >$@
+data/countries.inc.pl: tools/mkcountries-geonames data/countryInfo.txt
+       $(call cmdsave,$^)
+
+data/browser: data/browser/support.inc.pl data/browser/usage-wm.inc.pl
 
-data/caniuse.json:
-       tools/wget-ifmodified http://caniuse.com/data.json $@
+data/browser/caniuse/data.json: data/browser/caniuse
+data/browser/caniuse:
+       $(call gitsave,https://github.com/Fyrd/caniuse.git)
 
-data/browser/support.inc.pl: data/caniuse.json
-       tools/mkcaniuse $< >$@
+data/browser/support.inc.pl: tools/mkcaniuse data/browser/caniuse/data.json
+       $(call cmdsave,$^)
+
+data/browser/usage-wm.tsv:
+       tools/wget-ifmodified https://analytics.wikimedia.org/datasets/periodic/reports/metrics/browser/all_sites_by_browser_family_and_major_percent.tsv $@
+
+data/browser/usage-wm.inc.pl: tools/mkusage-wikimedia data/browser/usage-wm.tsv
+       $(call cmdsave,$^)
 
 clean:
-       -rm digraphs.inc.pl
-       -rm unicode-char.inc.pl
-       -rm unicode-age.inc.pl
-       -rm -rf ttfsupport/
-       -rm unicode-cover.inc.pl
+       -rm data/digraphs.inc.pl
+       -rm data/unicode-char.inc.pl
+       -rm data/unicode-age.inc.pl
+       -rm -rf data/font/
+       -rm data/unicode-cover.inc.pl
        -rm data/browser/support.inc.pl
+       -rm data/browser/usage-wm.inc.pl
+
+.SECONDEXPANSION:
+
+data/writing-latn.inc.pl: tools/perlinc-static $$(@F)
+       $(call cmdsave,$^)