2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00

build: Generate criu version from toplevel

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Cyrill Gorcunov 2016-04-14 14:01:01 +03:00 committed by Pavel Emelyanov
parent 08bb98266b
commit a870a170dc
3 changed files with 41 additions and 49 deletions

View File

@ -6,11 +6,6 @@ export __nmk_dir
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
@ -140,6 +135,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.
@ -153,9 +186,9 @@ $(eval $(call gen-built-in,images))
#
# But note that we're already included
# the nmk so we can reuse it there.
criu/%: images/built-in.o
criu/%: images/built-in.o $(VERSION_HEADER)
$(Q) $(MAKE) -C criu $@
criu: images/built-in.o
criu: images/built-in.o $(VERSION_HEADER)
$(Q) $(MAKE) -C criu all
.PHONY: criu
@ -188,6 +221,7 @@ clean: subclean
mrproper: subclean
$(Q) $(MAKE) $(build)=images $@
$(Q) $(MAKE) -C criu $@
$(Q) $(RM) $(VERSION_HEADER)
$(Q) $(RM) cscope.*
$(Q) $(RM) tags TAGS
.PHONY: mrproper

View File

@ -79,10 +79,6 @@ endif
# msg-* printing
include $(__nmk_dir)/msg.mk
#
# Version header file.
include Makefile.version
#
# Configure variables.
include Makefile.config

View File

@ -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