]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - version.sh
iw: support multiple regdom print
[thirdparty/iw.git] / version.sh
index 83e253edd46d76260ff570bf3dc4f7e6c9dd6b13..82af11e13b566b23f78e21aca2115af285bc35a0 100755 (executable)
@@ -1,17 +1,23 @@
 #!/bin/sh
 
-VERSION="1.0"
+VERSION="3.17"
+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)
+
+       # 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"