#!/usr/bin/make -f

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

export QPID_PREFIX=/usr

UPSTREAM = http://anonsvn.jboss.org/repos/rhmessaging/store/tags
PACKAGE := $(shell dpkg-parsechangelog | sed -ne 's/^Source: \(.*\)$$/\1/p')
SRC_VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')
TARBALL = $(PACKAGE)_$(SRC_VERSION).orig.tar.gz

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
CXXFLAGS += -Wno-error=cast-qual -Wno-error=cast-align
export CXXFLAGS

.PHONY: get-orig-source
get-orig-source:
	rm -rf get-orig-source $(TARBALL)
	mkdir -p get-orig-source/tmp
	svn export $(UPSTREAM)/qpid-$(SRC_VERSION)-release/cpp get-orig-source/$(PACKAGE)-$(SRC_VERSION)
	GZIP='--best --no-name' tar czf $(TARBALL) -C get-orig-source $(PACKAGE)-$(SRC_VERSION)
	rm -rf get-orig-source
	echo "  "$(TARBALL)" created; move it to the right destination to build the package"

override_dh_auto_configure:
	./bootstrap
	dh_auto_configure -- --with-qpid-prefix=/usr --with-sysconfigdir=/etc/qpid

override_dh_install:
	dh_install
	rm debian/qpidd-msgstore/usr/lib/qpid/daemon/msgstore.la

%:
	dh  $@ --with python2
