PKGNAME=rhpl
VERSION=$(shell awk '/Version:/ { print $$2 }' ${PKGNAME}.spec)
RELEASE=$(shell awk '/Release:/ { print $$2 }' ${PKGNAME}.spec)
TAG=r$(VERSION)-$(RELEASE)
SUBDIRS=src po

include Makefile.inc

MANDIR=/usr/share/man
PREFIX=/usr

default: all

all: subdirs

subdirs:
	for d in $(SUBDIRS); do make -C $$d; [ $$? = 0 ] || exit 1; done

clean:
	for d in $(SUBDIRS); do make -C $$d clean; done
	rm -f *.o *.so *.lo *.a *.pyc 

install: all
	mkdir -p $(DESTDIR)/$(PYDIR)

	for d in $(SUBDIRS); do make -C $$d install; done

	$(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(PYDIR)', 3, '$(PYDIR)', 1)"

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 $(TAG)" -f $(TAG)
	@echo "Tagged as $(TAG)"

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