[CRIU] [PATCH] criu: make criu static library

Yicheng Qin yichengq at google.com
Wed Aug 14 19:33:53 EDT 2013


Generate criu static library 'libcriu.a'.
The public function in criu can be called by using this library.

Function is recommended to be used by now:
*	int criu_main(int argc, char *argv[]);
	It has the same logic as main function of criu binary.

Signed-off-by: Yicheng Qin <yichengq at google.com>
---
 Makefile | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 8e34770..4a98b56 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,8 @@ NM		:= $(CROSS_COMPILE)nm
 SH		:= bash
 MAKE		:= make
 OBJCOPY		:= $(CROSS_COMPILE)objcopy
+AR		:= $(CROSS_COMPILE)ar
+CP		:= cp
 
 #
 # Fetch ARCH from the uname if not yet set
@@ -102,6 +104,7 @@ CFLAGS		+= $(WARNINGS) $(DEFINES)
 SYSCALL-LIB	:= arch/$(ARCH)/syscalls.built-in.o
 ARCH-LIB	:= arch/$(ARCH)/crtools.built-in.o
 CRIU-LIB	:= lib/libcriu.so
+CRIU-STATIC-LIB	:= libcriu.a
 
 export CC MAKE CFLAGS LIBS ARCH DEFINES MAKEFLAGS
 export SRC_DIR SYSCALL-LIB SH RM ARCH_DIR OBJCOPY LDARCH LD
@@ -127,7 +130,7 @@ ifeq ($(GCOV),1)
 endif
 
 all: config pie $(VERSION_HEADER) lib
-	$(Q) $(MAKE) $(PROGRAM)
+	$(Q) $(MAKE) $(PROGRAM) $(CRIU-STATIC-LIB)
 
 lib: $(VERSION_HEADER)
 	$(Q) $(MAKE) -C lib all
@@ -171,6 +174,14 @@ $(PROGRAM): $(SYSCALL-LIB) $(ARCH-LIB) $(PROGRAM-BUILTINS) $(MAIN-BUILTINS)
 	$(E) "  LINK    " $@
 	$(Q) $(CC) $(CFLAGS) $^ $(LIBS) $(LDFLAGS) -o $@
 
+libcriu.o: $(SYSCALL-LIB) $(ARCH-LIB) $(PROGRAM-BUILTINS)
+	$(E) "  LINK    " $@
+	$(Q) $(LD) $(LDFLAGS) -r $^ -o $@
+
+$(CRIU-STATIC-LIB): libcriu.o
+	$(E) "  GEN    " $@
+	$(Q) $(AR) crs $@ $^
+
 zdtm: all
 	$(Q) $(MAKE) -C test/zdtm all
 
-- 
1.8.3



More information about the CRIU mailing list