Make threading support optional
authorMarcel Holtmann <marcel@holtmann.org>
Mon, 24 Nov 2008 10:27:26 +0000 (11:27 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 24 Nov 2008 10:27:26 +0000 (11:27 +0100)
configure.ac
src/Makefile.am
src/main.c

index c3e4f7f..4807420 100644 (file)
@@ -56,10 +56,15 @@ PKG_CHECK_MODULES(GLIB, glib-2.0, dummy=yes,
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
-PKG_CHECK_MODULES(GTHREAD, gthread-2.0, dummy=yes,
+AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads],
+                                       [enable threading support]), [
+       AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required])
+
+       PKG_CHECK_MODULES(GTHREAD, gthread-2.0, dummy=yes,
                                AC_MSG_ERROR(gthread is required))
-AC_SUBST(GTHREAD_CFLAGS)
-AC_SUBST(GTHREAD_LIBS)
+       GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
+       GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
+])
 
 PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, dummy=yes,
                                AC_MSG_ERROR(libdbus is required))
index 6c3d603..f49e18e 100644 (file)
@@ -15,7 +15,7 @@ connmand_SOURCES = main.c connman.h log.c error.c plugin.c profile.c \
                        element.c device.c network.c security.c resolver.c \
                                storage.c manager.c agent.c rtnl.c dbus.c
 
-connmand_LDADD = @GDBUS_LIBS@ @GLIB_LIBS@ @GTHREAD_LIBS@ -ldl
+connmand_LDADD = @GDBUS_LIBS@ @GLIB_LIBS@ -ldl
 
 connmand_LDFLAGS = -Wl,--export-dynamic -Wl,--version-script=connman.ver
 
@@ -33,7 +33,7 @@ else
 plugindir = $(libdir)/connman/plugins
 endif
 
-AM_CFLAGS = @GTHREAD_CFLAGS@ @GLIB_CFLAGS@ @GDBUS_CFLAGS@ \
+AM_CFLAGS = @GLIB_CFLAGS@ @GDBUS_CFLAGS@ \
                        -DSTATEDIR=\""$(statedir)"\" \
                        -DSTORAGEDIR=\""$(storagedir)\"" \
                        -DPLUGINDIR=\""$(plugindir)"\"
index 104c5cc..5810813 100644 (file)
@@ -76,8 +76,10 @@ int main(int argc, char *argv[])
        DBusError err;
        struct sigaction sa;
 
+#ifdef NEED_THREADS
        if (g_thread_supported() == FALSE)
                g_thread_init(NULL);
+#endif
 
        context = g_option_context_new(NULL);
        g_option_context_add_main_entries(context, options, NULL);
@@ -108,10 +110,12 @@ int main(int argc, char *argv[])
 
        main_loop = g_main_loop_new(NULL, FALSE);
 
+#ifdef NEED_THREADS
        if (dbus_threads_init_default() == FALSE) {
                fprintf(stderr, "Can't init usage of threads\n");
                exit(1);
        }
+#endif
 
        dbus_error_init(&err);