#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

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

# This is the debhelper compatability version to use.
export DH_COMPAT=3

STRIP=strip --remove-section=.comment --remove-section=.note
PLUGIN_DIR=$$(xmms-config --general-plugin-dir)

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.
	./configure --prefix=/usr --mandir=\$${prefix}/share/man 
	#./configure --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info

	touch configure-stamp

build: configure-stamp 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 configure-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean
	-rm -rf debian/tmp debain/*~ debian/files* debian/substvars

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/xmms-alarm.
	#$(MAKE) install prefix=$(CURDIR)/debian/xmms-alarm/usr


# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: checkroot build install
	-rm -rf debian/tmp

	install -d debian/tmp/DEBIAN/
#	install -m 755 debian/prerm debian/postinst debian/tmp/DEBIAN/

	install -d debian/tmp/$(PLUGIN_DIR)
	install -m 644 src/.libs/libalarm.so debian/tmp/$(PLUGIN_DIR)/
	$(STRIP) --strip-unneeded debian/tmp/$(PLUGIN_DIR)/*

	install -d debian/tmp/usr/share/doc/xmms-alarm/
#	install -m 644 debian/changelog debian/tmp/usr/share/doc/xmms-alarm/changelog.Debian
	install -m 644 debian/changelog debian/tmp/usr/share/doc/xmms-alarm/changelog
	install -m 644 README debian/tmp/usr/share/doc/xmms-alarm/
#	install -m 644 Changelog debian/tmp/usr/share/doc/xmms-alarm/changelog
	gzip -9v debian/tmp/usr/share/doc/xmms-alarm/*
	install -m 644 debian/copyright debian/tmp/usr/share/doc/xmms-alarm/

	dpkg-shlibdeps debian/tmp/$(PLUGIN_DIR)/libalarm.so
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

binary: binary-indep binary-arch

checkroot:
        test root = "`whoami`"

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