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

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

PKD = $(abspath $(dir $(MAKEFILE_LIST)))
PKG = $(word 2,$(shell dpkg-parsechangelog -l$(PKD)/changelog | grep ^Source))

%:
	dh $@ --parallel --max-parallel=3

override_dh_auto_configure:
	@echo "## checking integrity..."
	sha1sum --strict --check debian/files_sha1.txt

DD=$(CURDIR)/debian/$(PKG)/usr/share/games/freespace2-open/data/movies
override_dh_auto_install:
	[ -d "$(DD)" ] || mkdir -v -p "$(DD)"
	for F in *.zip; do unzip -j "$$F" -d "$(DD)" ;done

override_dh_builddeb:
	dh_builddeb -- -Zxz -z4

get-orig-source:
	sha1sum --strict --check debian/files_sha1.txt \
	|| wget --tries=3 --timeout=60 --read-timeout=60 --continue --timestamping --content-disposition \
            "http://www.freespacemods.net/request.php?128"
	@echo "## generating checksums..."
	sha1sum --binary *.zip | tee debian/files_sha1.txt~NEW
	diff -U0 debian/files_sha1.txt debian/files_sha1.txt~NEW \
        && $(RM) debian/files_sha1.txt~NEW
