#!/usr/bin/make -f

DEB_DH_MAKESHLIBS_ARGS_libtelepathy-glib0 := -V"libtelepathy-glib0 (>= 0.5.10)"

include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/simple-patchsys.mk

# We don't want the .la files, but complain if anything else is missing
binary-post-install/libtelepathy-glib-dev::
	rm -f debian/tmp/usr/lib/*.la
common-binary-post-install-arch:: list-missing

DEB_DH_STRIP_ARGS := --dbg-package=libtelepathy-glib0

DEB_CONFIGURE_EXTRA_FLAGS := --prefix=/usr
#	--enable-gtk-doc \
#	--with-html-dir=\$${prefix}/share/doc/libtelepathy-glib-doc

# we symlink many of the doc directories together
DEB_INSTALL_DOCS_libtelepathy-glib0-dbg := --no-act
DEB_INSTALL_CHANGELOGS_libtelepathy-glib0-dbg := --no-act
DEB_INSTALL_DOCS_libtelepathy-glib-dev := --no-act
DEB_INSTALL_CHANGELOGS_libtelepathy-glib-dev := --no-act
DEB_INSTALL_DOCS_libtelepathy-glib-unstable-dev := --no-act
DEB_INSTALL_CHANGELOGS_libtelepathy-glib-unstable-dev := --no-act

# Use soft-float and thumb mode if it enabled.
ifneq (,$(findstring thumb,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -mthumb
endif

ifneq (,$(findstring coverage,$(DEB_BUILD_OPTIONS)))
	SBOX_USE_CCACHE := no
	DEB_CONFIGURE_EXTRA_FLAGS += --enable-coverage
endif

# Use parallel jobs if possible
ifneq (,$(findstring parallel,$(DEB_BUILD_OPTIONS)))
	PARALLEL_JOBS := $(shell echo $(DEB_BUILD_OPTIONS) | \
		sed -e 's/.*parallel=\([0-9]\+\).*/\1/')
	ifeq ($(DEB_BUILD_OPTIONS),$(PARALLEL_JOBS))
		PARALLEL_JOBS := $(shell if [ -f /proc/cpuinfo ]; \
			then echo `cat /proc/cpuinfo | grep 'processor' | wc -l`; \
			else echo 1; fi)
	endif
	NJOBS := -j$(PARALLEL_JOBS)
endif
DEB_MAKE_ENVVARS := MAKEFLAGS=$(NJOBS)

makebuilddir::
	CFLAGS="$(CFLAGS)" sh ./autogen.sh $(cdbs_configure_flags) $(DEB_CONFIGURE_EXTRA_FLAGS) $(DEB_CONFIGURE_USER_FLAGS)
