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

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

VERSION=$(shell expr "`dpkg-parsechangelog 2>/dev/null |grep Version:`" : '.*Version: \(.*\)')
POD2MAN=pod2man -c Debhelper -r "$(VERSION)"

build-indep:
	$(POD2MAN) dh_installzope dh_installzope.1
	$(POD2MAN) dh_installzopeinstance dh_installzopeinstance.1

	for p in autoscripts/*-dzproduct; do \
	  e=$$(echo $$p | sed 's/dzproduct/dzextension/'); \
	  sed 's/product/extension/g' $$p > $$e; \
	done

build-arch:

build: build-indep build-arch

clean:
	dh_testdir
	dh_testroot
	rm -f dh_installzope.1
	rm -f dh_installzopeinstance.1
	rm -f autoscripts/*-dzextension
	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs \
		usr/bin \
		usr/share/man/man1 \
		usr/share/debhelper/autoscripts

	cp -p dh_installzope debian/zope-debhelper/usr/bin/
	cp -p dh_installzope.1 debian/zope-debhelper/usr/share/man/man1/

	cp -p dh_installzopeinstance debian/zope-debhelper/usr/bin/
	cp -p dh_installzopeinstance.1 debian/zope-debhelper/usr/share/man/man1/

	cp -p autoscripts/* debian/zope-debhelper/usr/share/debhelper/autoscripts/

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	dh_installdocs
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_perl
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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

binary: binary-indep binary-arch

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