[telepathy-mission-control/master] Add a configure option for whether to support plugins

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Jun 1 08:37:49 PDT 2009


In Debian we don't want to support MC's plugin architecture yet (if at
all), to reduce the amount of API/ABI exposed.

When plugins are disabled, we don't need GModule,
libmissioncontrol-server doesn't need to be installed or be a shared
library, and the headers don't need to be installed either.
---
 autogen.sh               |    4 ++--
 configure.ac             |   30 ++++++++++++++++++++++++++----
 src/Makefile.am          |   44 ++++++++++++++++++++++++++++----------------
 src/mcd-master.c         |    8 ++++++++
 test/twisted/Makefile.am |    8 +++++++-
 5 files changed, 71 insertions(+), 23 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index 6a545f2..4229f56 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -31,6 +31,6 @@ for arg in $*; do
 done
 
 if test $run_configure = true; then
-    echo "Running ./configure --enable-gtk-doc $*"
-    ./configure --enable-gtk-doc "$@"
+    echo "Running ./configure --enable-gtk-doc --enable-plugins $*"
+    ./configure --enable-gtk-doc --enable-plugins "$@"
 fi
diff --git a/configure.ac b/configure.ac
index c3bc6bd..77b5832 100644
--- a/configure.ac
+++ b/configure.ac
@@ -200,7 +200,7 @@ AC_ARG_ENABLE(examples,
 AM_CONDITIONAL(HAVE_EXAMPLES, [test x$examples_enabled = xyes])
 
 server_enabled="yes"
-AC_MSG_CHECKING(whether to build the sample server)
+AC_MSG_CHECKING(whether to build the daemon)
 AC_ARG_ENABLE(server,
 	[  --enable-server         build server. default=yes],
 	[
@@ -214,6 +214,25 @@ AC_ARG_ENABLE(server,
 )
 AM_CONDITIONAL(HAVE_SERVER, [test x$server_enabled = xyes])
 
+plugins_enabled="no"
+AC_MSG_CHECKING(whether to support plugins)
+AC_ARG_ENABLE(plugins,
+	[  --enable-plugins          support plugins. default=no],
+	[
+		AC_MSG_RESULT(${enableval})
+		plugins_enabled="${enableval}"
+	],
+	[
+		AC_MSG_RESULT(no)
+		plugins_enabled="no"
+	]
+)
+AM_CONDITIONAL(ENABLE_PLUGINS, [test x$plugins_enabled = xyes])
+if test "x$plugins_enabled" = xyes
+then
+  AC_DEFINE([ENABLE_PLUGINS], [1], [Define if plugins should be enabled])
+fi
+
 PKG_CHECK_MODULES(DBUS, [dbus-1 >= 0.51, dbus-glib-1 >= 0.51], have_dbus=yes, have_dbus=no)
 AC_SUBST(DBUS_CFLAGS)
 AC_SUBST(DBUS_LIBS)
@@ -231,9 +250,12 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 gobject-2.0)
 AC_SUBST(GLIB_LIBS)
 AC_SUBST(GLIB_CFLAGS)
 
-PKG_CHECK_MODULES(GMODULE, gmodule-no-export-2.0)
-AC_SUBST(GMODULE_LIBS)
-AC_SUBST(GMODULE_CFLAGS)
+if test "x$plugins_enabled" = xyes
+then
+  PKG_CHECK_MODULES(GMODULE, gmodule-no-export-2.0)
+  AC_SUBST(GMODULE_LIBS)
+  AC_SUBST(GMODULE_CFLAGS)
+fi
 
 dnl docs/Makefile.am needs to know whether it's an out of tree build
 dnl (srcdir != builddir)
diff --git a/src/Makefile.am b/src/Makefile.am
index f8c6ae6..3a606e1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,14 +2,11 @@ INCLUDES = \
 	   $(GCONF_CFLAGS) \
 	   $(TELEPATHY_CFLAGS) \
 	   $(DBUS_CFLAGS) \
-	   $(GMODULE_CFLAGS) \
 	   $(GLIB_CFLAGS) \
-	   -DMCD_DEFAULT_FILTER_PLUGIN_DIR=\"@pluginlibdir@\" \
 	   -DDBUS_API_SUBJECT_TO_CHANGE \
 	   -DMC_DISABLE_DEPRECATED -I$(top_srcdir)
 
-mission_control_includedir = $(includedir)/mission-control
-mission_control_include_HEADERS = \
+mc_headers = \
 	mcd-account.h \
 	mcd-account-compat.h \
 	mcd-account-conditions.h \
@@ -34,8 +31,7 @@ mission_control_include_HEADERS = \
 	mcd-provisioning.h \
 	mcd-provisioning-factory.h
 
-genincludedir = $(mission_control_includedir)/_gen
-nodist_geninclude_HEADERS = \
+mc_gen_headers = \
 	_gen/cli-client.h \
 	_gen/cli-Connection_Interface_Contact_Capabilities.h \
 	_gen/enums.h \
@@ -74,7 +70,8 @@ nodist_libmissioncontrol_server_la_SOURCES = \
 	_gen/svc-Account_Manager_Interface_Query.c \
 	_gen/svc-dispatcher.c \
 	_gen/svc-dispatch-operation.c \
-	_gen/svc-request.c
+	_gen/svc-request.c \
+	$(mc_gen_headers)
 
 BUILT_SOURCES = \
 	_gen/all.xml \
@@ -84,26 +81,40 @@ BUILT_SOURCES = \
 	mcd-enum-types.h \
 	stamp-mcd-enum-types.h \
 	$(nodist_libmissioncontrol_server_la_SOURCES) \
-	$(nodist_geninclude_HEADERS)
+	$(mc_gen_headers)
  
 CLEANFILES = $(BUILT_SOURCES)
 
-lib_LTLIBRARIES = libmissioncontrol-server.la
-
 libmissioncontrol_server_la_LIBADD = \
 	$(top_builddir)/libmcclient/libmcclient.la \
 	$(GCONF_LIBS) \
 	$(TELEPATHY_LIBS) \
 	$(DBUS_LIBS) \
-	$(GMODULE_LIBS) \
 	$(GLIB_LIBS)
 
+if ENABLE_PLUGINS
+lib_LTLIBRARIES = libmissioncontrol-server.la
+libmissioncontrol_server_la_LIBADD += $(GMODULE_LIBS)
+
 libmissioncontrol_server_la_LDFLAGS = \
 	-export-symbols-regex '^((mc_)|(mcd_)|(mission_control_))' \
 	-version-info "10":"0":"4"
 # the redundant quoting here is to prevent the libtool command line from
 # looking like an error message in an oddly named file
 
+mission_control_includedir = $(includedir)/mission-control
+mission_control_include_HEADERS = $(mc_headers)
+
+genincludedir = $(mission_control_includedir)/_gen
+nodist_geninclude_HEADERS = $(mc_gen_headers)
+
+INCLUDES += \
+	$(GMODULE_CFLAGS) \
+	-DMCD_DEFAULT_FILTER_PLUGIN_DIR=\"@pluginlibdir@\"
+else
+noinst_LTLIBRARIES = libmissioncontrol-server.la
+endif
+
 libmissioncontrol_server_la_SOURCES = \
 	mcd-account.c \
 	mcd-account-compat.c \
@@ -147,7 +158,8 @@ libmissioncontrol_server_la_SOURCES = \
 	mcd-transport.c \
 	mcd-provisioning.c \
 	mcd-provisioning-factory.c \
-	sp_timestamp.h
+	sp_timestamp.h \
+	$(mc_headers)
 
 # bin_PROGRAMS = mission-control
 # mission_control_LDFLAGS = -export-dynamic
@@ -169,18 +181,18 @@ libmissioncontrol_server_la_SOURCES = \
 
 mcd-enum-types.h: stamp-mcd-enum-types.h
 	@true
-stamp-mcd-enum-types.h: Makefile $(mission_control_include_HEADERS) mcd-enum-types.c
+stamp-mcd-enum-types.h: Makefile $(mc_headers) mcd-enum-types.c
 	( cd $(srcdir) && glib-mkenums \
 		--fhead "#ifndef __MCD_ENUM_TYPES_H__\n#define __MCD_ENUM_TYPES_H__\n\n#include \"mcd-mission.h\"\n#include \"mcd-channel.h\"\n#include \"mcd-provisioning.h\"\n#include \"mcd-transport.h\"\n\nG_BEGIN_DECLS\n" \
 		--fprod "/* enumerations from \"@filename@\" */\n" \
 		--vhead "GType @enum_name at _get_type (void) G_GNUC_CONST;\n#define MCD_TYPE_ at ENUMSHORT@ (@enum_name at _get_type())\n" \
 		--ftail "G_END_DECLS\n\n#endif /* __MCD_ENUM_TYPES_H__ */" \
-	    $(mission_control_include_HEADERS) ) >> xgen-geth \
+	    $(mc_headers) ) >> xgen-geth \
 	&& (cmp -s xgen-geth mcd-enum-types.h || cp xgen-geth mcd-enum-types.h ) \
 	&& rm -f xgen-geth \
 	&& echo timestamp > $(@F)
 
-mcd-enum-types.c: Makefile $(mission_control_include_HEADERS)
+mcd-enum-types.c: Makefile $(mc_headers)
 	( cd $(srcdir) && glib-mkenums \
 		--fhead "#include \"mcd-enum-types.h\"\n#define g_intern_static_string(s) (s)\n" \
 		--fprod "\n/* enumerations from \"@filename@\" */" \
@@ -188,7 +200,7 @@ mcd-enum-types.c: Makefile $(mission_control_include_HEADERS)
 		--vhead "GType\n at enum_name@_get_type (void)\n{\n  static GType etype = 0;\n  if (etype == 0) {\n    static const G at Type@Value values[] = {" \
 		--vprod "      { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
 		--vtail "      { 0, NULL, NULL }\n    };\n    etype = g_ at type@_register_static (g_intern_static_string (\"@EnumName@\"), values);\n  }\n  return etype;\n}\n" \
-	    $(mission_control_include_HEADERS) ) > xgen-getc \
+	    $(mc_headers) ) > xgen-getc \
 	&& cp xgen-getc mcd-enum-types.c  \
 	&& rm -f xgen-getc
 
diff --git a/src/mcd-master.c b/src/mcd-master.c
index 19ca738..2d4213c 100644
--- a/src/mcd-master.c
+++ b/src/mcd-master.c
@@ -48,6 +48,8 @@
  * is subject to all device control.
  */
 
+#include <config.h>
+
 #include <glib/gi18n.h>
 #include <gconf/gconf-client.h>
 #include <gmodule.h>
@@ -265,6 +267,7 @@ on_transport_status_changed (McdTransportPlugin *plugin,
     }
 }
 
+#ifdef ENABLE_PLUGINS
 static void
 mcd_master_unload_plugins (McdMaster *master)
 {
@@ -346,6 +349,7 @@ mcd_master_load_plugins (McdMaster *master)
     }
     g_dir_close (dir);
 }
+#endif
 
 static void
 _mcd_master_connect (McdMission * mission)
@@ -523,10 +527,12 @@ _mcd_master_dispose (GObject * object)
 	priv->transport_plugins = NULL;
     }
 
+#ifdef ENABLE_PLUGINS
     if (priv->plugins)
     {
 	mcd_master_unload_plugins (MCD_MASTER (object));
     }
+#endif
 
     if (priv->account_manager)
     {
@@ -578,7 +584,9 @@ mcd_master_constructor (GType type, guint n_params,
     mcd_operation_take_mission (MCD_OPERATION (priv->proxy),
 				MCD_MISSION (priv->dispatcher));
 
+#ifdef ENABLE_PLUGINS
     mcd_master_load_plugins (master);
+#endif
 
     /* we assume that at this point all transport plugins have been registered.
      * We get the active transports and check whether some accounts should be
diff --git a/test/twisted/Makefile.am b/test/twisted/Makefile.am
index 4273b41..3732450 100644
--- a/test/twisted/Makefile.am
+++ b/test/twisted/Makefile.am
@@ -22,7 +22,6 @@ TWISTED_BASIC_TESTS = \
 	dispatcher/create-text.py \
 	dispatcher/dispatch-activatable.py \
 	dispatcher/dispatch-obsolete.py \
-	dispatcher/dispatch-rejected-by-plugin.py \
 	dispatcher/dispatch-text.py \
 	dispatcher/exploding-bundles.py \
 	dispatcher/fdo-21034.py \
@@ -34,11 +33,17 @@ TWISTED_BASIC_TESTS = \
 	test-account.py \
 	test-connect.py
 
+if ENABLE_PLUGINS
+TWISTED_BASIC_TESTS += \
+	dispatcher/dispatch-rejected-by-plugin.py
+endif
+
 TWISTED_SEPARATE_TESTS = \
 	account-manager/auto-connect.py \
 	crash-recovery/crash-recovery.py \
 	dispatcher/create-at-startup.py
 
+if ENABLE_PLUGINS
 # A demo dispatcher plugin
 noinst_LTLIBRARIES = test-plugin.la
 test_plugin_la_SOURCES = test-plugin.c
@@ -46,6 +51,7 @@ test_plugin_la_SOURCES = test-plugin.c
 # library even though it's not going to be installed - the default for noinst
 # libraries is static
 test_plugin_la_LDFLAGS = -module -shared -avoid-version -rpath @abs_builddir@
+endif
 
 # A debug version of the normal MC executable, which exits cleanly on
 # disconnection from D-Bus (so gcov info gets written out)
-- 
1.5.6.5




More information about the telepathy-commits mailing list