#!/usr/bin/make -f

# Pass -Wall and some other compiler options we wish to use.
CFLAGS = "-Wall $(DEB_CFLAGS)"
CXXFLAGS = "-Wall $(DEB_CXXFLAGS)"

# nostrip option implies noopt
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
   TYPE=Release
else
   TYPE=Debug
endif

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

# Use this variable to allow options passed to cmake to be overridable
DEB_CMAKE_OPTIONS ?= -DCMAKE_VERBOSE_MAKEFILE=ON \
		-DCMAKE_BUILD_TYPE=$(TYPE) \
		-DCMAKE_INSTALL_PREFIX="/usr" \
		-DCMAKE_C_FLAGS="$(CFLAGS)" \
		-DCMAKE_CXX_FLAGS="$(CXXFLAGS)" \
		-DCMAKE_CXX_COMPILER="g++" \
		-DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)"

%:
	dh $@

override_dh_auto_clean:
	rm -rf build/*

override_dh_auto_configure:
	cd build && cmake $(DEB_CMAKE_OPTIONS) ..

override_dh_auto_build:
	$(MAKE) --directory=build

override_dh_auto_install:
	$(MAKE) --directory=build install DESTDIR=$(CURDIR)/debian/tmp

override_dh_gencontrol:
	dh_gencontrol
	debian/alure-dynload-shlibdeps

get-orig-source:
	$(dir $_)alure-get-orig-source
