#!/usr/bin/make -f
# -*- makefile -*-

export DEB_BUILD_MAINT_OPTIONS := hardening=+all
export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed
# defined for most of the code anyway; doing this here helps the PCH
export DEB_CPPFLAGS_MAINT_APPEND := -DQT_NO_DEBUG

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure -- \
	    -DCMAKE_SKIP_RPATH=ON \
	    -DUSE_SYSTEM_FREETYPE=ON

override_dh_auto_build:
	dh_auto_build -- lrelease all

override_dh_installchangelogs-arch:
	dh_installchangelogs -pmusescore debian/upstream-changelog
	dh_installchangelogs --remaining-packages

override_dh_install-indep:
	# move stuff to packages
	dh_install
	cd debian/musescore-common/usr/share && \
	    rm -f mscore && ln -s mscore-* mscore
	# make system-wide soundfonts available
	mkdir -p debian/musescore-common/usr/share/mscore/sound
	ln -sf ../../sounds/sf2 ../../sounds/sf3 ../../sounds/sfz \
	    debian/musescore-common/usr/share/mscore/sound/

.PHONY: get-orig-source
## Usage: debian/rules get-orig-source
## Based on: http://wiki.debian.org/onlyjob/get-orig-source
get-orig-source: PKG_DIR:=$(abspath $(dir $(MAKEFILE_LIST)))
get-orig-source:
	# Simply call uscan (changes for DFSG done in debian/watch and debian/repack)
	uscan --noconf --verbose --destdir=$(CURDIR) \
	  --check-dirname-level=0 --force-download $(PKG_DIR)
