config_file.l: Instruct flex to create a reentrant scanner.
[lopsub.git] / version-gen.sh
1 #!/bin/sh
2
3 version_file='version.c'
4 ver='unnamed_version'
5 # First try git, then gitweb, then default.
6 if [ -e '.git' -o -e '../.git' ]; then
7 git_ver=$(git describe --abbrev=4 HEAD 2>/dev/null)
8 [ -z "$git_ver" ] && git_ver="$ver"
9 # update stat information in index to match working tree
10 git update-index -q --refresh > /dev/null
11 # if there are differences (exit code 1), the working tree is dirty
12 git diff-index --quiet HEAD || git_ver=$git_ver-dirty
13 ver=$git_ver
14 elif [ "${PWD%%-*}" = 'lopsub-' ]; then
15 ver=${PWD##*/lopsub-}
16 fi
17 ver=${ver#v}
18
19 echo "$ver"
20
21 # update version file if necessary
22 content="const char *lls_version(void) {return \"$ver\";};"
23 [ -r "$version_file" ] && echo "$content" | cmp -s - $version_file && exit 0
24 echo >&2 "new git version: $ver"
25 echo "$content" > $version_file