Browse Source

add git version as compile flag

Steffen Jaeckel 8 years ago
parent
commit
7ac857686d
2 changed files with 11 additions and 1 deletions
  1. 5 1
      demos/test.c
  2. 6 0
      makefile.include

+ 5 - 1
demos/test.c

@@ -1,5 +1,9 @@
 #include <tomcrypt_test.h>
 #include <tomcrypt_test.h>
 
 
+#ifndef GIT_VERSION
+#define GIT_VERSION "Undefined version"
+#endif
+
 #define LTC_TEST_FN(f)  { f, #f }
 #define LTC_TEST_FN(f)  { f, #f }
 
 
 static const struct {
 static const struct {
@@ -37,7 +41,7 @@ int main(int argc, char **argv)
    long delta, dur = 0;
    long delta, dur = 0;
    reg_algs();
    reg_algs();
 
 
-   printf("build == \n%s\n", crypt_build_settings);
+   printf("build == %s\n%s\n", GIT_VERSION, crypt_build_settings);
 
 
 #ifdef USE_LTM
 #ifdef USE_LTM
    ltc_mp = ltm_desc;
    ltc_mp = ltm_desc;

+ 6 - 0
makefile.include

@@ -78,6 +78,12 @@ CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare
 endif
 endif
 
 
 
 
+GIT_VERSION := $(shell [ -e .git ] && { echo -n git- ; git describe --tags --always --dirty ; } || echo $(VERSION))
+ifneq ($(GIT_VERSION),)
+CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
+endif
+
+
 HASH=hashsum
 HASH=hashsum
 CRYPT=encrypt
 CRYPT=encrypt
 SMALL=small
 SMALL=small