#!/usr/bin/make -f
# -*- makefile -*-
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#DH_VERBOSE = 1


# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_CXXFLAGS_MAINT_APPEND=-DENABLE_BOOST_ATOMIC_COUNT

%:
	dh $@

override_dh_autoreconf:
	cp -a doc/html doc/html.bak
	touch INSTALL ChangeLog
	dh_autoreconf

override_dh_auto_configure:
	dh_auto_configure -- --without-java --without-python --without-ruby --with-openssl
	# Restore empty lib/ directory used by upstream build system
	mkdir $(CURDIR)/lib

override_dh_auto_build:
	dh_auto_build
	(cd $(CURDIR)/doc ; ./document.sh)

override_dh_installexamples:
	dh_installexamples
	find debian -name "*.o" -delete
	find debian -name .libs | xargs rm -rf \{\} \;

override_dh_clean:
	dh_clean
	if [ -d doc/html.bak ] ; then rm -rf doc/html; mv doc/html.bak doc/html ; fi
	rm -rf INSTALL ChangeLog $(CURDIR)/lib
	find doc -name "*.md5" -delete
	find doc -name "*.png" -delete
	find doc -name "*.map" -delete
	find examples -name Makefile -delete
	find src -name Makefile -delete
	find test -name Makefile -delete

override_dh_fixperms:
	dh_fixperms
	find $(CURDIR)/debian \( -name Market.cpp -o -name '*.bat' \) -exec chmod 644 {} \;
