#!/usr/bin/make -f

#export DH_VERBOSE=1

include /usr/share/quilt/quilt.make

DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
	CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
else
	CROSS= --build $(DEB_BUILD_GNU_TYPE)
endif

build: build-stamp
build-stamp: debian/stamp-patched
	dh_testdir

	$(MAKE) -j $(NCPUS)

	touch $@

clean: unpatch
	dh_testdir
	dh_testroot
	rm -f build-stamp

	[ ! -f Makefile ] || $(MAKE) clean

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep

	$(MAKE) install PREFIX=$(CURDIR)/debian/m2vrequantiser/usr

# Build architecture-independent files here.
binary-indep: build install

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs README.txt
	dh_installman
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb -- -Zbzip2

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