#!/usr/bin/make -f
# -*- makefile -*-

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

# compile with libtbb-dev only with linux 64bit intel/ppc architectures,
# fallback in pentium4 processors is not implemented, see also note of
# libtbb-dev:
#
# Note: if you are a user of the i386 architecture, i.e., 32-bit Intel
# or compatible hardware, this package only supports Pentium4-compatible
# and higher processors.
#
arch = $(shell dpkg-architecture -qDEB_BUILD_ARCH | egrep "(amd64|ia64|ppc64)")
os = $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS | grep linux)

CONFIGPARMS = --prefix=/usr --with-claspre
TOPBUILDDIR = build/release
ifeq ($(and $(if $(os),good), $(if $(arch),good)), good)
	CONFIGPARMS += --with-mt TBB_INCLUDE=/usr/include TBB_LIB=/usr/lib
	TOPBUILDDIR = build/release_mt
endif


%:
	dh $@

# call ./configure.sh $(CONFIGPARMS)
override_dh_auto_configure:
	./configure.sh $(CONFIGPARMS)

# build in $(TOPBUILDDIR)
override_dh_auto_build:
	dh_auto_build --builddirectory=$(TOPBUILDDIR)

# install clasp binary built in $(TOPBUILDDIR)
override_dh_auto_install:
	dh_auto_install --builddirectory=$(TOPBUILDDIR) -- INSTALL_DIR=$(CURDIR)/debian/clasp/usr/bin

# remove the whole build dir
override_dh_auto_clean:
	rm -rf ./build

# install CHANGES as changelog
override_dh_installchangelogs:
	dh_installchangelogs CHANGES
