tools: preserve make errors, ignore empty output
[sheet.git] / Makefile
index b12614a..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: tools/mkcharver data/DerivedAge.txt
-       $< $(word 2,$^) >$@
+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: tools/mkdigraphlist data/rfc1345.txt shiar.inc.txt
-       $< $(word 2,$^) >$@
+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: tools/mkcharinfo digraphs.inc.pl unicode-age.inc.pl
-       $< >$@
+data/xcolors/themes: data/xcolors
+data/xcolors:
+       $(call gitsave,https://github.com/tlatsas/xcolors)
 
-ttfsupport: tools/mkttfinfo
+data/termcol-xcolor.inc.pl: tools/mktermcol-xcolor data/xcolors/themes
+       $(call cmdsave,$^/*)
+
+.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) ttfsupport/all
+       $(MAKE) data/font/all
        touch $@
 
-ttfsupport/all: ttfsupport/all-ms ttfsupport/all-apple ttfsupport/all-dejavu ttfsupport/all-google ttfsupport/unifont.inc.pl ttfsupport/c2k.inc.pl
-
-ttfsupport/all-ms: ttfsupport/verdana.inc.pl ttfsupport/times.inc.pl ttfsupport/arial.inc.pl ttfsupport/courier.inc.pl ttfsupport/comic.inc.pl ttfsupport/georgia.inc.pl ttfsupport/arialuni.inc.pl
-ttfsupport/verdana.inc.pl: tools/mkttfinfo
-       $< Verdana.ttf $@
-ttfsupport/times.inc.pl: tools/mkttfinfo
-       $< Times_New_Roman.ttf $@
-ttfsupport/arial.inc.pl: tools/mkttfinfo
-       $< Arial.ttf $@
-ttfsupport/courier.inc.pl: tools/mkttfinfo
-       $< Courier_New.ttf $@
-ttfsupport/comic.inc.pl: tools/mkttfinfo
-       $< Comic_Sans_MS.ttf $@
-ttfsupport/georgia.inc.pl: tools/mkttfinfo
-       $< Georgia.ttf $@
-ttfsupport/arialuni.inc.pl: tools/mkttfinfo
-       $< 'arial*uni*.ttf' $@
-
-ttfsupport/all-apple: ttfsupport/lucida.inc.pl ttfsupport/garamond.inc.pl
-ttfsupport/lucida.inc.pl: tools/mkttfinfo
-       $< Lucida\?Grande.ttf $@
-ttfsupport/garamond.inc.pl: tools/mkttfinfo
-       $< AppleGaramond.ttf $@
-
-ttfsupport/all-dejavu: ttfsupport/dvsans.inc.pl ttfsupport/dvserif.inc.pl ttfsupport/dvmono.inc.pl
-ttfsupport/dvsans.inc.pl: tools/mkttfinfo
-       $< DejaVuSans.ttf $@
-ttfsupport/dvserif.inc.pl: tools/mkttfinfo
-       $< DejaVuSerif.ttf $@
-ttfsupport/dvmono.inc.pl: tools/mkttfinfo
-       $< DejaVuSansMono.ttf $@
-
-ttfsupport/all-google: ttfsupport/droid.inc.pl ttfsupport/droidserif.inc.pl ttfsupport/droidmono.inc.pl ttfsupport/roboto.inc.pl ttfsupport/noto.inc.pl ttfsupport/notoserif.inc.pl
-ttfsupport/droid.inc.pl: tools/mkttfinfo
-       $< DroidSans.ttf $@
-ttfsupport/droidserif.inc.pl: tools/mkttfinfo
-       $< DroidSerif-Regular.ttf $@
-ttfsupport/droidmono.inc.pl: tools/mkttfinfo
-       $< DroidSansMono.ttf $@
-ttfsupport/roboto.inc.pl: tools/mkttfinfo
-       $< Roboto-Regular.ttf $@
-ttfsupport/noto.inc.pl: tools/mkttfinfo
-       $< NotoSans-Regular.ttf $@
-ttfsupport/notoserif.inc.pl: tools/mkttfinfo
-       $< NotoSerif-Regular.ttf $@
-
-ttfsupport/unifont.inc.pl: tools/mkttfinfo
-       $< unifont.ttf $@
-ttfsupport/c2k.inc.pl: tools/mkttfinfo
-       $< code2000.ttf $@
-
-unicode-cover.inc.pl: tools/mkfontinfo ttfsupport
-       $< >$@
+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: tools/mkcountries-geonames data/countryInfo.txt
-       $< $(word 2,$^) >$@
+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: tools/mkcaniuse data/caniuse.json
-       $< $(word 2,$^) >$@
+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,$^)