#!/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)

ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
	confflags += --build `echo $(DEB_BUILD_GNU_TYPE) | sed -e 's/i[345]86/i686/'`
else
	confflags += --build `echo $(DEB_BUILD_GNU_TYPE) | sed -e 's/i[345]86/i686/'` --host `echo $(DEB_HOST_GNU_TYPE) | sed -e 's/i[345]86/i686/'`
endif

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS = -g
	CXXFLAGS = -g
else
	CFLAGS = -O2 -g
	CXXFLAGS = -O2 -g
endif

%:
	dh $@

configure: configure.ac cf/boinc.m4
	autoreconf --install --symlink --force

binary: configure
	dh $@ --before dh_auto_configure
	# Add here commands to configure the package.
	# autoreconf
	./configure $(confflags) \
		--prefix=/usr \
		--enable-gtk-doc \
		--enable-backend-boinc \
		--disable-backend-condor \
		--enable-backend-local \
		--with-html-dir=/usr/share/doc/libdcapi-doc \
		--disable-java \
		CFLAGS="$(CFLAGS)" \
		CXXFLAGS="$(CXXFLAGS)"
	dh $@ --after dh_auto_configure -X.svn --dbg-package=libdcapi-dbg
