diff --git a/klustakwik.cpp b/klustakwik.cpp index 25f6cf4..53dfc99 100644 --- a/klustakwik.cpp +++ b/klustakwik.cpp @@ -2,6 +2,10 @@ // // Fast clustering using the CEM algorithm with Masks. +#ifndef VERSION +#define VERSION "0.3.0-nogit" +#endif + // Disable some Visual Studio warnings #define _CRT_SECURE_NO_WARNINGS @@ -1783,6 +1787,7 @@ int main(int argc, char **argv) scalar BestScore = HugeScore; integer p, i; SetupParams((integer)argc, argv); // This function is defined in parameters.cpp + Output("Starting KlustaKwik. Version: %s\n", VERSION); if (RamLimitGB == 0.0) { RamLimitGB = (1.0*total_physical_memory()) / (1024.0*1024.0*1024.0); diff --git a/makefile b/makefile index 5612dc4..3d4bdba 100644 --- a/makefile +++ b/makefile @@ -6,6 +6,7 @@ CC = g++ DEBUG = -g PROFILE = -pg OPTIMISATIONS = -O3 -ffast-math -march=native +GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags) ifdef NOOPENMP OPENMPFLAG = @@ -13,7 +14,13 @@ else OPENMPFLAG = -fopenmp endif +# If the git command failed, GIT_VERSION will be empty, so don't pass a DVERSION flag (fallback) +ifeq ($(strip $(GIT_VERSION)),) CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) $(OPENMPFLAG) +else +CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) $(OPENMPFLAG) -DVERSION=\"$(GIT_VERSION)\" +endif + LFLAGS = -Wall $(OPENMPFLAG) all: executable