#!/usr/bin/make -f

# Path to the debian directory
DEBIAN_DIR := $(shell echo ${MAKEFILE_LIST} | awk '{print $$1}' | xargs dirname )
UPSTREAM_VERSION ?=$(shell uscan --dehs | sed -n 's/.*<upstream-version>\(.*\)<\/upstream-version>.*/\1/p')
PKG = $(shell dpkg-parsechangelog | sed -ne 's/^Source: //p')
DATE := $(shell date -u -d "$$(dpkg-parsechangelog -SDate)" +"%Y/%m/%d")

CPPFLAGS+=-DBUILD_DATE='"$(DATE)"'
CXXFLAGS+=-std=c++11
LDFLAGS+=-Wl,--as-needed

%:
	dh $@ --parallel --with autoreconf,autotools-dev

override_dh_autoreconf:
	./autogen.sh
	dh_autoreconf

override_dh_auto_configure:
	dh_auto_configure -- --target=linux

override_dh_auto_test:
	@echo home: $(HOME)
	HOME=/tmp dh_auto_test -a || (grep . test-suite.log giada_test.log; false)
	#make check      || (grep . test-suite.log giada_test.log; false)

override_dh_auto_clean:
	dh_auto_clean
	test -e src/deps/rtaudio-mode/Makefile && make -C src/deps/rtaudio-mod/ distclean || true

## all the file-exclusion magic is handled by debian/copyright
get-orig-source:
	uscan  --download
