#!/usr/bin/make -f

#export DH_VERBOSE=1

export DH_COMPAT=3

THEMES_DIR=debian/metacity-themes/usr/share/themes

build: build-stamp

build-stamp: 
	dh_testdir
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp 
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	for i in *.tar.gz; do \
		echo "Extracting theme $$i"; \
		tar zxf $$i -C $(THEMES_DIR); \
	done
	for i in *.tar.bz2; do \
		echo "Extracting theme $$i"; \
		bunzip2 -k -c $$i | tar -x -C $(THEMES_DIR); \
	done
	# dh_fixperms ignores /usr/share/themes
	chmod -R 0644 $(THEMES_DIR);
	chmod -R +X $(THEMES_DIR);
	# The makedoc scripts generates documentation for each theme and the 
	# package, removes duplicate licenses and copy any documentation provided
	# with the theme to the correct location
	debian/makedoc.pl


binary-indep: build install

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installchangelogs 
	dh_fixperms
	dh_compress
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install 
