diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 54 |
1 files changed, 39 insertions, 15 deletions
@@ -1,3 +1,20 @@ +# 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... + +# Dependencies: +# - bsdtar +# - coreutils +# - gitget <https://git.parabola.nu/packages/libretools.git/tree/src/gitget/gitget> +# - java (for closure-compiler) +# - node (for UglifyJS 1) +# - npm (for UglifyJS 2) +# - patch +# - perl +# - pngcrush +# - sed +# - wget + # Where are we? dl-cache = ../download-cache www = $(dl-cache)/www @@ -31,7 +48,9 @@ targets = \ sitestatic/jquery.tablesorter-$(tablesorter-ver).min.js \ sitestatic/konami.min.js \ visualize/static/d3-$(d3-ver).js \ - visualize/static/d3-$(d3-ver).min.js + visualize/static/d3-$(d3-ver).min.js \ + retro/static/2013/bootstrap-typeahead.min.1aacd3d7f4db.js \ + retro/static/2013/konami.min.e165c814457d.js js-basenames = $(sort $(patsubst %.min,%,$(patsubst %.js,%,$(filter %.js,$(targets))))) generated = $(sort $(targets) $(foreach f,$(js-basenames),$f.js $f.min.js)) @@ -56,8 +75,8 @@ clean: $(dl-cache) $(dl-cache)/unzip $(bin): mkdir -p '$@' -# Don't have non-minimized .js stick around unless we asked for them. -.INTERMEDIATE: $(filter-out $(targets),$(generated)) +# Don't clean up the pre-minified files +.SECONDARY: # Turn on sane error handling .DELETE_ON_ERROR: @@ -86,8 +105,9 @@ $(www)/git/%: FORCE test -d '$@' || { rm -rf -- '$@'; false; } -# Downloaded images +# The meat of the Makefile +# 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/$*' > '$@' @@ -103,7 +123,7 @@ $(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 +# Non-minified JavaScript sitestatic/bootstrap-typeahead.js: sitestatic/%: $(www)/https/raw.github.com/twitter/bootstrap/v$(bootstrap-ver)/js/% Makefile.d/%.patch cp $< $@ patch -i Makefile.d/$*.patch $@ @@ -114,6 +134,20 @@ sitestatic/jquery.tablesorter-$(tablesorter-ver).js: $(www)/https/raw.github.com sitestatic/konami.js: sitestatic/%: $(www)/https/raw.github.com/snaptortoise/konami-js/$(konami-ver)/% Makefile.d/%.patch cp $< $@ patch -i Makefile.d/$*.patch $@ +visualize/static/d3-$(d3-ver).js: %: $(www)/https/raw.github.com/mbostock/d3/v$(d3-ver)/d3.js + cp $< $@ + +# JavaScript minification +JSMIN = { sed -n '1,/\*\//p' $1; uglifyjs --mangle --compress < $1; } > $2 +%.min.js: %.js + $(call JSMIN,$<,$@) + +# Files that make use of that minified JavaScript +retro/static/2013/konami.min.e165c814457d.js: sitestatic/konami.min.js + cp $< $@ +retro/static/2013/bootstrap-typeahead.min.1aacd3d7f4db.js: sitestatic/bootstrap-typeahead.min.js + @# Trim trailing semicolon and newline + < $< sed 's/;$$//' | perl -pe 'chomp if eof' > $@ sitestatic/homepage.js: sitestatic/bootstrap-typeahead.min.js sitestatic/konami.min.js Makefile.d/homepage.js.in { \ echo '/* bootstrap-typeahead.min.js: */' && \ @@ -125,13 +159,3 @@ sitestatic/homepage.js: sitestatic/bootstrap-typeahead.min.js sitestatic/konami. 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 minimization processes - -JSMIN = { sed -n '1,/\*\//p' $1; uglifyjs --mangle --compress < $1; } > $2 - -%.min.js: %.js - $(call JSMIN,$<,$@) |