From 38f5c8abeb14713804a568caf44a27ea89706147 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 24 Jul 2010 20:28:39 +0300 Subject: [PATCH] * make requirement for GIO optional (issue #22) --- configure.ac | 22 ++++++++++++++++------ src/mu-log.c | 25 ++++++++++++++++++++----- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index cf79fe20..a15adf43 100644 --- a/configure.ac +++ b/configure.ac @@ -80,17 +80,27 @@ AC_STRUCT_DIRENT_D_INO # glib2? -PKG_CHECK_MODULES(GLIB, glib-2.0 gio-2.0) +PKG_CHECK_MODULES(GLIB, glib-2.0) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) + +# gio has only been added to recent glib +PKG_CHECK_MODULES(GIO,gio-2.0,[have_gio=yes],[have_gio=no]) +AM_CONDITIONAL(HAVE_GIO, [test "x$have_gio" = "xyes"]) +AS_IF([test "x$have_gio" = "xno"],[ + AC_MSG_WARN([GIO not supported]) +],[ + AC_DEFINE(HAVE_GIO,[1],[Wether we have GIO]) +]) + + # g_test was introduced in glib 2.16 -PKG_CHECK_MODULES(g_test,glib-2.0 >= 2.16, - [have_gtest=yes],[have_gtest=no]) +PKG_CHECK_MODULES(g_test,glib-2.0 >= 2.16, [have_gtest=yes],[have_gtest=no]) AM_CONDITIONAL(HAVE_GTEST, test "x$have_gtest" = "xyes") -if test "x$have_gtest" = "xno"; then - AC_MSG_WARN([You need GLIB version >= 2.16 to build the tests]) -fi +AS_IF([test "x$have_gtest" = "xno"],[ + AC_MSG_WARN([You need GLIB version >= 2.16 to build the tests]) +]) # gmime2? diff --git a/src/mu-log.c b/src/mu-log.c index 297369c0..845e5f92 100644 --- a/src/mu-log.c +++ b/src/mu-log.c @@ -27,7 +27,10 @@ #include #include #include + +#ifdef HAVE_GIO #include +#endif /*HAVE_GIO*/ #include "mu-log.h" #include "mu-util.h" @@ -61,7 +64,6 @@ try_close (int fd) __FUNCTION__, fd, strerror(errno)); } - static void silence (void) { @@ -117,6 +119,7 @@ mu_log_init_with_fd (int fd, gboolean doclose, /* log file is too big!; we move it to .old, overwriting */ +#ifdef HAVE_GIO static gboolean move_log_file (const char* logfile) { @@ -131,19 +134,31 @@ move_log_file (const char* logfile) g_free (tmp); err = NULL; - rv = g_file_move (src, dst, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &err); + rv = g_file_move (src, dst, G_FILE_COPY_OVERWRITE, NULL, + NULL, NULL, &err); if (!rv) { - g_warning ("Failed to move %s to %s.old: %s", logfile, logfile, - err ? err->message : "?"); + g_warning ("Failed to move %s to %s.old: %s", + logfile, logfile, err ? err->message : "?"); if (err) g_error_free (err); - } + } g_object_unref (G_OBJECT(src)); g_object_unref (G_OBJECT(dst)); return rv; } +#else +static gboolean +move_log_file (const char *logfile) +{ + g_warning ("Failed to move log file '%s', because this 'mu'" + "was built without GIO support", logfile); + return FALSE; +} +#endif /* HAVE_GIO */ + + static gboolean log_file_backup_maybe (const char *logfile)