#!/usr/bin/make -f
# -*- makefile -*-

include /usr/share/dpatch/dpatch.make

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

configure: configure-stamp
configure-stamp: patch-stamp
	dh_testdir
	# Add here commands to configure the package.
	
	touch configure-stamp

#Architecture 
build: build-indep
build-indep: build-indep-stamp
build-indep-stamp: configure-stamp 

	# Add here commands to compile the indep part of the package.
	#$(MAKE) doc
	$(MAKE) 
	touch build-indep-stamp

clean: unpatch
	dh_testdir
	dh_testroot
	rm -f build-indep-stamp

	# Delete po/yum.pot so it doesn't polute the diff.gz
	rm -f po/yum.pot

	# Add here commands to clean up after the build process.
	[ ! -f Makefile ] || $(MAKE) clean

	dh_clean 

install: install-indep
install-indep:
	dh_testdir
	dh_testroot
	dh_clean -k -i 
	dh_installdirs -i

	$(MAKE) install DESTDIR=$(CURDIR)/debian/yum

	# Install our /etc/default file to disable yum-updatesd by default
	install -D -m 0644 debian/yum-updatesd-defaults $(CURDIR)/debian/yum/etc/default/yum-updatesd

	# In Debian, it's not etc/rc.d but etc/init.d, plus we use OUR (eg:
	# Debian specific) init.d script instead.
	rm -rf $(CURDIR)/debian/yum/etc/rc.d
	chmod 0644 $(CURDIR)/debian/yum/etc/yum/yum-updatesd.conf
	chmod 0644 $(CURDIR)/debian/yum/etc/dbus-1/system.d/yum-updatesd.conf

binary-common:
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installexamples
	dh_installinit --name=yum-updatesd
	dh_installman
	dh_link
	dh_strip
	dh_compress 
	dh_fixperms
	dh_pysupport /usr/share/yum-cli
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture independant packages using the common target.
binary-indep: build-indep install-indep
	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common

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