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

# List of architectures for which test execution is enabled
TEST_ARCHS=i386 amd64 powerpc ppc64el armhf arm64 s390x
TEST_ARCHS=i386 amd64 powerpc ppc64el
TEST_ARCHS=
TEST_ARCHS=i386 amd64 powerpc ppc64el armhf arm64 s390x

export DEB_CFLAGS_MAINT_APPEND = -fno-strict-aliasing
export DEB_CXXFLAGS_MAINT_APPEND = -fno-strict-aliasing

%:
	dh ${@} --parallel --with autoreconf

override_dh_auto_test:
  ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
    ifneq (,$(filter $(DEB_HOST_ARCH), arm64))
	@echo Skip running the tests on arm64, hanging the buildds
    else ifneq (,$(filter $(DEB_HOST_ARCH), armhf))
	-dh_auto_test
	@echo Ignoring test results on armhf
    else ifneq (,$(filter $(DEB_HOST_ARCH), $(TEST_ARCHS)))
	dh_auto_test
    endif
  endif

override_dh_install:
	mv debian/tmp/usr/bin/pprof \
		debian/tmp/usr/bin/google-pprof
	mv debian/tmp/usr/share/man/man1/pprof.1 \
		debian/tmp/usr/share/man/man1/google-pprof.1
	sed -i -e 's/pprof/google-pprof/g' \
		debian/tmp/usr/share/man/man1/google-pprof.1
	: # remove files which are not installed
	rm -f debian/tmp/usr/lib/*/*.la

	dh_install --fail-missing

override_dh_strip:
	dh_strip -plibtcmalloc-minimal4 --dbg-package=libtcmalloc-minimal4-dbg
	dh_strip -plibgoogle-perftools4 --dbg-package=libgoogle-perftools4-dbg
	dh_strip -Nlibtcmalloc-minimal4 -Nlibgoogle-perftools4
