#!/usr/bin/make -f

# Force automake to be verbose
export V=1

export DEB_HOST_MULTIARCH

ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
# build-config/common/m4/ac_scorep_sys_detection.m4 otherwise assumes that Linux never cross-compiles
export ac_scorep_cross_compiling=yes
endif

%:
	dh $@

override_dh_auto_clean:
	dh_auto_clean
	# Make sure to regenerate from templates
	python3 -X pycache_prefix=debian/tmp < debian/drop-generated.py

override_dh_autoreconf:
	dh_autoreconf debian/autogen

override_dh_auto_configure:
	dh_auto_configure -- \
		CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" FFLAGS="$(FFLAGS)" FCFLAGS="$(FCFLAGS)" \
		--enable-backend-test-runs --with-custom-compilers

override_dh_auto_build:
	dh_auto_build -- generate=true

override_dh_auto_install:
	dh_auto_install
	rm -f debian/tmp/usr/lib/python*/site-packages/_otf2/_otf2.la
	rm -fr debian/tmp/usr/share/otf2/python/otf2/__pycache__
	rm -fr debian/tmp/usr/share/doc/otf2/python/doctrees

# the otf2 module explicitly loads _otf2.so, thus --no-ext-rename :/
override_dh_python3:
	dh_python3 --no-ext-rename
