#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

export PYBUILD_NAME = petsc4py

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

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

PETSC_VERSION=3.7$(PETSC_EXT)
export PETSC_DIR=/usr/lib/petscdir/$(PETSC_VERSION)

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


# main packaging script based on dh7 syntax
%:
	dh $@ --with python2,python3 --buildsystem=pybuild

override_dh_clean:
	dh_clean
	rm -rf .eggs

override_dh_auto_build:
	PETSC_DIR=$(PETSC_DIR)  dh_auto_build
	# petsc4py embeds the deep PETSC_DIR path as RPATH in its library.
	# Swap it out for a standard path, or else dh_shlibdeps gets confused
	chrpath -d .pybuild/pythonX.Y_*/build/petsc4py/lib/PETSc*.so

override_dh_auto_install:
	PETSC_DIR=$(PETSC_DIR)  dh_auto_install

override_dh_python2:
	dh_python2
	dh_numpy

override_dh_python3:
	dh_python3
	dh_numpy3

override_dh_compress:
	dh_compress -Xpdf

