#!/usr/bin/make -f
# debian/rules for wallpapers-at
# Andreas Tille <tille@debian.org>
# GPL

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

pkg=wallpapers-at
pkg4x3=$(pkg)-1600x1200
pkg5x4=$(pkg)-1280x1024
pkg16x9=$(pkg)-1600x900
imgsrc=/var/lib/$(pkg)

RESOLUTIONS=1600x1200 \
            1280x1024 \
	    1600x900

build: build-stamp
build-stamp:
	dh_testdir

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	rm -f debian/*.{preinst,postrm}

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	for res in $(RESOLUTIONS) ; do \
	   mkdir -p `pwd`/debian/$(pkg)-$${res}/$(imgsrc) ; \
	   cp -a $${res}/*.jpg `pwd`/debian/$(pkg)-$${res}/$(imgsrc) ; \
	done

	for res in $(RESOLUTIONS) ; do \
		for script in preinst postrm ; do \
			sed -e "s/#PKG#/wallpapers-at-$${res}/" debian/diversions.template > debian/wallpapers-at-$${res}.$${script} ; \
		done ; \
	done

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_installdebconf
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

	# just clean debian build-dirs after build to save disk space at build machine
	for dir in `dh_listpackages` ; do \
	    rm -rf debian/$${dir} ; \
	done

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