#!/usr/bin/make -f

PKGDIR=debian/apt-proxy

build: build-stamp
build-stamp:
	dh_testdir

	$(MAKE) -C doc apt-proxy-import.8
	po4a doc/po4a.cfg
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f doc/*.??.*
	$(MAKE) -C doc clean
	rm -f build-stamp install-stamp AptProxy-shutdown-2.tap
	find . -name "*.pyc" |xargs -r rm
	find . -name "*.tmlc" |xargs -r rm
	debconf-updatepo
	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	dh_install
	dh_installdebconf
	dh_installdocs
	dh_installexamples
	dh_installman
	dh_installchangelogs
	dh_installlogrotate
	dh_pycentral
	dh_python
	dh_installinit

	#install -g root -o root -m 755 \
	#	apt-proxy debian/apt-proxy/usr/sbin/apt-proxy
	#install -g root -o root -m 755 \
	#	apt-proxy-import debian/apt-proxy/usr/sbin/apt-proxy-import
	#install -g root -o root -m 644 \
	#	apt-proxy.conf debian/apt-proxy/etc/apt-proxy/apt-proxy.conf
	
	# Temporary rename to apt-proxy.conf to make it easier to
	# upgrade/downgrade between v1 and v2.
	mv $(PKGDIR)/etc/apt-proxy/apt-proxy.conf $(PKGDIR)/etc/apt-proxy/apt-proxy-v2.conf

	touch install-stamp

binary-arch: build install

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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 install
