#!/usr/bin/make -f

DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

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=autoreconf,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 python-ecasound, $(shell dh_listpackages)))
	chmod a-x debian/python-ecasound/usr/share/pyshared/pyeca.py
	chmod a-x debian/python-ecasound/usr/share/pyshared/ecacontrol.py
	chmod a-x debian/python-ecasound/usr/share/pyshared/eci.py
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
