tools: preserve make errors, ignore empty output
[sheet.git] / Makefile
index 6a46507..85fc990 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,44 +1,61 @@
-all: digraphs.inc.pl unicode-cover.inc.pl countries.inc.pl data/browser/support.inc.pl termcol-xcolor.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/xorg-compose 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) $@
 
 data/digraphs-rfc.inc.pl: tools/mkdigraphs-rfc data/rfc1345.txt
-       $< $(word 2,$^) >$@
+       $(call cmdsave,$^)
 
 data/digraphs-shiar.inc.pl: tools/mkdigraphs-shiar shiar.inc.txt
-       $< $(word 2,$^) >$@
+       $(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
-       $< $(word 2,$^) >$@
+       $(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,$<)
 
-digraphs.inc.pl: tools/mkdigraphlist data/digraphs-rfc.inc.pl data/digraphs-vim.inc.pl data/digraphs-shiar.inc.pl unicode-char.inc.pl
-       $< >$@
+data/font/%.inc.pl: tools/mkttfinfo data/font/%.ttf
+       $(call cmdsave,$^) || true
 
-unicode-char.inc.pl: tools/mkcharinfo data/digraphs-rfc.inc.pl data/digraphs-shiar.inc.pl unicode-age.inc.pl
-       $< >$@
+data/unicode-sampler:
+       $(call gitsave,git://git.shiar.nl/unicode-sampler)
 
-ttfsupport/%.inc.pl: tools/mkttfinfo data/font/%.ttf
-       $< $(word 2,$^) $@ || true
+data/xcolors/themes: data/xcolors
+data/xcolors:
+       $(call gitsave,https://github.com/tlatsas/xcolors)
 
-termcol-xcolor.inc.pl: tools/mktermcol-xcolor data/xcolors/themes
-       $< $(word 2,$^)/* >$@
+data/termcol-xcolor.inc.pl: tools/mktermcol-xcolor data/xcolors/themes
+       $(call cmdsave,$^/*)
 
 .SECONDARY:
 data/font/%.ttf:
@@ -58,46 +75,56 @@ data/font/roboto.ttf:
 data/font/noto%.ttf:
        find /usr/share/fonts/truetype/noto/ -iname "Noto$(*F)-Regular.ttf" | head -1 | xargs -i ln -sf {} $@
 
-ttfsupport: tools/mkttfinfo
+data/font: tools/mkttfinfo
        mkdir -p $@
-       $(MAKE) ttfsupport/all
+       $(MAKE) data/font/all
        touch $@
 
-ttfsupport/all: ttfsupport/all-win2k ttfsupport/all-dejavu ttfsupport/all-google ttfsupport/all-other
-ttfsupport/all-win2k: ttfsupport/verdana.win2k.inc.pl ttfsupport/times.win2k.inc.pl ttfsupport/arial.win2k.inc.pl ttfsupport/cour.win2k.inc.pl ttfsupport/comic.win2k.inc.pl ttfsupport/georgia.win2k.inc.pl ttfsupport/arialuni.inc.pl
-ttfsupport/all-dejavu: ttfsupport/dvsans.inc.pl ttfsupport/dvserif.inc.pl ttfsupport/dvmono.inc.pl
-ttfsupport/all-google: ttfsupport/droidsans.inc.pl ttfsupport/droidserif.inc.pl ttfsupport/droidmono.inc.pl ttfsupport/roboto.inc.pl ttfsupport/notosans.inc.pl ttfsupport/notoserif.inc.pl
-ttfsupport/all-other: ttfsupport/unifont.inc.pl ttfsupport/code2000.inc.pl ttfsupport/freesans.inc.pl ttfsupport/freeserif.inc.pl
+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
 
-#ttfsupport/unifont.inc.pl: tools/mkttfinfo
+#data/font/unifont.inc.pl: tools/mkttfinfo
 #      $< unifont.ttf $@
 #      $< --headless unifont_upper.ttf >>$@
 
-unicode-cover.inc.pl: tools/mkfontinfo ttfsupport $(patsubst data/font/%.ttf,ttfsupport/%.inc.pl,$(wildcard data/font/*.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/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/browser/caniuse/data.json
+       $(call cmdsave,$^)
 
-data/caniuse.json:
-       tools/wget-ifmodified http://caniuse.com/data.json $@
+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/support.inc.pl: tools/mkcaniuse data/caniuse.json
-       $< $(word 2,$^) >$@
+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: $$(@F)
-       perl -MData::Dumper -wE 'my @t = do "$<" or die $$@; print Data::Dumper->new([\@t])->Terse(1)->Quotekeys(0)->Indent(1)->Dump' >$@
+data/writing-latn.inc.pl: tools/perlinc-static $$(@F)
+       $(call cmdsave,$^)