summaryrefslogtreecommitdiff
path: root/Makefile
blob: 506dc288225ab7ed8798c76cef8f0f85669880b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Where are we?
topdir := $(dir $(lastword $(MAKEFILE_LIST)))
www = $(topdir)/../web-cache/www
artwork = $(topdir)/../web-cache/artwork
branding = $(artwork)/official-2013/optimized-text


# Where is the the Javascript minimizer?
JSMIN = { sed -n '1,/\*\//p' $1; closure-compiler --js $1; } > $2

# What versions of 3rd party libraries are we using?
jquery-ver=1.8.3
bootstrap-ver=2.1.1
tablesorter-ver=2.7
d3-ver=3.0.6
konami-ver=c0f686e647765860ff4d2fcb7b48122785432b75

# What files do we make?
javascripts = \
	sitestatic/bootstrap-typeahead.js \
	sitestatic/homepage.js \
	sitestatic/jquery-$(jquery-ver).min.js \
	sitestatic/jquery.tablesorter-$(tablesorter-ver).js \
	sitestatic/jquery.tablesorter-$(tablesorter-ver).min.js \
	sitestatic/konami.min.js \
	visualize/static/d3-$(d3-ver).js \
	visualize/static/d3-$(d3-ver).min.js
images += sitestatic/favicon.ico sitestatic/silhouette.png
images += sitestatic/archnavbar/archlogo.png
images += \
	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

javascript_basenames = $(sort $(patsubst %.min,%,$(patsubst %.js,%,$(javascripts))))
targets = $(foreach i,$(javascript_basenames),$i.js $i.min.js) $(images)


# The base rules

all: $(targets) sitestatic/.gitignore visualize/.gitignore
clean: sitestatic/.gitignore visualize/.gitignore
	rm -f -- $(targets)
.PHONY: all clean

%/.gitignore: $(MAKEFILE_LIST)
	printf -- '%s\n' $(patsubst $*%,%,$(filter $*/%,$(targets))) | LC_COLLATE=C sort > $@

# Turn on sane error handling
.DELETE_ON_ERROR:


# How to download files

$(www)/http/%:
	mkdir -p '$(@D)'
	wget 'http://$*' -O '$@'
	touch '$@'

$(www)/https/%:
	mkdir -p '$(@D)'
	wget 'https://$*' -O '$@'
	touch '$@'

$(branding)/%:
	gitget checkout 'git://projects.parabola.nu/artwork.git#branch=master' '$(artwork)'
	make -C '$(branding)'


# Non-minimized files
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 $@
sitestatic/jquery-$(jquery-ver).js: sitestatic/%: $(www)/http/code.jquery.com/%
	cp $< $@
sitestatic/jquery.tablesorter-$(tablesorter-ver).js: $(www)/https/raw.github.com/Mottie/tablesorter/v$(tablesorter-ver)/js/jquery.tablesorter.js
	cp $< $@
sitestatic/konami.js: sitestatic/%: $(www)/https/raw.github.com/snaptortoise/konami-js/$(konami-ver)/% Makefile.d/%.patch
	cp $< $@
	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 $< $@

$(foreach i,$(images),$(eval $i: $$(branding)/$(notdir $i); install -Dm644 $$< $$@))


# The minimization processes

%.min.js: %.js
	$(call JSMIN,$<,$@)