#!/bin/sh
-VERSION="0.9"
+VERSION="4.3"
+OUT="$1"
-(
-echo "#define VERSION \"$VERSION\""
-if head=`git rev-parse --verify HEAD 2>/dev/null`; then
+if [ -d .git ] && head=`git rev-parse --verify HEAD 2>/dev/null`; then
git update-index --refresh --unmerged > /dev/null
- printf "#define IW_GIT_VERSION \"-g%.8s" "$head"
+ descr=$(git describe --match=v*)
+
+ # on git builds check that the version number above
+ # is correct...
+ [ "${descr%%-*}" = "v$VERSION" ] || exit 2
+
+ v="${descr#v}"
if git diff-index --name-only HEAD | read dummy ; then
- printf -- "-dirty"
+ v="$v"-dirty
fi
- echo '"'
else
- echo '#define IW_GIT_VERSION ""'
+ v="$VERSION"
fi
-) > version.h
+
+echo '#include "iw.h"' > "$OUT"
+echo "const char iw_version[] = \"$v\";" >> "$OUT"