[CRIU] [PATCH]v1 criu: Initial skeleton for criu library

Kупреев Руслан kupruser at gmail.com
Wed Jul 17 13:51:53 EDT 2013


Hello all!

I make an initial skeleton for CRIU library. It will be used to add 
different useful functionality.


-------------- next part --------------
commit f55694e821e76873cf87a00e4855910beeffd293
Author: Ruslan Kupreev <kupruser at gmail.com>
Date:   Wed Jul 17 20:34:31 2013 +0300

    Add an initian skeleton for criu library.

diff --git a/Makefile b/Makefile
index aabfded..0c073f0 100644
--- a/Makefile
+++ b/Makefile
@@ -101,6 +101,7 @@ endif
 CFLAGS		+= $(WARNINGS) $(DEFINES)
 SYSCALL-LIB	:= arch/$(ARCH)/syscalls.built-in.o
 ARCH-LIB	:= arch/$(ARCH)/crtools.built-in.o
+CRIU-LIB	:= lib/libcriu.so
 
 export CC MAKE CFLAGS LIBS ARCH DEFINES MAKEFLAGS
 export SRC_DIR SYSCALL-LIB SH RM ARCH_DIR OBJCOPY LDARCH LD
@@ -119,15 +120,18 @@ build-crtools := -r -R -f scripts/Makefile.build makefile=Makefile.crtools obj
 PROGRAM		:= criu
 
 .PHONY: all zdtm test rebuild clean distclean tags cscope	\
-	docs help pie protobuf arch/$(ARCH) clean-built
+	docs help pie protobuf arch/$(ARCH) clean-built lib
 
 ifeq ($(GCOV),1)
 %.o $(PROGRAM): override CFLAGS += --coverage
 endif
 
-all: config pie $(VERSION_HEADER)
+all: config pie $(VERSION_HEADER) lib
 	$(Q) $(MAKE) $(PROGRAM)
 
+lib:
+	$(Q) $(MAKE) -C lib all
+
 protobuf/%::
 	$(Q) $(MAKE) $(build)=protobuf $@
 protobuf:
@@ -156,9 +160,9 @@ $(ARCH_DIR)/vdso-pie.o: pie
 	$(Q) $(MAKE) $(build)=pie $(ARCH_DIR)/vdso-pie.o
 PROGRAM-BUILTINS	+= $(ARCH_DIR)/vdso-pie.o
 
-$(PROGRAM): $(SYSCALL-LIB) $(ARCH-LIB) $(PROGRAM-BUILTINS)
+$(PROGRAM): $(SYSCALL-LIB) $(ARCH-LIB) $(PROGRAM-BUILTINS) $(CRIU-LIB)
 	$(E) "  LINK    " $@
-	$(Q) $(CC) $(CFLAGS) $^ $(LIBS) $(LDFLAGS) -o $@
+	$(Q) $(CC) $(CFLAGS) $^ $(LIBS) $(LDFLAGS) -L. lib/libcriu.so -o $@
 
 zdtm: all
 	$(Q) $(MAKE) -C test/zdtm all
@@ -175,6 +179,7 @@ clean-built:
 	$(Q) $(MAKE) -C Documentation clean
 	$(Q) $(RM) ./include/config.h
 	$(Q) $(RM) ./$(PROGRAM)
+	$(Q) $(MAKE) -C lib clean
 
 rebuild: clean-built
 	$(E) "  FORCE-REBUILD"
diff --git a/lib/Makefile b/lib/Makefile
new file mode 100644
index 0000000..629962e
--- /dev/null
+++ b/lib/Makefile
@@ -0,0 +1,12 @@
+.PHONY: all clean
+
+all: libcriu.so
+
+libcriu.so: criu.o
+	$(Q) $(CC) $(CFLAGS) -shared -o $@ criu.o
+
+criu.o: 
+	$(Q) $(CC) $(CFLAGS) -fPIC -c criu.c ../include/version.h
+clean:
+	$(Q) $(RM) -f *.o
+	$(Q) $(RM) -f *.so
diff --git a/lib/criu.c b/lib/criu.c
new file mode 100644
index 0000000..e613c91
--- /dev/null
+++ b/lib/criu.c
@@ -0,0 +1,3 @@
+#include "../include/version.h"
+/*TMPversion is temporary used to avoid -Werror=unused-variable*/
+const char* TMPversion = version;


More information about the CRIU mailing list