SVN_TOPDIR = $(TOPDIR)/../..

SVN_REV = $(shell svnversion $(SVN_TOPDIR) 2>/dev/null | sed 's/:/../g' | grep -e "[0-9]\+")

ifeq "$(SVN_REV)" ""
SVN_REV = $(shell cat $(SVN_TOPDIR)/.revision 2>/dev/null | sed 's/:/../g' | grep -e "[0-9]\+")

ifeq "$(SVN_REV)" ""
SVN_REV = Unknown
endif

endif

.PHONY: svnversion

all: svnversion

svnversion:
	@echo $(SVN_REV) > $(SVN_TOPDIR)/.revision
