criu/scripts/Makefile.version
Cyrill Gorcunov 46a0e74d5f make: version -- Ensure that .gitid exist vefore read
In case if there is no .gitid file we might endup
with build error. Make sure it exist.

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-05-07 18:38:26 +03:00

36 lines
1.3 KiB
Text

CRTOOLSVERSION := $(VERSION_MAJOR)$(if $(VERSION_MINOR),.$(VERSION_MINOR))$(if $(VERSION_SUBLEVEL),.$(VERSION_SUBLEVEL))
VERSION_HEADER := include/version.h
GITID_FILE := .gitid
GITID := $(shell if [ -d ".git" ]; then git describe; fi)
ifeq ($(GITID),)
GITID := 0
else
GITID_FILE_VALUE := $(shell if [ -f '.gitid' ]; then if [ `cat .gitid` = $(GITID) ]; then echo y; fi; fi)
ifneq ($(GITID_FILE_VALUE),y)
.PHONY: $(GITID_FILE)
endif
endif
$(GITID_FILE):
$(E) " GEN " $@
$(Q) echo "$(GITID)" > $(GITID_FILE)
$(VERSION_HEADER): Makefile scripts/Makefile.version $(GITID_FILE)
$(E) " GEN " $@
$(Q) echo "/* Autogenerated, do not edit */" > $(VERSION_HEADER)
$(Q) echo "#ifndef __CR_VERSION_H__" >> $(VERSION_HEADER)
$(Q) echo "#define __CR_VERSION_H__" >> $(VERSION_HEADER)
$(Q) echo "#define CRIU_VERSION \"$(CRTOOLSVERSION)\"" >> $(VERSION_HEADER)
$(Q) echo "#define CRIU_VERSION_MAJOR " $(VERSION_MAJOR) >> $(VERSION_HEADER)
$(Q) echo "#define CRIU_VERSION_MINOR " $(VERSION_MINOR) >> $(VERSION_HEADER)
$(Q) echo "#define CRIU_GITID \"$(GITID)\"" >> $(VERSION_HEADER)
$(Q) echo "#endif /* __CR_VERSION_H__ */" >> $(VERSION_HEADER)
##
## In case if someone add last resort rule
## together with .SUFFIXES not cleaned, this
## will slow down the build procedure
scripts/Makefile.version::
@true