#!/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-arch: build
build-indep: build

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
	# There is no target clean, distclean ...
	# $(MAKE) clean
	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	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/icewm-themes.
	$(MAKE) install LIBDIR=$(CURDIR)/debian/icewm-themes/usr/share/icewm/themes
	mv `pwd`/debian/icewm-themes/usr/share/icewm/themes/jaywalk/doc `pwd`/debian/icewm-themes/usr/share/doc/icewm-themes/jaywalk
	tar -c */{,*/}README | tar -x -C $(CURDIR)/debian/icewm-themes/usr/share/doc/icewm-themes
	rm $(CURDIR)/debian/icewm-themes/usr/share/icewm/themes/xp/.default.theme.swp
# Both fonts are apparently broken
#	mkdir -p debian/icewm-themes/usr/X11R6/lib/X11/fonts/misc debian/icewm-themes/usr/X11R6/lib/X11/fonts/TrueType
#	cp Aalglatt/snap.pcf.gz debian/icewm-themes/usr/X11R6/lib/X11/fonts/misc
#	cp jim-mac/Chicago.ttf debian/icewm-themes/usr/X11R6/lib/X11/fonts/TrueType
	find debian/icewm-themes -type f | xargs  -n1 -i chmod -x "{}"
#drop all the crap
	find debian/icewm-themes/usr/share/icewm/themes | grep -i "xvpics\|xcf\|gz$$\|akefile\|dir$$\|readme\|debug\|gif\|COPYING\|convert.sh" | xargs -n1 -i rm -rf "{}"
#	symlinks -c -s -r debian/icewm-themes
#	symlinks -c -s -r debian/icewm-themes
#	symlinks -c -s -r debian/icewm-themes

	touch install-stamp

# Build architecture-independent files here.
binary-indep: build install
#	perl debian/symlink-dupes.pl debian/icewm-themes
	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 -- -Zxz

# 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
