#!/usr/bin/make -f
#export DH_VERBOSE=1

include /usr/share/quilt/quilt.make

build build-indep build-arch: build-stamp
build-stamp: $(QUILT_STAMPFN)
	# libdds
	$(MAKE)
	# dds
	$(MAKE) -C ddd
	sed -ne '/^\/\* =/,/^\*\//p' ddd/giblib.h > ddd/giblib.txt
	# pydds
	-ln -s ../dll.h ../dds.cpp python
	cd python && python setup.py build
	touch $@

install: build-stamp
	dh_testroot
	dh_clean -k
	# libdds
	$(MAKE) install PREFIX=/usr DESTDIR=$(CURDIR)/debian/libdds-dev
	# dds
	$(MAKE) -C ddd install PREFIX=/usr DESTDIR=$(CURDIR)/debian/dds
	# pydds
	cd python && python setup.py install --root $(CURDIR)/debian/python-pydds

binary-indep:

binary-arch: install
	dh_installchangelogs -a release_notes.txt
	dh_installdocs -a -A debian/README.Debian
	dh_installman -a
	dh_installexamples -a
	dh_strip -a
	dh_compress -a
	dh_pycentral -p'python-pydds'
	dh_fixperms -a
	dh_shlibdeps -a
	dh_installdeb -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch

clean: unpatch
	dh_testdir
	-$(MAKE) clean
	-$(MAKE) -C ddd clean
	rm -rf python/build
	dh_clean build-stamp ddd/giblib.txt python/dll.h python/dds.cpp

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