Makefiles += gen.sh pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH))))) pick = $(firstword $(foreach prog,$1,$(call pathsearch,$(prog))) false) COFFEE = coffee CONVERT = convert CP = cp MKDIRS = mkdir -p PHP = $(call pick,php5 php) RM = rm -f SASS = sass PDF2PPM = pdftoppm PDF2TXT = pdftotext PHP2ANY = $(PHP) -f PPM2JPG = ppmtojpeg SCSS2CSS = $(SASS) all: PHONY echo */|sed 's@/\s*@\n@g'|sort -n|xargs bash gen.sh .SECONDARY: %.ppm: %.pdf $(MAKEFILES) $(PDF2PPM) '$<' > '$@' %.jpg: %.ppm $(MAKEFILES) $(PPM2JPG) '$<' > '$@' %.txt: %.pdf $(MAKEFILES) $(PDF2TXT) '$<' > '$@' %: %.php $(MAKEFILES) $(PHP2ANY) '$<' > '$@' %.css: %.scss $(MAKEFILES) $(SCSS2CSS) '$<' > '$@' %.js: %.coffee $(MAKEFILES) $(COFFEE) -c '$<' %.small.jpg: %.jpg $(MAKEFILES) $(CONVERT) '$<' -resize x700 '$@' %/index.php: issue.php $(MAKEFILES) $(CP) '$<' '$@' %/view.css: view.css $(MAKEFILES) $(CP) '$<' '$@' %/view.js: view.js $(MAKEFILES) $(CP) '$<' '$@' .PHONY: PHONY