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' |\ fgrep -v '/feed/' |\ fgrep -v '/wp-admin/' |\ fgrep -v '/wp-content/' |\ fgrep -v 'wlwmanifest.xml' |\ fgrep -v 'xmlrpc.php' |\ fgrep -v 'wp-login.php' |\ sed 's/\#.*//' | sort | uniq endef sleep = x=$$RANDOM; let 'x %= 15'; sleep $$((30+$$x)) download = wget -U '$(ua)' '$(call url,$1)' -O tmp/$$$$ && mkdir -vp $(@D) && mv -v tmp/$$$$ $@ default: rm -rf mk $(MAKE) mk/lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/index.chtml .SECONDARY: web/%: $(call download,$*); $(sleep) web/%/index.chtml: $(call download,$*/); $(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 %.html: %.chtml sed '1,3d' < $< > $@ html: find web -name '*.chtml'|sed 's/chtml$$/html/' |xargs $(MAKE)