#!/usr/bin/make -f
# export DH_VERBOSE=1
export JAVA_HOME=/usr/lib/jvm/default-java

%:
	dh $@ --with javahelper

override_dh_auto_install:
	install --mode=755 $(CURDIR)/dist/MediathekView.jar \
	$(CURDIR)/debian/mediathekview/usr/share/mediathekview/MediathekView.jar

override_dh_compress:
	dh_compress --exclude=.pdf

override_dh_link:
	dh_link usr/share/mediathekview/MediathekView.jar usr/bin/mediathekview


DPATH := $(abspath $(dir $(MAKEFILE_LIST)))
PKG := mediathekview
VER ?= $(shell dpkg-parsechangelog -l$(DPATH)/changelog | perl -ne 'print $$1 if m{Version:\s*(\d[\d\.]*(?:\+(?:git)?\d+))}')
.PHONY: get-orig-source
get-orig-source: $(PKG)_$(VER).orig.tar.gz
	@

$(PKG)_$(VER).orig.tar.gz:
	@echo "# Cloning upstream git repository..."
	git clone git://git.code.sf.net/p/zdfmediathk/code $(PKG)-$(VER)
	@echo "# Clean-up..."
	cd $(PKG)-$(VER) \
	&& git checkout -b debiansource 1553f86c9d54925ca4181924b57afd9f7fc84e53 \
	&& cp -r -v \
		dist/info/MediathekView.png \
		dist/info/MediathekView.svg \
		dist/info/MediathekView.xpm \
		dist/info/releases.txt \
		dist/bin/flv.sh \
		dist/Anleitung . \
	&& $(RM) -r -v \
		src/com/ \
		dist/ \
		libs/ \
		launch4j.xml manifest.mf post_make.sh \
		.git/ \
	&& mv -v \
		releases.txt changelog
	@echo "# Packing..."
	tar cvfz "$(PKG)_$(VER).orig.tar.gz" "$(PKG)-$(VER)" \
	&& $(RM) -r "$(PKG)-$(VER)"
