diff --git a/server/Makefile b/server/Makefile index 0ca0dab1c..e8681c9cd 100644 --- a/server/Makefile +++ b/server/Makefile @@ -12,9 +12,11 @@ V ?= 2 LDLIBS = -pthread -lrt -lm -lconfig CFLAGS = -std=c99 -Iinclude/ -MMD -Wall CFLAGS += -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -DV=$(V) -CFLAGS += -D__GIT_REV__='"-$(shell git rev-parse --short HEAD)"' -# Conditional flags +# Add git commit hash +ifneq (,$(shell which git)) + CFLAGS += -D_GIT_REV='"$(shell git rev-parse --short HEAD)"' +endif ifdef DEBUG CFLAGS += -O0 -g else diff --git a/server/include/config.h b/server/include/config.h index f5e306078..b6002c26e 100644 --- a/server/include/config.h +++ b/server/include/config.h @@ -11,9 +11,12 @@ #ifndef _CONFIG_H_ #define _CONFIG_H_ -/** The version number of the s2ss server */ +#ifndef _GIT_REV + #define _GIT_REV "nogit" +#endif -#define VERSION "v0.4" __GIT_REV__ +/** The version number of the s2ss server */ +#define VERSION "v0.4-" _GIT_REV /** Maximum number of double values in a struct msg */ #define MAX_VALUES 64 diff --git a/server/include/utils.h b/server/include/utils.h index 9f4e34c7f..90c233e34 100644 --- a/server/include/utils.h +++ b/server/include/utils.h @@ -55,8 +55,14 @@ #define LEFT(n) "" #endif +/* CPP stringification */ +#define XSTR(x) STR(x) +#define STR(x) #x + +/** Calculate the number of elements in an array. */ #define ARRAY_LEN(a) ( sizeof (a) / sizeof (a)[0] ) +/** Swap two values by using a local third one. */ #define SWAP(a, b) do { \ __typeof__(a) tmp = a; \ a = b; \