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

TEST_SKIP_ARCHS=
TEST_IGNORE_ARCHS=arm64 armhf

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 (,$(findstring $(DEB_HOST_ARCH), $(TEST_SKIP_ARCHS)))
	@echo Skip running the tests on $(DEB_HOST_ARCH), hanging the buildds
    else ifneq (,$(findstring $(DEB_HOST_ARCH), $(TEST_IGNORE_ARCHS)))
	-dh_auto_test --no-parallel
	@echo Ignoring test results on $(DEB_HOST_ARCH)
    else
	dh_auto_test --no-parallel
    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
	dh_strip -plibgoogle-perftools4
	dh_strip -Nlibtcmalloc-minimal4 -Nlibgoogle-perftools4
