SUBDIRS=kde
KDE_ICON=AUTO

crystaldir=$(kde_icondir)/crystalsvg
crystal_DATA=index.desktop

COPYRIGHT=Copyright: Crystal Icons (C) Copyright 2002 by Everaldo Coelho <everaldo@everaldo.com> and Torsten Rahn <tackat@tackat.com>
LICENSE=License: LGPL

generate:
	@echo "Converting SVG files to PNG files, starting..."
	@echo "Sizes: 16x16; 32x32; 48x48; 64x64"
	@rm -f $(top_builddir)/pics/crystalsvg/generated -Rf
	@mkdir $(top_builddir)/pics/crystalsvg/generated

	@for file in $(top_srcdir)/pics/crystalsvg/*.svg*; do \
		echo "Processing: $$file..."; \
		$(top_builddir)/pics/ksvgtopng 16 16 $$file $(top_builddir)/pics/crystalsvg/generated/`basename $$file | sed -e 's/crsc/cr16/' | sed -e 's/svg\|svgz/png/'`; \
		$(top_builddir)/pics/ksvgtopng 32 32 $$file $(top_builddir)/pics/crystalsvg/generated/`basename $$file | sed -e 's/crsc/cr32/' | sed -e 's/svg\|svgz/png/'`; \
		$(top_builddir)/pics/ksvgtopng 48 48 $$file $(top_builddir)/pics/crystalsvg/generated/`basename $$file | sed -e 's/crsc/cr48/' | sed -e 's/svg\|svgz/png/'`; \
		$(top_builddir)/pics/ksvgtopng 64 64 $$file $(top_builddir)/pics/crystalsvg/generated/`basename $$file | sed -e 's/crsc/cr64/' | sed -e 's/svg\|svgz/png/'`; \
	done

addcopyright:
	@echo "Adding copyrights to SVG files..."

	@rm $(top_builddir)/pics/crystalsvg/Temporary -Rf
	@mkdir $(top_builddir)/pics/crystalsvg/Temporary

	@cp $(top_srcdir)/pics/crystalsvg/*.svg* $(top_builddir)/pics/crystalsvg/Temporary/

	@for file in $(top_builddir)/pics/crystalsvg/Temporary/*.svg*; do \
		mv $$file `echo $$file | sed -e 's/svg\|svgz/gz/'`; \
	done

	@gzip -d $(top_builddir)/pics/crystalsvg/Temporary/*.gz

	@cd $(top_builddir)/pics/crystalsvg/Temporary && find -type f | xargs perl -pi -e 's/Generator:/$(COPYRIGHT)\n\t $(LICENSE)\n\t Generator:/ if /!--/'

	@for file in $(top_builddir)/pics/crystalsvg/Temporary/*; do \
		gzip -c $$file > $$file".svgz"; \
		rm $$file; \
	done

	@mv $(top_builddir)/pics/crystalsvg/Temporary/* $(top_srcdir)/pics/crystalsvg	
	@rm $(top_builddir)/pics/crystalsvg/Temporary -Rf
