]> git.ipfire.org Git - thirdparty/iw.git/blob - version.sh
iw: bump version to 4.7
[thirdparty/iw.git] / version.sh
1 #!/bin/sh
2
3 VERSION="4.7"
4 OUT="$1"
5
6 # get the absolute path for the OUT file
7 OUT_NAME=$(basename ${OUT})
8 OUT_DIR=$(cd $(dirname ${OUT}); pwd)
9 OUT="${OUT_DIR}/${OUT_NAME}"
10
11 # the version check should be under the source directory
12 # where this script is located, instead of the currect directory
13 # where this script is excuted.
14 SRC_DIR=$(dirname $0)
15 SRC_DIR=$(cd ${SRC_DIR}; pwd)
16 cd "${SRC_DIR}"
17
18 v=""
19 if [ -d .git ] && head=`git rev-parse --verify HEAD 2>/dev/null`; then
20 git update-index --refresh --unmerged > /dev/null
21 descr=$(git describe --match=v* 2>/dev/null)
22 if [ $? -eq 0 ]; then
23 # on git builds check that the version number above
24 # is correct...
25 if [ "${descr%%-*}" = "v$VERSION" ]; then
26 v="${descr#v}"
27 if git diff-index --name-only HEAD | read dummy ; then
28 v="$v"-dirty
29 fi
30 fi
31 fi
32 fi
33
34 # set to the default version when failed to get the version
35 # information with git
36 if [ -z "${v}" ]; then
37 v="$VERSION"
38 fi
39
40 echo '#include "iw.h"' > "$OUT"
41 echo "const char iw_version[] = \"$v\";" >> "$OUT"