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
	cd .. && rpm -ta ${NAME}-${DATE}.tar.bz2

tarbz2: spec clean
	cd .. && cp -a ${PWD} ${NAME}-${DATE}
	cd .. && tar --exclude .svn -cjf ${NAME}-${DATE}.tar.bz2 ${NAME}-${DATE}
	cd .. && rm -rf ${NAME}-${DATE}

spec:
	perl -pi -e 's/^%define date.*/%define date ${DATE}/' rootfiles-vl.spec

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

