Add "git describe" based version string postfix

If hostapd or wpa_supplicant is built from a git repository, add a
VERSION_STR postfix from the current git branch state. This is from "git
describe --dirty=+". VERSION_STR will thus look something like
"2.6-devel-hostap_2_5-132-g4363c0d+" for development builds from a
modified repository.

This behavior is enabled automatically if a build within git repository
is detected (based on ../.git existing). This can be disabled with
CONFIG_NO_GITVER=y in wpa_supplicant/.config and hostapd/.config.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-10-16 22:20:55 +03:00
parent 4363c0d6f5
commit ca33a5e895
3 changed files with 25 additions and 1 deletions

View file

@ -18,6 +18,16 @@ export BINDIR ?= /usr/local/bin/
-include .config -include .config
ifndef CONFIG_NO_GITVER
# Add VERSION_STR postfix for builds from a git repository
ifeq ($(wildcard ../.git),../.git)
GITVER := $(shell git describe --dirty=+)
ifneq ($(GITVER),)
CFLAGS += -DGIT_VERSION_STR_POSTFIX=\"-$(GITVER)\"
endif
endif
endif
ifdef CONFIG_TESTING_OPTIONS ifdef CONFIG_TESTING_OPTIONS
CFLAGS += -DCONFIG_TESTING_OPTIONS CFLAGS += -DCONFIG_TESTING_OPTIONS
CONFIG_WPS_TESTING=y CONFIG_WPS_TESTING=y

View file

@ -5,6 +5,10 @@
#define VERSION_STR_POSTFIX "" #define VERSION_STR_POSTFIX ""
#endif /* VERSION_STR_POSTFIX */ #endif /* VERSION_STR_POSTFIX */
#define VERSION_STR "2.6-devel" VERSION_STR_POSTFIX #ifndef GIT_VERSION_STR_POSTFIX
#define GIT_VERSION_STR_POSTFIX ""
#endif /* GIT_VERSION_STR_POSTFIX */
#define VERSION_STR "2.6-devel" VERSION_STR_POSTFIX GIT_VERSION_STR_POSTFIX
#endif /* VERSION_H */ #endif /* VERSION_H */

View file

@ -17,6 +17,16 @@ CFLAGS += -I$(abspath ../src/utils)
-include .config -include .config
ifndef CONFIG_NO_GITVER
# Add VERSION_STR postfix for builds from a git repository
ifeq ($(wildcard ../.git),../.git)
GITVER := $(shell git describe --dirty=+)
ifneq ($(GITVER),)
CFLAGS += -DGIT_VERSION_STR_POSTFIX=\"-$(GITVER)\"
endif
endif
endif
ifdef CONFIG_TESTING_OPTIONS ifdef CONFIG_TESTING_OPTIONS
CFLAGS += -DCONFIG_TESTING_OPTIONS CFLAGS += -DCONFIG_TESTING_OPTIONS
CONFIG_WPS_TESTING=y CONFIG_WPS_TESTING=y