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

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

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

%:
	dh $@ -- --buildsystem=cmake --parallel

override_dh_auto_configure:
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
	dh_auto_configure -- -DENABLE_DOCS:BOOL=ON -DLPP_USE_ALLOCATOR:BOOL=OFF -DCMAKE_TOOLCHAIN_FILE=CMakeCross.txt -Wno-dev
	# HACK: cmake removes the /usr/lib path when cross building, so manually add it back
	find -iname "link.txt" | xargs sed -i "s|lboost_thread-mt|lboost_thread-mt -L/usr/lib |g"
else
	dh_auto_configure -- -DENABLE_DOCS:BOOL=ON -DLPP_USE_ALLOCATOR:BOOL=OFF
endif

override_dh_auto_build:
	dh_auto_build -- lucene++ lucene++-contrib lucene++-tester demo doc
