1#!/bin/sh 2 3if [ $# -eq 1 ] ; then 4 OUTPUT=$1 5fi 6 7GVF=${OUTPUT}PERF-VERSION-FILE 8DEF_VER=v0.0.2.PERF 9 10LF=' 11' 12 13# First see if there is a version file (included in release tarballs), 14# then try git-describe, then default. 15if test -f version 16then 17 VN=$(cat version) || VN="$DEF_VER" 18elif test -d .git -o -f .git && 19 VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && 20 case "$VN" in 21 *$LF*) (exit 1) ;; 22 v[0-9]*) 23 git update-index -q --refresh 24 test -z "$(git diff-index --name-only HEAD --)" || 25 VN="$VN-dirty" ;; 26 esac 27then 28 VN=$(echo "$VN" | sed -e 's/-/./g'); 29else 30 VN="$DEF_VER" 31fi 32 33VN=$(expr "$VN" : v*'\(.*\)') 34 35if test -r $GVF 36then 37 VC=$(sed -e 's/^PERF_VERSION = //' <$GVF) 38else 39 VC=unset 40fi 41test "$VN" = "$VC" || { 42 echo >&2 "PERF_VERSION = $VN" 43 echo "PERF_VERSION = $VN" >$GVF 44} 45 46 47