Now libqblock can be packaged and installed by
"sudo make install-libqblock'.

Signed-off-by: Wenchao Xia <xiaw...@linux.vnet.ibm.com>
---
 libqblock/Makefile          |   37 ++++++++++++++++++++++++++++++++-----
 libqblock/libqblock.pc.in   |   13 +++++++++++++
 2 files changed, 45 insertions(+), 5 deletions(-)
 create mode 100644 libqblock/libqblock-error.h
 create mode 100644 libqblock/libqblock-types.h
 create mode 100644 libqblock/libqblock.h
 create mode 100644 libqblock/libqblock.pc.in

diff --git a/libqblock/Makefile b/libqblock/Makefile
index cdbfffb..b1c9897 100644
--- a/libqblock/Makefile
+++ b/libqblock/Makefile
@@ -1,4 +1,6 @@
-TOOLS += libqblock.la
+libqblock_includedir= $(includedir)/qblock
+
+TOOLS += libqblock.la libqblock.pc
 
 # objects linked into a shared library, built with libtool with -fPIC if 
required
 libqblock-obj-y = $(libqblock-y) $(util-obj-y)
@@ -7,13 +9,22 @@ libqblock-obj-y += $(block-obj-y)
 
 libqblock-lobj-y=$(patsubst %.o, %.lo, $(libqblock-obj-y))
 
+libqblock-pub-headers= $(SRC_PATH)/libqblock/libqblock.h \
+                       $(SRC_PATH)/libqblock/libqblock-types.h \
+                       $(SRC_PATH)/libqblock/libqblock-error.h
+
+libqblock-requires-y = rt gthread-2.0 glib-2.0 z
+libqblock-requires-$(CONFIG_CURL) += curl
+libqblock-requires-$(CONFIG_LIBCAP) += cap-ng
+libqblock-requires-$(CONFIG_UUID) += uuid
+
 # libtool will build the .o files, too
 $(libqblock-obj-y): | $(libqblock-lobj-y)
 
-LIBQBLOCK_CLEAN_TARGETS=$(libqblock-lobj-y) libqblock.la libqblock/.libs
+LIBQBLOCK_CLEAN_TARGETS=$(libqblock-lobj-y) libqblock.la libqblock.pc 
libqblock/.libs
 SUBDIR_CLEAN_RULES+=libqblock-clean
 
-all: libqblock.la
+all: libqblock.la libqblock.pc
 
 #########################################################################
 # Rules for building libqblock standalone library
@@ -24,8 +35,24 @@ libqblock.la: LDFLAGS += -rpath $(libdir) -no-undefined \
 libqblock.la: $(libqblock-lobj-y)
        $(call LINK,$^)
 
-
-.PHONY: libqblock-clean
+libqblock.pc: $(SRC_PATH)/libqblock/libqblock.pc.in
+       $(call quiet-command,sed -e 's|@LIBDIR@|$(libdir)|' \
+               -e 's|@INCLUDEDIR@|$(libqblock_includedir)|' \
+           -e 's|@VERSION@|$(shell cat $(SRC_PATH)/VERSION)|' \
+               -e 's|@PREFIX@|$(prefix)|' \
+               -e 's|@REQUIRES@|$(libqblock-requires-y)|' \
+               $< > libqblock.pc,\
+       "  GEN   $@")
+
+.PHONY: libqblock-clean install-libqblock
+
+install-libqblock: libqblock.la libqblock.pc
+       $(INSTALL_DIR) "$(DESTDIR)$(libdir)"
+       $(INSTALL_DIR) "$(DESTDIR)$(libdir)/pkgconfig"
+       $(INSTALL_DIR) "$(DESTDIR)$(libqblock_includedir)"
+       $(INSTALL_LIB) libqblock.la "$(DESTDIR)$(libdir)"
+       $(INSTALL_DATA) libqblock.pc "$(DESTDIR)$(libdir)/pkgconfig"
+       $(INSTALL_DATA) $(libqblock-pub-headers) 
"$(DESTDIR)$(libqblock_includedir)"
 
 libqblock-clean:
        rm $(LIBQBLOCK_CLEAN_TARGETS) -rf
diff --git a/libqblock/libqblock-error.h b/libqblock/libqblock-error.h
new file mode 100644
index 0000000..e69de29
diff --git a/libqblock/libqblock-types.h b/libqblock/libqblock-types.h
new file mode 100644
index 0000000..e69de29
diff --git a/libqblock/libqblock.h b/libqblock/libqblock.h
new file mode 100644
index 0000000..e69de29
diff --git a/libqblock/libqblock.pc.in b/libqblock/libqblock.pc.in
new file mode 100644
index 0000000..0901672
--- /dev/null
+++ b/libqblock/libqblock.pc.in
@@ -0,0 +1,13 @@
+prefix=@PREFIX@
+exec_prefix=${prefix}
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: qblock
+Description: Qemu block layer library
+Version: @VERSION@
+
+Requires: @REQUIRES@
+Libs: -L${libdir} -lqblock
+Libs.private:
+Cflags: -I${includedir}
-- 
1.7.1



Reply via email to