2 # SPDX-License-Identifier: GPL-2.0-only
8 # First try git, then gitweb, then default.
9 if [ -e '.git' -o -e '../.git' ]; then
10 git_ver=$(git describe --abbrev=4 HEAD 2>/dev/null)
11 [ -z "$git_ver" ] && git_ver="$ver"
12 # update stat information in index to match working tree
13 git update-index -q --refresh > /dev/null
14 # if there are differences (exit code 1), the working tree is dirty
15 git diff-index --quiet HEAD || git_ver=$git_ver-dirty
17 elif [ "${PWD%%-*}" = $package- ]; then
18 ver=${PWD##*/$package-}
23 [ -z "${version_file}" ] && exit 0
24 # update version file if necessary
25 content="const char *${package}_version(void) {return \"$ver\";};"
26 [ -r "$version_file" ] && echo "$content" | cmp -s - $version_file && exit 0
27 echo "$content" > $version_file