#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.

export HOME := $(CURDIR)/debian

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

v = 1.3.1

%:
	dh $@ --buildsystem=rebar --with rebar

override_dh_auto_build:
	dh_auto_build -O--buildsystem=rebar
	$(MAKE) -C test

override_dh_auto_clean:
	dh_auto_clean -O--buildsystem=rebar
	rm -f test/*.beam

override_dh_auto_install:
	dh_auto_install -O--buildsystem=rebar
	install -m 755 -d debian/tmp/usr/lib/erlang/lib/esdl-$(v)/src
	install -m 644 src/*.hrl debian/tmp/usr/lib/erlang/lib/esdl-$(v)/src

override_dh_compress:
	dh_compress -X.wav -X.erl -X.bmp -X.beam -O--buildsystem=rebar

override_dh_fixperms-arch:
	dh_fixperms -a -O--buildsystem=rebar

override_dh_fixperms-indep:
	dh_fixperms -i -O--buildsystem=rebar
	chmod a-x debian/erlang-esdl-doc/usr/share/doc/erlang-esdl-doc/html/*
	chmod a-x debian/erlang-esdl-doc/usr/share/doc/erlang-esdl-doc/examples/*

get-orig-source:
	wget -O esdl_$(v).orig.tar.gz \
		http://heanet.dl.sourceforge.net/sourceforge/esdl/esdl-$(v).src.tgz

.PHONY: get-orig-source override_dh_auto_build override_dh_auto_clean \
	override_dh_auto_install override_dh_compress override_dh_fixperms-arch \
	override_dh_fixperms-indep
