[CRIU] [PATCH 6/8] build: Move C and Python libraries into lib

Cyrill Gorcunov gorcunov at openvz.org
Fri Feb 5 01:01:18 PST 2016


Both CRIU library and CRIT python data are moved into
lib/c and lib/py.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 Makefile                              | 18 +++++++------
 lib/Makefile                          | 48 +++++++++++++++++++++++++++--------
 lib/c/Makefile                        | 13 ++++++++++
 lib/{ => c}/criu.c                    |  0
 lib/{ => c}/criu.h                    |  0
 lib/{ => c}/criu.pc.in                |  0
 {pycriu => lib/py}/.gitignore         |  0
 {pycriu => lib/py}/Makefile           |  0
 {pycriu => lib/py}/__init__.py        |  0
 {pycriu => lib/py}/criu.py            |  0
 {pycriu => lib/py}/images/.gitignore  |  0
 {pycriu => lib/py}/images/Makefile    |  0
 {pycriu => lib/py}/images/__init__.py |  0
 {pycriu => lib/py}/images/images.py   |  0
 {pycriu => lib/py}/images/pb2dict.py  |  0
 15 files changed, 61 insertions(+), 18 deletions(-)
 create mode 100644 lib/c/Makefile
 rename lib/{ => c}/criu.c (100%)
 rename lib/{ => c}/criu.h (100%)
 rename lib/{ => c}/criu.pc.in (100%)
 rename {pycriu => lib/py}/.gitignore (100%)
 rename {pycriu => lib/py}/Makefile (100%)
 rename {pycriu => lib/py}/__init__.py (100%)
 rename {pycriu => lib/py}/criu.py (100%)
 rename {pycriu => lib/py}/images/.gitignore (100%)
 rename {pycriu => lib/py}/images/Makefile (100%)
 rename {pycriu => lib/py}/images/__init__.py (100%)
 rename {pycriu => lib/py}/images/images.py (100%)
 rename {pycriu => lib/py}/images/pb2dict.py (100%)

diff --git a/Makefile b/Makefile
index 5dc2c473da02..d55c4bd47905 100644
--- a/Makefile
+++ b/Makefile
@@ -163,7 +163,7 @@ CFLAGS		+= $(WARNINGS) $(DEFINES)
 SYSCALL-LIB	:= $(ARCH_DIR)/syscalls.built-in.o
 ARCH-LIB	:= $(ARCH_DIR)/crtools.built-in.o
 CRIU-SO		:= libcriu
-CRIU-LIB	:= lib/$(CRIU-SO).so
+CRIU-LIB	:= lib/c/$(CRIU-SO).so
 CRIU-INC	:= lib/criu.h include/criu-plugin.h include/criu-log.h protobuf/rpc.proto
 ifeq ($(piegen-y),y)
 piegen		:= pie/piegen/piegen
@@ -226,9 +226,15 @@ built-in.o: $(VERSION_HEADER) pie
 	$(Q) $(MAKE) $(build-old-crtools)=. $@
 
 lib/%:: $(VERSION_HEADER) config built-in.o
-	$(Q) $(MAKE) $(build-old)=lib $@
+	$(Q) $(MAKE) -C lib $@
 lib: $(VERSION_HEADER) config built-in.o
-	$(Q) $(MAKE) $(build-old)=lib all
+	$(Q) $(MAKE) -C lib all
+
+$(CRIU-LIB): lib
+	@true
+crit: lib
+	@true
+
 
 PROGRAM-BUILTINS	+= protobuf/built-in.o
 PROGRAM-BUILTINS	+= built-in.o
@@ -239,9 +245,6 @@ $(PROGRAM): $(SYSCALL-LIB) $(ARCH-LIB) $(PROGRAM-BUILTINS)
 	$(E) "  LINK    " $@
 	$(Q) $(CC) $(CFLAGS) $^ $(LIBS) $(LDFLAGS) $(GMONLDOPT) -rdynamic -o $@
 
-crit:
-	$(Q) $(MAKE) -C pycriu all
-
 zdtm: all
 	$(Q) $(MAKE) -C test/zdtm all
 
@@ -254,7 +257,7 @@ clean-built:
 	$(Q) $(MAKE) $(build-old)=protobuf clean
 	$(Q) $(MAKE) $(build-old)=pie/piegen clean
 	$(Q) $(MAKE) $(build-old)=pie clean
-	$(Q) $(MAKE) $(build-old)=lib clean
+	$(Q) $(MAKE) -C lib clean
 	$(Q) $(MAKE) $(build-old-crtools)=. clean
 	$(Q) $(MAKE) -C Documentation clean
 	$(Q) $(RM) ./include/config.h
@@ -273,7 +276,6 @@ clean: clean-built
 	$(Q) $(RM) -r ./gcov
 	$(Q) $(RM) protobuf-desc-gen.h
 	$(Q) $(MAKE) -C test $@
