#!/usr/bin/make -f

DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
OSTYPE   ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
HOSTTYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU)
CFLAGS = -Wall -g


ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

version=4.8.0
major=4

configure: configure-stamp
configure-stamp:
	dh_testdir

	touch configure-stamp


build: build-stamp
build-stamp: configure-stamp 
	dh_testdir
	$(MAKE) OSTYPE=$(OSTYPE) HOSTTYPE=$(HOSTTYPE)

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	-$(MAKE) clean OSTYPE=$(OSTYPE) HOSTTYPE=$(HOSTTYPE)

	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs

	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp OSTYPE=$(OSTYPE) HOSTTYPE=$(HOSTTYPE)


binary-indep: build install

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	dh_installdocs
	dh_installexamples
	dh_install --sourcedir=$(CURDIR)/debian/tmp
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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