[CRIU] [PATCH 3/3] build: Generate criu version from toplevel

Cyrill Gorcunov gorcunov at openvz.org
Thu Apr 14 04:01:01 PDT 2016


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 Makefile              | 48 +++++++++++++++++++++++++++++++++++++++++-------
 criu/Makefile         |  4 ----
 criu/Makefile.version | 38 --------------------------------------
 3 files changed, 41 insertions(+), 49 deletions(-)
 delete mode 100644 criu/Makefile.version

diff --git a/Makefile b/Makefile
index 441c9b78b14f..ddb678ca4441 100644
--- a/Makefile
+++ b/Makefile
@@ -7,11 +7,6 @@ include $(__nmk_dir)/include.mk
 include $(__nmk_dir)/macro.mk
 
 #
-# Import tools versions early
-# so subsequents may refer them.
-include Makefile.versions
-
-#
 # To build host helpers.
 HOSTCC		?= gcc
 HOSTLD		?= ld
@@ -135,6 +130,44 @@ endif
 CFLAGS			+= $(WARNINGS) $(DEFINES)
 
 #
+# Version headers.
+include Makefile.versions
+
+VERSION_HEADER		:= $(SRC_DIR)/criu/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_FILE)' ]; then if [ `cat '$(GITID_FILE)'` = $(GITID) ]; then echo y; fi; fi)
+        ifneq ($(GITID_FILE_VALUE),y)
+                .PHONY: $(GITID_FILE)
+        endif
+endif
+
+$(GITID_FILE):
+	$(call msg-gen, $@)
+	$(Q) echo "$(GITID)" > $(GITID_FILE)
+
+$(VERSION_HEADER): Makefile.versions $(GITID_FILE)
+	$(call msg-gen, $@)
+	$(Q) echo "/* Autogenerated, do not edit */"			 	 > $@
+	$(Q) echo "#ifndef __CR_VERSION_H__"					>> $@
+	$(Q) echo "#define __CR_VERSION_H__"					>> $@
+	$(Q) echo "#define CRIU_VERSION \"$(CRIU_VERSION)\""			>> $@
+	$(Q) echo "#define CRIU_VERSION_MAJOR " $(CRIU_VERSION_MAJOR)		>> $@
+	$(Q) echo "#define CRIU_VERSION_MINOR " $(CRIU_VERSION_MINOR)		>> $@
+ifneq ($(CRIU_VERSION_SUBLEVEL),)
+	$(Q) echo "#define CRIU_VERSION_SUBLEVEL " $(CRIU_VERSION_SUBLEVEL)	>> $@
+endif
+ifneq ($(CRIU_VERSION_EXTRA),)
+	$(Q) echo "#define CRIU_VERSION_EXTRA " $(CRIU_VERSION_EXTRA)		>> $@
+endif
+	$(Q) echo "#define CRIU_GITID \"$(GITID)\""				>> $@
+	$(Q) echo "#endif /* __CR_VERSION_H__ */"				>> $@
+
+#
 # Protobuf images first, they are not depending
 # on anything else.
 $(eval $(call gen-built-in,images))
@@ -151,9 +184,9 @@ compel/%:
 #
 # But note that we're already included
 # the nmk so we can reuse it there.
-criu/%: images/built-in.o compel/compel
+criu/%: images/built-in.o compel/compel $(VERSION_HEADER)
 	$(Q) $(MAKE) -C criu $@
-criu: images/built-in.o compel/compel
+criu: images/built-in.o compel/compel $(VERSION_HEADER)
 	$(Q) $(MAKE) -C criu all
 .PHONY: criu
 
@@ -188,6 +221,7 @@ mrproper: subclean
 	$(Q) $(MAKE) $(build)=images $@
 	$(Q) $(MAKE) $(build)=compel $@
 	$(Q) $(MAKE) -C criu $@
+	$(Q) $(RM) $(VERSION_HEADER)
 	$(Q) $(RM) cscope.*
 	$(Q) $(RM) tags TAGS
 .PHONY: mrproper
diff --git a/criu/Makefile b/criu/Makefile
index 775a6a7a4dae..4f484b8eefe1 100644
--- a/criu/Makefile
+++ b/criu/Makefile
@@ -80,10 +80,6 @@ endif
 include $(__nmk_dir)/msg.mk
 
 #
-# Version header file.
-include Makefile.version
-
-#
 # Configure variables.
 include Makefile.config
 config: $(VERSION_HEADER)
diff --git a/criu/Makefile.version b/criu/Makefile.version
deleted file mode 100644
index 123487b5c4f1..000000000000
--- a/criu/Makefile.version
+++ /dev/null
@@ -1,38 +0,0 @@
-include $(__nmk_dir)msg.mk
-
-VERSION_HEADER		:= include/version.h
-GITID_FILE		:= ../.gitid
-GITID			:= $(shell if [ -d "../.git" ]; then cd .. && git describe; fi)
-
-ifeq ($(GITID),)
-        GITID := 0
-else
-        GITID_FILE_VALUE := $(shell if [ -f '$(GITID_FILE)' ]; then if [ `cat '$(GITID_FILE)'` = $(GITID) ]; then echo y; fi; fi)
-        ifneq ($(GITID_FILE_VALUE),y)
-                .PHONY: $(GITID_FILE)
-        endif
-endif
-
-$(GITID_FILE):
-	$(call msg-gen, $@)
-	$(Q) echo "$(GITID)" > $(GITID_FILE)
-
-$(VERSION_HEADER): ../Makefile.versions $(GITID_FILE)
-	$(call msg-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 \"$(CRIU_VERSION)\""			>> $(VERSION_HEADER)
-	$(Q) echo "#define CRIU_VERSION_MAJOR " $(CRIU_VERSION_MAJOR)		>> $(VERSION_HEADER)
-	$(Q) echo "#define CRIU_VERSION_MINOR " $(CRIU_VERSION_MINOR)		>> $(VERSION_HEADER)
-ifneq ($(CRIU_VERSION_SUBLEVEL),)
-	$(Q) echo "#define CRIU_VERSION_SUBLEVEL " $(CRIU_VERSION_SUBLEVEL)	>> $(VERSION_HEADER)
-endif
-ifneq ($(CRIU_VERSION_EXTRA),)
-	$(Q) echo "#define CRIU_VERSION_EXTRA " $(CRIU_VERSION_EXTRA)		>> $(VERSION_HEADER)
-endif
-	$(Q) echo "#define CRIU_GITID \"$(GITID)\""				>> $(VERSION_HEADER)
-	$(Q) echo "#endif /* __CR_VERSION_H__ */"				>> $(VERSION_HEADER)
-
-Makefile.version:
-	@true
-- 
2.5.5



More information about the CRIU mailing list