#!/usr/bin/make -f

#export DH_VERBOSE=1

get-orig-source:
	@if [ -z "$(UPSTREAM_VERSION)" ]; then echo "Please run as .../debian/rules UPSTREAM_VERSION=xxx $@"; exit 1; fi
	wget -O "pam-python_$(UPSTREAM_VERSION).orig.tar.gz" "http://www.stuart.id.au/russell/files/pam_python/pam_python-$(UPSTREAM_VERSION).tar.gz"

BIN_PACKAGE	= libpam-python
DOC_PACKAGE	= libpam-python-doc
DOC_DIR		= usr/share/doc/$(DOC_PACKAGE)

configure: configure-stamp
configure-stamp:
	dh_testdir
	touch configure-stamp

build: configure-stamp build-stamp
build-stamp:
	dh_testdir
	$(MAKE)
	touch build-stamp

clean:
	dh_testdir
	$(MAKE) clean
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdocs -p$(BIN_PACKAGE)
	dh_installchangelogs -p$(BIN_PACKAGE) ChangeLog.txt
	dh_installdocs -p$(DOC_PACKAGE) README.txt
	dh_installchangelogs -p$(DOC_PACKAGE)
	$(MAKE) DESTDIR=$(CURDIR)/debian/tmp DOCDIR=/$(DOC_DIR) install
	rm $(CURDIR)/debian/tmp/$(DOC_DIR)/html/_static/jquery.js
	dh_movefiles -p$(BIN_PACKAGE) lib/security
	dh_movefiles -p$(DOC_PACKAGE) $(DOC_DIR)

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_link -p$(DOC_PACKAGE) /usr/share/javascript/jquery/jquery.js $(DOC_DIR)/html/_static/jquery.js
	dh_compress -i -X$(DOC_DIR)/html
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_link -a
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

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