summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile84
1 files changed, 61 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 6b633158..5bf8fd83 100644
--- a/Makefile
+++ b/Makefile
@@ -3,14 +3,9 @@
# ways, using specific versions of various JS minimizers...
# Where are we?
-topdir := $(dir $(lastword $(MAKEFILE_LIST)))
-www = $(topdir)/../web-cache/www
-
-# Where are the Javascript minimizers?
-# Any of the 1.3.x or 2.2.x will produce the same output for these
-uglifyjs-1.3 = ~/Downloads/UglifyJS/bin/uglifyjs --no-copyright --ascii --max-line-len 0
-uglifyjs-2.2 = ~/Downloads/UglifyJS2/bin/uglifyjs --mangle --compress --
-closure-compiler = java -jar ~/Downloads/compiler-20121212/compiler.jar
+dl-cache = ../download-cache
+www = $(dl-cache)/www
+bin = $(dl-cache)/bin
# What versions of 3rd party libraries are we using?
jquery-ver=1.8.3
@@ -20,6 +15,8 @@ d3-ver=3.0.6
konami-ver=c0f686e647765860ff4d2fcb7b48122785432b75
targets = \
+ sitestatic/rss.png \
+ sitestatic/rss@2x.png \
sitestatic/bootstrap-typeahead.js \
sitestatic/homepage.js \
sitestatic/jquery-$(jquery-ver).min.js \
@@ -35,12 +32,16 @@ targets = \
all: $(targets)
.PHONY: all
-basenames = $(sort $(patsubst %.min,%,$(patsubst %.js,%,$(targets))))
-generated = $(addsuffix .js,$(basenames)) $(addsuffix .min.js,$(basenames))
+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
+# Make directories
+$(dl-cache) $(bin):
+ mkdir -p '$@'
+
# Don't have non-minimized .js stick around unless we asked for them.
.INTERMEDIATE: $(filter-out $(targets),$(generated))
@@ -50,17 +51,35 @@ clean:
# How to download files
+ mangle = $(subst %,^25,$(subst :,^3A,$(subst =,^3D,$(subst ^,^5E,$1))))
+unmangle = $(subst ^5E,^,$(subst ^3D,=,$(subst ^3A,:,$(subst ^25,%,$1))))
+
$(www)/http/%:
mkdir -p '$(@D)'
- wget 'http://$*' -O '$@'
- touch '$@'
+ wget 'http://$(call unmangle,$*)' -O '$@'
+ test -f '$@' && touch '$@'
$(www)/https/%:
mkdir -p '$(@D)'
- wget 'https://$*' -O '$@'
- touch '$@'
+ wget 'https://$(call unmangle,$*)' -O '$@'
+ test -f '$@' && touch '$@'
+
+$(www)/git/%:
+ mkdir -p '$(@D)'
+ gitget checkout 'git://$(call unmangle,$*)' '$@' || { rm -rf -- '$@'; false; }
+ test -d '$@' && touch '$@' || { rm -rf -- '$@'; false; }
+# Downloaded images
+
+$(dl-cache)/unzip/Feedicons_v.2/%: $(www)/https/web.archive.org/web/20120514074507/http^3A//www.zeusboxstudio.com/file_download/1/Feedicons_v.2.zip
+ mkdir -p '$(@D)'
+ bsdtar xfO $< 'Feedicons v.2/$*' > '$@'
+sitestatic/rss.png: $(dl-cache)/unzip/Feedicons_v.2/RSS_16.png
+ cp $< $@
+sitestatic/rss@2x.png: $(dl-cache)/unzip/Feedicons_v.2/RSS_32.png
+ pngcrush $< $@
+
# Non-minimized .js files
sitestatic/bootstrap-typeahead.js: sitestatic/%: $(www)/https/raw.github.com/twitter/bootstrap/v$(bootstrap-ver)/js/% Makefile.d/%.patch
cp $< $@
@@ -86,15 +105,34 @@ visualize/static/d3-$(d3-ver).js: %: $(www)/https/raw.github.com/mbostock/d3/v$(
# The crazy minimization processes
-sitestatic/bootstrap-typeahead.min.js: %.min.js: %.js
- $(uglifyjs-1.3) $< > $@
+# 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 '$@'
+
+# 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 '$@'
+
+# Closure compiler 20121212 produces the same output
+$(dl-cache)/unzip/compiler-20121212/%: $(www)/https/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 && echo && $(uglifyjs-1.3) $<; } > $@
-sitestatic/jquery.tablesorter-$(tablesorter-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 && echo && $(closure-compiler) $< | tr '\n' ' ' | sed 's, $$,\n,'; } > $@
-sitestatic/konami.min.js: %.min.js: %.js
+ { 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.
- $(uglifyjs-2.2) $< | 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: %.js
- $(uglifyjs-2.2) $< > $@
+ $^ | 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
+ $^ > $@