[CRIU] [PATCH] build: generate config.h in the top-make

Dmitry Safonov dsafonov at virtuozzo.com
Mon Sep 26 06:05:43 PDT 2016


So, we need CONFIG_HAS_* feature-defines in compel, libsoccr
tools. Let's move this tests upper.

It also reverts commit 411cde8815a4 ("make, soccr: let CRIU depend on
libsoccr"), as we don't need -lsoccr to build feature tests now.
To eliminate any races here, I added $(LIB_FEATURES).

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 Makefile                                | 27 ++++++++++++++++++++++++---
 Makefile.compel                         |  4 ++--
 criu/Makefile.config => Makefile.config | 14 +++++++++-----
 criu/Makefile                           | 23 +----------------------
 criu/Makefile.packages                  |  2 +-
 5 files changed, 37 insertions(+), 33 deletions(-)
 rename criu/Makefile.config => Makefile.config (84%)

diff --git a/Makefile b/Makefile
index 334ec6e273f6..accbc0941c9d 100644
--- a/Makefile
+++ b/Makefile
@@ -175,6 +175,26 @@ endif
 	$(Q) echo "#endif /* __CR_VERSION_H__ */"				>> $@
 
 #
+# piegen tool might be disabled by hands. Don't use it until
+# you know what you're doing.
+ifneq ($(filter ia32 x86 ppc64,$(ARCH)),)
+        ifneq ($(PIEGEN),no)
+                piegen-y := y
+                export piegen-y
+        endif
+endif
+
+#
+# Configure variables.
+export CONFIG_HEADER := $(SRC_DIR)/criu/include/config.h
+ifeq ($(filter clean mrproper,$(MAKECMDGOALS)),)
+include $(SRC_DIR)/Makefile.config
+else
+# To clean all files, enable make/build options here
+export CONFIG_COMPAT := y
+endif
+
+#
 # Protobuf images first, they are not depending
 # on anything else.
 $(eval $(call gen-built-in,images))
@@ -189,9 +209,9 @@ include Makefile.compel
 # Next the socket CR library
 #
 SOCCR_A := soccr/libsoccr.a
-soccr/%: .FORCE
+soccr/%: $(CONFIG_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=soccr $@
-soccr/built-in.o: .FORCE
+soccr/built-in.o: $(CONFIG_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=soccr all
 $(SOCCR_A): |soccr/built-in.o
 
@@ -203,7 +223,7 @@ $(SOCCR_A): |soccr/built-in.o
 #
 # But note that we're already included
 # the nmk so we can reuse it there.
-criu/%: images/built-in.o compel/compel-host $(SOCCR_A) $(VERSION_HEADER) .FORCE
+criu/%: images/built-in.o compel/compel-host $(VERSION_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=criu $@
 criu: images/built-in.o compel/compel-host $(SOCCR_A) $(VERSION_HEADER)
 	$(Q) $(MAKE) $(build)=criu all
@@ -243,6 +263,7 @@ mrproper: subclean
 	$(Q) $(MAKE) $(build)=criu $@
 	$(Q) $(MAKE) $(build)=compel $@
 	$(Q) $(MAKE) $(build)=soccr $@
+	$(Q) $(RM) $(CONFIG_HEADER)
 	$(Q) $(RM) $(VERSION_HEADER)
 	$(Q) $(RM) $(COMPEL_VERSION_HEADER)
 	$(Q) $(RM) cscope.*
diff --git a/Makefile.compel b/Makefile.compel
index 7f2f62f6c4d0..b18cd8edca8a 100644
--- a/Makefile.compel
+++ b/Makefile.compel
@@ -13,12 +13,12 @@ $(COMPEL_VERSION_HEADER): $(SRC_DIR)/Makefile.versions
 
 #
 # Compel itself.
-compel/%: $(COMPEL_VERSION_HEADER) .FORCE
+compel/%: $(COMPEL_VERSION_HEADER) $(CONFIG_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=compel $@
 
 #
 # Plugins
-compel/plugins/%: $(COMPEL_VERSION_HEADER) .FORCE
+compel/plugins/%: $(COMPEL_VERSION_HEADER) $(CONFIG_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=compel/plugins $@
 
 compel/compel: compel/built-in.o compel/lib.a $(COMPEL_VERSION_HEADER)
diff --git a/criu/Makefile.config b/Makefile.config
similarity index 84%
rename from criu/Makefile.config
rename to Makefile.config
index 7bcecb380e7a..9e132f80feb4 100644
--- a/criu/Makefile.config
+++ b/Makefile.config
@@ -3,15 +3,17 @@ include $(__nmk_dir)msg.mk
 include $(SRC_DIR)/scripts/feature-tests.mak
 
 ifeq ($(call try-cc,$(FEATURE_TEST_LIBBSD_DEV),-lbsd),true)
-        LIBS		+= -lbsd
+        LIBS_FEATURES	+= -lbsd
         FEATURE_DEFINES	+= -DCONFIG_HAS_LIBBSD
 endif
 
 ifeq ($(call pkg-config-check,libselinux),y)
-        LIBS		+= -lselinux
+        LIBS_FEATURES	+= -lselinux
         FEATURE_DEFINES	+= -DCONFIG_HAS_SELINUX
 endif
 
+export LIBS += $(LIBS_FEATURES)
+
 ifeq ($(SRCARCH),x86)
 # CONFIG_COMPAT is only for x86 now, no need for compile-test other archs
 ifeq ($(call try-cc,$(FEATURE_TEST_X86_COMPAT),-m32),true)
@@ -28,17 +30,19 @@ FEATURES_LIST	:= TCP_REPAIR STRLCPY STRLCAT PTRACE_PEEKSIGINFO \
 
 # $1 - config name
 define gen-feature-test
-ifeq ($$(call try-cc,$$(FEATURE_TEST_$(1)),$$(LIBS),$$(DEFINES)),true)
+ifeq ($$(call try-cc,$$(FEATURE_TEST_$(1)),$$(LIBS_FEATURES),$$(DEFINES)),true)
 	$(Q) @echo '#define CONFIG_HAS_$(1)' >> $$@
 	$(Q) @echo '' >> $$@
 endif
 endef
 
-$(obj)/include/config-base.h:
+CONFIG_BASE := $(SRC_DIR)/criu/include/config-base.h
+
+$(CONFIG_BASE):
 	@true
 
 define config-header-rule
-$(CONFIG_HEADER): $(obj)/include/config-base.h
+$(CONFIG_HEADER): $(CONFIG_BASE)
 	$$(call msg-gen, $$@)
 	$(Q) @echo '#ifndef __CR_CONFIG_H__'				> $$@
 	$(Q) @echo '#define __CR_CONFIG_H__'				>> $$@
diff --git a/criu/Makefile b/criu/Makefile
index f7a25ab4c893..410b431b38e9 100644
--- a/criu/Makefile
+++ b/criu/Makefile
@@ -24,16 +24,6 @@ ifeq ($(GMON),1)
 	GMONLDOPT	:= -pg
 endif
 
-#
-# piegen tool might be disabled by hands. Don't use it until
-# you know what you're doing.
-ifneq ($(filter ia32 x86 ppc64,$(ARCH)),)
-        ifneq ($(PIEGEN),no)
-                piegen-y := y
-                export piegen-y
-        endif
-endif
-
 # msg-* printing
 include $(__nmk_dir)/msg.mk
 
@@ -42,16 +32,6 @@ include $(__nmk_dir)/msg.mk
 include $(SRC_DIR)/criu/Makefile.packages
 
 #
-# Configure variables.
-CONFIG_HEADER := $(obj)/include/config.h
-ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
-include $(SRC_DIR)/criu/Makefile.config
-else
-# To clean all files, enable make/build options here
-export CONFIG_COMPAT := y
-endif
-
-#
 # System calls library.
 ifeq ($(ARCH),x86)
 # Do not need 32-bit compatible syscall lib compiled in criu
@@ -59,7 +39,7 @@ SYSCALL-LIB		:= $(ARCH_DIR)/syscalls-64.built-in.o
 else
 SYSCALL-LIB		:= $(ARCH_DIR)/syscalls.built-in.o
 endif
-syscalls_lib: $(CONFIG_HEADER)
+syscalls_lib:
 	$(Q) $(MAKE) $(call build-as,Makefile.syscalls,$(ARCH_DIR)) all
 .PHONY: syscalls_lib
 
@@ -128,7 +108,6 @@ subproper:
 	$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) mrproper
 	$(Q) $(MAKE) $(build)=$(PIE_DIR) mrproper
 .PHONY: subproper
-mrproper-y     += $(CONFIG_HEADER)
 mrproper: subproper
 
 UAPI_HEADERS := $(SRC_DIR)/criu/include/criu-plugin.h
diff --git a/criu/Makefile.packages b/criu/Makefile.packages
index 1c6b787f7095..53fbdae895a0 100644
--- a/criu/Makefile.packages
+++ b/criu/Makefile.packages
@@ -19,7 +19,7 @@ REQ-DEB-PKG-NAMES	+= libcap-dev
 
 REQ-DEB-PKG-TEST-NAMES  += libaio-dev
 
-export LIBS		:= -lrt -lpthread -lprotobuf-c -ldl -lnl-3 -lsoccr -Lsoccr/
+export LIBS		+= -lrt -lpthread -lprotobuf-c -ldl -lnl-3 -lsoccr -Lsoccr/
 
 check-packages-failed:
 	$(warning Can not find some of the required libraries)
-- 
2.10.0



More information about the CRIU mailing list