#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Enable SSE only on amd64, since its part of the base architecture:
FLAGS=
CONFFLAGS=
ifeq ($(DEB_HOST_ARCH_CPU),$(filter $(DEB_HOST_ARCH_CPU),amd64))
	CONFFLAGS = --enable-sse
	FLAGS = -msse3 -mfpmath=sse
else
	CONFFLAGS = --enable-sse=no
endif
FLAGS += -ffast-math
CFLAGS += $(FLAGS)
CXXFLAGS += $(FLAGS)

%:
	dh $@ --parallel --with autoreconf

override_dh_auto_configure:
	# change --libdir to install lv2's .so where they correspond
	dh_auto_configure -- \
		--enable-lv2=yes \
		--enable-cli=yes \
		--enable-resampler \
		--with-test=no \
		--libdir=/usr/lib/ \
		$(CONFFLAGS)

override_dh_auto_test:
	# do not run tests, upstream says they aren't in shape

override_dh_auto_install:
	dh_auto_install
	# per policy 3.9.1.0:
	rm debian/drumgizmo/usr/lib/lv2/drumgizmo.lv2/drumgizmo.la
	# remove unused:
	rm debian/drumgizmo/usr/lib/lv2/drumgizmo.lv2/drumgizmo.a
