summaryrefslogtreecommitdiff
path: root/Makefile
blob: 31418c9e99a2b8ce664fd0b195ab043d0d24596d (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
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
sed 's/[ \t<>]/\n/g #tokenize' '$1'|\
grep href |\
sed -r \
  -e "s/'/\"/g                     #normalize quotes" \
  -e 's@^href="http://([^"]*)"@\1@ #strip href off'   \
  -e 's@^/@http://lukeshu.ath.cx/@ #fix docroot' |\
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