#!/usr/bin/make -f

export REPACK_SH=$(CURDIR)/debian/repack.sh
DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
CONFIGURE_FLAGS = --with-alsa --with-jack

CFLAGS += -g
ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
endif

export CFLAGS

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

override_dh_clean:
	dh_clean -Xtests/midiprobe.cpp~

override_dh_auto_clean:
	dh_auto_clean
	rm -rf doc/html doc/images

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIGURE_FLAGS)

override_dh_auto_install:
	mkdir -p debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig
	mkdir -p debian/tmp/usr/include
	for file in `ls librtmidi.so*`; do \
	   cp -d $$file debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/ ; \
	done
	install -m 0644 RtMidi.h debian/tmp/usr/include
	install -m 0644 rtmidi.pc \
		debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/

override_dh_strip:
	dh_strip --dbg-package=librtmidi-dbg

get-orig-source:
	uscan --force-download
