#!/usr/bin/make -f
# MAde with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Some lines taken from debmake, by Cristoph Lameter.

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

SHELL=/bin/bash
build: build-stamp
build-stamp:
	dh_testdir

	
	# Add here commands to compile the package.
	$(MAKE) 

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp install-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) clean

	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs /usr/share/icewm/themes /usr/share/doc/icewm-themes/jaywalk /usr/share/doc/icewm-themes

	# Add here commands to install the package into debian/tmp.
	$(MAKE) install LIBDIR=`pwd`/debian/tmp/usr/share/icewm/themes
	mv `pwd`/debian/tmp/usr/share/icewm/themes/jaywalk/doc `pwd`/debian/tmp/usr/share/doc/icewm-themes/jaywalk
	tar -c */{,*/}README | tar -x -C `pwd`/debian/tmp/usr/share/doc/icewm-themes
# Both fonts are apparently broken
#	mkdir -p debian/tmp/usr/X11R6/lib/X11/fonts/misc debian/tmp/usr/X11R6/lib/X11/fonts/TrueType
#	cp Aalglatt/snap.pcf.gz debian/tmp/usr/X11R6/lib/X11/fonts/misc
#	cp jim-mac/Chicago.ttf debian/tmp/usr/X11R6/lib/X11/fonts/TrueType
	find debian/tmp -type f | xargs  -n1 -i chmod -x "{}"
#drop all the crap
	find debian/tmp/usr/share/icewm/themes | grep -i "xvpics\|xcf\|gz$$\|akefile\|dir$$\|readme\|debug\|gif" | xargs -n1 -i rm -f "{}"
#	symlinks -c -s -r debian/tmp
#	symlinks -c -s -r debian/tmp
#	symlinks -c -s -r debian/tmp

	touch install-stamp

# Build architecture-independent files here.
binary-indep: build install
#	perl debian/symlink-dupes.pl debian/tmp
	dh_testdir
	dh_testroot
	dh_installdocs debian/README.contribution README.gradient-themes
	dh_installchangelogs 
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install

source diff:                                                                  
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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