File: mkversion.sh

package info (click to toggle)
swi-prolog 8.0.2%2Bdfsg-3%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 72,036 kB
  • sloc: ansic: 349,612; perl: 306,654; java: 5,208; cpp: 4,436; sh: 3,042; ruby: 1,594; yacc: 845; makefile: 136; xml: 82; sed: 12; sql: 6
file content (37 lines) | stat: -rwxr-xr-x 785 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

if [ ! -z "$1" ]; then
  dir="$1"
else
  dir=.
fi

cat >> version.h.new <<_EOM_
/*  Generated file that contains the version identifier from
    the "git describe" command.

    DO NOT EDIT.   Check Makefile and mkversion.sh in src.
*/

_EOM_

gitversion=''
if v=$(git -C $dir describe --match 'V*' 2>/dev/null); then
    if [ ! -z $v ]; then
	gitversion=$(echo $v | sed 's/^V//')
	if [ $(git -C $dir diff | wc -c) != 0 ]; then
	  gitversion="$gitversion-DIRTY";
	fi
	echo "#define GIT_VERSION "'"'$gitversion'"' >> version.h.new
    fi
fi

if [ ! -r version.h ]; then
    mv version.h.new version.h
elif cmp version.h version.h.new >/dev/null; then
#   echo "No GIT version change"
    rm version.h.new
else
    echo "Updated GIT version"
    mv version.h.new version.h
fi