#!/usr/bin/make -f
export DH_VERBOSE = 1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

export PYBUILD_NAME=qiskit-aer
export PYBUILD_TEST_PYTEST=1

# Skip some tests:
# * TestNoiseTransformer: several tests depend on features that require "cvxpy"
export PYBUILD_TEST_ARGS={build_dir}/test/terra -k "not TestNoiseTransformer"

# Used by upstream for determining if build the simulators as a library.
export UPSTREAM_CMAKE_ARGS=-DSKBUILD:BOOL=TRUE

%:
	dh $@ --buildsystem=cmake --with=python3

# Upstream package uses "skbuild" for invoking cmake from setuptools. As the
# package is not available in debian, this file resorts to compiling the shared
# libs using cmake, and packaging using setuptools.

override_dh_auto_clean:
	dh_auto_clean
	dh_auto_clean --buildsystem=pybuild

override_dh_auto_configure:
	dh_auto_configure --builddirectory=build/python -- \
        -DCMAKE_INSTALL_PREFIX=../.. \
        ${UPSTREAM_CMAKE_ARGS}

override_dh_auto_build:
	# Build using cmake in a custom directory, running cmake install
	# for placing the resulting .so in the expected locations.
	dh_auto_build --builddirectory=build/python ; cmake --install build/python
	dh_auto_build --buildsystem=pybuild

override_dh_auto_install:
	dh_auto_install --buildsystem=pybuild

override_dh_auto_test:
	dh_auto_test --buildsystem=pybuild
