#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. 
# GNU copyright 1997 by Joey Hess.
#
# This version is for a hypothetical package that builds an
# architecture-dependant package, as well as an architecture-andependent
# package.

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

configure:
	dh_testdir
	#./autogen.sh
	# Add here commands to configure the package.
	./configure --prefix=/usr --mandir=\$${prefix}/share/man \
	--infodir=\$${prefix}/share/info --sysconfdir=/etc \
	--enable-libext2fs --with-log-dir=/var/log/partimage \
	--with-included-gettext --disable-cheuid

	touch configure-stamp

build: configure
	dh_testdir

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

	touch build-stamp



clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp intl/libintl.h po/*.gmo

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

	dh_clean

install: DH_OPTIONS=
install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/partimage.
	$(MAKE) install prefix=$(CURDIR)/debian/tmp/usr \
	sysconfdir=$(CURDIR)/debian/tmp/etc

	install -d $(CURDIR)/debian/tmp/etc/init.d
	install -d $(CURDIR)/debian/tmp/usr/share/man/man1
	install -d $(CURDIR)/debian/tmp/usr/share/man/man8
	install -d $(CURDIR)/debian/tmp/usr/share/doc/partimage-server
	install -d $(CURDIR)/debian/tmp/var/run/partimaged
	install -m '755' debian/partimaged.init $(CURDIR)/debian/tmp/etc/init.d/partimaged
	install -m '640' debian/partimage-certs.cnf $(CURDIR)/debian/tmp/etc/partimaged/
	install -m '644' debian/partimage.1 $(CURDIR)/debian/tmp/usr/share/man/man1
	install -m '644' debian/partimaged.8 $(CURDIR)/debian/tmp/usr/share/man/man8
	gzip -9 $(CURDIR)/debian/tmp/usr/share/man/man1/partimage.1
	gzip -9 $(CURDIR)/debian/tmp/usr/share/man/man8/partimaged.8

	mv $(CURDIR)/debian/tmp/usr/share/info/* $(CURDIR)/debian/tmp/usr/share/doc/partimage-server

	dh_movefiles

# Build architecture-independent files here.
# Pass -a to all debhelper commands in this target to reduce clutter.
binary-indep: install

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir -a
	dh_testroot -a
	dh_installdebconf -a
	dh_installdocs -a
	dh_installexamples -a
	dh_installmenu -a
#	dh_installmanpages -a -ppartimage-server partimaged.8
#	dh_installmanpages -a -ppartimage partimage.1
#	dh_installlogrotate -a
#	dh_installemacsen -a
#	dh_installpam -a
#	dh_installmime -a
	dh_installinit -a -ppartimage-server partimaged.init
	dh_installcron -a
#	dh_installman -a
	dh_installinfo -a
#	dh_undocumented -a
	dh_installchangelogs ChangeLog -a
	dh_strip -a
	dh_link -a
	dh_compress -a
	dh_fixperms -a
#	dh_makeshlibs -a
	dh_installdeb -a
#	dh_perl -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

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