From d5dfe7d457b559bd9c53d65d0315c55611cc6a79 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 15 Dec 2013 12:32:15 +0100 Subject: configure.ac: add option "--disable-glib" Allows building without GLib. This fails to compile currently, because GLib is still used in the MPD core. --- src/LogBackend.cxx | 14 ++++++++++++++ src/LogInit.cxx | 7 ++++++- src/Main.cxx | 8 +++++++- src/event/SignalMonitor.cxx | 1 + src/system/FatalError.cxx | 6 +++++- src/system/FatalError.hxx | 2 ++ 6 files changed, 35 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/LogBackend.cxx b/src/LogBackend.cxx index a5c0a691f..bddf8db16 100644 --- a/src/LogBackend.cxx +++ b/src/LogBackend.cxx @@ -23,18 +23,24 @@ #include "util/Domain.hxx" #include "util/CharUtil.hxx" +#ifdef HAVE_GLIB #include +#endif #include #include #include +#include #ifdef HAVE_SYSLOG #include #endif static LogLevel log_threshold = LogLevel::INFO; + +#ifdef HAVE_GLIB static const char *log_charset; +#endif static bool enable_timestamp; @@ -48,12 +54,16 @@ SetLogThreshold(LogLevel _threshold) log_threshold = _threshold; } +#ifdef HAVE_GLIB + void SetLogCharset(const char *_charset) { log_charset = _charset; } +#endif + void EnableLogTimestamp() { @@ -142,6 +152,7 @@ LogFinishSysLog() static void FileLog(const Domain &domain, const char *message) { +#ifdef HAVE_GLIB char *converted; if (log_charset != nullptr) { @@ -153,13 +164,16 @@ FileLog(const Domain &domain, const char *message) message = converted; } else converted = nullptr; +#endif fprintf(stderr, "%s%s: %.*s\n", enable_timestamp ? log_date() : "", domain.GetName(), chomp_length(message), message); +#ifdef HAVE_GLIB g_free(converted); +#endif } void diff --git a/src/LogInit.cxx b/src/LogInit.cxx index 42d86951f..bd858a32c 100644 --- a/src/LogInit.cxx +++ b/src/LogInit.cxx @@ -31,13 +31,16 @@ #include "util/Domain.hxx" #include "system/FatalError.hxx" +#ifdef HAVE_GLIB +#include +#endif + #include #include #include #include #include #include -#include #define LOG_LEVEL_SECURE LogLevel::INFO @@ -110,9 +113,11 @@ log_init(bool verbose, bool use_stdout, Error &error) { const struct config_param *param; +#ifdef HAVE_GLIB const char *charset; g_get_charset(&charset); SetLogCharset(charset); +#endif if (verbose) SetLogThreshold(LogLevel::DEBUG); diff --git a/src/Main.cxx b/src/Main.cxx index 2d25297c9..da8458340 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -79,7 +79,9 @@ #include "ArchiveList.hxx" #endif +#ifdef HAVE_GLIB #include +#endif #include @@ -92,6 +94,8 @@ #include #endif +#include + static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096; static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10; @@ -359,11 +363,13 @@ int mpd_main(int argc, char *argv[]) setlocale(LC_CTYPE,""); #endif +#ifdef HAVE_GLIB g_set_application_name("Music Player Daemon"); #if !GLIB_CHECK_VERSION(2,32,0) /* enable GLib's thread safety code */ g_thread_init(nullptr); +#endif #endif winsock_init(); @@ -473,7 +479,7 @@ int mpd_main(int argc, char *argv[]) } if (!glue_state_file_init(error)) { - g_printerr("%s\n", error.GetMessage()); + LogError(error); return EXIT_FAILURE; } diff --git a/src/event/SignalMonitor.cxx b/src/event/SignalMonitor.cxx index 0d96fb138..bb75f49a3 100644 --- a/src/event/SignalMonitor.cxx +++ b/src/event/SignalMonitor.cxx @@ -40,6 +40,7 @@ #include #include +#include class SignalMonitor final : private SocketMonitor { #ifdef USE_SIGNALFD diff --git a/src/system/FatalError.cxx b/src/system/FatalError.cxx index 11a0944df..b54a677f2 100644 --- a/src/system/FatalError.cxx +++ b/src/system/FatalError.cxx @@ -23,7 +23,7 @@ #include "util/Domain.hxx" #include "LogV.hxx" -#ifdef WIN32 +#ifdef HAVE_GLIB #include #endif @@ -78,12 +78,16 @@ FatalError(const char *msg, const Error &error) FormatFatalError("%s: %s", msg, error.GetMessage()); } +#ifdef HAVE_GLIB + void FatalError(const char *msg, GError *error) { FormatFatalError("%s: %s", msg, error->message); } +#endif + void FatalSystemError(const char *msg) { diff --git a/src/system/FatalError.hxx b/src/system/FatalError.hxx index 2845359ef..4ef290714 100644 --- a/src/system/FatalError.hxx +++ b/src/system/FatalError.hxx @@ -45,9 +45,11 @@ gcc_noreturn void FatalError(const char *msg, const Error &error); +#ifdef HAVE_GLIB gcc_noreturn void FatalError(const char *msg, GError *error); +#endif /** * Call this after a system call has failed that is not supposed to -- cgit v1.2.3