#!/usr/bin/make -f
# -*- makefile -*-
# Debian rules file for codeville
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Python
DEB_PYTHON_SYSTEM=pysupport

################################################################################
# CDBS File Inclusions and Variable Declarations
################################################################################
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/python-distutils.mk

# Careful, fails to recognize epochs
UPSTREAM_VERSION=$(shell dpkg-parsechangelog|sed -n -e 's/^Version: \(.*\)-.*/\1/ p')

# Pure python library for site-python directory
#DEB_PYTHON_INSTALL_ARGS_ALL = --no-compile -O0 --install-purelib=/usr/lib/site-python

doc-update: doc-update-stamp
doc-update-stamp:
	@echo "Fetching documentation from site and wiki."
	lynx -dump http://codeville.org/news.php > debian/NEWS.upstream
	lynx -dump http://codeville.org/doc//QuickStartGuide > debian/QuickStartGuide.txt
	lynx -source http://codeville.org/doc//QuickStartGuide > debian/QuickStartGuide.html
	lynx -dump http://codeville.org/doc/ServerReference > debian/ServerReference.txt
	lynx -source http://codeville.org/doc/ServerReference > debian/ServerReference.html
	lynx -dump http://codeville.org/doc/ClientReference > debian/ClientReference.txt
	lynx -source http://codeville.org/doc/ClientReference > debian/ClientReference.html
	lynx -dump http://codeville.org/doc/ToDoList > debian/ToDoList.txt
	lynx -source http://codeville.org/doc/ToDoList > debian/ToDoList.html
	: > $@

# codeville tries to install documentation in the Right Place(TM), but
# gets it wrong for Debian.  Already included the LICENSE.txt in the
# copyright file.
install/codeville::
	mkdir -p debian/codeville/etc
	mv debian/codeville/usr/share/doc/Codeville-$(UPSTREAM_VERSION)/cdvserver.conf.sample \
		debian/codeville/etc/cdvserver.conf
	rm -rf debian/codeville/usr/share/doc/Codeville-$(UPSTREAM_VERSION)

clean::
	-find -name \*.pyc -exec rm \{\} \;
	-rm doc-update-stamp
