diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 79 |
1 files changed, 39 insertions, 40 deletions
@@ -1,7 +1,3 @@ -# The idea here is to be able to re-generate the exact Javascript -# files as they exist in git. This means munging whitespace in weird -# ways, using specific versions of various JS minimizers... - # Where are we? dl-cache = ../download-cache www = $(dl-cache)/www @@ -14,7 +10,18 @@ tablesorter-ver=2.7 d3-ver=3.0.6 konami-ver=c0f686e647765860ff4d2fcb7b48122785432b75 +# What files do we make? +branding-images = \ + sitestatic/favicon.ico sitestatic/silhouette.png \ + sitestatic/archnavbar/archlogo.png \ + sitestatic/logos/apple-touch-icon-114x114.png \ + sitestatic/logos/apple-touch-icon-144x144.png \ + sitestatic/logos/apple-touch-icon-57x57.png \ + sitestatic/logos/apple-touch-icon-72x72.png \ + sitestatic/logos/icon-transparent-64x64.png targets = \ + $(branding-images) \ + sitestatic/.gitignore visualize/.gitignore \ sitestatic/rss.png \ sitestatic/rss@2x.png \ sitestatic/bootstrap-typeahead.js \ @@ -26,20 +33,27 @@ targets = \ visualize/static/d3-$(d3-ver).js \ visualize/static/d3-$(d3-ver).min.js +js-basenames = $(sort $(patsubst %.min,%,$(patsubst %.js,%,$(filter %.js,$(targets))))) +generated = $(sort $(targets) $(foreach f,$(js-basenames),$f.js $f.min.js)) + +generated := $(generated) +targets := $(generated) + # The base rules all: $(targets) .PHONY: all -js-basenames = $(sort $(patsubst %.min,%,$(patsubst %.js,%,$(filter %.js,$(targets))))) -generated = $(sort $(targets) $(foreach f,$(js-basenames),$f.js $f.min.js)) clean: rm -f -- $(generated) .PHONY: clean +%/.gitignore: $(MAKEFILE_LIST) + printf -- '%s\n' $(patsubst $*%,%,$(filter $*/%,$(generated))) | LC_COLLATE=C sort > $@ + # Make directories -$(dl-cache) $(bin): +$(dl-cache) $(dl-cache)/unzip $(bin): mkdir -p '$@' # Don't have non-minimized .js stick around unless we asked for them. @@ -48,6 +62,8 @@ $(dl-cache) $(bin): # Turn on sane error handling .DELETE_ON_ERROR: +.PHONY: FORCE + # How to download files @@ -64,10 +80,10 @@ $(www)/https/%: wget 'https://$(call unmangle,$*)' -O '$@' test -f '$@' && touch '$@' -$(www)/git/%: +$(www)/git/%: FORCE mkdir -p '$(@D)' gitget checkout 'git://$(call unmangle,$*)' '$@' || { rm -rf -- '$@'; false; } - test -d '$@' && touch '$@' || { rm -rf -- '$@'; false; } + test -d '$@' || { rm -rf -- '$@'; false; } # Downloaded images @@ -80,6 +96,13 @@ sitestatic/rss.png: $(dl-cache)/unzip/Feedicons_v.2/RSS_16.png sitestatic/rss@2x.png: $(dl-cache)/unzip/Feedicons_v.2/RSS_32.png pngcrush $< $@ +$(dl-cache)/unzip/parabola-artwork: $(www)/git/projects.parabola.nu/artwork.git\#branch=official/2013 | $(dl-cache)/unzip + cp -rT '$<' '$@' + make -C '$@' +$(dl-cache)/unzip/parabola-artwork/%: $(dl-cache)/unzip/parabola-artwork + test -e $@ && touch $@ +$(foreach i,$(branding-images),$(eval $i: $$(dl-cache)/unzip/parabola-artwork/$(notdir $i); install -Dm644 $$< $$@)) + # Non-minimized .js files sitestatic/bootstrap-typeahead.js: sitestatic/%: $(www)/https/raw.github.com/twitter/bootstrap/v$(bootstrap-ver)/js/% Makefile.d/%.patch cp $< $@ @@ -93,46 +116,22 @@ sitestatic/konami.js: sitestatic/%: $(www)/https/raw.github.com/snaptortoise/kon patch -i Makefile.d/$*.patch $@ sitestatic/homepage.js: sitestatic/bootstrap-typeahead.min.js sitestatic/konami.min.js Makefile.d/homepage.js.in { \ + echo '/* bootstrap-typeahead.min.js: */' && \ cat sitestatic/bootstrap-typeahead.min.js && \ echo && \ + echo '/* konami.min.js: */' && \ sed -e 's,^\s*,,' -e 's,^return.*,&;,' sitestatic/konami.min.js && \ echo && \ + echo '/* Main homepage.js content: */' && \ cat Makefile.d/homepage.js.in ; \ } > $@ visualize/static/d3-$(d3-ver).js: %: $(www)/https/raw.github.com/mbostock/d3/v$(d3-ver)/d3.js cp $< $@ -# The crazy minimization processes - -# Any of the UglifyJS 1.3.x releases will produce the same output for these inputs -$(bin)/uglifyjs-1.3: $(www)/git/github.com/mishoo/UglifyJS.git\#tag=v1.3.5 | $(bin) - printf '%s\n' '#!/bin/sh' 'exec $</bin/uglifyjs --no-copyright --ascii --max-line-len 0 "$$@"' | install -m755 /dev/stdin '$@' +# The minimization processes -# Any of the UglifyJS 2.2.x releases will produce the same output for these inputs -$(dl-cache)/uglifyjs-2.2: $(www)/git/github.com/mishoo/UglifyJS2.git\#tag=v2.2.5 | $(dl-cache) - cp -r $< $@ || { rm -rf -- '$@'; false; } - cd $@ && npm install || { rm -rf -- '$@'; false; } -$(bin)/uglifyjs-2.2: $(dl-cache)/uglifyjs-2.2 | $(bin) - printf '%s\n' '#!/bin/sh' 'exec $</bin/uglifyjs --mangle --compress -- "$$@"' | install -m755 /dev/stdin '$@' +JSMIN = { sed -n '1,/\*\//p' $1; uglifyjs --mangle --compress < $1; } > $2 -# Closure compiler 20121212 produces the same output -$(dl-cache)/unzip/compiler-20121212/%: $(www)/https/web.archive.org/web/20151226141014/https^3A//closure-compiler.googlecode.com/files/compiler-20121212.tar.gz - mkdir -p '$(@D)' - bsdtar xfO '$<' '$*' > '$@' -$(bin)/closure-compiler: $(dl-cache)/unzip/compiler-20121212/compiler.jar | $(bin) - printf '%s\n' '#!/bin/sh' 'exec java -jar $< "$$@"' | install -m755 /dev/stdin '$@' - -# Which minimizer to use for each -sitestatic/bootstrap-typeahead.min.js: %.min.js: $(bin)/uglifyjs-1.3 %.js - $^ > $@ -sitestatic/jquery-$(jquery-ver).min.js: sitestatic/%.min.js: sitestatic/%.js Makefile.d/%.min.js.preamble - { cat Makefile.d/$*.min.js.preamble && $(bin)/uglifyjs-1.3 $<; } > $@ -sitestatic/jquery.tablesorter-$(tablesorter-ver).min.js: sitestatic/%.min.js: sitestatic/%.js Makefile.d/%.min.js.preamble $(bin)/closure-compiler - @# The tr/sed is to turn all of the newlines except for the last one into spaces - { cat Makefile.d/$*.min.js.preamble && $(bin)/closure-compiler $< | tr '\n' ' ' | sed 's, $$,\n,'; } > $@ -sitestatic/konami.min.js: %.min.js: $(bin)/uglifyjs-2.2 %.js - @# The sed is to insert newlines and whitespace at the correct places; presumably to match Dan copy/pasting into an editor. - $^ | sed -r -e 's:e\.iphone\.stop_x|s=this\.tap===:\n\t&:g' -e 's,return"string",\n&,' | sed -e 's,;$$,,' -e '$$s,$$,\n,' > $@ -visualize/static/d3-$(d3-ver).min.js: %.min.js: $(bin)/uglifyjs-2.2 %.js - $^ > $@ +%.min.js: %.js + $(call JSMIN,$<,$@) |