c/src/Makefile: Remove `-Wall`, `-Werror` and `-Wextra` from `LDFLAGS`
[sunny256-utils.git] / Lib / std / c / src / Gen-version
blob00b31f30db7bcfab02bc8b88ae6198accbe368a9
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 # GCOV: Compile with coverage code for gcov(1)
49 test -n "$GCOV" && newdef GCOV
51 # NDEBUG: Disable assert()
52 test -n "$NDEBUG" && newdef NDEBUG
54 # Compile with profiling code for gprof(1) to find bottlenecks
55 test -n "$PROF" && newdef PROF
57 # UNUSED: Compile unused code
58 test -n "$UNUSED" && newdef UNUSED
60 exit 0
62 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :