xref: /openwifi/user_space/sdrctl_src/version.sh (revision a6085186d94dfe08b0e09c18c8d4b1b4fe38ea35)
1#!/bin/sh
2
3# SPDX-FileCopyrightText: 2019 Jiao Xianjun <[email protected]>
4# SPDX-License-Identifier: AGPL-3.0-or-later
5
6VERSION="3.17"
7OUT="$1"
8
9if [ -d .git ] && head=`git rev-parse --verify HEAD 2>/dev/null`; then
10	git update-index --refresh --unmerged > /dev/null
11	descr=$(git describe)
12
13	# on git builds check that the version number above
14	# is correct...
15	[ "${descr%%-*}" = "v$VERSION" ] || exit 2
16
17	v="${descr#v}"
18	if git diff-index --name-only HEAD | read dummy ; then
19		v="$v"-dirty
20	fi
21else
22	v="$VERSION"
23fi
24
25echo '#include "sdrctl.h"' > "$OUT"
26echo "const char sdrctl_version[] = \"$v\";" >> "$OUT"
27