#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

PYSUPPORT_DIR=debian/python-networkx/usr/share/python-support/python-networkx
DEBIANDOC_DIR=$(CURDIR)/debian/python-networkx/usr/share/doc/python-networkx

clean:
	dh_testdir
	dh_testroot

	# Add here commands to clean up after the build process.
	rm -fr build

	# Make sure that there's no .pyc left
	find . -name '*.pyc' -exec rm {} ';'

	# This directory is generated during the build
	rm -rf networkx.egg-info

	dh_clean

install:
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Install w/o compiling *.pyc files
	# Install egg-info directories (--single-... option)
	python setup_egg.py install --no-compile --root=$(CURDIR)/debian/python-networkx \
		--single-version-externally-managed --install-layout=deb

	# Fix executable bits:
	chmod +x debian/python-networkx/usr/lib/`pyversions -d`/*-packages/networkx/tests/test.py
	find debian/python-networkx -name '*.bz2' -exec chmod a-x {} ';'

	# Do some cleanup: delete unneeded files:
	rm $(DEBIANDOC_DIR)/INSTALL.txt $(DEBIANDOC_DIR)/LICENSE.txt

	# Rename the README file.
	mv $(DEBIANDOC_DIR)/README.txt $(DEBIANDOC_DIR)/README


# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs	doc/source
	rm $(DEBIANDOC_DIR)/source/install.rst $(DEBIANDOC_DIR)/source/reference/legal.rst
	dh_installexamples
	dh_pysupport
	dh_installman
	dh_link
	dh_compress -Xexamples/
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
