#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
PACKAGE=linkchecker
DOCDIR = debian/$(PACKAGE)/usr/share/doc/$(PACKAGE)

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

# This is the debhelper compatability version to use.
export DH_COMPAT=3

# This has to be exported to make some magic below work.
export DH_OPTIONS

configure: configure-stamp
configure-stamp:
	dh_testdir
	./setup.py config -lcrypto
	touch configure-stamp


build: configure-stamp build-stamp
build-stamp:
	dh_testdir
	rm -rf debian/linkchecker debian/linkchecker-ssl
	python setup.py build
	touch build-stamp

clean:
	dh_testdir
	rm -f build-stamp configure-stamp
	$(MAKE) clean
	dh_clean

install: build
	dh_testdir
	dh_clean -k
	dh_installdirs
	$(MAKE) locale
	python setup.py install --root=$(CURDIR)/debian/$(PACKAGE) --no-compile
	# remove man pages, we install them with dh_installman
	rm -r debian/$(PACKAGE)/usr/man
	# remove files, we install them below
	rm -r debian/$(PACKAGE)/usr/share/linkchecker/examples
	# remove any SSL related files
	rm -r debian/$(PACKAGE)/usr/lib/python2.1/site-packages/linkcheckssl
	# install additional doc files
	install -c -m 644 DNS/README $(DOCDIR)/README_DNS.txt
	install -c -m 644 test/*.py $(DOCDIR)/test
	install -c -m 644 test/html/*.html $(DOCDIR)/test/html
	install -c -m 644 test/output/test_* $(DOCDIR)/test/output
	# install CGI files
	install -c -m 644 lconline/*.html $(DOCDIR)/lconline
	install -c -m 755 lc.cgi debian/$(PACKAGE)/usr/lib/cgi-bin/lconline
	# install system wide configuration file in etc
	mv debian/$(PACKAGE)/usr/share/linkchecker/linkcheckerrc debian/$(PACKAGE)/etc


# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
#	dh_installdebconf
	dh_installdocs
#	dh_installexamples
#	dh_installmenu
#	dh_installemacsen
#	dh_installpam
#	dh_installinit
#	dh_installcron
	dh_installman linkchecker.1
#	dh_installinfo
#	dh_undocumented linkchecker.1
	dh_installchangelogs 
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_makeshlibs
	dh_installdeb
#	dh_perl
#	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install

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