#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

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

# Upstream does not use CPPFLAGS
CFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) \
        $(shell dpkg-buildflags --get CFLAGS)
export CFLAGS

%:
	dh $@ --sourcedirectory=src --with autotools_dev --with autoreconf

.PHONY: override_dh_autoreconf
override_dh_autoreconf:
	dh_autoreconf bash -- -c "cd src && autoreconf -i -f"

.PHONY: override_dh_auto_configure
override_dh_auto_configure:
	dh_auto_configure --sourcedirectory=src -- \
		--with-static-lib=yes \
		--with-shared-lib=yes \
		--with-shlib \
		--with-perf-events \
		--with-pfm-incdir=/usr/include \
		--with-pfm-libdir=/usr/lib/$(DEB_HOST_MULTIARCH)

.PHONY: override_dh_auto_build
override_dh_auto_build:
	dh_auto_build --sourcedirectory=src

.PHONY: override_dh_auto_test
override_dh_auto_test:
	-dh_auto_test

.PHONY: override_dh_auto_install
override_dh_auto_install:
	dh_auto_install --sourcedirectory=src -- install-all
	# clean built examples, we need to install the sources from the source tree
	$(MAKE) -C src/ctests clean
	$(MAKE) -C src/ftests clean
	$(MAKE) -C src/testlib clean

.PHONY: override_dh_shlibdeps
override_dh_shlibdeps:
	dh_shlibdeps -a -- --warnings=7

.PHONY: override_dh_install
override_dh_install:
	dh_install --list-missing

.PHONY: override_dh_installchangelogs
override_dh_installchangelogs:
	dh_installchangelogs RELEASENOTES.txt

.PHONY: override_dh_strip
override_dh_strip:
	dh_strip --dbg-package=papi-dbg

.PHONY: override_dh_compress
override_dh_compress:
	dh_compress -X.c -X.h -X.F -XMakefile
