#!/usr/bin/make -f

DEB_DH_INSTALL_SOURCEDIR=debian/tmp

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

DEB_CONFIGURE_PREFIX=/usr

DEB_CONFIGURE_EXTRA_FLAGS = --enable-gtk-doc --disable-Werror --enable-python PYTHON=/usr/bin/python2.5

ifeq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
    CFLAGS += -DG_DISABLE_CAST_CHECKS
endif

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

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)

post-patches::
	[ -x configure ] || ./autogen.sh --no-configure

include $(CURDIR)/debian/update-patches.mk
