Delete the rest of the `r` variables and make the functions `void`
[sunny256-utils.git] / Lib / std / c / src / Gen-version
blobdd5c90d2d5a06bbd289a42e83e60671f32aa9bf7
1 #!/bin/sh
3 #==============================================================================
4 # Gen-version
5 # File ID: STDuuidDTS
7 # Generate version.h
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname=Gen-version
15 exec_version=0.0.0
16 exec_date=STDyearDTS-00-00
18 tag_prefix="v$exec_version"
19 has_git=$(git --version | grep -q "git version" && echo 1 || echo 0)
21 newdef() {
22 echo "#define $1 1" >>version.h
25 if test -d ../.git -a $has_git -eq 1; then
26 if git tag | grep -q ^$tag_prefix; then
27 numsince=$(git log --format=%h $tag_prefix.. 2>/dev/null \
28 | wc -l \
29 | tr -d '\t ').
30 else
31 numsince=''
33 gitsha=$(git rev-parse --short=12 HEAD)
34 test -n "$(git diff-index --name-only HEAD)" \
35 && gitsha="$gitsha-dirty"
36 exec_fullversion="$exec_version+${numsince}git-$gitsha"
37 exec_date=$(git log -1 --format=%ci | cut -c -10)
38 else
39 exec_fullversion=$exec_version
42 cat <<END >version.h
43 /* Generated by $progname */
44 #define EXEC_VERSION "$exec_fullversion"
45 #define EXEC_DATE "$exec_date"
46 END
48 # FAKE_MEMLEAK: Insert memleak in print_version(), used for Valgrind testing.
49 test -n "$FAKE_MEMLEAK" && newdef FAKE_MEMLEAK
51 # GCOV: Compile with coverage code for gcov(1)
52 test -n "$GCOV" && newdef GCOV
54 # NDEBUG: Disable assert()
55 test -n "$NDEBUG" && newdef NDEBUG
57 # PROF: Compile with profiling code for gprof(1) to find bottlenecks
58 test -n "$PROF" && newdef PROF
60 # UNUSED: Compile unused code
61 test -n "$UNUSED" && newdef UNUSED
63 # USE_NEW: Compile with new unstable code
64 test -n "$USE_NEW" && newdef USE_NEW
66 exit 0
68 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :