* 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? # 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_CFLAGS)
AC_SUBST(GLIB_LIBS) 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 # g_test was introduced in glib 2.16
PKG_CHECK_MODULES(g_test,glib-2.0 >= 2.16, PKG_CHECK_MODULES(g_test,glib-2.0 >= 2.16, [have_gtest=yes],[have_gtest=no])
[have_gtest=yes],[have_gtest=no])
AM_CONDITIONAL(HAVE_GTEST, test "x$have_gtest" = "xyes") AM_CONDITIONAL(HAVE_GTEST, test "x$have_gtest" = "xyes")
if test "x$have_gtest" = "xno"; then AS_IF([test "x$have_gtest" = "xno"],[
AC_MSG_WARN([You need GLIB version >= 2.16 to build the tests]) AC_MSG_WARN([You need GLIB version >= 2.16 to build the tests])
fi ])
# gmime2? # gmime2?

View File

@ -27,7 +27,10 @@
#include <time.h> #include <time.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#ifdef HAVE_GIO
#include <gio/gio.h> #include <gio/gio.h>
#endif /*HAVE_GIO*/
#include "mu-log.h" #include "mu-log.h"
#include "mu-util.h" #include "mu-util.h"
@ -61,7 +64,6 @@ try_close (int fd)
__FUNCTION__, fd, strerror(errno)); __FUNCTION__, fd, strerror(errno));
} }
static void static void
silence (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 */ /* log file is too big!; we move it to <logfile>.old, overwriting */
#ifdef HAVE_GIO
static gboolean static gboolean
move_log_file (const char* logfile) move_log_file (const char* logfile)
{ {
@ -131,10 +134,11 @@ move_log_file (const char* logfile)
g_free (tmp); g_free (tmp);
err = NULL; 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) { if (!rv) {
g_warning ("Failed to move %s to %s.old: %s", logfile, logfile, g_warning ("Failed to move %s to %s.old: %s",
err ? err->message : "?"); logfile, logfile, err ? err->message : "?");
if (err) if (err)
g_error_free (err); g_error_free (err);
} }
@ -144,6 +148,17 @@ move_log_file (const char* logfile)
return rv; 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 static gboolean
log_file_backup_maybe (const char *logfile) log_file_backup_maybe (const char *logfile)