ICONS := \
	icon_flexirpg.svg \
	tool_add_mini.svg \
	tool_freehand.svg \
	tool_polyline.svg \
	tool_select.svg \
	tool_text.svg

WINDOWS_ICONS := \
	icon_flexirpg.svg

INKSCAPE := inkscape
ICOTOOL := icotool

%.png:svg/%.svg
	$(INKSCAPE) -C -e $@ $<

%.ico:svg/%.svg
	( set -e ; \
	t48=$$(tempfile --suffix=".png") ; \
	t32=$$(tempfile --suffix=".png") ; \
	t16=$$(tempfile --suffix=".png") ; \
	trap "rm -f -- '$$t48' '$$t32' '$$t16'" EXIT ; \
	$(INKSCAPE) -C -e $$t48 -w 48 -h 48 $< ; \
	$(INKSCAPE) -C -e $$t32 -w 32 -h 32 $< ; \
	$(INKSCAPE) -C -e $$t16 -w 16 -h 16 $< ; \
	$(ICOTOOL) -c -o $@ $$t16 $$t32 $$t48 )

all: icons tree-icons

icons: $(ICONS:%.svg=%.png) $(WINDOWS_ICONS:%.svg=%.ico)

tree-icons:
	svg/generate-icons.py

clean:
	rm -f icons.xml tree_*.png $(ICONS:%.svg=%.png) $(WINDOWS_ICONS:%.svg=%.png)
