#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

include /usr/share/dpkg/pkg-info.mk

%:
	dh $@

override_dh_auto_configure:
	if echo "$(DEB_VERSION)" | grep -q '~git' ; then \
		_git_commit=$$(echo "$(DEB_VERSION)" | cut -d'+' -f2) ; \
	else \
		_git_commit="unknown" ; \
	fi ; \
	dh_auto_configure --parallel --	\
		-DENABLE_GTK=ON		\
		-DENABLE_QT5=ON		\
		-DENABLE_TOOLS=ON	\
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DGIT_COMMIT="$$_git_commit"


override_dh_install:
	find debian/tmp/usr/bin/ -type f ! -name *.pl -exec chrpath --delete {} ';'
	chrpath --delete debian/tmp/usr/lib/*/libcelestia.so.*
	rm debian/tmp/usr/share/celestia/COPYING
	dh_install
	dh_missing --fail-missing
	mv debian/celestia-common/usr/share/celestia/celestia.cfg \
	   debian/celestia-common/etc/celestia.cfg
	ln -s /etc/celestia.cfg debian/celestia-common/usr/share/celestia/
	rm debian/celestia-common/usr/share/celestia/fonts/*
	ln -s /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf \
	      debian/celestia-common/usr/share/celestia/fonts/
	ln -s /usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf \
	      debian/celestia-common/usr/share/celestia/fonts/
