[network-manager-applet] Use Makefile.glib to build marshallers



commit 0d116154fb1e85e6a9551f48e76efdf3ac510373
Author: Dan Winship <danw gnome org>
Date:   Wed May 16 13:28:46 2012 -0400

    Use Makefile.glib to build marshallers
    
    Also copy in a local version of the GLIB_CONFIG autoconf macro, and
    use that (to get gschema stuff configured in for free too)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=662767

 .gitignore                         |    3 +-
 Makefile.am                        |    3 +-
 Makefile.glib                      |  169 ++++++++++++++++++++++++++++++++++++
 configure.ac                       |    2 +-
 m4/glib-makefile.m4                |   31 +++++++
 src/marshallers/Makefile.am        |   25 +++---
 src/marshallers/nma-marshal-main.c |    2 -
 src/marshallers/nma-marshal.list   |    9 --
 8 files changed, 217 insertions(+), 27 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 5e79879..e470b84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@ missing
 mkinstalldirs
 POTFILES
 stamp-*
+*.stamp
 .deps
 .libs
 autom4te.cache
@@ -37,7 +38,7 @@ nm-applet.schemas
 src/connection-editor/nm-connection-editor
 src/connection-editor/nm-connection-editor-service-glue.h
 src/libnm-gtk/libnm-gtk.pc
-src/marshallers/nma-marshal.[ch]
+src/marshallers/nma-marshal.*
 src/nm-applet
 src/nm-applet-migration-tool
 src/applet-dbus-bindings.h
diff --git a/Makefile.am b/Makefile.am
index 96c272b..319066d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,7 +6,8 @@ EXTRA_DIST =				\
 	CONTRIBUTING			\
 	intltool-extract.in		\
 	intltool-merge.in		\
-	intltool-update.in
+	intltool-update.in		\
+	Makefile.glib
 
 autostartdir = $(sysconfdir)/xdg/autostart
 autostart_in_files = nm-applet.desktop.in
diff --git a/Makefile.glib b/Makefile.glib
new file mode 100644
index 0000000..951ce6f
--- /dev/null
+++ b/Makefile.glib
@@ -0,0 +1,169 @@
+# -*- Mode: makefile -*-
+#
+# Work-in-progress...
+# See https://bugzilla.gnome.org/show_bug.cgi?id=654395
+
+_GLIB_CLEANFILES =
+_GLIB_DISTCLEANFILES =
+
+_GLIB_V_GEN = $(_glib_v_gen_$(V))
+_glib_v_gen_ = $(_glib_v_gen_$(AM_DEFAULT_VERBOSITY))
+_glib_v_gen_0 = @echo "  GEN   " $(subst .stamp,,$@);
+
+
+### glib-genmarshal
+
+_GLIB_MARSHAL_GENERATED = $(subst .h,,$(filter %marshal.h,$(GLIB_GENERATED)))
+
+_glib_marshal_prefix = $(subst marshal,,$(subst _marshal,,$(subst -,_,$(notdir $(1)))))_marshal
+_glib_marshal_sources_var = $(subst -,_,$(notdir $(1)))_sources
+_glib_marshal_sources = $(filter-out %.h,$(filter-out $(GLIB_GENERATED),$($(_glib_marshal_sources_var))))
+
+define _glib_make_genmarshal_rules
+$(if $(_glib_marshal_sources),,$(error Need to define $(_glib_marshal_sources_var) for $(1).[ch]))
+
+$(1).list.stamp: $(_glib_marshal_sources)
+	$$(_GLIB_V_GEN) LC_ALL=C sed -ne 's/.*_$(_glib_marshal_prefix)_\([_A-Z]*\).*/\1/p' $$^ | sort -u | sed -e 's/__/:/' -e 's/_/,/g' > $(1).list.tmp && \
+	(cmp -s $(1).list.tmp $(1).list || cp $(1).list.tmp $(1).list) && \
+	rm -f $(1).list.tmp && \
+	echo timestamp > $$@
+
+$(1).list: $(1).list.stamp
+	@true
+
+$(1).h: $(1).list
+	$$(_GLIB_V_GEN) $$(GLIB_GENMARSHAL) \
+		--prefix=_$(_glib_marshal_prefix) --header \
+		$$(GLIB_GENMARSHAL_H_FLAGS) \
+		$$($(_glib_marshal_prefix)_GENMARSHAL_H_FLAGS) \
+		$$< > $$  tmp && \
+	mv $$  tmp $$@
+
+$(1).c: $(1).list
+	$$(_GLIB_V_GEN) (echo "#include \"$$(subst .c,.h,$$(@F))\""; $$(GLIB_GENMARSHAL) \
+		--prefix=_$(_glib_marshal_prefix) --body \
+		$$(GLIB_GENMARSHAL_C_FLAGS) \
+		$$($(_glib_marshal_prefix)_GENMARSHAL_C_FLAGS) \
+		$$< ) > $$  tmp && \
+	mv $$  tmp $$@
+
+_GLIB_CLEANFILES += $(1).list.stamp $(1).list
+_GLIB_DISTCLEANFILES += $(1).h $(1).c
+endef
+
+$(foreach f,$(_GLIB_MARSHAL_GENERATED),$(eval $(call _glib_make_genmarshal_rules,$f)))
+
+
+### glib-mkenums
+
+_GLIB_ENUM_TYPES_GENERATED = $(subst .h,,$(filter %enum-types.h %enumtypes.h,$(GLIB_GENERATED)))
+
+_glib_enum_types_prefix = $(subst -,_,$(notdir $(1)))
+_glib_enum_types_guard = __$(shell LC_ALL=C echo $(_glib_enum_types_prefix) | tr 'a-z' 'A-Z')_H__
+_glib_enum_types_sources_var = $(_glib_enum_types_prefix)_sources
+_glib_enum_types_sources = $(filter-out $(GLIB_GENERATED),$($(_glib_enum_types_sources_var)))
+_glib_enum_types_h_sources = $(filter %.h,$(_glib_enum_types_sources))
+
+define _glib_make_mkenums_rules
+$(if $(_glib_enum_types_sources),,$(error Need to define $(_glib_enum_types_sources_var) for $(1).[ch]))
+
+$(1).h.stamp: $(_glib_enum_types_h_sources)
+	$$(_GLIB_V_GEN) $$(GLIB_MKENUMS) \
+		--fhead "/* Generated by glib-mkenums. Do not edit */\n\n#ifndef $(_glib_enum_types_guard)\n#define $(_glib_enum_types_guard)\n\n" \
+		$$(GLIB_MKENUMS_H_FLAGS) \
+		$$($(_glib_enum_types_prefix)_MKENUMS_H_FLAGS) \
+		--fhead "#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 /* $(_glib_enum_types_guard) */" \
+		$$^ > $(1).h.tmp && \
+	(cmp -s $(1).h.tmp $(1).h || cp $(1).h.tmp $(1).h) && \
+	rm -f $(1).h.tmp && \
+	echo timestamp > $$@
+
+$(1).h: $(1).h.stamp
+	@true
+
+$(1).c.stamp: $(_glib_enum_types_h_sources)
+	$$(_GLIB_V_GEN) $$(GLIB_MKENUMS) \
+		--fhead "/* Generated by glib-mkenums. Do not edit */\n\n#include \"$(notdir $(1)).h\"\n" \
+		$$(GLIB_MKENUMS_C_FLAGS) \
+		$$($(_glib_enum_types_prefix)_MKENUMS_C_FLAGS) \
+		--fhead "$$(foreach f,$$(^F),\n#include \"$$(f)\")\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" \
+		$$^ > $(1).c.tmp && \
+	(cmp -s $(1).c.tmp $(1).c || cp $(1).c.tmp $(1).c) && \
+	rm -f $(1).c.tmp && \
+	echo timestamp > $$@
+
+$(1).c: $(1).c.stamp
+	@true
+
+_GLIB_CLEANFILES += $(1).h.stamp $(1).c.stamp
+_GLIB_DISTCLEANFILES += $(1).h $(1).c $(1).h.stamp $(1).c.stamp
+endef
+
+$(foreach f,$(_GLIB_ENUM_TYPES_GENERATED),$(eval $(call _glib_make_mkenums_rules,$f)))
+
+
+### glib-compile-schemas
+
+_GLIB_ENUMS_XML_GENERATED = $(filter %.enums.xml,$(GLIB_GENERATED))
+_GLIB_GSETTINGS_SCHEMA_FILES = $(filter %.gschema.xml,$(gsettingsschema_DATA))
+_GLIB_GSETTINGS_VALID_FILES = $(subst .xml,.valid,$(_GLIB_GSETTINGS_SCHEMA_FILES))
+
+_glib_enums_xml_prefix = $(subst .,_,$(notdir $(1)))
+_glib_enums_xml_sources_var = $(_glib_enums_xml_prefix)_sources
+_glib_enums_xml_sources = $(filter-out $(GLIB_GENERATED),$($(_glib_enums_xml_sources_var)))
+_glib_enums_xml_namespace = $(subst .enums.xml,,$(notdir $(1)))
+
+define _glib_make_enums_xml_rule
+$(if $(_glib_enums_xml_sources),,$(error Need to define $(_glib_enums_xml_sources_var) for $(1)))
+
+$(1): $(_glib_enums_xml_sources)
+	$$(_GLIB_V_GEN) $$(GLIB_MKENUMS) --comments '<!-- @comment@ -->' --fhead "<schemalist>" --vhead "  <@type@ id='$(_glib_enums_xml_namespace)  EnumName@'>" --vprod "    <value nick='@valuenick@' value='@valuenum@'/>" --vtail "  </@type@>" --ftail "</schemalist>" $$^ > $$  tmp && mv $$  tmp $$@
+endef
+
+_GLIB_V_CHECK = $(_glib_v_check_$(V))
+_glib_v_check_ = $(_glib_v_check_$(AM_DEFAULT_VERBOSITY))
+_glib_v_check_0 = @echo "  CHECK " $(subst .valid,.xml,$@);
+
+define _glib_make_schema_validate_rule
+$(subst .xml,.valid,$(1)): $(_GLIB_ENUMS_XML_GENERATED) $(1)
+	$$(_GLIB_V_CHECK) $$(GLIB_COMPILE_SCHEMAS) --strict --dry-run $$(addprefix --schema-file=,$$^) && touch $$@
+endef
+
+define _glib_make_schema_rules
+all-am: $(_GLIB_GSETTINGS_VALID_FILES)
+
+install-data-am: glib-install-schemas-hook
+
+glib-install-schemas-hook: install-gsettingsschemaDATA
+	@test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || (echo $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir); $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir))
+
+uninstall-am: glib-uninstall-schemas-hook
+
+glib-uninstall-schemas-hook: uninstall-gsettingsschemaDATA
+	@test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || (echo $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir); $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir))
+
+.PHONY: glib-install-schemas-hook glib-uninstall-schemas-hook
+endef
+
+_GLIB_CLEANFILES += $(_GLIB_ENUMS_XML_GENERATED) $(_GLIB_GSETTINGS_VALID_FILES)
+
+$(foreach f,$(_GLIB_ENUMS_XML_GENERATED),$(eval $(call _glib_make_enums_xml_rule,$f)))
+$(foreach f,$(_GLIB_GSETTINGS_SCHEMA_FILES),$(eval $(call _glib_make_schema_validate_rule,$f)))
+$(if $(_GLIB_GSETTINGS_SCHEMA_FILES),$(eval $(_glib_make_schema_rules)))
+
+
+### Cleanup
+.PHONY: clean-glib distclean-glib
+
+clean-am: clean-glib
+clean-glib:
+	$(if $(strip $(_GLIB_CLEANFILES)),-rm -f $(_GLIB_CLEANFILES))
+
+distclean-am: distclean-glib
+distclean-glib:
+	$(if $(strip $(_GLIB_DISTCLEANFILES)),-rm -f $(_GLIB_DISTCLEANFILES))
diff --git a/configure.ac b/configure.ac
index b3199c8..fbd814f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -193,7 +193,7 @@ esac
 
 AM_CONDITIONAL(HAVE_GBT, test x"$have_gbt" = "xyes")
 
-AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
+GLIB_CONFIG_NMA
 
 dnl GConf stuff
 AC_PATH_PROG(GCONFTOOL, gconftool-2)
diff --git a/m4/glib-makefile.m4 b/m4/glib-makefile.m4
new file mode 100644
index 0000000..f4d59a9
--- /dev/null
+++ b/m4/glib-makefile.m4
@@ -0,0 +1,31 @@
+dnl GLIB_CONFIG([MINIMUM-VERSION, [, MODULES]])
+dnl Test for GLIB (and error out if it's not available). Define
+dnl GLIB_CFLAGS and GLIB_LIBS, GLIB_MAKEFILE, and variables for
+dnl various glib developer tools (eg, GLIB_GENMARSHAL). If
+dnl gmodule, gobject, or gio is specified in MODULES, pass to
+dnl pkg-config
+dnl
+AC_DEFUN([GLIB_CONFIG_NMA],
+[dnl
+  min_glib_version=ifelse([$1], ,2.31.5,$1)
+  pkg_config_args=
+  for module in glib $2; do
+    pkg_config_args="$pkg_config_args $module-2.0 >= $min_glib_version"
+  done
+
+  PKG_CHECK_MODULES(GLIB, $pkg_config_args)
+
+  GLIB_CFLAGS="$GLIB_CFLAGS -DG_DISABLE_SINGLE_INCLUDES"
+
+  GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
+  GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+
+  #GLIB_MAKEFILE=`$PKG_CONFIG --variable=glib_makefile glib-2.0`
+  GLIB_MAKEFILE='$(top_srcdir)/Makefile.glib'
+
+  AC_SUBST(GLIB_GENMARSHAL)
+  AC_SUBST(GLIB_MKENUMS)
+  AC_SUBST(GLIB_MAKEFILE)
+
+  GLIB_GSETTINGS
+])
diff --git a/src/marshallers/Makefile.am b/src/marshallers/Makefile.am
index be4fe3c..ee2edf2 100644
--- a/src/marshallers/Makefile.am
+++ b/src/marshallers/Makefile.am
@@ -1,11 +1,21 @@
+include $(GLIB_MAKEFILE)
+
 noinst_LTLIBRARIES = libmarshallers.la
 
-BUILT_SOURCES = \
+GLIB_GENERATED = \
 	nma-marshal.h \
 	nma-marshal.c
 
+BUILT_SOURCES = $(GLIB_GENERATED)
+
+nma_marshal_sources = \
+	$(top_srcdir)/src/*.c \
+	$(top_srcdir)/src/gnome-bluetooth/*.c \
+	$(top_srcdir)/src/connection-editor/*.c
+
 libmarshallers_la_SOURCES = \
-	nma-marshal-main.c
+	nma-marshal.h \
+	nma-marshal.c
 
 libmarshallers_la_CPPFLAGS = \
 	$(GOBJECT_CFLAGS) \
@@ -14,14 +24,3 @@ libmarshallers_la_CPPFLAGS = \
 
 libmarshallers_la_LIBADD = $(GOBJECT_LIBS)
 
-EXTRA_DIST = nma-marshal.list
-CLEANFILES = $(BUILT_SOURCES)
-
-nma-marshal.h: nma-marshal.list
-	$(GLIB_GENMARSHAL) $< --prefix=_nma_marshal --header > $@
-
-nma-marshal.c: nma-marshal.list
-	$(GLIB_GENMARSHAL) $< --prefix=_nma_marshal --body > $@
-
-nma-marshal-main.c: nma-marshal.c nma-marshal.h
-



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