From 3e9c5ad75a7f703be53a7cea493e7239f958fb44 Mon Sep 17 00:00:00 2001
From: Anthony Liguori <aliguori@us.ibm.com>
Date: Mon, 5 Mar 2012 17:43:43 -0500
Subject: [PATCH 16/98] Add hard build dependency on glib

GLib is an extremely common library that has a portable thread implementation
along with tons of other goodies.

GLib and GObject have a fantastic amount of infrastructure we can leverage in
QEMU including an object oriented programming infrastructure.

Short term, it has a very nice thread pool implementation that we could leverage
in something like virtio-9p.  It also has a test harness implementation that
this series will use.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@gmail.com>
(cherry picked from commit e18df14185e817ba735bce57ecdef9a55fb3d093)

Conflicts:

	Makefile
	Makefile.objs
	Makefile.target
	configure
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 Makefile        |    2 ++
 Makefile.objs   |    1 +
 Makefile.target |    1 +
 configure       |   13 +++++++++++++
 4 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index 6daa0ee..3889af4 100644
--- a/Makefile
+++ b/Makefile
@@ -104,6 +104,8 @@ recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
 audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
 QEMU_CFLAGS+=$(CURL_CFLAGS)
 
+QEMU_CFLAGS+=$(GLIB_CFLAGS)
+
 cocoa.o: cocoa.m
 
 keymaps.o: keymaps.c keymaps.h
diff --git a/Makefile.objs b/Makefile.objs
index 4ff5ba3..b05c378 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -186,3 +186,4 @@ hw-obj-y += dma-helpers.o sysbus.o isa-bus.o
 hw-obj-$(CONFIG_QDEV_ADDR) += qdev-addr.o
 
 all: $(HWLIB)
+vl.o: QEMU_CFLAGS+=$(GLIB_CFLAGS)
diff --git a/Makefile.target b/Makefile.target
index 78af60a..906ea41 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -229,6 +229,7 @@ adlib.o fmopl.o: QEMU_CFLAGS += -DBUILD_Y8950=0
 
 QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
 QEMU_CFLAGS += $(VNC_SASL_CFLAGS)
+QEMU_CFLAGS += $(GLIB_CFLAGS)
 
 # xen backend driver support
 obj-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o
diff --git a/configure b/configure
index aba99dd..3e1cb6c 100755
--- a/configure
+++ b/configure
@@ -1485,6 +1485,18 @@ EOF
 fi
 
 ##########################################
+# glib support probe
+if $pkg_config --modversion gthread-2.0 gio-2.0 > /dev/null 2>&1 ; then
+    glib_cflags=`$pkg_config --cflags gthread-2.0 gio-2.0 2>/dev/null`
+    glib_libs=`$pkg_config --libs gthread-2.0 gio-2.0 2>/dev/null`
+    libs_softmmu="$glib_libs $libs_softmmu"
+    libs_tools="$glib_libs $libs_tools"
+else
+    echo "glib-2.0 required to compile QEMU"
+    exit 1
+fi
+
+##########################################
 # kvm probe
 if test "$kvm" != "no" ; then
     cat > $TMPC <<EOF
@@ -2451,6 +2463,7 @@ if test "$bluez" = "yes" ; then
   echo "CONFIG_BLUEZ=y" >> $config_host_mak
   echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
 fi
+echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
 if test "$xen" = "yes" ; then
   echo "CONFIG_XEN=y" >> $config_host_mak
 fi
-- 
1.7.7.6

