#!/usr/bin/make -f

ifneq (,$(findstring parallel=,$(DEB_BUILD_OPTIONS)))
	NCPUS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
else
	NCPUS:=1
endif

export DEB_LDFLAGS_MAINT_APPEND = -Wl,-z,defs -Wl,--as-needed
export DEB_CXXFLAGS_MAINT_APPEND = -fPIC -DPIC
export QT_SELECT=5

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
	--docdir='$${datarootdir}/doc/mkvtoolnix-gui' \
	--enable-debug

#	exit 1

override_dh_auto_build:
	rake -j $(NCPUS)

override_dh_clean:
	[ ! -f build-config ] || rake clean:dist

	dh_clean config.status rake.d/dependecy.d/*.rb src/input/*.d \
	config.h build-config

override_dh_install:
	rake install DESTDIR=$(CURDIR)/debian/tmp

#	cp share/desktop/org.bunkus.mkvtoolnix-gui.desktop debian/tmp/usr/share/applications

	dh_install -Xmkvtoolnix.xml

override_dh_missing:
	dh_missing --fail-missing -Xmkvtoolnix.xml

override_dh_strip:
	dh_strip --no-automatic-dbgsym
