1#!/bin/sh
2
3VERSION="4.1"
4OUT="$1"
5
6if [ -d .git ] && head=`git rev-parse --verify HEAD 2>/dev/null`; then
7	git update-index --refresh --unmerged > /dev/null
8	descr=$(git describe --match=v*)
9
10	# on git builds check that the version number above
11	# is correct...
12	[ "${descr%%-*}" = "v$VERSION" ] || exit 2
13
14	v="${descr#v}"
15	if git diff-index --name-only HEAD | read dummy ; then
16		v="$v"-dirty
17	fi
18else
19	v="$VERSION"
20fi
21
22echo '#include "iw.h"' > "$OUT"
23echo "const char iw_version[] = \"$v\";" >> "$OUT"
24