#!/usr/bin/make -f

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

build:
	./configure --prefix=/usr --sysconfdir=/etc/ssh
	$(MAKE)
	touch build

clean: checkdir
	rm -f build
	$(MAKE) -i distclean
	dh_clean

binary-indep: build

binary-arch: checkroot build
	dh_clean -k
	dh_installdirs

	$(MAKE) exec_prefix=`pwd`/debian/tmp/usr etcdir=`pwd`/debian/tmp/etc/ssh mandir=`pwd`/debian/tmp/usr/share/man install

#pam stuff

	install -d -o root -g root -m 755 debian/tmp/etc/pam.d
	install -p -o root -g root -m 644 sshd.pam debian/tmp/etc/pam.d/sshd
	install -p -o root -g root -m 644 debian/host_config.sample debian/tmp/etc/ssh/sshd_config

	dh_installdocs -popenssh OVERVIEW README README.openssh COPYING.Ylonen RFC.nroff
	dh_installinit -popenssh

	dh_undocumented
	dh_installchangelogs -popenssh ChangeLog ChangeLog.Ylonen
	dh_movefiles
	dh_strip
	dh_compress
#	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_makeshlibs
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b';false

checkdir:
	@test -f ssh.c -a -f debian/rules

checkroot: checkdir
	@test 0 = `id -u` || { echo "Error: not super-user"; exit 1; }

