#!/usr/bin/make -f

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

%:
	dh $@   --with python2

override_dh_auto_install:
	cd doc && make html
	cd doc && make latexpdf 
	python setup.py install --prefix=debian/macsyfinder/usr/ --install-conf=debian/macsyfinder/etc/ --no-viewer
	# The better solution would be to use
	#	dh_auto_install -- --prefix=/usr --install-conf=/etc --no-viewer
	# and fiy setup.py to use --root as install location (which is ignored unfortunately)
	# Since I have no idea how to fix setup.py here the broken config files are hacked afterwards
	for conffile in \
		etc/macsyfinder/macsyfinder.conf.new \
		usr/lib/python2.7/site-packages/macsypy/config.py \
		usr/lib/python2.7/site-packages/macsypy/registries.py \
		; do \
	    sed -i 's:debian/macsyfinder::g' debian/macsyfinder/$${conffile} ; \
	done
	mv debian/macsyfinder/etc/macsyfinder/macsyfinder.conf.new debian/macsyfinder/etc/macsyfinder/macsyfinder.conf
	rm debian/macsyfinder/usr/share/doc/macsyfinder/html/_static/jquery.js
	rm debian/macsyfinder/usr/share/doc/macsyfinder/html/_static/underscore.js
	rm -Rf debian/macsyfinder/usr/share/macsyfinder/macsyview

override_dh_clean:
	rm -Rf doc/_build
	rm -f uninstall.cfg
	rm -f uninstall_files
	dh_clean
