#!/usr/bin/make -f

pd64ext:=$(shell /usr/share/puredata/debian/dekencpu $(DEB_HOST_ARCH))

builddir=debian/build/
FLAVORS = pd32
ifneq ($(pd64ext), )
	FLAVORS += pd64
endif

CONFIG = 
CONFIG_pd32 =
CONFIG_pd64 = -DPD_FLOATSIZE=64 -DPD_EXTENSION=.linux-$(pd64ext)-64.so

%:
	dh $@

# Add configuration options:
override_dh_auto_configure: $(patsubst %,configure_%,$(FLAVORS))
configure_%:
	dh_auto_configure --builddir=$(builddir)$* -- $(strip $(CONFIG) $(CONFIG_$*))

override_dh_auto_build-arch: $(patsubst %,build_%,$(FLAVORS))
build_%:
	dh_auto_build -a --builddir=$(builddir)$*

override_dh_auto_install:
	chmod -x */examples/*.*
	find * -name "*.pd_linux" -exec chmod  -v -x {} + || true
	find * -name "*.so"       -exec chmod  -v -x {} + || true

DEB_COPYRIGHT_CHECK_IGNORE_REGEX = \
	debian/.*
# licensecheck v1
.PHONY: licensecheck
licensecheck:
	LANG=C.UTF-8 licensecheck \
		-i "^($(DEB_COPYRIGHT_CHECK_IGNORE_REGEX))$$" \
		--check '.*' --recursive --deb-machine --lines 0 * \
		> debian/copyright_newhints
	cmp debian/copyright_hints debian/copyright_newhints \
		&& rm debian/copyright_newhints
