DESTDIR=
NAME=rootfiles-vine
DATE:=$(shell date +'%Y%m%d')
PWD:=$(shell pwd)
EXCLUDE= Makefile rootfiles-vl.spec

VERSION := $(shell awk '/Version:/ { print $$2 }' rootfiles-vl.spec)
RELEASE := $(shell awk '/Release:/ { print $$2 }' rootfiles-vl.spec)
TAG=$(NAME)-$(VERSION)

install:
	mkdir -p ${DESTDIR}/root
	tar --exclude Makefile --exclude rootfiles-vl.spec -cvf - . \
	| (cd ${DESTDIR}/root ; tar -xf -)

rpm: tarbz2
	rpm -ba rootfiles-vl.spec

tarbz2: clean
	if [ -d ../${NAME}-${VERSION} ]; then rm -rf ../${NAME}-${VERSION} ;fi
	cd .. && cp -a ${PWD} ${NAME}-${VERSION}
	cd .. && tar --exclude .svn -cjf ${NAME}-${VERSION}.tar.bz2 ${NAME}-${VERSION}
	cp -f ../${NAME}-${VERSION}.tar.bz2 $(shell rpm --eval %{_sourcedir})/
	if [ -d ../${NAME}-${VERSION} ]; then rm -rf ../${NAME}-${VERSION} ;fi

tag:
	if [ ! -d ../tags/$(TAG) ] ;then \
		svn copy ../trunk ../tags/$(TAG) ;\
		svn commit -m "tagging as $(TAG)" ../tags/$(TAG) ;\
		echo "Tagged as $(TAG)" ;\
	fi

clean:
	rm -fv *~ .*.swp

