#!/usr/bin/make -f

export REPACK_SH=$(CURDIR)/debian/repack.sh

UPSTREAM_VERSION=$(shell dpkg-parsechangelog | grep 'Version:' | sed 's/^Version:\s\(.*\)\(~ds[0-9]*\)-.*/\1/')
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

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

export CFLAGS+=$(CPPFLAGS)
export CXXFLAGS+=$(CPPFLAGS)

%:
	dh $@ --parallel --with=autoreconf,python3

override_dh_auto_configure:
	dh_auto_configure -- --libdir=/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_auto_install:
	dh_auto_install
	find debian/tmp -type f -name "*.la" -ls -delete
	cd debian/tmp/usr/share/doc/lives-$(UPSTREAM_VERSION) && \
		rm \
			ChangeLog \
			FEATURES \
			BUGS \
			AUTHORS
	rm -rf \
	 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/lives/plugins/effects/realtime/weed/data/.svn/ \
	 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/lives/plugins/effects/realtime/weed/icons/.svn/
	find debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/lives -type d -empty -delete
	chmod a-x \
		debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/lives/plugins/effects/realtime/weed/data/fourKlives/songs/*.txt

override_dh_strip:
	dh_strip -plibweed0 --dbg-package=libweed-dbg
	dh_strip -plives --dbg-package=lives-dbg
	dh_strip -plives-plugins --dbg-package=lives-dbg
	dh_strip --remaining-packages

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