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

-include /usr/share/dpkg/buildflags.mk

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

configure: configure-stamp
configure-stamp:
	dh_testdir
	CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --prefix=/usr
	touch $@

build: build-arch build-indep

build-arch build-indep: build-stamp

build-stamp: configure-stamp
	dh_testdir
	$(MAKE)
	touch $@

clean: configure-stamp
	dh_testdir
	dh_testroot
	rm -f build-stamp
	$(MAKE) distclean
	dh_clean
	find . -type f -name Makefile -exec rm -fv {} \;
	find . -type d -name .deps -print0 | xargs -0 rm -rf

install: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
	rm -vf $(CURDIR)/debian/tmp/usr/lib/*.la
	rm -vf $(CURDIR)/debian/tmp/usr/lib/*.a
	mv $(CURDIR)/debian/tmp/usr/bin/example $(CURDIR)/debian/tmp/usr/bin/activemqcpp-example

binary-indep:

binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_installexamples
	dh_installman
	dh_installlogrotate
	dh_installcron
	dh_install --fail-missing
	dh_link
	dh_strip -pactivemq-cpp-examples --dbg-package=activemq-cpp-examples-dbg
	dh_strip -plibactivemq-cpp17 --dbg-package=libactivemq-cpp17-dbg
	dh_compress
	dh_fixperms
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-arch binary-indep
