#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-

DEB_DIRECTORY = $(dir $(firstword $(MAKEFILE_LIST)))
SOURCE_DIRECTORY = $(realpath $(DEB_DIRECTORY)/..)
EXAMPLES_DIRECTORY = $(DEB_DIRECTORY)/python-gdata-doc/usr/share/doc/python-gdata-doc/examples

%:
	dh $@ --with python2

override_dh_auto_build:
	dh_auto_build
	cd pydocs; sh ./generate_docs
	sed -i 's|$(SOURCE_DIRECTORY)/src|/usr/lib/python2.7/dist-packages|g' pydocs/*.html

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	set -ex; for pyversion in $(shell pyversions -vr); do \
		PYTHONPATH=src python$$pyversion tests/run_data_tests.py; \
	done	
endif

override_dh_installchangelogs:
	dh_installchangelogs RELEASE_NOTES.txt

override_dh_installexamples:
	dh_installexamples
	rm -rf $(EXAMPLES_DIRECTORY)/apps/marketplace_sample
	rm -rf $(EXAMPLES_DIRECTORY)/apps/provisioning_oauth_example
	rm -rf $(EXAMPLES_DIRECTORY)/blogger/app
	rm -rf $(EXAMPLES_DIRECTORY)/blogger/oauth-appengine

override_dh_compress:
	dh_compress -X.py -X.c

get-orig-source:
	uscan --verbose --download-current-version
