#!/usr/bin/make -f

include /usr/share/ocaml/ocamlvars.mk

%:
	dh $@ --with ocaml

override_dh_auto_clean:
	dh_auto_clean
	rm -f meta_ocamlbricks.ml

override_dh_auto_test:
	# do nothing

# see https://launchpad.net/ocamlbricks/trunk
PACKAGE = ocamlbricks
SRC_VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')
BZR_REVISION := $(shell echo $(SRC_VERSION) | awk -F"+" '{ print $$2 }' | sed 's/bzr//' )
TARBALL = $(PACKAGE)_$(SRC_VERSION).orig.tar.gz
get-orig-source:
	rm -rf get-orig-source $(TARBALL)
	mkdir get-orig-source
	bzr branch -r $(BZR_REVISION) lp:$(PACKAGE)/trunk get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig
	rm -rf get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig/.bzr
	GZIP=--best tar czf $(TARBALL) -C get-orig-source $(PACKAGE)-$(SRC_VERSION).orig
	rm -rf get-orig-source
	echo "  "$(TARBALL)" created; move it to the right destination to build the package"

.PHONY: get-orig-source
