#!/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 full.cfg OpenLayers.js
	uglifyjs -o build/OpenLayers.min.js build/OpenLayers.js

	cd build && ./build.py light.cfg OpenLayers.light.js
	uglifyjs -o build/OpenLayers.light.min.js build/OpenLayers.light.js

	cd build && ./build.py lite.cfg OpenLayers.lite.js
	uglifyjs -o build/OpenLayers.lite.min.js build/OpenLayers.lite.js

	cd build && ./build.py mobile.cfg OpenLayers.mobile.js
	uglifyjs -o build/OpenLayers.mobile.min.js build/OpenLayers.mobile.js

	cd build && ./build.py tests.cfg OpenLayers.tests.js
	uglifyjs -o build/OpenLayers.tests.min.js build/OpenLayers.tests.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

override_dh_install:
	dh_install

	# Remove executable bit
	chmod 644 debian/*/usr/share/openlayers/img/*.png

	# Remove duplicate license & readme
	$(RM) debian/*/usr/share/doc/*/examples/Firebug/*.txt

override_dh_compress:
	dh_compress -Xexamples

get-orig-source:
	uscan --verbose --force-download

