[CRIU] [PATCH 2/2] Always re-build version.h

Cyrill Gorcunov gorcunov at gmail.com
Thu Apr 16 03:21:17 PDT 2015


On Thu, Apr 16, 2015 at 12:24:48PM +0300, Pavel Emelyanov wrote:
> On 04/15/2015 08:46 PM, Tycho Andersen wrote:
> > 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.
> > 
> > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> 
> Well, "make" on freshly built tree re-build several files. This is indeed
> annoying. Is there anything better that can be done about it?

Would the patch below do the trick?
---
diff --git a/scripts/Makefile.version b/scripts/Makefile.version
index 53ee53753db1..85389c3c16e5 100644
--- a/scripts/Makefile.version
+++ b/scripts/Makefile.version
@@ -1,12 +1,22 @@
 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 [ `cat .gitid` = `git describe` ]; then echo y; fi)
+        ifneq ($(GITID_FILE_VALUE),y)
+                .PHONY: $(GITID_FILE)
+                $(GITID_FILE):
+			$(E) "  GEN     " $@
+			$(Q) echo "$(GITID)" > $(GITID_FILE)
+        endif
 endif
 
-$(VERSION_HEADER): Makefile scripts/Makefile.version
+$(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)


More information about the CRIU mailing list