#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

ifneq ($(DEB_HOST_ARCH_OS),linux)
	CONFIGURE_FLAGS += --disable-alsa
endif

PYVER := $(shell py3versions -d -v)

CONFIGURE_FLAGS += PYTHONPATH=/usr/bin/python3
CONFIGURE_FLAGS += --with-python-modules=/usr/lib/python$(PYVER)
CONFIGURE_FLAGS += --enable-python-force-site-packages

%:
	dh $@ --with=python3

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIGURE_FLAGS)

override_dh_auto_build:
	dh_auto_build
	$(MAKE) docs

override_dh_fixperms:
	dh_fixperms
ifneq (,$(findstring python3-ecasound, $(shell dh_listpackages)))
	find debian/python3-ecasound -name "*.py" -print0 | xargs -0 chmod a-x
endif
ifneq (,$(findstring ruby-ecasound, $(shell dh_listpackages)))
	chmod a-x debian/ruby-ecasound/usr/lib/ruby/vendor_ruby/ecasound.rb
endif

override_dh_installchangelogs:
	dh_installchangelogs NEWS

override_dh_auto_test:
	TERM=xterm LD_LIBRARY_PATH=$(CURDIR)/libecasoundc/.libs \
	  dh_auto_test --no-parallel

override_dh_python3:
	dh_python3 --shebang=/usr/bin/python3
