Commit a870a170 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

build: Generate criu version from toplevel

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 08bb9826
...@@ -6,11 +6,6 @@ export __nmk_dir ...@@ -6,11 +6,6 @@ export __nmk_dir
include $(__nmk_dir)/include.mk include $(__nmk_dir)/include.mk
include $(__nmk_dir)/macro.mk include $(__nmk_dir)/macro.mk
#
# Import tools versions early
# so subsequents may refer them.
include Makefile.versions
# #
# To build host helpers. # To build host helpers.
HOSTCC ?= gcc HOSTCC ?= gcc
...@@ -140,6 +135,44 @@ endif ...@@ -140,6 +135,44 @@ endif
CFLAGS += $(WARNINGS) $(DEFINES) 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 # Protobuf images first, they are not depending
# on anything else. # on anything else.
...@@ -153,9 +186,9 @@ $(eval $(call gen-built-in,images)) ...@@ -153,9 +186,9 @@ $(eval $(call gen-built-in,images))
# #
# But note that we're already included # But note that we're already included
# the nmk so we can reuse it there. # the nmk so we can reuse it there.
criu/%: images/built-in.o criu/%: images/built-in.o $(VERSION_HEADER)
$(Q) $(MAKE) -C criu $@ $(Q) $(MAKE) -C criu $@
criu: images/built-in.o criu: images/built-in.o $(VERSION_HEADER)
$(Q) $(MAKE) -C criu all $(Q) $(MAKE) -C criu all
.PHONY: criu .PHONY: criu
...@@ -188,6 +221,7 @@ clean: subclean ...@@ -188,6 +221,7 @@ clean: subclean
mrproper: subclean mrproper: subclean
$(Q) $(MAKE) $(build)=images $@ $(Q) $(MAKE) $(build)=images $@
$(Q) $(MAKE) -C criu $@ $(Q) $(MAKE) -C criu $@
$(Q) $(RM) $(VERSION_HEADER)
$(Q) $(RM) cscope.* $(Q) $(RM) cscope.*
$(Q) $(RM) tags TAGS $(Q) $(RM) tags TAGS
.PHONY: mrproper .PHONY: mrproper
......
...@@ -79,10 +79,6 @@ endif ...@@ -79,10 +79,6 @@ endif
# msg-* printing # msg-* printing
include $(__nmk_dir)/msg.mk include $(__nmk_dir)/msg.mk
#
# Version header file.
include Makefile.version
# #
# Configure variables. # Configure variables.
include Makefile.config include Makefile.config
......
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
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