We don't currently have any enum in our API, but we will need some.
This commit adds the generation of libvirt-gconfig-enum-types.[ch]
using glib-mkenums. These files will register the various enums
that will get added to libvirt-gconfig header files with glib.
---
configure.ac | 4 ++
libvirt-gconfig/Makefile.am | 21 +++++++++++-
.../libvirt-gconfig-enum-types.c.template | 36 ++++++++++++++++++++
.../libvirt-gconfig-enum-types.h.template | 24 +++++++++++++
libvirt-gconfig/libvirt-gconfig.h | 1 +
5 files changed, 85 insertions(+), 1 deletions(-)
create mode 100644 libvirt-gconfig/libvirt-gconfig-enum-types.c.template
create mode 100644 libvirt-gconfig/libvirt-gconfig-enum-types.h.template
diff --git a/configure.ac b/configure.ac
index 464160c..3281baa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,10 @@ PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED)
GTK_DOC_CHECK([1.10],[--flavour no-tmpl])
+# Setup GLIB_MKENUMS to use glib-mkenums even if GLib is uninstalled.
+GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+AC_SUBST(GLIB_MKENUMS)
+
dnl Extra link-time flags for Cygwin.
dnl Copied from libxml2 configure.in, but I removed mingw changes
dnl for now since I'm not supporting mingw at present. - RWMJ
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 3fd268a..a0dec08 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -1,6 +1,9 @@
SUBDIRS = . tests
-EXTRA_DIST = libvirt-gconfig.sym
+EXTRA_DIST = \
+ libvirt-gconfig.sym \
+ libvirt-gconfig-enum-types.h.template \
+ libvirt-gconfig-enum-types.c.template
lib_LTLIBRARIES = libvirt-gconfig-1.0.la
@@ -28,6 +31,8 @@ GCONFIG_SOURCE_FILES = \
libvirt-gconfig-clock.c \
libvirt-gconfig-domain.c \
libvirt-gconfig-domain-snapshot.c \
+ libvirt-gconfig-enum-types.c \
+ libvirt-gconfig-enum-types.h \
libvirt-gconfig-helpers.c \
libvirt-gconfig-interface.c \
libvirt-gconfig-network.c \
@@ -64,6 +69,20 @@ libvirt_gconfig_1_0_la_LDFLAGS = \
-Wl,--version-script=$(srcdir)/libvirt-gconfig.sym \
-version-info $(LIBVIRT_GLIB_VERSION_INFO)
+BUILT_SOURCES = \
+ libvirt-gconfig-enum-types.c \
+ libvirt-gconfig-enum-types.h
+
+libvirt-gconfig-enum-types.h: $(GCONFIG_HEADER_FILES)
libvirt-gconfig-enum-types.h.template
+ $(AM_V_GEN) ( cd $(srcdir) \
+ && $(GLIB_MKENUMS) --template libvirt-gconfig-enum-types.h.template
$(GCONFIG_HEADER_FILES) ) >libvirt-gconfig-enum-types.h.tmp \
+ && sed -e "s/G_TYPE_VIR/GVIR_TYPE/" -e "s/g_vir/gvir/"
libvirt-gconfig-enum-types.h.tmp >libvirt-gconfig-enum-types.h
+
+libvirt-gconfig-enum-types.c: $(GCONFIG_HEADER_FILES)
libvirt-gconfig-enum-types.c.template
+ $(AM_V_GEN) ( cd $(srcdir) \
+ && $(GLIB_MKENUMS) --template libvirt-gconfig-enum-types.c.template
$(GCONFIG_HEADER_FILES) ) >libvirt-gconfig-enum-types.c.tmp \
+ && sed -e "s/G_TYPE_VIR/GVIR_TYPE/" -e "s/g_vir/gvir/"
libvirt-gconfig-enum-types.c.tmp >libvirt-gconfig-enum-types.c
+
if WITH_GOBJECT_INTROSPECTION
LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la $(G_IR_SCANNER) Makefile.am
diff --git a/libvirt-gconfig/libvirt-gconfig-enum-types.c.template
b/libvirt-gconfig/libvirt-gconfig-enum-types.c.template
new file mode 100644
index 0000000..cccea77
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-enum-types.c.template
@@ -0,0 +1,36 @@
+/*** BEGIN file-header ***/
+#include <libvirt-gconfig/libvirt-gconfig.h>
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+ static volatile gsize g_define_type_id__volatile = 0;
+
+ if (g_once_init_enter (&g_define_type_id__volatile))
+ {
+ static const G@Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+ GType g_define_type_id =
+ g_@type@_register_static (g_intern_static_string ("@EnumName@"),
values);
+ g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+ }
+
+ return g_define_type_id__volatile;
+}
+
+/*** END value-tail ***/
diff --git a/libvirt-gconfig/libvirt-gconfig-enum-types.h.template
b/libvirt-gconfig/libvirt-gconfig-enum-types.h.template
new file mode 100644
index 0000000..2cab1c5
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-enum-types.h.template
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef __LIBVIRT_GCONFIG_ENUM_TYPES_H__
+#define __LIBVIRT_GCONFIG_ENUM_TYPES_H__
+
+#include <libvirt-gconfig/libvirt-gconfig.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 7cb34b0..26ad20e 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -31,6 +31,7 @@
#include <libvirt-gconfig/libvirt-gconfig-clock.h>
#include <libvirt-gconfig/libvirt-gconfig-domain.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h>
+#include <libvirt-gconfig/libvirt-gconfig-enum-types.h>
#include <libvirt-gconfig/libvirt-gconfig-helpers.h>
#include <libvirt-gconfig/libvirt-gconfig-interface.h>
#include <libvirt-gconfig/libvirt-gconfig-network.h>
--
1.7.7