]> err.no Git - libchamplain/commitdiff
Build GTypes for enums
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sat, 31 Jan 2009 10:30:25 +0000 (12:30 +0200)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sat, 31 Jan 2009 10:30:25 +0000 (12:30 +0200)
champlain/Makefile.am

index 9bb55a63a06bb716f3857cd2e6db0d12261b08fe..d36a8b864dd54742e7c673b9bc25885d6a497289 100644 (file)
@@ -1,7 +1,10 @@
 
 BUILT_SOURCES = \
-       champlain-marshal.h             \
-       champlain-marshal.c
+       champlain-marshal.h \
+       champlain-marshal.c \
+       champlain-enum-types.h \
+       champlain-enum-types.c \
+       stamp-enum-types
 
 CLEANFILES = $(BUILT_SOURCES)
 
@@ -10,6 +13,17 @@ CHAMPLAIN_MARSHAL_LIST = champlain-marshal.list
 
 lib_LTLIBRARIES = libchamplain-0.3.la
 
+libchamplain_headers = \
+       champlain.h                     \
+       champlain-defines.h             \
+       champlain-view.h                \
+       champlain-layer.h               \
+       champlain-marker.h              \
+       champlain-map.h                 \
+       champlain-zoom-level.h          \
+       champlain-tile.h
+
+
 libchamplain_0_3_la_SOURCES = \
        $(CHAMPLAIN_MARSHAL_LIST)       \
        $(BUILT_SOURCES)                \
@@ -42,7 +56,8 @@ noinst_HEADERS = \
        sources/googlemap.h             \
        sources/googlesat.h             \
        sources/googleterrain.h         \
-       sources/debugmap.h
+       sources/debugmap.h              \
+       champlain-enum-types.h
 
 libchamplain_include_HEADERS = \
        champlain.h                     \
@@ -70,3 +85,42 @@ champlain-marshal.h: $(CHAMPLAIN_MARSHAL_LIST)
 
 champlain-marshal.c: $(CHAMPLAIN_MARSHAL_LIST)
        @GLIB_GENMARSHAL@ --body --prefix=cpl_marshal $< > $(CHAMPLAIN_MARSHAL).c
+
+champlain-enum-types.h: stamp-enum-types
+       @true
+
+stamp-enum-types: $(libchamplain_headers) Makefile
+       (cd $(srcdir) \
+       && glib-mkenums \
+                       --fhead "#ifndef __CHAMPLAIN_ENUM_TYPES_H__\n" \
+                       --fhead "#define __CHAMPLAIN_ENUM_TYPES_H__ 1\n\n" \
+                       --fhead "#include <glib-object.h>\n\n" \
+                       --fhead "G_BEGIN_DECLS\n\n" \
+                       --ftail "G_END_DECLS\n\n" \
+                       --ftail "#endif /* __CHAMPLAIN_ENUM_TYPES_H__ */\n" \
+                       --fprod "#include <champlain/@filename@>\n" \
+                       --eprod "#define CHAMPLAIN_TYPE_@ENUMSHORT@ @enum_name@_get_type()\n" \
+                       --eprod "GType @enum_name@_get_type (void);\n" \
+               $(libchamplain_headers) ) > xgen-gth \
+       && (cmp -s xgen-gth champlain-enum-type.h || cp xgen-gth champlain-enum-types.h) \
+       && rm -f xgen-gth \
+       && echo timestamp > $(@F)
+
+champlain-enum-types.c: $(libchamplain_headers) Makefile
+       (cd $(srcdir) \
+       && glib-mkenums \
+                       --fhead "#include <config.h>\n" \
+                       --fhead "#include <glib-object.h>\n" \
+                       --fhead "#include \"champlain-enum-types.h\"\n\n" \
+                       --fprod "\n/* enumerations from \"@filename@\" */" \
+                       --vhead "static const G@Type@Value _@enum_name@_values[] = {" \
+                       --vprod "  { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
+                       --vtail "  { 0, NULL, NULL }\n};\n\n" \
+                       --vtail "GType\n@enum_name@_get_type (void)\n{\n" \
+                       --vtail "  static GType type = 0;\n\n" \
+                       --vtail "  if (!type)\n" \
+                       --vtail "    type = g_@type@_register_static (\"@EnumName@\", _@enum_name@_values);\n\n" \
+                       --vtail "  return type;\n}\n\n" \
+               $(libchamplain_headers) ) > xgen-gtc \
+       && cp xgen-gtc $(@F) \
+       && rm -f xgen-gtc