#!/usr/bin/make -f

%:
	dh $@ --with python2

override_dh_auto_configure:
# make sure docs are generated and the manifest is built
	$(MAKE) locale
	$(MAKE) -C doc/html all
	python setup.py sdist --manifest-only

override_dh_auto_build:
# force usage of setup.py over Makefile
	dh_auto_build --buildsystem python_distutils

override_dh_installchangelogs:
# install custom changelog
	dh_installchangelogs doc/changelog.txt


ROOTDIR=$(CURDIR)/debian/linkchecker
DOCDIR=$(ROOTDIR)/usr/share/doc/linkchecker
SHAREDIR=$(ROOTDIR)/usr/share/linkchecker
HTMLDIR=$(SHAREDIR)/lconline
CGIDIR=$(ROOTDIR)/usr/lib/cgi-bin
LOCALEDIR=$(ROOTDIR)/usr/share/locale
ETCDIR=$(ROOTDIR)/etc

override_dh_auto_install:
	dh_auto_install --buildsystem python_distutils
# install system wide configuration files in etc
	install -m 644 config/linkcheckerrc $(ETCDIR)/linkchecker/
	install -m 644 config/logging.conf $(ETCDIR)/linkchecker/
# install CGI files
	install -m 644 cgi-bin/lconline/*.html $(HTMLDIR)
	install -m 644 cgi-bin/lconline/*.de $(HTMLDIR)
	install -m 644 cgi-bin/lconline/*.en $(HTMLDIR)
	install -m 644 cgi-bin/lconline/*.js $(HTMLDIR)
	install -m 644 cgi-bin/lconline/*.css $(HTMLDIR)
	install -m 755 cgi-bin/lc.cgi $(CGIDIR)
# install bash_completion script
	install -m 644 config/linkchecker-completion $(ETCDIR)/bash_completion.d
# install .mo files
	install -m 644 build/share/locale/de/LC_MESSAGES/LinkChecker.mo $(LOCALEDIR)/de/LC_MESSAGES/
# apache configuration
	install -m 644 config/linkchecker.apache2.conf $(ETCDIR)/apache2/conf.d/linkchecker

# clean generated files
override_dh_clean:
	dh_clean doc/html/*.qch doc/html/*.qhc _LinkChecker_configdata.py

# do not run test suite when building
override_dh_auto_test:

