#!/usr/bin/make -f
# debian/rules for blends
# This file is public domain software, originally written by Andreas Tille.

# $Id: rules 1751 2009-08-08 19:21:19Z tille $

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

pkg=blends
VERSION := $(shell grep '^blends *(.\+)' debian/changelog | head -n 1 | sed 's/^blends \+(\(.\+\)) .*/\1/' )
DISTDIR := $(pkg)-$(VERSION)

build: build-stamp
build-stamp:
	dh_testdir

	cd doc; $(MAKE) html; $(MAKE) txt; $(MAKE) pdf

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	cd doc; $(MAKE) clean

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs
	dh_install

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	# avoid installing doc directory for transitional packages
	dh_installchangelogs -p$(pkg)-dev -p$(pkg)-common -p$(pkg)-doc
	dh_installdocs       -p$(pkg)-dev -p$(pkg)-common -p$(pkg)-doc
	dh_installexamples
	dh_installman
	dh_lintian
	dh_link
	dh_compress -X.pdf
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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

dist:
	if [ ! -f debian/changelog ] ; then \
	    echo "File debian/changelog is missing. Something is wrong!" ; \
	    exit -1 ; \
	fi
	if [ "$(VERSION)" = "" ] ; then \
	    echo "Unable to obtain version number from debian/changelog. Something is wrong!" ; \
	    exit -1 ; \
	fi ;
	rm -rf $(DISTDIR)
	mkdir $(DISTDIR)
	chmod 777 $(DISTDIR)
	rsync -a --exclude $(DISTDIR) --exclude CVS --exclude .svn --exclude svn-commit.tmp * $(DISTDIR)
	ln -sf sources.list.unstable $(DISTDIR)/sources.list
	# ln -s control.stub $(DISTDIR)/examples/debian/control
	rm -f `find . -name "*~"`
	GZIP=-9 tar -czf ../$(pkg)_$(VERSION).tar.gz $(DISTDIR)
	rm -rf $(DISTDIR)

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

