PKGNAME=booty
VERSION=$(shell awk '/Version:/ { print $$2 }' ${PKGNAME}.spec)
RELEASE=$(shell awk '/Release:/ { print $$2 }' ${PKGNAME}.spec |sed -e 's/%{?dist}//')
SNAPRELEASE = $(RELEASE)$(shell date "+.%Y%m%d%H%M")

PYFILES = $(wildcard *.py)
PYTHONLIBDIR = /usr/lib/booty

PYTHON = python2.4
PYTHONINCLUDE = /usr/include/$(PYTHON)

PYTHONLIBDIR = /usr/lib/booty

CFLAGS=-Wall -O -g -fpic -I$(PYTHONINCLUDE)# -DDEBUG

all: 

clean:
	rm -f *.o *.so *.pyc *.lo

# this rule is a hack
install-python:
	cp -var $(PYFILES) $(DESTDIR)/$(PYTHONLIBDIR)
	./py-compile --basedir $(DESTDIR)/$(PYTHONLIBDIR) $(PYFILES)

install: 
	@if [ "$(DESTDIR)" = "" ]; then \
		echo " "; \
		echo "ERROR: A destdir is required"; \
		exit 1; \
	fi

	mkdir -p $(DESTDIR)/$(PYTHONLIBDIR)

	cp -var $(PYFILES) $(DESTDIR)/$(PYTHONLIBDIR)
	./py-compile --basedir $(DESTDIR)/$(PYTHONLIBDIR) $(PYFILES)

rpmlog:
	@echo "* `date "+%a %b %d %Y"` `git-config user.name` <`git-config user.email`> - $(VERSION)-$(RELEASE)"
	@git-log --pretty="format:- %s (%ae)" r$(VERSION)-$(RELEASE).. |sed -e 's/@.*)/)/'
	@echo

tag:
	@git tag -a -m "Tag as r$(VERSION)-$(RELEASE)" -f r$(VERSION)-$(RELEASE)
	@echo "Tagged as r$(VERSION)-$(RELEASE)"

archive: tag
	@git-archive --format=tar --prefix=booty-$(VERSION)/ HEAD |bzip2 > booty-$(VERSION).tar.bz2
	@echo "The final archive is in booty-$(VERSION).tar.bz2"

src: tag create-archive
	@rpmbuild -ts --nodeps booty-$(VERSION).tar.bz2

pycheck:
	pychecker *.py textw/*.py iw/*.py  | grep -v "__init__() not called" 

pycheck-file:
	PYTHONPATH=. pychecker $(CHECK) | grep -v "__init__() not called" 
