#!/usr/bin/make -f
# -*- makefile -*-
# debian/rules for openstreetmap-map-icons that uses debhelper.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

SVNREPO := http://svn.openstreetmap.org/applications/share/map-icons
DATE := $(shell date +%Y%m%d)
VERSION := 0.0.svn${SVNREV}
DESTDIR := ../tarballs/openstreetmap-map-icons-${VERSION}
DESTTGZ := ../tarballs/openstreetmap-map-icons_${VERSION}.orig.tar.gz

%:
	dh $@

override_dh_install:
	dh_install
	for i in classic scalable scalable square ; do \
		find $(CURDIR)/debian/openstreetmap-map-icons-$$i/usr/share/icons/openstreetmap/ -type d -empty -delete ; \
		find $(CURDIR)/debian/openstreetmap-map-icons-$$i/usr/share/icons/openstreetmap/ -type f | xargs chmod 644 ; \
	done

	rm -rf $(CURDIR)/debian/openstreetmap-map-icons-scalable/usr/share/icons/openstreetmap/scalable-twotone/*.sh
	rm -rf $(CURDIR)/debian/openstreetmap-map-icons-scalable/usr/share/icons/openstreetmap/scalable-twotone/LICENSE.txt

override_dh_auto_configure:
	# pass

override_dh_auto_build:
	# pass

get-orig-source:
	dh_testdir
	test -d ../tarballs/. || mkdir -p ../tarballs
	@echo Downloading openstreetmap-map-icons from $(SVNREPO)
	svn -r $(SVNREV) export $(SVNREPO) $(DESTDIR)
	@echo Removing directories: debian nickw japan
	rm -rf $(DESTDIR)/debian    # not really needed with "3.0 (quilt)"
	rm -rf $(DESTDIR)/nickw
	rm -rf $(DESTDIR)/japan
	@echo Building snapshot tarball
	tar czf $(DESTTGZ) -C `dirname $(DESTDIR)` `basename $(DESTDIR)`
	@echo Cleaning up
	rm -rf $(DESTDIR)
	@echo .
	@echo To update debian/changelog type
	@echo dch -v $(VERSION)-1
	@echo .
