From eed6ffb235f6889b9490aabe8b2f166e3aaad094 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Wed, 12 Aug 2009 15:35:30 +0200 Subject: [PATCH] [build] Using templates for glib-mkenums Added adg-type-builtins.[ch].template and generating adg-type-builtins.[ch] from them instead of hardcoding the code inside adg/Makefile.am. Also, improved Makefile.am to work under a VPATH build. --- adg/Makefile.am | 61 ++++++++++++++++++---------------------- adg/adg-type-builtins.c.template | 39 +++++++++++++++++++++++++ adg/adg-type-builtins.h.template | 26 +++++++++++++++++ 3 files changed, 92 insertions(+), 34 deletions(-) create mode 100644 adg/adg-type-builtins.c.template create mode 100644 adg/adg-type-builtins.h.template diff --git a/adg/Makefile.am b/adg/Makefile.am index 9d1c8275..832315b6 100644 --- a/adg/Makefile.am +++ b/adg/Makefile.am @@ -1,11 +1,12 @@ -## Process this file with automake to produce Makefile.in - AM_CFLAGS= @GTK2_CFLAGS@ \ -I$(top_srcdir) AM_LDFLAGS= @GTK2_LIBS@ +GLIB_MKENUMS= `which glib-mkenums` \ + --template $(srcdir)/$@.template \ + $(srcdir)/adg-enums.h # file groups -adg_h_sources= adg.h \ +h_sources= adg.h \ adg-adim.h \ adg-arrow-style.h \ adg-canvas.h \ @@ -33,8 +34,8 @@ adg_h_sources= adg.h \ adg-translatable.h \ adg-util.h \ adg-widget.h -adg_built_h_sources= adg-type-builtins.h -adg_private_h_sources= adg-adim-private.h \ +built_h_sources= $(builddir)/adg-type-builtins.h +private_h_sources= adg-adim-private.h \ adg-arrow-style-private.h \ adg-canvas-private.h \ adg-container-private.h \ @@ -54,8 +55,8 @@ adg_private_h_sources= adg-adim-private.h \ adg-title-block-private.h \ adg-toy-text-private.h \ adg-widget-private.h -adg_built_private_h_sources= -adg_c_sources= adg-adim.c \ +built_private_h_sources= +c_sources= adg-adim.c \ adg-arrow-style.c \ adg-canvas.c \ adg-container.c \ @@ -83,42 +84,34 @@ adg_c_sources= adg-adim.c \ adg-translatable.c \ adg-util.c \ adg-widget.c -adg_built_c_sources= adg-type-builtins.c +built_c_sources= $(builddir)/adg-type-builtins.c +EXTRA_DIST= adg-type-builtins.c.template \ + adg-type-builtins.h.template # targets -BUILT_SOURCES= $(adg_built_h_sources) \ - $(adg_built_private_h_sources) \ - $(adg_built_c_sources) +BUILT_SOURCES= $(built_h_sources) +DISTCLEANFILES= $(built_h_sources) \ + $(built_private_h_sources) \ + $(built_c_sources) libadg_includedir= $(includedir)/adg -libadg_include_DATA= $(adg_h_sources) \ - $(adg_built_h_sources) +libadg_include_DATA= $(h_sources) \ + $(built_h_sources) lib_LTLIBRARIES= libadg.la libadg_la_LDFLAGS= -release @PACKAGE_VERSION@ -libadg_la_SOURCES= $(adg_h_sources) \ - $(adg_built_h_sources) \ - $(adg_private_h_sources) \ - $(adg_built_private_h_sources) \ - $(adg_c_sources) \ - $(adg_built_c_sources) +libadg_la_SOURCES= $(h_sources) \ + $(private_h_sources) \ + $(c_sources) +nodist_libadg_la_SOURCES= $(built_h_sources) \ + $(built_private_h_sources) \ + $(built_c_sources) libadg_la_LIBADD= $(top_builddir)/cpml/libcpml.la libadg_la_DEPENDENCIES= $(top_builddir)/cpml/libcpml.la -adg-type-builtins.h: adg-enums.h Makefile - glib-mkenums \ - --fhead "#ifndef __ADG_TYPE_BUILTINS_H__\n#define __ADG_TYPE_BUILTINS_H__\n\n#include \n\nG_BEGIN_DECLS\n\n" \ - --fprod "\n/* enumerations from \"@filename@\" */\n" \ - --vhead "#define ADG_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\nGType @enum_name@_get_type(void) G_GNUC_CONST;\n\n" \ - --ftail "G_END_DECLS\n\n#endif /* __ADG_TYPE_BUILTINS_H__ */" \ - adg-enums.h > $@ +adg-type-builtins.c: adg-type-builtins.c.template adg-enums.h + $(GLIB_MKENUMS) > $@ -adg-type-builtins.c: adg-enums.h Makefile - glib-mkenums \ - --fhead "#include \"adg-enums.h\"\n\n" \ - --fprod "\n/* enumerations from \"@filename@\" */" \ - --vhead "\nGType\n@enum_name@_get_type(void)\n{\n static GType etype = 0;\n if (G_UNLIKELY(etype == 0)) {\n static const G@Type@Value values[] = {" \ - --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \ - --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static(\"@EnumName@\", values);\n }\n return etype;\n}\n" \ - adg-enums.h > $@ +adg-type-builtins.h: adg-type-builtins.h.template adg-enums.h + $(GLIB_MKENUMS) > $@ diff --git a/adg/adg-type-builtins.c.template b/adg/adg-type-builtins.c.template new file mode 100644 index 00000000..bf11f73d --- /dev/null +++ b/adg/adg-type-builtins.c.template @@ -0,0 +1,39 @@ +/** + * SECTION:adg-type-builtins + * @title: ADG enums + * @short_description: Public enums used throughout the ADG library + * + * This code is autogenerated by inspecting the ADG sources + * with glib-mkenums. + **/ + +/*** BEGIN file-header ***/ +#include "adg-enums.h" + + +/*** END file-header ***/ +/*** BEGIN file-production ***/ +/* Enumerations from "@filename@" */ +/*** END file-production ***/ +/*** BEGIN value-header ***/ +GType +@enum_name@_get_type(void) +{ + static GType etype = 0; + if (G_UNLIKELY(etype == 0)) { + static const G@Type@Value values[] = { +/*** END value-header ***/ +/*** BEGIN value-production ***/ + { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, +/*** END value-production ***/ +/*** BEGIN value-tail ***/ + { 0, NULL, NULL } + }; + + etype = g_@type@_register_static("@EnumName@", values); + } + + return etype; +} + +/*** END value-tail ***/ diff --git a/adg/adg-type-builtins.h.template b/adg/adg-type-builtins.h.template new file mode 100644 index 00000000..3a84f669 --- /dev/null +++ b/adg/adg-type-builtins.h.template @@ -0,0 +1,26 @@ +/*** BEGIN file-header ***/ +#ifndef __ADG_TYPE_BUILTINS_H__ +#define __ADG_TYPE_BUILTINS_H__ + +#include + + +G_BEGIN_DECLS + +/*** END file-header ***/ +/*** BEGIN file-production ***/ +/* Enumerations from "@filename@" */ +/*** END file-production ***/ +/*** BEGIN value-header ***/ + +#define ADG_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) + +GType @enum_name@_get_type(void) G_GNUC_CONST; + +/*** END value-header ***/ +/*** BEGIN file-tail ***/ + +G_END_DECLS + +#endif /* __ADG_TYPE_BUILTINS_H__ */ +/*** END file-tail ***/ -- 2.11.4.GIT