#!/usr/bin/make -f
# -*- makefile -*-
# TileCache debian/rules

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

PREFIX := debian/tilecache
PYSUPPORT := /usr/share/python-support/python-package

build: build-stamp

build-stamp:
	dh_testdir
	# Add here commands to compile the package.
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	# Add here commands to clean up after the build process.
	# -$(MAKE) clean

	dh_clean *.pyc lib/TileCache/*.pyc

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs

	# Add here commands to install the package into debian/tilecache.
	python ./setup.py install --debian --no-compile --root=$(PREFIX) --install-lib=$(PYSUPPORT)

	# eliminates script-not-executable warning from lintian
	chmod +x $(PREFIX)$(PYSUPPORT)/TileCache/Service.py
	chmod +x $(PREFIX)$(PYSUPPORT)/TileCache/Client.py

	rm $(PREFIX)/usr/bin/tilecache_install_config.py # only used for eggs
	mv $(PREFIX)/usr/bin/tilecache.* $(PREFIX)/usr/lib/cgi-bin # .cgi, .fcgi
	mv $(PREFIX)/usr/bin/tilecache_seed.py $(PREFIX)/usr/sbin/tilecache_seed
	mv $(PREFIX)/usr/bin/tilecache_clean.py $(PREFIX)/usr/sbin/tilecache_clean
	mv $(PREFIX)/usr/bin/tilecache_http_server.py $(PREFIX)/usr/sbin/tilecache_http_server
	rmdir $(PREFIX)/usr/bin

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs docs/CHANGELOG.txt
	dh_installdocs
	dh_installexamples
	dh_installman
	dh_link
	dh_compress
	dh_fixperms
	dh_pysupport
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep

.PHONY: build clean binary-indep binary install
