#!/usr/bin/make -f

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

ifeq ($(shell cat /etc/issue | cut -d' ' -f2), 11.10)
	SUBSTVARS = -Vdist:Depends="qemu-arm-static, syslinux (>= 2:4.05)"
else
	SUBSTVARS = -Vdist:Depends="qemu-user-static, syslinux (>= 2:4.05), extlinux (>= 2:4.05)"
endif


build: build-stamp
build-stamp:
	dh_testdir

	python setup.py build
	make man

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Installing package
	mkdir -p $(CURDIR)/debian/mic $(CURDIR)/debian/mic/usr/bin $(CURDIR)/debian/mic/usr/share/man/man1
	install -m644 doc/mic.1 $(CURDIR)/debian/mic/usr/share/man/man1
	python setup.py install --root=$(CURDIR)/debian/mic

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_install
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_pysupport
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol -- $(SUBSTVARS)
	dh_md5sums
	dh_builddeb

binary-arch: build install

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