* make requirement for GIO optional (issue #22)

This commit is contained in:
Dirk-Jan C. Binnema 2010-07-24 20:28:39 +03:00
parent fed8d20503
commit 38f5c8abeb
2 changed files with 36 additions and 11 deletions

View File

@ -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?

View File

@ -27,7 +27,10 @@
#include <time.h>
#include <errno.h>
#include <string.h>
#ifdef HAVE_GIO
#include <gio/gio.h>
#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 <logfile>.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)