#!/usr/bin/make -f

PKG_TMP=$(CURDIR)/debian/tmp

export ROOTSYNOPSIS=$(CURDIR)/debian/synopsis
export ROOTSYNOPSISDOC=$(CURDIR)/debian/synopsis-doc

clean:
	dh clean
	# cancel mor stuff, to build it twice in a row
	find $(CURDIR)/Synopsis -name "*.pyc" -delete
	rm -rf build/

%:
	dh $@ --with python2

override_dh_auto_clean:

override_dh_link:
	dh_link usr/lib/synopsis/synopsis usr/bin/synopsis
	dh_link usr/lib/synopsis/sxr-server usr/bin/sxr-server
	dh_link

override_dh_auto_configure:
	python setup.py config --prefix=/usr --with-gc-prefix=/usr

override_dh_auto_build:
	python setup.py build

override_dh_auto_install:
	python setup.py install\
		--no-compile -O0 --install-layout=deb\
		--install-lib=/usr/lib/synopsis\
		--install-scripts=/usr/lib/synopsis\
		--root=$(PKG_TMP)\
		--prefix=/usr
	mv -f $(PKG_TMP)/usr/share/doc/synopsis-* $(PKG_TMP)/usr/share/doc/synopsis-doc
	rm -f $(PKG_TMP)/usr/share/doc/synopsis-doc/COPYING

override_dh_install:
	mkdir -p debian/tmp/usr/bin
	dh_install --sourcedir=debian/tmp
