From 5714a584a3f8cd576df4a2042286b10cf76e54c3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 29 Nov 2011 17:09:39 -0500 Subject: Add ability to use imagemagick convert instead of rsvg-convert * Add `pick' function to pick the first program found in $PATH from a list * Set SVG2PNG = $(call pick,rsvg-convert convert) * If SVG2PNG resolves to rsvg-convert, set SVG2PNG_OUTFLAG=-o * Change the SVG2PNG invocation from $(SVG2PNG) $< > $@.$$$$ to $(SVG2PNG) $< $(SVG2PNG_OUTFLAG) $@.$$$$ --- Makefile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 7df9dba..550c18b 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,16 @@ pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH))))) +pick = $(firstword $(foreach prog,$1,$(call pathsearch,$(prog))) false) RM = rm -f CP = cp PATCH = patch SASS = sass -PHP := $(firstword $(call pathsearch,php5) $(call pathsearch,php)) -SVG2PNG = rsvg-convert -PNGCRUSH = $(firstword $(call pathsearch,pngcrush) $(call pathsearch,cp)) +PHP = $(call pick,php5 php) +PNGCRUSH = $(call pick,pngcrush cp) +SVG2PNG = $(call pick,rsvg-convert convert) +ifeq ($(notdir $(SVG2PNG)),rsvg-convert) +SVG2PNG_OUTFLAG = -o +endif default: all @@ -28,9 +32,11 @@ all: .gitignore $(targets) $(PHP) -f $< > $@ %.png: %.svg - $(SVG2PNG) $< > $@.$$$$ && $(PNGCRUSH) $@.$$$$ $@ ; $(RM) $@.$$$$ + $(SVG2PNG) $< $(SVG2PNG_OUTFLAG) $@.$$$$ && \ + $(PNGCRUSH) $@.$$$$ $@ ; \ + $(RM) $@.$$$$ -################################################################################ +########################################################################### in_dir = $(patsubst ./%,%,$(dir $1)) my_dir = $(patsubst %/,%,$(dir $1)) @@ -50,7 +56,7 @@ endef echo '# but these:' >> '$@' $(foreach file,$(srcfiles),$(call gitignore_file,$(file))) -################################################################################ +########################################################################### git2make = $1 $(subst *,.*,$1) gitignore_y = $(call git2make,$(shell sed -n 's/^[^\#!]/&/p' .gitignore)) @@ -63,7 +69,7 @@ clean: .gitignore PHONY distclean: .gitignore PHONY $(RM) -r $(gitignore) -################################################################################ +########################################################################### .PHONY: FORCE PHONY FORCE: ; -- cgit v1.2.3