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

# 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

# Environment information.
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

# Fixes FTBFS on mips64* architectures. See #805893.
ifneq (,$(filter mips64%,$(DEB_HOST_ARCH)))
DEB_CFLAGS_MAINT_APPEND += -mxgot
DEB_CXXFLAGS_MAINT_APPEND += -mxgot
endif

# Common build options.
export CMAKE_BUILD_OPTIONS = \
	-DBUILD_RUNTIME=ON \
	-DBUILD_TEST=OFF \
	-DBUILD_PERFORMANCE=OFF \
	-DBUILD_CLIENT=ON \
	-DBUILD_KTEST=OFF \
	-DBUILD_SHARED_LIBS=ON \
	-DSUFFIX_LIB="/$(DEB_TARGET_MULTIARCH)"

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

%:
	dh $@ --parallel --sourcedirectory=src

override_dh_auto_clean:
	dh_auto_clean
	find . -name "*.pyc" -delete

override_dh_auto_configure:
	dh_auto_configure -- $(CMAKE_BUILD_OPTIONS)

override_dh_auto_build-indep:
	cd doc && doxygen clBLAS.doxy

override_dh_installdocs-indep:
	dh_installdocs --indep
	dh_doxygen --indep

override_dh_compress-indep:
	dh_compress --indep --exclude=examples
