[CRIU] [PATCH 10/10] build: criu -- Generate version and config from toplevel

Pavel Emelyanov xemul at virtuozzo.com
Thu Mar 24 07:52:05 PDT 2016


On 03/22/2016 10:15 PM, Cyrill Gorcunov wrote:
> The version and configs will be needed in compel.

Compel would eventually have its own version. Will it?

> Moreover we should move to general toplevel build
> scheme with small steps since it's more convenient
> (as it was pre-2.0).
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  Makefile              | 130 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  criu/Makefile         |  43 +----------------
>  criu/Makefile.config  |  60 -----------------------
>  criu/Makefile.version |  32 -------------
>  4 files changed, 130 insertions(+), 135 deletions(-)
>  delete mode 100644 criu/Makefile.config
>  delete mode 100644 criu/Makefile.version
> 
> diff --git a/Makefile b/Makefile
> index 24033e7c2c33..5f16c28da855 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -5,6 +5,7 @@ export __nmk_dir
>  
>  include $(__nmk_dir)/include.mk
>  include $(__nmk_dir)/macro.mk
> +include $(__nmk_dir)/utils.mk
>  
>  #
>  # Import tools versions early
> @@ -104,6 +105,129 @@ endif
>  CFLAGS			+= $(WARNINGS) $(DEFINES)
>  
>  #
> +# Architecture specific options.
> +#
> +ifeq ($(ARCH),x86)
> +        SRCARCH		:= x86
> +        LDARCH		:= i386:x86-64
> +        VDSO		:= y
> +endif
> +
> +ifeq ($(ARCH),arm)
> +        SRCARCH		:= arm
> +endif
> +
> +ifeq ($(ARCH),arm64)
> +        ARCH		:= aarch64
> +        SRCARCH		:= aarch64
> +        VDSO		:= y
> +endif
> +
> +ifeq ($(ARCH),ppc64)
> +        SRCARCH		:= ppc64
> +        LDARCH		:= powerpc:common64
> +        VDSO		:= y
> +endif
> +
> +LDARCH			?= $(SRCARCH)
> +SRCARCH			?= $(ARCH)
> +
> +export SRCARCH LDARCH VDSO
> +
> +#
> +# CRIU version header.
> +CRIU_VERSION_HEADER	:= 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)
> +
> +$(CRIU_VERSION_HEADER): Makefile.versions $(GITID_FILE)
> +	$(call msg-gen, $@)
> +	$(Q) echo "/* Autogenerated, do not edit */"			 > $(CRIU_VERSION_HEADER)
> +	$(Q) echo "#ifndef __CR_VERSION_H__"				>> $(CRIU_VERSION_HEADER)
> +	$(Q) echo "#define __CR_VERSION_H__"				>> $(CRIU_VERSION_HEADER)
> +	$(Q) echo "#define CRIU_VERSION \"$(CRIU_VERSION)\""		>> $(CRIU_VERSION_HEADER)
> +	$(Q) echo "#define CRIU_VERSION_MAJOR " $(CRIU_VERSION_MAJOR)	>> $(CRIU_VERSION_HEADER)
> +	$(Q) echo "#define CRIU_VERSION_MINOR " $(CRIU_VERSION_MINOR)	>> $(CRIU_VERSION_HEADER)
> +	$(Q) echo "#define CRIU_GITID \"$(GITID)\""			>> $(CRIU_VERSION_HEADER)
> +	$(Q) echo "#endif /* __CR_VERSION_H__ */"			>> $(CRIU_VERSION_HEADER)
> +
> +#
> +# CRIU config header.
> +#
> +include scripts/feature-tests.mak
> +
> +CRIU_CONFIG_HEADER	:= criu/include/config.h
> +
> +ifeq ($(call try-cc,$(FEATURE_TEST_LIBBSD_DEV),-lbsd),y)
> +        LIBS	+= -lbsd
> +        DEFINES	+= -DCONFIG_HAS_LIBBSD
> +endif
> +
> +ifeq ($(call pkg-config-check,libselinux),y)
> +        LIBS	+= -lselinux
> +        DEFINES	+= -DCONFIG_HAS_SELINUX
> +endif
> +
> +ifeq ($(call try-cc,$(FEATURE_TEST_UFFD)),y)
> +	export UFFD := 1
> +endif
> +
> +FEATURES_LIST		:=	TCP_REPAIR PRLIMIT	\
> +				STRLCPY			\
> +				STRLCAT			\
> +				PTRACE_PEEKSIGINFO	\
> +				SETPROCTITLE_INIT	\
> +				MEMFD
> +
> +define gen-feature-test
> +ifeq ($$(call try-cc,$$(FEATURE_TEST_$(1)),$$(LIBS),$$(DEFINES)),y)
> +	$(Q) @echo '#define CONFIG_HAS_$(1)' >> $$@
> +	$(Q) @echo '' >> $$@
> +endif
> +endef
> +
> +define config-header-rule
> +$(CRIU_CONFIG_HEADER): scripts/feature-tests.mak
> +	$$(call msg-gen, $$@)
> +	$(Q) @echo '#ifndef __CR_CONFIG_H__'				 > $$@
> +	$(Q) @echo '#define __CR_CONFIG_H__'				>> $$@
> +	$(Q) @echo ''							>> $$@
> +	$(Q) @echo '#include "config-base.h"'				>> $$@
> +	$(Q) @echo ''							>> $$@
> +$(call map,gen-feature-test,$(FEATURES_LIST))
> +ifeq ($$(VDSO),y)
> +	$(Q) @echo '#define CONFIG_VDSO'				>> $$@
> +	$(Q) @echo ''							>> $$@
> +endif
> +ifeq ($$(UFFD),1)
> +	$(Q) @echo '#define CONFIG_HAS_UFFD'				>> $$@
> +	$(Q) @echo ''							>> $$@
> +endif
> +ifeq ($$(piegen-y),y)
> +	$(Q) @echo '#define CONFIG_PIEGEN'				>> $$@
> +	$(Q) @echo ''							>> $$@
> +endif
> +	$(Q) @echo '#endif /* __CR_CONFIG_H__ */'			>> $$@
> +endef
> +
> +$(eval $(config-header-rule))
> +
> +#
>  # Protobuf images first, they are not depending
>  # on anything else.
>  $(eval $(call gen-built-in,images))
> @@ -120,9 +244,9 @@ $(eval $(call gen-built-in,compel))
>  #
>  # But note that we're already included
>  # the nmk so we can reuse it there.
> -criu/%: images/built-in.o compel/compel
> +criu/%: $(CRIU_VERSION_HEADER) $(CRIU_CONFIG_HEADER) compel/compel images/built-in.o
>  	$(Q) $(MAKE) -C criu $@
> -criu: images/built-in.o compel/compel
> +criu: $(CRIU_VERSION_HEADER) $(CRIU_CONFIG_HEADER) compel/compel images/built-in.o
>  	$(Q) $(MAKE) -C criu all
>  .PHONY: criu
>  
> @@ -145,6 +269,8 @@ clean-built:
>  	$(Q) $(MAKE) -C criu clean
>  	$(Q) $(MAKE) -C lib clean
>  	$(Q) $(MAKE) -C Documentation clean
> +	$(Q) $(RM) $(CRIU_VERSION_HEADER)
> +	$(Q) $(RM) $(CRIU_CONFIG_HEADER)
>  .PHONY: clean-built
>  
>  clean: clean-built
> diff --git a/criu/Makefile b/criu/Makefile
> index 4a9464d4dcaf..c4217c0d8b40 100644
> --- a/criu/Makefile
> +++ b/criu/Makefile
> @@ -12,37 +12,9 @@ LDFLAGS			+= -Wl,--wrap=nla_parse,--wrap=nlmsg_parse
>  
>  export HOSTCC HOSTLD HOSTCFLAGS
>  
> -ifeq ($(ARCH),x86)
> -        SRCARCH		:= x86
> -        LDARCH		:= i386:x86-64
> -        VDSO		:= y
> -endif
> -
> -ifeq ($(ARCH),arm)
> -        SRCARCH		:= arm
> -endif
> -
> -ifeq ($(ARCH),arm64)
> -        ARCH		:= aarch64
> -        SRCARCH		:= aarch64
> -        VDSO		:= y
> -endif
> -
> -ifeq ($(ARCH),ppc64)
> -        SRCARCH		:= ppc64
> -        LDARCH		:= powerpc:common64
> -        VDSO		:= y
> -endif
> -
> -LDARCH ?= $(SRCARCH)
> -
> -export SRCARCH LDARCH VDSO
> -
> -SRCARCH			?= $(ARCH)
> -LDARCH			?= $(SRCARCH)
>  ARCH_DIR		:= arch/$(SRCARCH)
>  
> -export SRCARCH LDARCH ARCH_DIR VDSO
> +export ARCH_DIR
>  
>  $(if $(wildcard $(ARCH_DIR)),,$(error "The architecture $(ARCH) isn't supported"))
>  
> @@ -119,18 +91,9 @@ endif
>  include $(__nmk_dir)/msg.mk
>  
>  #
> -# Version header file.
> -include Makefile.version
> -
> -#
> -# Configure variables.
> -include Makefile.config
> -config: $(VERSION_HEADER)
> -
> -#
>  # System calls library.
>  SYSCALL-LIB		:= $(ARCH_DIR)/syscalls.built-in.o
> -syscalls_lib: config
> +syscalls_lib:
>  	$(Q) $(MAKE) $(call build-as,Makefile.syscalls,$(ARCH_DIR)) all
>  .PHONY: syscalls_lib
>  
> @@ -176,8 +139,6 @@ clean:
>  	$(Q) $(RM) ./*.{gcda,gcno,gcov}
>  	$(Q) $(RM) ./pie/*.{gcda,gcno,gcov}
>  	$(Q) $(RM) -r ./gcov
> -	$(Q) $(RM) $(VERSION_HEADER)
> -	$(Q) $(RM) $(CONFIG_HEADER)
>  	$(Q) $(RM) criu
>  .PHONY: clean
>  
> diff --git a/criu/Makefile.config b/criu/Makefile.config
> deleted file mode 100644
> index 2b8c25f0d4e7..000000000000
> --- a/criu/Makefile.config
> +++ /dev/null
> @@ -1,60 +0,0 @@
> -include $(__nmk_dir)/utils.mk
> -include $(__nmk_dir)msg.mk
> -include ../scripts/feature-tests.mak
> -
> -CONFIG_HEADER := include/config.h
> -
> -ifeq ($(call try-cc,$(FEATURE_TEST_LIBBSD_DEV),-lbsd),y)
> -        LIBS	+= -lbsd
> -        DEFINES	+= -DCONFIG_HAS_LIBBSD
> -endif
> -
> -ifeq ($(call pkg-config-check,libselinux),y)
> -        LIBS	+= -lselinux
> -        DEFINES	+= -DCONFIG_HAS_SELINUX
> -endif
> -
> -ifeq ($(call try-cc,$(FEATURE_TEST_UFFD)),y)
> -	export UFFD := 1
> -endif
> -
> -FEATURES_LIST	:= TCP_REPAIR PRLIMIT STRLCPY STRLCAT PTRACE_PEEKSIGINFO \
> -	SETPROCTITLE_INIT MEMFD
> -
> -# $1 - config name
> -define gen-feature-test
> -ifeq ($$(call try-cc,$$(FEATURE_TEST_$(1)),$$(LIBS),$$(DEFINES)),y)
> -	$(Q) @echo '#define CONFIG_HAS_$(1)' >> $$@
> -	$(Q) @echo '' >> $$@
> -endif
> -endef
> -
> -define config-header-rule
> -$(CONFIG_HEADER): include/config-base.h
> -	$$(call msg-gen, $$@)
> -	$(Q) @echo '#ifndef __CR_CONFIG_H__'				> $$@
> -	$(Q) @echo '#define __CR_CONFIG_H__'				>> $$@
> -	$(Q) @echo ''							>> $$@
> -	$(Q) @echo '#include "config-base.h"'				>> $$@
> -	$(Q) @echo ''							>> $$@
> -$(call map,gen-feature-test,$(FEATURES_LIST))
> -ifeq ($$(VDSO),y)
> -	$(Q) @echo '#define CONFIG_VDSO'				>> $$@
> -	$(Q) @echo ''							>> $$@
> -endif
> -ifeq ($$(UFFD),1)
> -	$(Q) @echo '#define CONFIG_HAS_UFFD'				>> $$@
> -	$(Q) @echo ''							>> $$@
> -endif
> -ifeq ($$(piegen-y),y)
> -	$(Q) @echo '#define CONFIG_PIEGEN'				>> $$@
> -	$(Q) @echo ''							>> $$@
> -endif
> -	$(Q) @echo '#endif /* __CR_CONFIG_H__ */'			>> $$@
> -endef
> -
> -$(eval $(config-header-rule))
> -
> -$(CONFIG_HEADER): ../scripts/feature-tests.mak
> -config: $(CONFIG_HEADER)
> -.PHONY: config
> diff --git a/criu/Makefile.version b/criu/Makefile.version
> deleted file mode 100644
> index 9b5a614b5831..000000000000
> --- a/criu/Makefile.version
> +++ /dev/null
> @@ -1,32 +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)
> -	$(Q) echo "#define CRIU_GITID \"$(GITID)\""			>> $(VERSION_HEADER)
> -	$(Q) echo "#endif /* __CR_VERSION_H__ */"			>> $(VERSION_HEADER)
> -
> -Makefile.version:
> -	@true
> 



More information about the CRIU mailing list