-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-gitversion
executable file
·37 lines (32 loc) · 1.49 KB
/
check-gitversion
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
# echo "This is the git version checker"
test -f gitversion-stamp && BGD=`cat gitversion-stamp` || :
# echo "existing gitversion-stamp is $BGD"
GD=`git describe --tags --dirty --broken --always 2>/dev/null`
if [ x"$GD" = x ] ; then
GD="NA"
fi
# echo "current git description is $GD"
if [ x"$GD" != x"$BGD" ] ; then
echo "build: $GD" # optional -- displays git version if new or different
echo $GD > gitversion-stamp
echo "// Do not edit!" > gitversion.h
echo "// This file is automatically generated." >> gitversion.h
echo -n " char git_version_string[] = \"" >> gitversion.h
## the tr is because we need to remove the trailing newline
cat gitversion-stamp | tr -d '[[:space:]]' >> gitversion.h
echo "\";" >> gitversion.h
fi
# Usage. Below is what you would add to Makefile.am. When it runs, the
# following two files are generated: 'gitversion-stamp' and 'gitversion.h'.
# gitversion-stamp stores the most recently used git description.
# gitversion.h is a C header file containing that git description as a string.
# Put this script in the top level source folder and make sure it has execute permission.
# These are the lines (remove the leading '#' on each) to add to the Makefile.am file:
# ## Check if the git version information has changed and rebuild gitversion.h if so.
# .PHONY: gitversion-check
# gitversion-check:
# $(top_srcdir)/check-gitversion
# ## You may have to change from += to = below:
# BUILT_SOURCES += gitversion-check
# CLEANFILES += gitversion-stamp gitversion.h