pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH))))) RM = rm -f CP = cp PATCH = patch SASS = sass PHP := $(firstword $(call pathsearch,php5) $(call pathsearch,php)) srcfiles = \ .gitignore \ img/swoosh.svg \ style.scss \ header.php.patch \ Makefile \ logo-style.scss.php \ license.txt \ css_shadow.php \ twentyeleven-fix.scss all: header.php style.css img/swoosh.png .gitignore style.css: logo-style.scss twentyeleven-fix.scss %: %.patch ../twentyeleven/% $(RM) $@ $(CP) ../twentyeleven/$@ $@ $(PATCH) $@ < $@.patch %.css: %.scss $(SASS) $< $@ %: %.php $(PHP) -f $< > $@ %.png: %.svg rsvg-convert $< > $@.$$$$ && pngcrush $@.$$$$ $@ ; $(RM) $@.$$$$ in_dir = $(patsubst ./%,%,$(dir $1)) my_dir = $(patsubst %/,%,$(dir $1)) define gitignore_file $(if $(in_dir), $(call gitignore_file,$(my_dir)) echo '$(my_dir)/*' >> '$@'; ) echo '!$1' >> '$@'; endef .gitignore: Makefile echo "# DO NOT EDIT, this file is automatically made by \`Makefile'" >$@ echo '# ' >> '$@' echo '# ignore everyting' >> '$@' echo '*' >> '$@' echo '# but these:' >> '$@' $(foreach file,$(srcfiles),$(call gitignore_file,$(file)))