Commit 1b406338 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

make: Rebuild version if git commit id is changed

Original message from Tycho:

This might be a slightly controversial change since it always causes crtools.h
to be rebuilt, which may be annoying. However, right now version.h is only
generated on the initial git build and never again touched, which is also
incorrect.

We could potentially do something fancy by monitoring .git/HEAD for changes,
but since it may not always exist if building from a tarball, it is a little
sticky.

CC: Andersen <tycho.andersen@canonical.com>
CC: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 58ef9bc4
...@@ -30,3 +30,4 @@ include/config.h ...@@ -30,3 +30,4 @@ include/config.h
protobuf-desc-gen.h protobuf-desc-gen.h
criu.pc criu.pc
build build
.gitid
CRTOOLSVERSION := $(VERSION_MAJOR)$(if $(VERSION_MINOR),.$(VERSION_MINOR))$(if $(VERSION_SUBLEVEL),.$(VERSION_SUBLEVEL)) CRTOOLSVERSION := $(VERSION_MAJOR)$(if $(VERSION_MINOR),.$(VERSION_MINOR))$(if $(VERSION_SUBLEVEL),.$(VERSION_SUBLEVEL))
VERSION_HEADER := include/version.h VERSION_HEADER := include/version.h
GITID_FILE := .gitid
GITID := $(shell if [ -d ".git" ]; then git describe; fi) GITID := $(shell if [ -d ".git" ]; then git describe; fi)
ifeq ($(GITID),) ifeq ($(GITID),)
GITID := 0 GITID := 0
else
GITID_FILE_VALUE := $(shell if [ `cat .gitid` = $(GITID) ]; then echo y; fi)
ifneq ($(GITID_FILE_VALUE),y)
.PHONY: $(GITID_FILE)
endif
endif endif
$(VERSION_HEADER): Makefile scripts/Makefile.version $(GITID_FILE):
$(E) " GEN " $@
$(Q) echo "$(GITID)" > $(GITID_FILE)
$(VERSION_HEADER): Makefile scripts/Makefile.version $(GITID_FILE)
$(E) " GEN " $@ $(E) " GEN " $@
$(Q) echo "/* Autogenerated, do not edit */" > $(VERSION_HEADER) $(Q) echo "/* Autogenerated, do not edit */" > $(VERSION_HEADER)
$(Q) echo "#ifndef __CR_VERSION_H__" >> $(VERSION_HEADER) $(Q) echo "#ifndef __CR_VERSION_H__" >> $(VERSION_HEADER)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment