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

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

DEBVER=$(shell dpkg-parsechangelog | grep ^Version | cut -d\  -f2)
UPVER=$(shell echo $(DEBVER) | cut -d+ -f1)

%:
	dh $@

override_dh_auto_build:
	dh_auto_build
	
	( cd build ; \
	./build.py ; \
	yui-compressor -o min.js OpenLayers.js ; \
	cat license.txt min.js > OpenLayers.min.js )

	mkdir gendoc
	naturaldocs -i lib/ -o HTML gendoc/ -p doc_config/ -s Default OL

override_dh_auto_clean:
	dh_auto_clean
	-rm -rf gendoc

get-orig-source:
	uscan --force-download \
		--download-version $(UPVER) \
		--rename \
		--destdir .
	tar xvf openlayers_$(UPVER).orig.tar.gz
	cd OpenLayers-$(UPVER)/
	rm -rf OpenLayers.js
	for i in BeautifulSoup.py exampleparser.py jsmin.c jsmin.py \
	    minimize.py shrinksafe.py update_dev_dir.sh; do \
		rm -rf tools/$$i ; \
	done
	cd ..
	tar zcf openlayers_$(UPVER)+ds1.orig.tar.gz OpenLayers-$(UPVER)/
	-rm -rf OpenLayers-$(UPVER)/
