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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed -fvisibility=hidden

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

# deduce documentation option (build-indep target)
ifeq "" "$(filter %-doc,$(shell dh_listpackages))"
  BUILDDOC = OFF
else
  BUILDDOC = ON
endif

ifeq ($(DEB_HOST_ARCH),amd64)
  export DEB_BUILD_OPTIONS=parallel=2
endif

.PHONY: override_dh_strip override_dh_shlibdeps override_dh_auto_test

%:
	dh $@ --parallel

override_dh_auto_configure:
	dh_auto_configure -- \
	-DALWAYS_CREATE_DOC=$(BUILDDOC)  \
	-DSTRICT_DEPENDECIES=ON \
	-DMIA_CREATE_MANPAGES=ON \
	-DMIA_CREATE_USERDOC=$(BUILDDOC) \
	-DMIA_CREATE_NIPYPE_INTERFACES=ON

override_dh_builddeb:
	dh_builddeb -- -Z xz

# dh_strip detects executable files, so make *.mia files executable then strip then 
# remove the executable flag 
override_dh_strip:
	`pwd`/debian/run_strip

override_dh_auto_build-indep: 
	dh_auto_build -- doc

override_dh_auto_build-arch: 
	dh_auto_build

override_dh_shlibdeps:
	dh_shlibdeps -- $(shell find  debian/libmia-2.4-0/ -name "*.mia")


