[easytag/wip/gsettings: 20/29] Generate enum descriptions with glib-mkenums



commit 9dd303233c5207e9ddb7a25c331c224d648a3024
Author: David King <amigadave amigadave com>
Date:   Sun Mar 24 19:49:29 2013 +0000

    Generate enum descriptions with glib-mkenums

 .gitignore   |    2 ++
 Makefile.am  |   43 ++++++++++++++++++++++++++++++++++++++++---
 configure.ac |    7 +++++++
 3 files changed, 49 insertions(+), 3 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 728785b..b4d3733 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,4 +38,6 @@ src/libapetag/libapetag.a
 src/libmpg123/.deps/
 src/libmpg123/libmpg123.a
 /src/win32/.deps/
+/src/enums.c
+/src/enums.h
 stamp-h1
diff --git a/Makefile.am b/Makefile.am
index 43c4c44..c9aeddb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,6 +54,7 @@ easytag_SOURCES = \
        src/crc32.c \
        src/dlm.c \
        src/easytag.c \
+       src/enums.c \
        src/et_core.c \
        src/flac_header.c \
        src/flac_tag.c \
@@ -127,6 +128,44 @@ easytag_LDADD = \
        $(EASYTAG_LIBS) \
        $(ID3LIB_LIBS)
 
+BUILT_SOURCES = \
+       src/enums.h
+
+enum_data = \
+       src/enums.c \
+       src/enums.h
+
+easytag_enum_headers = \
+       $(srcdir)/src/setting.h
+
+src/enums.c: $(easytag_enum_headers) src/enums.h Makefile
+       $(AM_V_GEN)$(GLIB_MKENUMS) \
+               --fhead "#include \"enums.h\"\n\n" \
+               --fprod "/* enumerations from \"@filename \" */\n" \
+               --fprod "#include \"@filename \"\n" \
+               --vhead "GType\n enum_name@_get_type (void)\n{\n" \
+               --vhead "    static GType type = 0;\n\n" \
+               --vhead "    if (!type)\n    {\n" \
+               --vhead "        static const G Type@Value _ enum_name@_values[] = {" \
+               --vprod "            { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+               --vtail "            { 0, NULL, NULL }\n        };\n\n" \
+               --vtail "        type = g_ type@_register_static (\"@EnumName \", _ enum_name@_values);\n    
}\n\n" \
+               --vtail "  return type;\n}\n\n" \
+               $(easytag_enum_headers) > $@
+
+src/enums.h: $(easytag_enum_headers) Makefile
+       $(AM_V_GEN)$(GLIB_MKENUMS) \
+               --fhead "#ifndef ET_ENUMS_H_\n" \
+               --fhead "#define ET_ENUMS_H_\n\n" \
+               --fhead "#include <glib-object.h>\n\n" \
+               --fhead "G_BEGIN_DECLS\n\n" \
+               --fprod "/* enumerations from @filename@ */\n" \
+               --vhead "GType @enum_name _get_type (void);\n" \
+               --vhead "#define ET_TYPE_ ENUMSHORT@ (@enum_name _get_type())\n" \
+               --ftail "G_END_DECLS\n\n" \
+               --ftail "#endif /* ET_ENUMS_H_ */" \
+               $(easytag_enum_headers) > $@
+
 # NSIS installer script.
 # TODO: Run script from dist dir.
 easytag-win32-installer.nsi: easytag-win32-installer.nsi.in Makefile
@@ -328,13 +367,11 @@ endif
 CLEANFILES = \
        $(check_SCRIPTS) \
        $(desktop_DATA) \
+       $(enum_data) \
        $(nodist_man_MANS) \
        easytag-win32-installer.nsi
 
 DISTCLEANFILES = \
-       intltool-extract \
-       intltool-merge \
-       intltool-update \
        po/.intltool-merge-cache
 
 MAINTAINERCLEANFILES = \
diff --git a/configure.ac b/configure.ac
index e9adb21..02ecfce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,13 @@ AC_PROG_CXXCPP
 AC_PROG_SED
 PKG_PROG_PKG_CONFIG([0.24])
 
+AC_MSG_CHECKING([for glib-mkenums script])
+GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+AS_IF([test "x$GLIB_MKENUMS" = "x"],
+    [AC_MSG_ERROR([glib-mkenums not listed in glib-2.0 pkg-config file])],
+    [AC_SUBST([GLIB_MKENUMS])
+     AC_MSG_RESULT([$GLIB_MKENUMS])])
+
 dnl Man page, generated with xsltproc from DocBook XML.
 AC_ARG_ENABLE([man],
     [AS_HELP_STRING([--disable-man], [Disable building the man page])])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]