Patchwork [V20,05/10] libqblock: build: add packaging support

login
register
mail settings
Submitter Wayne Xia
Date Feb. 27, 2013, 3:10 a.m.
Message ID <1361934618-32026-6-git-send-email-xiawenc@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/223494/
State New
Headers show

Comments

Wayne Xia - Feb. 27, 2013, 3:10 a.m.
Now libqblock can be packaged and installed by
"sudo make install-libqblock'.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 libqblock/Makefile          |   34 +++++++++++++++++++++++++++++-----
 libqblock/libqblock.pc.in   |   13 +++++++++++++
 2 files changed, 42 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

Patch

diff --git a/libqblock/Makefile b/libqblock/Makefile
index 4965dd6..75d9d18 100644
--- a/libqblock/Makefile
+++ b/libqblock/Makefile
@@ -1,4 +1,4 @@ 
-all: libqblock.la
+libqblock_includedir= $(includedir)/qblock
 
 # objects linked into a shared library, built with libtool with -fPIC if required
 libqblock-obj-y = libqblock/libqblock.o libqblock/libqblock-error.o
@@ -8,10 +8,18 @@  libqblock-obj-y += $(util-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-$(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)
 
-all: libqblock.la
+all: libqblock.la libqblock.pc
 
 #########################################################################
 # Rules for building libqblock standalone library
@@ -21,10 +29,26 @@  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 -rf $(libqblock-lobj-y) libqblock.la libqblock/.libs
+	rm -rf $(libqblock-lobj-y) libqblock.la libqblock.pc libqblock/.libs
 
 clean: libqblock-clean
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}