-	$(Q) $(MAKE) -C pycriu $@
 	$(Q) $(RM) ./*.pyc
 	$(Q) $(RM) -r build
 	$(Q) $(RM) -r usr
diff --git a/lib/Makefile b/lib/Makefile
index a9a661ff6afd..f07e07b9051e 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,14 +1,42 @@
-lib-so			+= $(CRIU-SO)
-obj-y			+= criu.o
-obj-ext-src-y		+= protobuf/rpc.pb-c.o
+include $(__nmk_dir)/include.mk
+include $(__nmk_dir)/macro.mk
 
-includes		+= -iquote $(obj)/../$(ARCH_DIR)/include -iquote $(obj)/../include -iquote $(obj)/.. -iquote $(obj)/../protobuf
-cflags-y		+= $(includes) -fPIC -Wa,--noexecstack -fno-stack-protector
-cflags-so		+= $(CFLAGS) -rdynamic -Wl,-soname,$(lib-so).so.$(VERSION_SO_MAJOR)
+VERSION_SO_MAJOR	:= 1
+VERSION_SO_MINOR	:= 0
+
+CRIU_SO			:= libcriu.so
+
+#
+# C language bindings.
+c/%:
+	$(call msg-gen, $@)
+	$(Q) $(MAKE) $(build)=c $@
+c/built-in.o:
+	$(call msg-gen, $@)
+	$(Q) $(MAKE) $(build)=c all
+
+ccflags-so		+= $(CFLAGS) -rdynamic -Wl,-soname,$(lib-so).so.$(VERSION_SO_MAJOR)
 ldflags-so		+= -lprotobuf-c
+c/$(CRIU_SO): c/built-in.o
+	$(call msg-link, $@)
+	$(Q) $(CC) -shared $(ccflags-so) -o $@ $^ $(ldflags-so) $(LDFLAGS)
+lib-c: c/$(CRIU_SO)
+PHONY += lib-c
+
+#
+# Python bindings.
+lib-py:
+	$(call msg-gen, $@)
+	$(Q) $(MAKE) -C py/images all
+PHONY += lib-py
 
-.SECONDARY:
+clean:
+	$(call msg-clean, lib-c)
+	$(Q) $(MAKE) $(build)=c $@
+	$(Q) $(RM) c/$(CRIU_SO)
+	$(call msg-clean, lib-py)
+	$(Q) $(MAKE) -C py/images $@
 
-ifneq ($(MAKECMDGOALS),clean)
-incdeps := y
-endif
+all: $(PHONY)
+	@true
+PHONY += all
diff --git a/lib/c/Makefile b/lib/c/Makefile
new file mode 100644
index 000000000000..16b4ef194004
--- /dev/null
+++ b/lib/c/Makefile
@@ -0,0 +1,13 @@
+obj-y			+= criu.o
+obj-y			+= $(SRC_DIR)/images/rpc.pb-c.o
+
+ccflags-y		+= -iquote $(SRC_DIR)/crtools/$(ARCH_DIR)/include
+ccflags-y		+= -iquote $(SRC_DIR)/crtools/include -iquote $(obj)/..
+ccflags-y		+= -iquote $(SRC_DIR)/images
+ccflags-y		+= -fPIC -Wa,--noexecstack -fno-stack-protector
+
+#
+# Remove once criu moved into proper place.
+ccflags-y		+= -iquote $(SRC_DIR)/$(ARCH_DIR)/include
+ccflags-y		+= -iquote $(SRC_DIR)/include -iquote $(obj)/..
+ccflags-y		+= -iquote $(SRC_DIR)/images
diff --git a/lib/criu.c b/lib/c/criu.c
similarity index 100%
rename from lib/criu.c
rename to lib/c/criu.c
diff --git a/lib/criu.h b/lib/c/criu.h
similarity index 100%
rename from lib/criu.h
rename to lib/c/criu.h
diff --git a/lib/criu.pc.in b/lib/c/criu.pc.in
similarity index 100%
rename from lib/criu.pc.in
rename to lib/c/criu.pc.in
diff --git a/pycriu/.gitignore b/lib/py/.gitignore
similarity index 100%
rename from pycriu/.gitignore
rename to lib/py/.gitignore
diff --git a/pycriu/Makefile b/lib/py/Makefile
similarity index 100%
rename from pycriu/Makefile
rename to lib/py/Makefile
diff --git a/pycriu/__init__.py b/lib/py/__init__.py
similarity index 100%
rename from pycriu/__init__.py
rename to lib/py/__init__.py
diff --git a/pycriu/criu.py b/lib/py/criu.py
similarity index 100%
rename from pycriu/criu.py
rename to lib/py/criu.py
diff --git a/pycriu/images/.gitignore b/lib/py/images/.gitignore
similarity index 100%
rename from pycriu/images/.gitignore
rename to lib/py/images/.gitignore
diff --git a/pycriu/images/Makefile b/lib/py/images/Makefile
similarity index 100%
rename from pycriu/images/Makefile
rename to lib/py/images/Makefile
diff --git a/pycriu/images/__init__.py b/lib/py/images/__init__.py
similarity index 100%
rename from pycriu/images/__init__.py
rename to lib/py/images/__init__.py
diff --git a/pycriu/images/images.py b/lib/py/images/images.py
similarity index 100%
rename from pycriu/images/images.py
rename to lib/py/images/images.py
diff --git a/pycriu/images/pb2dict.py b/lib/py/images/pb2dict.py
similarity index 100%
rename from pycriu/images/pb2dict.py
rename to lib/py/images/pb2dict.py
-- 
2.5.0



More information about the CRIU mailing list