#!/usr/bin/make -f

%:
	dh $@ --sourcedirectory=src

override_dh_auto_clean:
	dh_clean

override_dh_auto_build:
	dh_auto_build -- cube2font

override_dh_strip:
	dh_strip -pcube2font --dbg-package=cube2font-dbg

override_dh_auto_install:
	make -C src/ system-install-cube2font DESTDIR=../debian/cube2font \
		prefix=/usr

override_dh_builddeb:
	dh_builddeb -- -Zxz

VER=$(shell dpkg-parsechangelog | sed -rne 's/^Version: ([^-]+).*/\1/p')
DIR=cube2font-$(VER).orig
TAR=cube2font_$(VER).orig.tar.bz2
get-orig-source:
	uscan --noconf --force-download --download-current-version --destdir=.
	rm -rf $(DIR)
	tar -xf $(TAR)
	rm -f $(TAR)
	mv redeclipse/ $(DIR)
	find $(DIR) -mindepth 1 -not -name src \
				-not -name shared \
				-not -name install \
				-not -name nix \
				-not -name cube2font.1 \
				-not -name Makefile \
				-not -name system-install.mk \
				-not -wholename $(DIR)/license.txt \
				-not -name cube2font.c \
				-not -name redeclipse.cbp \
				-delete
	BZIP2="-9" tar -cj --owner root --group root --mode a+rX \
		-f $(TAR) $(DIR)
	rm -rf $(DIR)
