diff --git a/Makefile b/Makefile index c22f60251..e81abe212 100644 --- a/Makefile +++ b/Makefile @@ -70,9 +70,17 @@ EMULEX_DIR=emulex ISCSI_DIR=iscsi-scst -REVISION ?= $(shell if [ -e .git ]; then echo -n .; git rev-parse --short HEAD 2>/dev/null; fi) +SCST_GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null) + +REVISION ?= $(SCST_GIT_COMMIT) +export REVISION + VERSION_WITHOUT_REVISION := $(shell echo -n "$$(sed -n 's/^\#define[[:blank:]]SCST_VERSION_NAME[[:blank:]]*\"\([^-]*\).*\"/\1/p' scst/include/scst_const.h)") -VERSION := $(VERSION_WITHOUT_REVISION)$(REVISION) +ifneq (, $(REVISION)) +VERSION := $(VERSION_WITHOUT_REVISION).$(REVISION) +else +VERSION := $(VERSION_WITHOUT_REVISION) +endif DEBIAN_REVISION=1.1 RPMTOPDIR ?= $(shell if [ $$(id -u) = 0 ]; then echo /usr/src/packages;\ else echo $$PWD/rpmbuilddir; fi) diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index 819e470fa..b1659600f 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -37,6 +37,9 @@ #include "scst_itf_ver.h" +#define SCST_STRINGIFY_x(x...) #x +#define SCST_STRINGIFY(x...) SCST_STRINGIFY_x(x) + /* * Version numbers, the same as for the kernel. * @@ -45,9 +48,16 @@ */ #define SCST_VERSION(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + d) #define SCST_VERSION_CODE SCST_VERSION(3, 8, 0, 0) + +#ifdef SCST_VERSION_REVISION +#define SCST_VERSION_REVISION_SUFFIX "." SCST_STRINGIFY(SCST_VERSION_REVISION) +#else +#define SCST_VERSION_REVISION_SUFFIX "" +#endif + #define SCST_VERSION_STRING_SUFFIX #define SCST_VERSION_NAME "3.8.0-pre" -#define SCST_VERSION_STRING SCST_VERSION_NAME SCST_VERSION_STRING_SUFFIX +#define SCST_VERSION_STRING SCST_VERSION_NAME SCST_VERSION_STRING_SUFFIX SCST_VERSION_REVISION_SUFFIX #define SCST_CONST_VERSION SCST_CONST_INTF_VER diff --git a/scst/src/Kbuild b/scst/src/Kbuild index 257e2de3f..29af97767 100644 --- a/scst/src/Kbuild +++ b/scst/src/Kbuild @@ -1,8 +1,9 @@ # See also Documentation/core-api/symbol-namespaces.rst for more information # about DEFAULT_SYMBOL_NAMESPACE. -ccflags-y += -I$(src)/../include\ - -DDEFAULT_SYMBOL_NAMESPACE=SCST\ - $(shell [ -n "${CONFIG_SCST_NO_DLM}" ] && echo -DCONFIG_SCST_NO_DLM) +ccflags-y += -I$(src)/../include \ + -DDEFAULT_SYMBOL_NAMESPACE=SCST \ + $(shell [ -n "${CONFIG_SCST_NO_DLM}" ] && echo -DCONFIG_SCST_NO_DLM) \ + $(shell [ -n "${REVISION}" ] && echo -DSCST_VERSION_REVISION=${REVISION}) #ccflags-y += -DCONFIG_SCST_STRICT_SERIALIZING #ccflags-y += -DCONFIG_SCST_USE_EXPECTED_VALUES