summaryrefslogtreecommitdiff
path: root/Makefile
blob: f7c6be2cbc480f19980bde101f949f72076ccccd (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
url=https://webcache.googleusercontent.com/search?q=cache:http://$1+lukeshu.ath.cx&hl=en
ua=Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20111009 IceCat/7.0.1

define deps
cat '$1' |\
sed 's/[ \t<>]/\n/g #tokenize' |\
grep href |\
sed "s/'/\"/g" |\
grep -v 'href="\#' |\
sed 's@href="/@href="http://lukeshu.ath.cx/@' |\
sed -r 's@^href="http://([^"]*)"@\1@' |\
grep '^lukeshu\.ath\.cx/1/wordpress' |\
sed 's/\#.*//' |\
sort|uniq
endef

sleep = x=$$RANDOM; let 'x %= 15'; sleep $$((30+$$x))

default:
	rm -rf mk
	$(MAKE) mk/lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/index.chtml
.SECONDARY:

web/%:
	mkdir -p $(@D)
	wget -U '$(ua)' '$(call url,$*)'  -O tmp/$$$$ && mv tmp/$$$$ $@; $(sleep)
web/%/index.chtml:
	mkdir -p $(@D)
	wget -U '$(ua)' '$(call url,$*/)' -O tmp/$$$$ && mv tmp/$$$$ $@; $(sleep)

dep/%: web/% Makefile
	test -f $<
	mkdir -p $(@D)
	$(call deps,$<) > $@

mk/%: dep/%
	mkdir -p $(@D)
	touch $@
	sed -e 's@.@mk/&@' -e 's@/$@/index.chtml@' $< |xargs -d '\n' $(MAKE) -k