Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Include -devel-HASH(-dirty) in the version string

When not compiled with `make RELEASE=1`, the version string will include
a suffix with the exact version information based on the git hash. Also,
if the current working tree is dirty (it have uncommitted changed) an
extra suffix will be added (-dirty).

When using `make RELEASE=1` only the version information present in the
VERSION file will be used.
  • Loading branch information...
commit 8af79ed98e6f8a7249b88d90f4c74cce222fdf53 1 parent 714e3f2
@leandro-lucarella-sociomantic leandro-lucarella-sociomantic authored
Showing with 17 additions and 2 deletions.
  1. +17 −2 src/posix.mak
19 src/posix.mak
@@ -55,6 +55,7 @@ LDFLAGS=-lm -lstdc++ -lpthread
#OPT=-g -g3
@@ -195,8 +196,22 @@ impcnvgen : mtype.h impcnvgen.c
-verstr.h : ../VERSION
- printf \"`cat ../VERSION`\" > verstr.h
+# Create (or update) the verstr.h file.
+# The file is only updated if the VERSION file changes, or, only when RELEASE=1
+# is not used, when the full version string changes (i.e. when the git hash or
+# the working tree dirty states changes).
+# The full version string have the form VERSION-devel-HASH(-dirty).
+# The "-dirty" part is only present when the repository had uncommitted changes
+# at the moment it was compiled (only files already tracked by git are taken
+# into account, untracked files don't affect the dirty state).
+VERSION := $(shell cat ../VERSION)
+ifneq (1,$(RELEASE))
+VERSION_GIT := $(shell $(GIT) rev-parse --short HEAD)$(shell \
+ test -n "`$(GIT) status --porcelain -uno`" && echo -dirty)
+VERSION := $(addsuffix -devel$(if $(VERSION_GIT),-$(VERSION_GIT)),$(VERSION))
+$(shell test \"$(VERSION)\" != "`cat verstr.h 2> /dev/null`" \
+ && printf \"$(VERSION)\" > verstr.h )
Please sign in to comment.
Something went wrong with that request. Please try again.