#!/usr/bin/make -f

package=fetchmail


clean:
	dh_testdir
	dh_clean
	rm -f build
	-$(MAKE) -i distclean
	rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars


build-indep:    install-indep
#	touch build-indep
    
build-arch: install-arch
#	touch build-arch

build:  build-arch build-indep
	dh_testdir
	./configure --prefix=/usr --enable-nls
	$(MAKE) CFLAGS="-O2 -g -Wall" 
	touch build


install-indep:
#	dh_clean -k -i
#	dh_installfiles -i

install-arch:
#	dh_clean -k -a
#	dh_installfiles -a

install:	install-arch install-indep
	dh_clean
	dh_installdirs
	$(MAKE) install prefix=`pwd`/debian/tmp/usr
	(cd debian/tmp/usr/bin; ln -s fetchmail popclient)
	(cd debian/tmp/usr/man/man1; ln -s fetchmail.1.gz popclient.1.gz; ln -s fetchmail.1.gz fetchmailconf.1.gz; rm fetchmailconf.1)
	cp -R contrib/* debian/tmp/usr/doc/fetchmail/contrib/
	install -m 644 debian/fetchmail-up debian/tmp/usr/doc/fetchmail/
	install -m 644 debian/fetchmail-down debian/tmp/usr/doc/fetchmail/

binary-arch:	install
	dh_testdir -a
#	dh_testroot -a
#	dh_movefiles -a
	dh_installdocs -a NEWS NOTES README FAQ fetchmail-features.html sample.rcfile
#	dh_installmenu -a
	dh_installmanpages -a
	dh_installchangelogs -a
	dh_strip -a
	dh_makeshlibs -a
	dh_compress -a
	dh_fixperms -a
#	dh_suidregister -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_builddeb -a

binary:		binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean checkroot
