#!/usr/bin/make -f

LDFLAGS+=-Wl,--as-needed

%:
	dh $@ --parallel

override_dh_clean:
	dh_clean debian/*.xpm CMakeCache.txt cmake_install.cmake Makefile
	$(RM) -r CMakeFiles

override_dh_auto_configure:
	dh_auto_configure --builddirectory=$(CURDIR)

override_dh_auto_build:
	dh_auto_build
	## build menu icon
	convert astromenace_64.png -resize 32x32 debian/astromenace.xpm

override_dh_install:
	dh_install --exclude=astromenace_64.png

override_dh_installchangelogs:
	dh_installchangelogs ChangeLog.txt

override_dh_builddeb:
	dh_builddeb -- -Zxz

DPATH := $(abspath $(dir $(MAKEFILE_LIST)))
VER ?= $(shell dpkg-parsechangelog -l$(DPATH)/changelog | perl -ne 'print $$1 if m{Version:\s*([\d\.]+)}')
.PHONY: get-orig-source
get-orig-source:
	uscan --noconf --verbose --rename --destdir=$(CURDIR) --check-dirname-level=0 --force-download --download-version $(VER) $(DPATH)
	tar xjf "astromenace_$(VER).orig.tar.bz2"
	rm -r "AstroMenace/MacOSX.zip" "AstroMenace/RAW_VFS_DATA"
	tar -cJf "astromenace_$(VER)+repack.orig.tar.xz" "AstroMenace"
	rm -r "AstroMenace" "astromenace_$(VER).orig.tar.bz2"
