Patchwork [01/21] qom: add make infrastructure

login
register
mail settings
Submitter Anthony Liguori
Date July 25, 2011, 1:44 a.m.
Message ID <1311558293-5855-2-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/106593/
State New
Headers show

Comments

Anthony Liguori - July 25, 2011, 1:44 a.m.
QOM provides a unified model for separating modules into independently buildable
components.  To fully take advantage of this, we need a bit more make
infrastructure that lets us describe these modules and their dependencies.
Ultimately this will enable us to support tristate modules that can be demand
loaded as shared libraries.

For now, only support boolean modules and don't do any dependency resolution.  I
expect that we'll figure out how to borrow the kernel's Kconfig processing
scripts to make this all work.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 Makefile.objs        |    3 +++
 Makefile.qom         |    9 +++++++++
 Qconfig              |    1 +
 scripts/genconfig.sh |   30 ++++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100644 Makefile.qom
 create mode 100644 Qconfig
 create mode 100755 scripts/genconfig.sh

Patch

diff --git a/Makefile.objs b/Makefile.objs
index 6991a9f..9cc87fd 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -158,6 +158,9 @@  common-obj-$(CONFIG_SLIRP) += $(addprefix slirp/, $(slirp-obj-y))
 common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o
 common-obj-$(CONFIG_XEN_BACKEND) += xen_console.o xenfb.o xen_disk.o xen_nic.o
 
+# QEMU Object Model
+include $(SRC_PATH)/Makefile.qom
+
 ######################################################################
 # libuser
 
diff --git a/Makefile.qom b/Makefile.qom
new file mode 100644
index 0000000..8b14952
--- /dev/null
+++ b/Makefile.qom
@@ -0,0 +1,9 @@ 
+QEMU_CFLAGS += -I$(SRC_PATH)/include
+
+QCONFIGS = $(shell find $(SRC_PATH) -name "Qconfig" -print)
+
+config-qom.mak: $(SRC_PATH)/Qconfig $(QCONFIGS)
+	$(SRC_PATH)/scripts/genconfig.sh $< > $@
+
+-include config-qom.mak
+
diff --git a/Qconfig b/Qconfig
new file mode 100644
index 0000000..62b15d7
--- /dev/null
+++ b/Qconfig
@@ -0,0 +1 @@ 
+# Do nothing for now
diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh
new file mode 100755
index 0000000..14fef23
--- /dev/null
+++ b/scripts/genconfig.sh
@@ -0,0 +1,30 @@ 
+#!/bin/sh
+#
+# Simple Qconfig parser
+#
+# Copyright IBM, Corp. 2011
+#
+# Authors:
+#  Anthony Liguori   <aliguori@us.ibm.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+#
+
+# This is just intended as a placeholder.  Please do not enhance this script.
+# Instead, please try to port the Linux kernel's Kconfig parser.
+
+process() {
+    local basedir=`dirname $1`
+    cat "$1" | while read LINE; do
+	local first_word=`echo $LINE | cut -f1 -d' '`
+	if test "$first_word" = "config"; then
+	    echo $LINE | sed -e 's:^config \(.*\):CONFIG_\1=y:g'
+	elif test "$first_word" = "source"; then
+	    local rest=`echo $LINE | cut -f2- -d' '`
+	    process "$basedir/$rest"
+	fi
+    done
+}
+
+process "$1"