#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
#export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export JAVA_HOME=/usr/lib/jvm/default-java
export CLASSPATH=/usr/share/java/csv.jar:/usr/share/java/debug-disable.jar:/usr/share/java/itext.jar
export GTEST_DIR=/usr/src/gtest

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

# mapping all i.86 to x86 for Alljoyn
CPU=$(shell dpkg-architecture -qDEB_HOST_GNU_CPU | sed -e 's/i.86/x86/')
OS=linux
TARG=linux

export VERSION := 16.04
export SONAME := 1604
export VARIANT := release
export SCONS_ARGS := CPU=$(CPU) TARG=$(TARG) VARIANT=$(VARIANT) V=1 GTEST_DIR=$(GTEST_DIR)
export BUILD_DIR := $(CURDIR)/build/$(OS)/$(CPU)/$(VARIANT)/dist
export OBJ_DIR := $(CURDIR)/build/$(OS)/$(CPU)/$(VARIANT)/obj

%:
	dh $@

override_dh_auto_build:
	scons BINDINGS=cpp $(SCONS_ARGS) \
		WS=off BT=off ICE=off 

	touch ./to-be.removed-now.md5
	find ./* |grep '\.md5'|xargs rm

	dh_auto_build

override_dh_auto_clean:
	rm -f .sconsign.dblite
	rm -rf .sconf_temp
	rm -f config.log
	rm -rf dist
	touch ./to-be.removed-now.md5
	find ./* |grep '\.md5'|xargs rm
	touch ./to-be.removed-now.os
	find ./* |grep '\.os'|xargs rm
	touch ./to-be.removed-now.o
	find ./* |grep '\.o'|xargs rm
	rm -rf build
	dh_auto_clean

override_dh_install:
	dh_install
	## improve stuff
	#chmod 644 debian/alljoyn-services-1509/etc/alljoyn/*.conf
