#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

# Grab the version from the changelog, up to the first -
DEB_DEBIAN_DIR=$(dir $(firstword $(MAKEFILE_LIST)))
DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog -l$(DEB_DEBIAN_DIR)/changelog \
                               | sed -rne 's,^Version: ([^-]+).*,\1,p')
DEB_UPSTREAM_VERSFMT=$(shell echo ${DEB_UPSTREAM_VERSION} | sed -e "s/\./_/g")
 
%:
	dh $@ --buildsystem cmake --builddirectory=build

override_dh_auto_configure :
	dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/usr -DBUILDING_DEB:BOOL=TRUE

# as seen in https://wiki.ubuntu.com/PackagingGuide/Examples/ChangingTheOrigTarball
get-orig-source :
	uscan --noconf --force-download --rename --download-current-version --destdir=. $(DEB_DEBIAN_DIR)/..
	rm -rf laserboy-$(DEB_UPSTREAM_VERSION)
	unzip $(DEB_DEBIAN_DIR)../LaserBoy_$(DEB_UPSTREAM_VERSFMT).zip
	rm $(DEB_DEBIAN_DIR)../LaserBoy_$(DEB_UPSTREAM_VERSFMT).zip
	mv LaserBoy laserboy-$(DEB_UPSTREAM_VERSION)
	rm laserboy-$(DEB_UPSTREAM_VERSION)/*.exe
	rm laserboy-$(DEB_UPSTREAM_VERSION)/*.dll
	rm laserboy-$(DEB_UPSTREAM_VERSION)/*.bat
	mv laserboy-$(DEB_UPSTREAM_VERSION) laserboy-$(DEB_UPSTREAM_VERSION).orig
	GZIP=--best tar -cz --owner root --group root --mode a+rX \
                        -f laserboy_$(DEB_UPSTREAM_VERSION).orig.tar.gz \
                        laserboy-$(DEB_UPSTREAM_VERSION).orig
	rm -r laserboy-$(DEB_UPSTREAM_VERSION).orig

