qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@gmail.com,
	Wenchao Xia <xiawenc@linux.vnet.ibm.com>,
	blauwirbel@gmail.com, pbonzini@redhat.com, eblake@redhat.com,
	afaerber@suse.de
Subject: [Qemu-devel] [PATCH v3 5/5] [RFC] libqblock, build system
Date: Wed, 29 Aug 2012 19:05:59 +0800	[thread overview]
Message-ID: <1346238359-24653-1-git-send-email-xiawenc@linux.vnet.ibm.com> (raw)

  libqblock was placed in new directory ./libqblock, libtool will build
dynamic library there, source files of block layer remains in ./block.
So block related source code will generate 3 sets of binary, first is old
ones used in qemu, second and third are on PIC and PIC ones in ./libqblock.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 Makefile           |   23 +++++++++++++++-
 libqblock/Makefile |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+), 1 deletions(-)
 create mode 100644 libqblock/Makefile

diff --git a/Makefile b/Makefile
index 621cb86..942ec49 100644
--- a/Makefile
+++ b/Makefile
@@ -169,6 +169,27 @@ qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
 fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/virtio-9p-marshal.o oslib-posix.o $(trace-obj-y)
 fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
 
+######################################################################
+# Support building shared library libqblock
+
+.PHONY: libqblock.la
+ifeq ($(LIBTOOL),)
+libqblock.la:
+	@echo "libtool is missing, please install and rerun configure"; exit 1
+else
+libqblock.la:
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" libqblock.la,)
+libqblock-test:
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" libqblock-test,)
+libqblock-test-static:
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" libqblock-test-static,)
+endif
+
+#make native test file instead of libtool
+libqblock-test-native$(EXESUF): libqblock/libqblock.o libqblock/libqblock-test.o $(tools-obj-y) $(block-obj-y)
+	$(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^ $(LIBS),"  LINK  $@")
+
+########################################################################
 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $@")
 
@@ -227,7 +248,7 @@ clean:
 	rm -rf qapi-generated
 	rm -rf qga/qapi-generated
 	$(MAKE) -C tests/tcg clean
-	for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \
+	for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard libqblock; do \
 	if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
 	rm -f $$d/qemu-options.def; \
         done
diff --git a/libqblock/Makefile b/libqblock/Makefile
new file mode 100644
index 0000000..5b0aecb
--- /dev/null
+++ b/libqblock/Makefile
@@ -0,0 +1,74 @@
+###########################################################################
+# libqblock Makefile
+# Todo:
+#    1 trace related files is generated in this directory, move
+#  them to the root directory.
+##########################################################################
+-include ../config-host.mak
+-include $(SRC_PATH)/Makefile.objs
+-include $(SRC_PATH)/rules.mak
+
+#############################################################################
+# Library settings
+#############################################################################
+$(call set-vpath, $(SRC_PATH))
+
+#expand the foldered vars,especially ./block
+dummy := $(call unnest-vars-1)
+
+#library objects
+tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o qemu-timer.o \
+	qemu-timer-common.o main-loop.o notify.o \
+	iohandler.o cutils.o iov.o async.o
+tools-obj-$(CONFIG_POSIX) += compatfd.o
+
+libqblock-y=libqblock.o
+libqblock.lib-y=$(patsubst %.o,%.lo,$(libqblock-y))
+
+QEMU_OBJS=$(tools-obj-y) $(block-obj-y)
+QEMU_OBJS_FILTERED=$(filter %.o,$(QEMU_OBJS))
+QEMU_OBJS_LIB=$(patsubst %.o, %.lo,$(QEMU_OBJS_FILTERED))
+
+QEMU_CFLAGS+=-I../ -I../include
+
+#dependency libraries
+LIBS+=-lz $(LIBS_TOOLS)
+
+#library test case objects
+libqblock-test-objs=libqblock-test.lo
+
+
+
+#################################################################
+# Runtime rules
+#################################################################
+clean:
+	rm -f *.lo *.o *.d *.la libqblock-test trace.c trace.c-timestamp
+	rm -rf .libs block trace
+
+all: libqblock-test
+	@true
+
+help:
+	@echo type make libqblock-test at root dirtory, libtool is required
+
+ifeq ($(LIBTOOL),)
+libqblock.la:
+	@echo "libtool is missing, please install and rerun configure"; exit 1
+else
+#make dir block at runtime which would hold the output of block/*.c
+block:
+	@mkdir block
+
+libqblock.la: $(libqblock.lib-y) $(QEMU_OBJS_LIB)
+	$(call quiet-command,$(LIBTOOL) --mode=link --quiet --tag=CC $(CC) -rpath $(libdir) -o $@ $^ $(LIBS),"  lt LINK $@")
+
+libqblock-test: $(libqblock-test-objs) libqblock.la
+	$(call quiet-command,$(LIBTOOL) --mode=link --quiet --tag=CC $(CC) -shared -rpath $(libdir) -o $@ $^,"  lt LINK $@")
+
+libqblock-test-static: $(libqblock-test-objs) $(libqblock.lib-y) $(QEMU_OBJS_LIB)
+	$(call quiet-command,$(LIBTOOL) --mode=link --quiet --tag=CC $(CC) -o $@ $^ $(LIBS),"  lt LINK $@")
+
+.PHONY: libqblock.la liqblock-test
+
+endif
-- 
1.7.1

                 reply	other threads:[~2012-08-29 11:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346238359-24653-1-git-send-email-xiawenc@linux.vnet.ibm.com \
    --to=xiawenc@linux.vnet.ibm.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).