[PATCH] build: Use template files for enum types' sources generation



Source files for enum types are generated by passing segments of the
source code of the files to the `glib-mkenums` command.

This patch removes those parameters where source code is used from
meson build files by moving those segmeents to template files.
---
 clients/cli/meson.build                            |  2 +-
 clients/common/meson.build                         |  4 +-
 clients/meson.build                                |  2 +-
 clients/tui/meson.build                            |  2 +-
 clients/tui/newt/meson.build                       |  2 +-
 dispatcher/tests/meson.build                       |  2 +-
 examples/C/glib/meson.build                        |  4 +-
 libnm-core/meson.build                             | 29 ++------
 libnm-core/nm-core-enum-types.c.template           | 86 ++++++++++++++++++++++
 libnm-core/nm-core-enum-types.h.template           | 21 ++++++
 libnm-core/tests/meson.build                       | 30 +++-----
 .../tests/nm-core-tests-enum-types.c.template      | 35 +++++++++
 .../tests/nm-core-tests-enum-types.h.template      | 21 ++++++
 libnm-glib/meson.build                             | 54 ++++----------
 libnm-glib/nm-glib-enum-types.c.template           | 62 ++++++++++++++++
 libnm-glib/nm-glib-enum-types.h.template           | 21 ++++++
 libnm-glib/nm-vpn-enum-types.c.template            | 37 ++++++++++
 libnm-glib/nm-vpn-enum-types.h.template            | 21 ++++++
 libnm-glib/tests/meson.build                       |  2 +-
 libnm-util/meson.build                             | 27 ++-----
 libnm-util/nm-utils-enum-types.c.template          | 65 ++++++++++++++++
 libnm-util/nm-utils-enum-types.h.template          | 21 ++++++
 libnm-util/tests/meson.build                       |  4 +-
 libnm/meson.build                                  | 31 +++-----
 libnm/nm-enum-types.c.template                     | 76 +++++++++++++++++++
 libnm/nm-enum-types.h.template                     | 22 ++++++
 libnm/tests/meson.build                            |  2 +-
 src/meson.build                                    |  2 +-
 src/ppp/meson.build                                |  2 +-
 src/systemd/meson.build                            |  2 +-
 src/tests/meson.build                              |  2 +-
 31 files changed, 552 insertions(+), 141 deletions(-)
 create mode 100644 libnm-core/nm-core-enum-types.c.template
 create mode 100644 libnm-core/nm-core-enum-types.h.template
 create mode 100644 libnm-core/tests/nm-core-tests-enum-types.c.template
 create mode 100644 libnm-core/tests/nm-core-tests-enum-types.h.template
 create mode 100644 libnm-glib/nm-glib-enum-types.c.template
 create mode 100644 libnm-glib/nm-glib-enum-types.h.template
 create mode 100644 libnm-glib/nm-vpn-enum-types.c.template
 create mode 100644 libnm-glib/nm-vpn-enum-types.h.template
 create mode 100644 libnm-util/nm-utils-enum-types.c.template
 create mode 100644 libnm-util/nm-utils-enum-types.h.template
 create mode 100644 libnm/nm-enum-types.c.template
 create mode 100644 libnm/nm-enum-types.h.template

