diff --git a/Makefile b/Makefile index 8ac90733e..2461a5735 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,9 @@ BUILDDIR ?= build # Default debug level for executables V ?= 2 +# Version of VILLASnode +VERSION = 0.7 + # Common flags LDLIBS = CFLAGS += -std=c11 -Iinclude -Iinclude/villas -I. -MMD -mcx16 @@ -69,17 +72,17 @@ SRCDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) # Add git revision and build variant defines ifdef CI - CFLAGS += -D_GIT_REV='"${CI_BUILD_REF:0:7}"' - CFLAGS += -D_VARIANT='"-ci-$(VARIANT)"' + GIT_REV = ${CI_BUILD_REF:0:7} + VARIANT = ci-$(VARIANT) else - GIT = $(shell type -p git) - GIT_REV = $(shell git describe --tags --dirty) - ifneq ($(GIT),) - CFLAGS += -D_GIT_REV='"$(GIT_REV)"' + ifneq ($(shell type -p git),) +# GIT_REV = $(shell git describe --tags) + GIT_REV = $(shell REV=$$(git rev-parse HEAD); echo $${REV:0:7}) endif - CFLAGS += -D_VARIANT='"-$(VARIANT)"' endif +CFLAGS += -D_VERSION='$(VERSION)' -D_VARIANT='"$(VARIANT)"' -D_GIT_REV='"$(GIT_REV)"' + # pkg-config dependencies PKGS = libconfig diff --git a/config.h b/config.h index e394fff1c..88369094d 100644 --- a/config.h +++ b/config.h @@ -10,12 +10,8 @@ #pragma once -#ifndef _GIT_REV - #define _GIT_REV "nogit" -#endif - /** The version number of VILLASnode */ -#define VERSION "v0.7-" _GIT_REV _VARIANT +#define VERSION_STR "v" XSTR(_VERSION) "-" _GIT_REV "-" _VARIANT /** Default number of values in a sample */ #define DEFAULT_VALUES 64 @@ -38,7 +34,7 @@ #define SYSFS_PATH "/sys" #define PROCFS_PATH "/proc" -#define USER_AGENT "VILLASnode " VERSION +#define USER_AGENT "VILLASnode " VERSION_STR /* Required kernel version */ #define KERNEL_VERSION_MAJ 3 diff --git a/lib/nodes/opal.c b/lib/nodes/opal.c index d32f8548d..202198d4a 100644 --- a/lib/nodes/opal.c +++ b/lib/nodes/opal.c @@ -72,7 +72,7 @@ int opal_init(int argc, char *argv[], config_setting_t *cfg) info("Started as OPAL Asynchronous process"); info("This is VILLASnode %s (built on %s, %s)", - VERSION, __DATE__, __TIME__); + VERSION_STR, __DATE__, __TIME__); opal_print_global(); diff --git a/lib/utils.c b/lib/utils.c index 8732a3335..f43e6f78c 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -21,7 +21,7 @@ void print_copyright() { printf("VILLASnode %s (built on %s %s)\n", - BLU(VERSION), MAG(__DATE__), MAG(__TIME__)); + BLU(VERSION_STR), MAG(__DATE__), MAG(__TIME__)); printf(" copyright 2014-2016, Institute for Automation of Complex Power Systems, EONERC\n"); printf(" Steffen Vogel \n"); } diff --git a/src/node.c b/src/node.c index d24d3b706..1f0914e84 100644 --- a/src/node.c +++ b/src/node.c @@ -84,8 +84,8 @@ int main(int argc, char *argv[]) #endif super_node_init(&sn); - - info("This is VILLASnode %s (built on %s, %s)", BLD(YEL(VERSION)), + + info("This is VILLASnode %s (built on %s, %s)", BLD(YEL(VERSION_STR)), BLD(MAG(__DATE__)), BLD(MAG(__TIME__))); /* Checks system requirements*/