#!/usr/bin/make -f

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

# Hardening flags.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
export DEB_CXXFLAGS_MAINT_APPEND = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# Common cmake options.
CMAKE_BUILD_OPTIONS = \
	-DBUILD_SHARED_LIBS=ON \
	-DENABLE_CBLAS=ON \
	-DENABLE_OPENMP=ON \
	-DSHARK_INSTALL_DOC_DIR=share/doc/shark-doc \
	-DSHARK_INSTALL_EXAMPLE_DIR=share/doc/shark-doc/examples

# Disable build of testsuite if no check requested.
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
CMAKE_BUILD_OPTIONS += -DBUILD_TESTING=ON
else
CMAKE_BUILD_OPTIONS += -DBUILD_TESTING=OFF
endif

%:
	dh $@ --parallel

override_dh_auto_configure-arch:
	dh_auto_configure -- $(CMAKE_BUILD_OPTIONS) \
		-DBUILD_DOCUMENTATION=OFF \
		-DBUILD_EXAMPLES=OFF

override_dh_auto_configure-indep:
	dh_auto_configure -- $(CMAKE_BUILD_OPTIONS) \
		-DBUILD_DOCUMENTATION=ON \
		-DBUILD_EXAMPLES=ON \
		-DOPT_INSTALL_DOCUMENTATION=ON

override_dh_auto_test:
	dh_auto_test -- ARGS+="-LE 'slow'"

override_dh_installdocs-indep:
	dh_installdocs --indep
	dh_doxygen --indep \
		/usr/share/doc/shark-doc/html/doxygen_pages/html
	dh_sphinxdoc --indep --exclude=MathJax.js \
		/usr/share/doc/shark-doc/html/sphinx_pages

override_dh_compress:
	dh_compress --exclude=examples
