view source/Makefile @ 671:09c76e7ce675

Icon generation in Makefile
author Stefano Rivera <stefano@rivera.za.net>
date Sun, 08 Sep 2013 18:12:44 +0200
parents eba98879f47f
children 62b9eac8e236
line wrap: on
line source

IMG_SOURCES = $(shell find images -name '*.svg')
IMG_TARGETS = $(patsubst %.svg,../data/%.png,$(IMG_SOURCES))
ICONS = _16.png _32.png _64.png _128.png .xpm .icns .ico
ICO_TARGETS = $(patsubst %,../data/icons/werewolf-sonata%,$(ICONS))
OPTIMIZE = 1

all: $(IMG_TARGETS) $(ICO_TARGETS)

clean:
	rm -f $(IMG_TARGETS)

../data/%.png: %.svg
	mkdir -p $(dir $@)
	inkscape --export-png $@ --export-dpi 9 $<
ifeq ($(OPTIMIZE),1)
	optipng -o4 -preserve $@
	advpng -z4 $@
endif

../data/icons/%_1024.png: icons/%.svg
	inkscape --export-png $@ --export-width 1024 --export-height 1024 $<

../data/icons/%_512.png: icons/%.svg
	inkscape --export-png $@ --export-width 512 --export-height 512 $<

../data/icons/%_256.png: icons/%.svg
	inkscape --export-png $@ --export-width 256 --export-height 256 $<
ifeq ($(OPTIMIZE),1)
	optipng -o4 -preserve $@
	advpng -z4 $@
endif

../data/icons/%_128.png: icons/%.svg
	inkscape --export-png $@ --export-width 128 --export-height 128 $<
ifeq ($(OPTIMIZE),1)
	optipng -o4 -preserve $@
	advpng -z4 $@
endif

../data/icons/%_64.png: icons/%.svg
	inkscape --export-png $@ --export-width 64 --export-height 64 $<
ifeq ($(OPTIMIZE),1)
	optipng -o4 -preserve $@
	advpng -z4 $@
endif

../data/icons/%_48.png: icons/%.svg
	inkscape --export-png $@ --export-width 48 --export-height 48 $<

../data/icons/%_32.png: icons/%.svg
	inkscape --export-png $@ --export-width 32 --export-height 32 $<
ifeq ($(OPTIMIZE),1)
	optipng -o4 -preserve $@
	advpng -z4 $@
endif

../data/icons/%_16.png: icons/%.svg
	inkscape --export-png $@ --export-width 16 --export-height 16 $<
ifeq ($(OPTIMIZE),1)
	optipng -o4 -preserve $@
	advpng -z4 $@
endif

%.xpm: %_32.png
	convert $< $@

%.icns: %_16.png %_32.png %_48.png %_128.png %_256.png %_512.png %_1024.png
	png2icns $@ $^

%.ico: %_16.png %_32.png %_64.png %_48.png %_128.png %_256.png
	icotool -c -o $@ $(filter-out %_256.png,$^) --raw=$(filter %_256.png,$^)