diff --git a/clients/cli/meson.build b/clients/cli/meson.build
index 373bf75c3..ddf7060fd 100644
--- a/clients/cli/meson.build
+++ b/clients/cli/meson.build
@@ -48,7 +48,7 @@ endif
 
 executable(
   'nmcli',
-  sources + [libnm_core_enums_h],
+  sources + [libnm_core_enum[1]],
   include_directories: incs,
   dependencies: deps,
   c_args: cflags,
diff --git a/clients/common/meson.build b/clients/common/meson.build
index f1741d2cf..d74da1db7 100644
--- a/clients/common/meson.build
+++ b/clients/common/meson.build
@@ -26,7 +26,7 @@ sources = shared_utils + files(
 
 libnmc_base = static_library(
   'nmc-base',
-  sources: sources + [libnm_core_enums_h],
+  sources: sources + [libnm_core_enum[1]],
   include_directories: incs,
   dependencies: deps,
   c_args: common_cflags
@@ -74,7 +74,7 @@ sources += settings_docs_source
 
 libnmc = static_library(
   'nmc',
-  sources: sources + [libnm_core_enums_h],
+  sources: sources + [libnm_core_enum[1]],
   include_directories: incs,
   dependencies: deps,
   c_args: common_cflags,
diff --git a/clients/meson.build b/clients/meson.build
index 6c00fc0a2..4efbaea5a 100644
--- a/clients/meson.build
+++ b/clients/meson.build
@@ -23,7 +23,7 @@ endif
 
 executable(
   name,
-  [name + '.c', libnm_core_enums_h],
+  [name + '.c', libnm_core_enum[1]],
   include_directories: incs,
   dependencies: deps,
   c_args: cflags,
diff --git a/clients/tui/meson.build b/clients/tui/meson.build
index 2ed137b26..5a125d102 100644
--- a/clients/tui/meson.build
+++ b/clients/tui/meson.build
@@ -71,7 +71,7 @@ endif
 
 executable(
   'nmtui',
-  sources + [libnm_core_enums_h],
+  sources + [libnm_core_enum[1]],
   include_directories: incs,
   dependencies: deps,
   c_args: cflags,
diff --git a/clients/tui/newt/meson.build b/clients/tui/newt/meson.build
index 2920a8f9f..ec14f1264 100644
--- a/clients/tui/newt/meson.build
+++ b/clients/tui/newt/meson.build
@@ -23,7 +23,7 @@ sources = files(
 
 libnmt_newt = static_library(
   'nmt-newt',
-  sources: sources + [libnm_core_enums_h],
+  sources: sources + [libnm_core_enum[1]],
   include_directories: incs,
   dependencies: deps,
   c_args: cflags
diff --git a/dispatcher/tests/meson.build b/dispatcher/tests/meson.build
index 6e2beb1f8..20caf61d9 100644
--- a/dispatcher/tests/meson.build
+++ b/dispatcher/tests/meson.build
@@ -11,7 +11,7 @@ cflags = '-DSRCDIR="@0@"'.format(meson.current_source_dir())
 
 exe = executable(
   test_unit,
-  [test_unit + '.c', libnm_core_enums_h],
+  [test_unit + '.c', libnm_core_enum[1]],
   include_directories: incs,
   dependencies: glib_dep,
   c_args: cflags,
diff --git a/examples/C/glib/meson.build b/examples/C/glib/meson.build
index f6412643e..c32ebdeed 100644
--- a/examples/C/glib/meson.build
+++ b/examples/C/glib/meson.build
@@ -1,7 +1,7 @@
 examples = [
-  ['add-connection-gdbus', [uuid_dep], [libnm_core_enums_h, libnm_enums_h]],
+  ['add-connection-gdbus', [uuid_dep], [libnm_core_enum[1], libnm_enum[1]]],
   ['add-connection-libnm', [libnm_dep], []],
-  ['get-active-connections-gdbus', [], [libnm_core_enums_h, libnm_enums_h]],
+  ['get-active-connections-gdbus', [], [libnm_core_enum[1], libnm_enum[1]]],
   ['get-ap-info-libnm', [libnm_dep], []],
   ['list-connections-gdbus', [], []],
   ['list-connections-libnm', [libnm_dep], []],
diff --git a/libnm-core/meson.build b/libnm-core/meson.build
index 6f8ba1769..4f0a0f7d8 100644
--- a/libnm-core/meson.build
+++ b/libnm-core/meson.build
@@ -114,32 +114,19 @@ libnm_core_sources = libnm_core_settings_sources + files(
   'nm-vpn-plugin-info.c'
 )
 
-enums_headers = libnm_core_headers + [version_header]
-enums = 'nm-core-enum-types'
+enum_headers = libnm_core_headers + [version_header]
+enum_types = 'nm-core-enum-types'
 
-libnm_core_enums_h = gnome.mkenums(
-  enums + '.h',
-  sources: enums_headers,
+libnm_core_enum = gnome.mkenums(
+  enum_types,
+  sources: enum_headers,
   identifier_prefix: nm_id_prefix,
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#ifndef __NM_CORE_ENUM_TYPES_H__\n#define 
__NM_CORE_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n',
-  vhead: 'GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ 
(@enum_name@_get_type ())\n',
-  ftail: 'G_END_DECLS\n\n#endif /* __NM_CORE_ENUM_TYPES_H__ */',
+  c_template: enum_types + '.c.template',
+  h_template: enum_types + '.h.template',
   install_header: true,
   install_dir: libnm_pkgincludedir
 )
 
-libnm_core_enums_c = gnome.mkenums(
-  enums + '.c',
-  sources: enums_headers,
-  identifier_prefix: nm_id_prefix,
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#include "config.h"\n\n#include 
"nm-core-enum-types.h"\n#include "nm-default.h"\n\n#include "nm-version-macros.h" \n#include 
"nm-connection.h" \n#include "nm-core-types.h" \n#include "nm-dbus-interface.h" \n#include "nm-errors.h" 
\n#include "nm-setting-8021x.h" \n#include "nm-setting-adsl.h" \n#include "nm-setting-bluetooth.h" \n#include 
"nm-setting-bond.h" \n#include "nm-setting-bridge-port.h" \n#include "nm-setting-bridge.h" \n#include 
"nm-setting-cdma.h" \n#include "nm-setting-connection.h" \n#include "nm-setting-dcb.h" \n#include 
"nm-setting-dummy.h" \n#include "nm-setting-generic.h" \n#include "nm-setting-gsm.h" \n#include 
"nm-setting-infiniband.h" \n#include "nm-setting-ip-config.h" \n#include "nm-setting-ip-tunnel.h" \n#include 
"nm-setting-ip4-config.h" \n#include "nm-setting-ip6-config.h" \n#include "nm-setting-macsec.h" \n#include 
"nm-setting-macvlan.h" \n#include "nm-setting-olpc-mesh.h" \n#include "nm-setti
 ng-ovs-bridge.h" \n#include "nm-setting-ovs-interface.h" \n#include "nm-setting-ovs-patch.h" \n#include 
"nm-setting-ovs-port.h" \n#include "nm-setting-ppp.h" \n#include "nm-setting-pppoe.h" \n#include 
"nm-setting-proxy.h" \n#include "nm-setting-serial.h" \n#include "nm-setting-team-port.h" \n#include 
"nm-setting-team.h" \n#include "nm-setting-tun.h" \n#include "nm-setting-user.h" \n#include 
"nm-setting-vlan.h" \n#include "nm-setting-vpn.h" \n#include "nm-setting-vxlan.h" \n#include 
"nm-setting-wimax.h" \n#include "nm-setting-wired.h" \n#include "nm-setting-wireless-security.h" \n#include 
"nm-setting-wireless.h" \n#include "nm-setting.h" \n#include "nm-simple-connection.h" \n#include "nm-utils.h" 
\n#include "nm-version.h" \n#include "nm-vpn-dbus-interface.h" \n#include "nm-vpn-editor-plugin.h" \n#include 
"nm-vpn-plugin-info.h" \n\n',
-  vhead: 'GType\n@enum_name@_get_type (void)\n{\n  static volatile gsize g_define_type_id__volatile = 0;\n\n 
 if (g_once_init_enter (&g_define_type_id__volatile))\n    {\n      static const G@Type@Value values[] = {\n',
-  vprod: '        { @VALUENAME@, "@VALUENAME@", "@valuenick@" },\n',
-  vtail: '        { 0, NULL, NULL }\n      };\n      GType g_define_type_id =\n        
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);\n      g_once_init_leave 
(&g_define_type_id__volatile, g_define_type_id);\n    }\n\n  return g_define_type_id__volatile;\n}\n'
-)
-
-libnm_core_enums = [libnm_core_enums_c, libnm_core_enums_h]
-
 incs = [
   top_inc,
   shared_inc
@@ -169,7 +156,7 @@ endif
 
 libnm_core = static_library(
   'nm-core',
-  sources: libnm_core_sources + libnm_core_enums + shared_sources + [version_header],
+  sources: libnm_core_sources + libnm_core_enum + shared_sources + [version_header],
   include_directories: incs,
   dependencies: deps,
   c_args: cflags
diff --git a/libnm-core/nm-core-enum-types.c.template b/libnm-core/nm-core-enum-types.c.template
new file mode 100644
index 000000000..9c08f5265
--- /dev/null
+++ b/libnm-core/nm-core-enum-types.c.template
@@ -0,0 +1,86 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+
+#include "nm-core-enum-types.h"
+#include "nm-default.h"
+
+#include "nm-version-macros.h"
+#include "nm-connection.h"
+#include "nm-core-types.h"
+#include "nm-dbus-interface.h"
+#include "nm-errors.h"
+#include "nm-setting-8021x.h"
+#include "nm-setting-adsl.h"
+#include "nm-setting-bluetooth.h"
+#include "nm-setting-bond.h"
+#include "nm-setting-bridge-port.h"
+#include "nm-setting-bridge.h"
+#include "nm-setting-cdma.h"
+#include "nm-setting-connection.h"
+#include "nm-setting-dcb.h"
+#include "nm-setting-dummy.h"
+#include "nm-setting-generic.h"
+#include "nm-setting-gsm.h"
+#include "nm-setting-infiniband.h"
+#include "nm-setting-ip-config.h"
+#include "nm-setting-ip-tunnel.h"
+#include "nm-setting-ip4-config.h"
+#include "nm-setting-ip6-config.h"
+#include "nm-setting-macsec.h"
+#include "nm-setting-macvlan.h"
+#include "nm-setting-olpc-mesh.h"
+#include "nm-setting-ovs-bridge.h"
+#include "nm-setting-ovs-interface.h"
+#include "nm-setting-ovs-patch.h"
+#include "nm-setting-ovs-port.h"
+#include "nm-setting-ppp.h"
+#include "nm-setting-pppoe.h"
+#include "nm-setting-proxy.h"
+#include "nm-setting-serial.h"
+#include "nm-setting-team-port.h"
+#include "nm-setting-team.h"
+#include "nm-setting-tun.h"
+#include "nm-setting-user.h"
+#include "nm-setting-vlan.h"
+#include "nm-setting-vpn.h"
+#include "nm-setting-vxlan.h"
+#include "nm-setting-wimax.h"
+#include "nm-setting-wired.h"
+#include "nm-setting-wireless-security.h"
+#include "nm-setting-wireless.h"
+#include "nm-setting.h"
+#include "nm-simple-connection.h"
+#include "nm-utils.h"
+#include "nm-version.h"
+#include "nm-vpn-dbus-interface.h"
+#include "nm-vpn-editor-plugin.h"
+#include "nm-vpn-plugin-info.h"
+/*** END file-header ***/
+
+/*** 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/libnm-core/nm-core-enum-types.h.template b/libnm-core/nm-core-enum-types.h.template
new file mode 100644
index 000000000..0f1be1e13
--- /dev/null
+++ b/libnm-core/nm-core-enum-types.h.template
@@ -0,0 +1,21 @@
+/*** BEGIN file-header ***/
+#ifndef __NM_CORE_ENUM_TYPES_H__
+#define __NM_CORE_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN enumeration-production ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __NM_CORE_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/libnm-core/tests/meson.build b/libnm-core/tests/meson.build
index 490999327..d3fab70b1 100644
--- a/libnm-core/tests/meson.build
+++ b/libnm-core/tests/meson.build
@@ -7,26 +7,14 @@
 # -name "test-pkcs12" \
 # -out test-cert.p12
 
-enums_header = files('test-general-enums.h')
-enums = 'nm-core-tests-enum-types'
-
-enums_h = gnome.mkenums(
-  enums + '.h',
-  sources: enums_header,
-  identifier_prefix: 'NM',
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#ifndef __NM_CORE_TESTS_ENUM_TYPES_H__\n#define 
__NM_CORE_TESTS_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n',
-  vhead: 'GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ 
(@enum_name@_get_type ())\n',
-  ftail: 'G_END_DECLS\n\n#endif /* __NM_CORE_TESTS_ENUM_TYPES_H__ */'
-)
-
-enums_c = gnome.mkenums(
-  enums + '.c',
-  sources: enums_header,
-  identifier_prefix: 'NM',
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#include "config.h"\n\n#include 
"nm-core-tests-enum-types.h"\n\n#include "test-general-enums.h" \n\n',
-  vhead: 'GType\n@enum_name@_get_type (void)\n{\n  static volatile gsize g_define_type_id__volatile = 0;\n\n 
 if (g_once_init_enter (&g_define_type_id__volatile))\n    {\n      static const G@Type@Value values[] = {\n',
-  vprod: '        { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-  vtail: '        { 0, NULL, NULL }\n      };\n      GType g_define_type_id =\n        
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);\n      g_once_init_leave 
(&g_define_type_id__volatile, g_define_type_id);\n    }\n\n  return g_define_type_id__volatile;\n}\n'
+enum_types = 'nm-core-tests-enum-types'
+
+enum = gnome.mkenums(
+  enum_types,
+  sources: 'test-general-enums.h',
+  identifier_prefix: nm_id_prefix,
+  c_template: enum_types + '.c.template',
+  h_template: enum_types + '.h.template'
 )
 
 test_units = [
@@ -52,7 +40,7 @@ cflags = '-DTEST_CERT_DIR="@0@"'.format(test_cert_dir)
 foreach test_unit: test_units
   exe = executable(
     'libnm-core-' + test_unit,
-    [test_unit + '.c', enums_c, enums_h],
+    [test_unit + '.c'] + enum,
     include_directories: incs,
     dependencies: glib_dep,
     c_args: cflags,
diff --git a/libnm-core/tests/nm-core-tests-enum-types.c.template 
b/libnm-core/tests/nm-core-tests-enum-types.c.template
new file mode 100644
index 000000000..1160be86d
--- /dev/null
+++ b/libnm-core/tests/nm-core-tests-enum-types.c.template
@@ -0,0 +1,35 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+
+#include "nm-core-tests-enum-types.h"
+
+#include "test-general-enums.h"
+/*** END file-header ***/
+
+/*** 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/libnm-core/tests/nm-core-tests-enum-types.h.template 
b/libnm-core/tests/nm-core-tests-enum-types.h.template
new file mode 100644
index 000000000..62e82b77a
--- /dev/null
+++ b/libnm-core/tests/nm-core-tests-enum-types.h.template
@@ -0,0 +1,21 @@
+/*** BEGIN file-header ***/
+#ifndef __NM_CORE_TESTS_ENUM_TYPES_H__
+#define __NM_CORE_TESTS_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN enumeration-production ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __NM_CORE_TESTS_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/libnm-glib/meson.build b/libnm-glib/meson.build
index 4c3e68937..c8b2d8451 100644
--- a/libnm-glib/meson.build
+++ b/libnm-glib/meson.build
@@ -92,31 +92,18 @@ sources += custom_target(
   command: [dbus_binding_tool, '--prefix=nm_vpn_plugin', '--mode=glib-server', '--output=@OUTPUT@', 
'@INPUT@']
 )
 
-enums = 'nm-vpn-enum-types'
+enum_types = 'nm-vpn-enum-types'
 
-libnm_glib_vpn_enums_h = gnome.mkenums(
-  enums + '.h',
+libnm_glib_vpn_enum = gnome.mkenums(
+  enum_types,
   sources: vpn_headers,
   identifier_prefix: nm_id_prefix,
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#ifndef __NM_VPN_ENUM_TYPES_H__\n#define 
__NM_VPN_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n',
-  vhead: 'GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ 
(@enum_name@_get_type ())\n',
-  ftail: 'G_END_DECLS\n\n#endif /* __NM_VPN_ENUM_TYPES_H__ */',
+  c_template: enum_types + '.c.template',
+  h_template: enum_types + '.h.template',
   install_header: true,
   install_dir: libnm_glib_pkgincludedir
 )
 
-libnm_glib_vpn_enums_c = gnome.mkenums(
-  enums + '.c',
-  sources: vpn_headers,
-  identifier_prefix: nm_id_prefix,
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#include "config.h"\n\n#include 
"nm-vpn-enum-types.h"\n\n#include "nm-vpn-plugin.h" \n#include "nm-vpn-plugin-ui-interface.h" \n#include 
"nm-vpn-plugin-utils.h"\n\n',
-  vhead: 'GType\n@enum_name@_get_type (void)\n{\n  static volatile gsize g_define_type_id__volatile = 0;\n\n 
 if (g_once_init_enter (&g_define_type_id__volatile))\n    {\n      static const G@Type@Value values[] = {\n',
-  vprod: '        { @VALUENAME@, "@VALUENAME@", "@valuenick@" },\n',
-  vtail: '        { 0, NULL, NULL }\n      };\n      GType g_define_type_id =\n        
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);\n      g_once_init_leave 
(&g_define_type_id__volatile, g_define_type_id);\n    }\n\n  return g_define_type_id__volatile;\n}\n'
-)
-
-libnm_glib_vpn_enums = [libnm_glib_vpn_enums_c, libnm_glib_vpn_enums_h]
-
 deps = common_deps + [libnm_util_dep]
 
 symbol_map = join_paths(meson.current_source_dir(), 'libnm-glib-vpn.ver')
@@ -128,7 +115,7 @@ endif
 
 libnm_glib_vpn = shared_library(
   'nm-glib-vpn',
-  sources: sources + libnm_glib_vpn_enums + [libnm_utils_enums_h],
+  sources: sources + libnm_glib_vpn_enum + [libnm_utils_enum[1]],
   version: libnm_glib_vpn_version,
   include_directories: common_incs,
   dependencies: deps,
@@ -198,31 +185,18 @@ nm_secret_agent_glue = custom_target(
   command: [dbus_binding_tool, '--prefix=nm_secret_agent', '--mode=glib-server', '--output=@OUTPUT@', 
'@INPUT@']
 )
 
-enums = 'nm-glib-enum-types'
+enum_types = 'nm-glib-enum-types'
 
-libnm_glib_enums_h = gnome.mkenums(
-  enums + '.h',
+libnm_glib_enum = gnome.mkenums(
+  enum_types,
   sources: headers,
   identifier_prefix: nm_id_prefix,
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#ifndef __NM_GLIB_ENUM_TYPES_H__\n#define 
__NM_GLIB_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n',
-  vhead: 'GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ 
(@enum_name@_get_type ())\n',
-  ftail: 'G_END_DECLS\n\n#endif /* __NM_GLIB_ENUM_TYPES_H__ */',
+  c_template: enum_types + '.c.template',
+  h_template: enum_types + '.h.template',
   install_header: true,
   install_dir: libnm_glib_pkgincludedir
 )
 
-libnm_glib_enums_c = gnome.mkenums(
-  enums + '.c',
-  sources: headers,
-  identifier_prefix: nm_id_prefix,
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#include "config.h"\n\n#include 
"nm-glib-enum-types.h"\n\n#include "nm-object.h" \n#include "nm-client.h" \n#include "nm-device.h" \n#include 
"nm-device-ethernet.h" \n#include "nm-device-infiniband.h" \n#include "nm-device-adsl.h" \n#include 
"nm-device-wifi.h" \n#include "nm-device-bt.h" \n#include "nm-device-olpc-mesh.h" \n#include 
"nm-device-bond.h" \n#include "nm-device-team.h" \n#include "nm-device-bridge.h" \n#include 
"nm-device-vlan.h" \n#include "nm-device-generic.h" \n#include "nm-access-point.h" \n#include 
"nm-ip4-config.h" \n#include "nm-device-modem.h" \n#include "nm-vpn-connection.h" \n#include "nm-types.h" 
\n#include "nm-active-connection.h" \n#include "nm-dhcp4-config.h" \n#include "nm-ip6-config.h" \n#include 
"nm-dhcp6-config.h" \n#include "nm-remote-connection.h" \n#include "nm-remote-settings.h" \n#include 
"nm-secret-agent.h" \n#include "nm-device-wimax.h" \n#include "nm-wimax-nsp.h"\n\n',
-  vhead: 'GType\n@enum_name@_get_type (void)\n{\n  static volatile gsize g_define_type_id__volatile = 0;\n\n 
 if (g_once_init_enter (&g_define_type_id__volatile))\n    {\n      static const G@Type@Value values[] = {\n',
-  vprod: '        { @VALUENAME@, "@VALUENAME@", "@valuenick@" },\n',
-  vtail: '        { 0, NULL, NULL }\n      };\n      GType g_define_type_id =\n        
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);\n      g_once_init_leave 
(&g_define_type_id__volatile, g_define_type_id);\n    }\n\n  return g_define_type_id__volatile;\n}\n'
-)
-
-libnm_glib_enums = [libnm_glib_enums_c, libnm_glib_enums_h]
-
 deps = common_deps + [
   libudev_dep,
   libnm_util_dep
@@ -239,7 +213,7 @@ endif
 
 libnm_glib = shared_library(
   'nm-glib',
-  sources: sources + libnm_glib_enums + [nm_secret_agent_glue, libnm_utils_enums_h],
+  sources: sources + libnm_glib_enum + [nm_secret_agent_glue, libnm_utils_enum[1]],
   version: libnm_glib_version,
   include_directories: common_incs,
   dependencies: deps,
@@ -269,7 +243,7 @@ pkg.generate(
 )
 
 if enable_introspection
-  gir_sources = sources + headers + libnm_glib_enums
+  gir_sources = sources + headers + libnm_glib_enum
 
   deps = [
     dbus_glib_dep,
@@ -308,7 +282,7 @@ deps = common_deps + [libnm_util_dep]
 
 executable(
   name,
-  [name + '.c', libnm_utils_enums_h],
+  [name + '.c', libnm_utils_enum[1]],
   include_directories: common_incs,
   dependencies: deps,
   c_args: common_cflags,
diff --git a/libnm-glib/nm-glib-enum-types.c.template b/libnm-glib/nm-glib-enum-types.c.template
new file mode 100644
index 000000000..8bd4732e0
--- /dev/null
+++ b/libnm-glib/nm-glib-enum-types.c.template
@@ -0,0 +1,62 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+
+#include "nm-glib-enum-types.h"
+
+#include "nm-object.h"
+#include "nm-client.h"
+#include "nm-device.h"
+#include "nm-device-ethernet.h"
+#include "nm-device-infiniband.h"
+#include "nm-device-adsl.h"
+#include "nm-device-wifi.h"
+#include "nm-device-bt.h"
+#include "nm-device-olpc-mesh.h"
+#include "nm-device-bond.h"
+#include "nm-device-team.h"
+#include "nm-device-bridge.h"
+#include "nm-device-vlan.h"
+#include "nm-device-generic.h"
+#include "nm-access-point.h"
+#include "nm-ip4-config.h"
+#include "nm-device-modem.h"
+#include "nm-vpn-connection.h"
+#include "nm-types.h"
+#include "nm-active-connection.h"
+#include "nm-dhcp4-config.h"
+#include "nm-ip6-config.h"
+#include "nm-dhcp6-config.h"
+#include "nm-remote-connection.h"
+#include "nm-remote-settings.h"
+#include "nm-secret-agent.h"
+#include "nm-device-wimax.h"
+#include "nm-wimax-nsp.h"
+/*** END file-header ***/
+
+/*** 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/libnm-glib/nm-glib-enum-types.h.template b/libnm-glib/nm-glib-enum-types.h.template
new file mode 100644
index 000000000..c0699560b
--- /dev/null
+++ b/libnm-glib/nm-glib-enum-types.h.template
@@ -0,0 +1,21 @@
+/*** BEGIN file-header ***/
+#ifndef __NM_GLIB_ENUM_TYPES_H__
+#define __NM_GLIB_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN enumeration-production ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __NM_GLIB_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/libnm-glib/nm-vpn-enum-types.c.template b/libnm-glib/nm-vpn-enum-types.c.template
new file mode 100644
index 000000000..8aa02ff7e
--- /dev/null
+++ b/libnm-glib/nm-vpn-enum-types.c.template
@@ -0,0 +1,37 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+
+#include "nm-vpn-enum-types.h"
+
+#include "nm-vpn-plugin.h"
+#include "nm-vpn-plugin-ui-interface.h"
+#include "nm-vpn-plugin-utils.h"
+/*** END file-header ***/
+
+/*** 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/libnm-glib/nm-vpn-enum-types.h.template b/libnm-glib/nm-vpn-enum-types.h.template
new file mode 100644
index 000000000..47fd96bea
--- /dev/null
+++ b/libnm-glib/nm-vpn-enum-types.h.template
@@ -0,0 +1,21 @@
+/*** BEGIN file-header ***/
+#ifndef __NM_VPN_ENUM_TYPES_H__
+#define __NM_VPN_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN enumeration-production ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __NM_VPN_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/libnm-glib/tests/meson.build b/libnm-glib/tests/meson.build
index 525c3b321..c655f5fd9 100644
--- a/libnm-glib/tests/meson.build
+++ b/libnm-glib/tests/meson.build
@@ -24,7 +24,7 @@ test_units = [
 foreach test_unit: test_units
   exe = executable(
     test_unit,
-    [test_unit + '.c', libnm_utils_enums_h] + shared_test_utils,
+    [test_unit + '.c', libnm_utils_enum[1]] + shared_test_utils,
     include_directories: incs,
     dependencies: deps,
     c_args: cflags
diff --git a/libnm-util/meson.build b/libnm-util/meson.build
index bca88a91e..eea36367d 100644
--- a/libnm-util/meson.build
+++ b/libnm-util/meson.build
@@ -43,31 +43,18 @@ install_headers(
   subdir: nm_name
 )
 
-enums = 'nm-utils-enum-types'
+enum_types = 'nm-utils-enum-types'
 
-libnm_utils_enums_h = gnome.mkenums(
-  enums + '.h',
+libnm_utils_enum = gnome.mkenums(
+  enum_types,
   sources: enums_headers,
   identifier_prefix: nm_id_prefix,
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#ifndef __NM_UTILS_ENUM_TYPES_H__\n#define 
__NM_UTILS_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n',
-  vhead: 'GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ 
(@enum_name@_get_type ())\n',
-  ftail: 'G_END_DECLS\n\n#endif /* __NM_UTILS_ENUM_TYPES_H__ */',
+  c_template: enum_types + '.c.template',
+  h_template: enum_types + '.h.template',
   install_header: true,
   install_dir: nm_pkgincludedir
 )
 
-libnm_utils_enums_c = gnome.mkenums(
-  enums + '.c',
-  sources: enums_headers,
-  identifier_prefix: nm_id_prefix,
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#include "config.h"\n\n#include 
"nm-utils-enum-types.h"\n\n#include "nm-version-macros.h" \n#include "nm-connection.h" \n#include 
"nm-setting.h" \n#include "nm-setting-8021x.h" \n#include "nm-setting-adsl.h" \n#include 
"nm-setting-bluetooth.h" \n#include "nm-setting-bond.h" \n#include "nm-setting-team.h" \n#include 
"nm-setting-team-port.h" \n#include "nm-setting-bridge.h" \n#include "nm-setting-bridge-port.h" \n#include 
"nm-setting-connection.h" \n#include "nm-setting-dcb.h" \n#include "nm-setting-infiniband.h" \n#include 
"nm-setting-ip4-config.h" \n#include "nm-setting-vlan.h" \n#include "nm-setting-ip6-config.h" \n#include 
"nm-setting-ppp.h" \n#include "nm-setting-pppoe.h" \n#include "nm-setting-serial.h" \n#include 
"nm-setting-generic.h" \n#include "nm-setting-gsm.h" \n#include "nm-setting-cdma.h" \n#include 
"nm-setting-olpc-mesh.h" \n#include "nm-setting-wimax.h" \n#include "nm-setting-wired.h" \n#include "nm-sett
 ing-wireless.h" \n#include "nm-setting-wireless-security.h" \n#include "nm-setting-vpn.h" \n#include 
"nm-utils.h" \n#include "nm-version.h"\n\n',
-  vhead: 'GType\n@enum_name@_get_type (void)\n{\n  static volatile gsize g_define_type_id__volatile = 0;\n\n 
 if (g_once_init_enter (&g_define_type_id__volatile))\n    {\n      static const G@Type@Value values[] = {\n',
-  vprod: '        { @VALUENAME@, "@VALUENAME@", "@valuenick@" },\n',
-  vtail: '        { 0, NULL, NULL }\n      };\n      GType g_define_type_id =\n        
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);\n      g_once_init_leave 
(&g_define_type_id__volatile, g_define_type_id);\n    }\n\n  return g_define_type_id__volatile;\n}\n'
-)
-
-libnm_utils_enums = [libnm_utils_enums_c, libnm_utils_enums_h]
-
 sources = shared_utils + files(
   'crypto.c',
   'crypto_' + crypto + '.c',
@@ -132,7 +119,7 @@ endif
 
 libnm_util = shared_library(
   'nm-util',
-  sources: sources + libnm_utils_enums,
+  sources: sources + libnm_utils_enum,
   version: libnm_util_version,
   include_directories: incs,
   dependencies: deps,
@@ -161,7 +148,7 @@ pkg.generate(
 )
 
 if enable_introspection
-  gir_sources = sources + headers + libnm_utils_enums
+  gir_sources = sources + headers + libnm_utils_enum
 
   gir_includes = [
     'DBusGLib-1.0',
diff --git a/libnm-util/nm-utils-enum-types.c.template b/libnm-util/nm-utils-enum-types.c.template
new file mode 100644
index 000000000..e6505d343
--- /dev/null
+++ b/libnm-util/nm-utils-enum-types.c.template
@@ -0,0 +1,65 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+
+#include "nm-utils-enum-types.h"
+
+#include "nm-version-macros.h"
+#include "nm-connection.h"
+#include "nm-setting.h"
+#include "nm-setting-8021x.h"
+#include "nm-setting-adsl.h"
+#include "nm-setting-bluetooth.h"
+#include "nm-setting-bond.h"
+#include "nm-setting-team.h"
+#include "nm-setting-team-port.h"
+#include "nm-setting-bridge.h"
+#include "nm-setting-bridge-port.h"
+#include "nm-setting-connection.h"
+#include "nm-setting-dcb.h"
+#include "nm-setting-infiniband.h"
+#include "nm-setting-ip4-config.h"
+#include "nm-setting-vlan.h"
+#include "nm-setting-ip6-config.h"
+#include "nm-setting-ppp.h"
+#include "nm-setting-pppoe.h"
+#include "nm-setting-serial.h"
+#include "nm-setting-generic.h"
+#include "nm-setting-gsm.h"
+#include "nm-setting-cdma.h"
+#include "nm-setting-olpc-mesh.h"
+#include "nm-setting-wimax.h"
+#include "nm-setting-wired.h"
+#include "nm-setting-wireless.h"
+#include "nm-setting-wireless-security.h"
+#include "nm-setting-vpn.h"
+#include "nm-utils.h"
+#include "nm-version.h"
+/*** END file-header ***/
+
+/*** 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/libnm-util/nm-utils-enum-types.h.template b/libnm-util/nm-utils-enum-types.h.template
new file mode 100644
index 000000000..ac0cc3c84
--- /dev/null
+++ b/libnm-util/nm-utils-enum-types.h.template
@@ -0,0 +1,21 @@
+/*** BEGIN file-header ***/
+#ifndef __NM_UTILS_ENUM_TYPES_H__
+#define __NM_UTILS_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN enumeration-production ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __NM_UTILS_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/libnm-util/tests/meson.build b/libnm-util/tests/meson.build
index 15dd3a343..cb1656a90 100644
--- a/libnm-util/tests/meson.build
+++ b/libnm-util/tests/meson.build
@@ -19,7 +19,7 @@ test = 'test-libnm-linking'
 
 test_libnm_linking = executable(
   test,
-  [test + '.c', libnm_utils_enums_h],
+  [test + '.c', libnm_utils_enum[1]],
   include_directories: incs,
   dependencies: deps + [libnm_dep],
   c_args: cflags
@@ -37,7 +37,7 @@ test_units = [
 foreach test_unit: test_units
   exe = executable(
     'libnm-util-' + test_unit[0],
-    [test_unit[0] + '.c', libnm_utils_enums_h],
+    [test_unit[0] + '.c', libnm_utils_enum[1]],
     include_directories: incs,
     dependencies: deps,
     c_args: cflags,
diff --git a/libnm/meson.build b/libnm/meson.build
index 24e0fb0bf..f286faa80 100644
--- a/libnm/meson.build
+++ b/libnm/meson.build
@@ -81,32 +81,19 @@ install_headers(
   subdir: 'libnm'
 )
 
-enums_headers = libnm_headers + [version_header]
-enums = 'nm-enum-types'
+enum_headers = libnm_headers + [version_header]
+enum_types = 'nm-enum-types'
 
-libnm_enums_h = gnome.mkenums(
-  enums + '.h',
-  sources: enums_headers,
+libnm_enum = gnome.mkenums(
+  enum_types,
+  sources: enum_headers,
   identifier_prefix: nm_id_prefix,
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#ifndef __NM_ENUM_TYPES_H__\n#define 
__NM_ENUM_TYPES_H__\n\n#include <nm-core-enum-types.h>\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n',
-  vhead: 'GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ 
(@enum_name@_get_type ())\n',
-  ftail: 'G_END_DECLS\n\n#endif /* __NM_ENUM_TYPES_H__ */',
+  c_template: enum_types + '.c.template',
+  h_template: enum_types + '.h.template',
   install_header: true,
   install_dir: libnm_pkgincludedir
 )
 
-libnm_enums_c = gnome.mkenums(
-  enums + '.c',
-  sources: enums_headers,
-  identifier_prefix: nm_id_prefix,
-  fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#include "config.h"\n\n#include 
"nm-enum-types.h"\n#include "nm-default.h"\n\n#include "nm-version-macros.h" \n#include "NetworkManager.h" 
\n#include "nm-access-point.h" \n#include "nm-active-connection.h" \n#include "nm-checkpoint.h" \n#include 
"nm-client.h" \n#include "nm-device-adsl.h" \n#include "nm-device-bond.h" \n#include "nm-device-bridge.h" 
\n#include "nm-device-bt.h" \n#include "nm-device-dummy.h" \n#include "nm-device-ethernet.h" \n#include 
"nm-device-generic.h" \n#include "nm-device-infiniband.h" \n#include "nm-device-ip-tunnel.h" \n#include 
"nm-device-macsec.h" \n#include "nm-device-macvlan.h" \n#include "nm-device-modem.h" \n#include 
"nm-device-olpc-mesh.h" \n#include "nm-device-ovs-interface.h" \n#include "nm-device-ovs-port.h" \n#include 
"nm-device-ovs-bridge.h" \n#include "nm-device-ppp.h" \n#include "nm-device-team.h" \n#include 
"nm-device-tun.h" \n#include "nm-device-vlan.h" \n#include "nm-device-vx
 lan.h" \n#include "nm-device-wifi.h" \n#include "nm-device-wimax.h" \n#include "nm-device.h" \n#include 
"nm-dhcp-config.h" \n#include "nm-ip-config.h" \n#include "nm-object.h" \n#include "nm-remote-connection.h" 
\n#include "nm-types.h" \n#include "nm-vpn-connection.h" \n#include "nm-vpn-editor.h" \n#include 
"nm-wimax-nsp.h" \n#include "nm-secret-agent-old.h" \n#include "nm-vpn-plugin-old.h" \n#include 
"nm-vpn-service-plugin.h"\n\n',
-  vhead: 'GType\n@enum_name@_get_type (void)\n{\n  static volatile gsize g_define_type_id__volatile = 0;\n\n 
 if (g_once_init_enter (&g_define_type_id__volatile))\n    {\n      static const G@Type@Value values[] = {\n',
-  vprod: '        { @VALUENAME@, "@VALUENAME@", "@valuenick@" },\n',
-  vtail: '        { 0, NULL, NULL }\n      };\n      GType g_define_type_id =\n        
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);\n      g_once_init_leave 
(&g_define_type_id__volatile, g_define_type_id);\n    }\n\n  return g_define_type_id__volatile;\n}\n'
-)
-
-libnm_enums = [libnm_enums_c, libnm_enums_h]
-
 libnm_sources = files(
   'nm-access-point.c',
   'nm-active-connection.c',
@@ -172,7 +159,7 @@ endif
 
 libnm = shared_library(
   'nm',
-  sources: libnm_sources + libnm_enums,
+  sources: libnm_sources + libnm_enum,
   version: libnm_version,
   include_directories: incs + [libnm_core_inc],
   dependencies: deps,
@@ -212,7 +199,7 @@ run_target(
 )
 
 if enable_introspection
-  gir_sources = libnm_core_enums + libnm_core_headers + libnm_core_sources + libnm_enums + libnm_headers + 
libnm_sources + [version_header]
+  gir_sources = libnm_core_enum + libnm_core_headers + libnm_core_sources + libnm_enum + libnm_headers + 
libnm_sources + [version_header]
 
   gir_dir = join_paths(nm_datadir, 'gir-' + nm_gir_version)
   typelib_dir = join_paths(nm_libdir, 'girepository-' + nm_gir_version)
diff --git a/libnm/nm-enum-types.c.template b/libnm/nm-enum-types.c.template
new file mode 100644
index 000000000..5abd5c794
--- /dev/null
+++ b/libnm/nm-enum-types.c.template
@@ -0,0 +1,76 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+
+#include "nm-enum-types.h"
+#include "nm-default.h"
+
+#include "nm-version-macros.h"
+#include "NetworkManager.h"
+#include "nm-access-point.h"
+#include "nm-active-connection.h"
+#include "nm-checkpoint.h"
+#include "nm-client.h"
+#include "nm-device-adsl.h"
+#include "nm-device-bond.h"
+#include "nm-device-bridge.h"
+#include "nm-device-bt.h"
+#include "nm-device-dummy.h"
+#include "nm-device-ethernet.h"
+#include "nm-device-generic.h"
+#include "nm-device-infiniband.h"
+#include "nm-device-ip-tunnel.h"
+#include "nm-device-macsec.h"
+#include "nm-device-macvlan.h"
+#include "nm-device-modem.h"
+#include "nm-device-olpc-mesh.h"
+#include "nm-device-ovs-interface.h"
+#include "nm-device-ovs-port.h"
+#include "nm-device-ovs-bridge.h"
+#include "nm-device-ppp.h"
+#include "nm-device-team.h"
+#include "nm-device-tun.h"
+#include "nm-device-vlan.h"
+#include "nm-device-vxlan.h"
+#include "nm-device-wifi.h"
+#include "nm-device-wimax.h"
+#include "nm-device.h"
+#include "nm-dhcp-config.h"
+#include "nm-ip-config.h"
+#include "nm-object.h"
+#include "nm-remote-connection.h"
+#include "nm-types.h"
+#include "nm-vpn-connection.h"
+#include "nm-vpn-editor.h"
+#include "nm-wimax-nsp.h"
+#include "nm-secret-agent-old.h"
+#include "nm-vpn-plugin-old.h"
+#include "nm-vpn-service-plugin.h"
+/*** END file-header ***/
+
+/*** 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/libnm/nm-enum-types.h.template b/libnm/nm-enum-types.h.template
new file mode 100644
index 000000000..bd9ce40b2
--- /dev/null
+++ b/libnm/nm-enum-types.h.template
@@ -0,0 +1,22 @@
+/*** BEGIN file-header ***/
+#ifndef __NM_ENUM_TYPES_H__
+#define __NM_ENUM_TYPES_H__
+
+#include <nm-core-enum-types.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN enumeration-production ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __NM_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/libnm/tests/meson.build b/libnm/tests/meson.build
index 57791cede..fa7470f98 100644
--- a/libnm/tests/meson.build
+++ b/libnm/tests/meson.build
@@ -45,7 +45,7 @@ incs = [
 # just test, that we can build "nm-vpn-plugin-utils.c"
 libnm_vpn_plugin_utils_test = static_library(
   'nm-vpn-plugin-utils-test',
-  sources: shared_vpn_plugin_utils + [libnm_enums_h],
+  sources: shared_vpn_plugin_utils + [libnm_enum[1]],
   include_directories: incs,
   dependencies: glib_dep
 )
diff --git a/src/meson.build b/src/meson.build
index 36bd64fc8..a87c36e62 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -20,7 +20,7 @@ core_incs = [
 ]
 
 core_dep = declare_dependency(
-  sources: libnm_core_enums_h,
+  sources: libnm_core_enum[1],
   include_directories: core_incs,
   dependencies: glib_dep,
   compile_args: core_cflags
diff --git a/src/ppp/meson.build b/src/ppp/meson.build
index 4203561bf..36f9d5eb9 100644
--- a/src/ppp/meson.build
+++ b/src/ppp/meson.build
@@ -13,7 +13,7 @@ cflags = [
 nm_pppd_plugin = shared_module(
   name,
   name_prefix: '',
-  sources: [name + '.c', libnm_core_enums_h],
+  sources: [name + '.c', libnm_core_enum[1]],
   include_directories: core_incs,
   dependencies: deps,
   c_args: cflags,
diff --git a/src/systemd/meson.build b/src/systemd/meson.build
index 3b3ba8837..02889ce24 100644
--- a/src/systemd/meson.build
+++ b/src/systemd/meson.build
@@ -69,7 +69,7 @@ cflags = '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD'
 
 libsystemd_nm = static_library(
   'systemd-nm',
-  sources: sources + [libnm_core_enums_h],
+  sources: sources + [libnm_core_enum[1]],
   include_directories: incs,
   dependencies: glib_dep,
   c_args: cflags
diff --git a/src/tests/meson.build b/src/tests/meson.build
index c30a9b8c6..6a8be5585 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -27,7 +27,7 @@ cflags = '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD'
 
 exe = executable(
   test_unit,
-  [test_unit + '.c', libnm_core_enums_h] + shared_siphash,
+  [test_unit + '.c', libnm_core_enum[1]] + shared_siphash,
   include_directories: core_incs,
   dependencies: glib_dep,
   c_args: cflags,
-- 
2.15.1




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