# Copyright (c) 2005-2011  Francesco Poli <invernomuto@paranoici.org>
# 
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
SVGIMAGES           = $(wildcard *.svg)
PNGIMAGES_400x300   = $(SVGIMAGES:.svg=_400x300.png)
PNGIMAGES_800x600   = $(SVGIMAGES:.svg=_800x600.png)
PNGIMAGES_1280x960  = $(SVGIMAGES:.svg=_1280x960.png)
PNGIMAGES_1600x1200 = $(SVGIMAGES:.svg=_1600x1200.png)
JPGIMAGES_400x300   = $(SVGIMAGES:.svg=_400x300.jpg)
JPGIMAGES_800x600   = $(SVGIMAGES:.svg=_800x600.jpg)
JPGIMAGES_1280x960  = $(SVGIMAGES:.svg=_1280x960.jpg)
JPGIMAGES_1600x1200 = $(SVGIMAGES:.svg=_1600x1200.jpg)

PNGICONS = thinking-penguin_icon.png


all: verylow low medium high icons

png: verylow_png low_png medium_png high_png icons_png

jpg: verylow_jpg low_jpg medium_jpg high_jpg

verylow: verylow_png verylow_jpg
low:     low_png     low_jpg
medium:  medium_png  medium_jpg
high:    high_png    high_jpg
icons:   icons_png

verylow_png: $(PNGIMAGES_400x300)
low_png:     $(PNGIMAGES_800x600)
medium_png:  $(PNGIMAGES_1280x960)
high_png:    $(PNGIMAGES_1600x1200)

icons_png:   $(PNGICONS)

verylow_jpg: $(JPGIMAGES_400x300)
low_jpg:     $(JPGIMAGES_800x600)
medium_jpg:  $(JPGIMAGES_1280x960)
high_jpg:    $(JPGIMAGES_1600x1200)

$(PNGIMAGES_400x300): %_400x300.png: %.svg
	inkscape -w 400 -e $@ $<
	optipng -o9 $@

$(PNGIMAGES_800x600): %_800x600.png: %.svg
	inkscape -w 800 -e $@ $<
	optipng -o9 $@

$(PNGIMAGES_1280x960): %_1280x960.png: %.svg
	inkscape -w 1280 -e $@ $<
	optipng -o9 $@

$(PNGIMAGES_1600x1200): %_1600x1200.png: %.svg
	inkscape -w 1600 -e $@ $<
	optipng -o9 $@

%.jpg: %.png
	convert -quality 80 $< $@


thinking-penguin_icon.png: thinking-penguin.svg
	inkscape -w 32 -a 314:50:730:466 -e $@ $<
	optipng -o9 $@


.PHONY: distclean
distclean:
	-rm -f core *.png *.jpg
