[CRIU] [PATCH 4/7] make: add Makefile.packages and simplify it

Dmitry Safonov dsafonov at virtuozzo.com
Fri Jul 15 05:17:56 PDT 2016


I think, we can simplify criu's makefile by moving packages
checks out to special makefile.
Now we only need to make criu's target depend on 'check-packages'.

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/Makefile          | 47 +++++------------------------------------------
 criu/Makefile.packages | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 42 deletions(-)
 create mode 100644 criu/Makefile.packages

diff --git a/criu/Makefile b/criu/Makefile
index 7b008caa552e..90a616a6de9a 100644
--- a/criu/Makefile
+++ b/criu/Makefile
@@ -18,47 +18,6 @@ ccflags-y		+= -I/usr/include/libnl3
 
 export ccflags-y
 
-LIBS			:= -lrt -lpthread -lprotobuf-c -ldl -lnl-3
-
-REQ-RPM-PKG-NAMES	+= protobuf
-REQ-RPM-PKG-NAMES	+= protobuf-c
-REQ-RPM-PKG-NAMES	+= protobuf-c-devel
-REQ-RPM-PKG-NAMES	+= protobuf-compiler
-REQ-RPM-PKG-NAMES	+= protobuf-devel
-REQ-RPM-PKG-NAMES	+= protobuf-python
-REQ-RPM-PKG-NAMES	+= libnl3-devel
-REQ-RPM-PKG-NAMES	+= libcap-devel
-
-REQ-DEB-PKG-NAMES	+= libprotobuf-dev
-REQ-DEB-PKG-NAMES	+= libprotobuf-c0-dev
-REQ-DEB-PKG-NAMES	+= protobuf-c-compiler
-REQ-DEB-PKG-NAMES	+= protobuf-compiler
-REQ-DEB-PKG-NAMES	+= python-protobuf
-REQ-DEB-PKG-NAMES	+= libnl-3-dev
-REQ-DEB-PKG-NAMES	+= libcap-dev
-
-REQ-RPM-PKG-TEST-NAMES  += libaio-devel
-
-REQ-DEB-PKG-TEST-NAMES  += libaio-dev
-
-#
-# Make sure all required libs are installed
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(MAKECMDGOALS),mrproper)
-        ifneq ($(shell sh -c                                                            \
-                        'echo "int main(int argc, char *argv[]) { return 0; }" |        \
-                        "$(CC)" -x c - $(LIBS) -o /dev/null > /dev/null 2>&1 && echo y'),y)
-                $(warning "Couldn't find some of the required libraries")
-                $(warning "Make sure the following packages are installed")
-                $(warning "RPM based distros: $(REQ-RPM-PKG-NAMES)")
-                $(warning "DEB based distros: $(REQ-DEB-PKG-NAMES)")
-                $(warning "To run tests the following packages are needed")
-                $(warning "RPM based distros: $(REQ-RPM-PKG-TEST-NAMES)")
-                $(warning "DEB based distros: $(REQ-DEB-PKG-TEST-NAMES)")
-                $(error "Compilation aborted")
-        endif
-endif
-endif
 ifeq ($(GMON),1)
 	CFLAGS		+= -pg
 	GMONLDOPT	:= -pg
@@ -78,6 +37,10 @@ endif
 include $(__nmk_dir)/msg.mk
 
 #
+# Needed libraries checks
+include Makefile.packages
+
+#
 # Configure variables.
 include Makefile.config
 config: $(VERSION_HEADER)
@@ -176,6 +139,6 @@ uninstall:
 
 #
 # Final @all target.
-all: criu
+all: check-packages criu
 	@true
 .PHONY: all
diff --git a/criu/Makefile.packages b/criu/Makefile.packages
new file mode 100644
index 000000000000..4c51e8dc7a07
--- /dev/null
+++ b/criu/Makefile.packages
@@ -0,0 +1,42 @@
+REQ-RPM-PKG-NAMES	+= protobuf
+REQ-RPM-PKG-NAMES	+= protobuf-c
+REQ-RPM-PKG-NAMES	+= protobuf-c-devel
+REQ-RPM-PKG-NAMES	+= protobuf-compiler
+REQ-RPM-PKG-NAMES	+= protobuf-devel
+REQ-RPM-PKG-NAMES	+= protobuf-python
+REQ-RPM-PKG-NAMES	+= libnl3-devel
+REQ-RPM-PKG-NAMES	+= libcap-devel
+
+REQ-RPM-PKG-TEST-NAMES  += libaio-devel
+
+REQ-DEB-PKG-NAMES	+= libprotobuf-dev
+REQ-DEB-PKG-NAMES	+= libprotobuf-c0-dev
+REQ-DEB-PKG-NAMES	+= protobuf-c-compiler
+REQ-DEB-PKG-NAMES	+= protobuf-compiler
+REQ-DEB-PKG-NAMES	+= python-protobuf
+REQ-DEB-PKG-NAMES	+= libnl-3-dev
+REQ-DEB-PKG-NAMES	+= libcap-dev
+
+REQ-DEB-PKG-TEST-NAMES  += libaio-dev
+
+export LIBS		:= -lrt -lpthread -lprotobuf-c -ldl -lnl-3
+
+#
+# Make sure all required libs are installed
+check-build-packages:
+	$(Q) echo "int main(int argc, char *argv[]) { return 0; }" |	\
+		$(CC) -x c - $(LIBS) -o /dev/null > /dev/null 2>&1
+
+check-packages-failed:
+	$(warning Can not find some of the required libraries)
+	$(warning Make sure the following packages are installed)
+	$(warning RPM based distros: $(REQ-RPM-PKG-NAMES))
+	$(warning DEB based distros: $(REQ-DEB-PKG-NAMES))
+	$(warning To run tests the following packages are needed)
+	$(warning RPM based distros: $(REQ-RPM-PKG-TEST-NAMES))
+	$(warning DEB based distros: $(REQ-DEB-PKG-TEST-NAMES))
+	$(error Compilation aborted)
+
+check-packages:
+	$(Q) $(MAKE) check-build-packages || $(MAKE) check-packages-failed
+.PHONY: check-build-packages check-packages-failed check-packages
-- 
2.9.0



More information about the CRIU mailing list