diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile.am | 20 | ||||
-rw-r--r-- | configure.ac | 19 | ||||
-rw-r--r-- | src/LogBackend.cxx | 14 | ||||
-rw-r--r-- | src/LogInit.cxx | 7 | ||||
-rw-r--r-- | src/Main.cxx | 8 | ||||
-rw-r--r-- | src/event/SignalMonitor.cxx | 1 | ||||
-rw-r--r-- | src/system/FatalError.cxx | 6 | ||||
-rw-r--r-- | src/system/FatalError.hxx | 2 | ||||
-rw-r--r-- | test/run_decoder.cxx | 4 | ||||
-rw-r--r-- | test/run_input.cxx | 4 |
10 files changed, 70 insertions, 15 deletions
diff --git a/Makefile.am b/Makefile.am index 6ce95d034..11ae26960 100644 --- a/Makefile.am +++ b/Makefile.am @@ -990,14 +990,6 @@ libplaylist_plugins_a_SOURCES = \ src/playlist/ExtM3uPlaylistPlugin.hxx \ src/playlist/M3uPlaylistPlugin.cxx \ src/playlist/M3uPlaylistPlugin.hxx \ - src/playlist/PlsPlaylistPlugin.cxx \ - src/playlist/PlsPlaylistPlugin.hxx \ - src/playlist/XspfPlaylistPlugin.cxx \ - src/playlist/XspfPlaylistPlugin.hxx \ - src/playlist/AsxPlaylistPlugin.cxx \ - src/playlist/AsxPlaylistPlugin.hxx \ - src/playlist/RssPlaylistPlugin.cxx \ - src/playlist/RssPlaylistPlugin.hxx \ src/playlist/CuePlaylistPlugin.cxx \ src/playlist/CuePlaylistPlugin.hxx \ src/playlist/EmbeddedCuePlaylistPlugin.cxx \ @@ -1024,6 +1016,18 @@ libplaylist_plugins_a_SOURCES += \ PLAYLIST_LIBS += $(YAJL_LIBS) endif +if HAVE_GLIB +libplaylist_plugins_a_SOURCES += \ + src/playlist/PlsPlaylistPlugin.cxx \ + src/playlist/PlsPlaylistPlugin.hxx \ + src/playlist/XspfPlaylistPlugin.cxx \ + src/playlist/XspfPlaylistPlugin.hxx \ + src/playlist/AsxPlaylistPlugin.cxx \ + src/playlist/AsxPlaylistPlugin.hxx \ + src/playlist/RssPlaylistPlugin.cxx \ + src/playlist/RssPlaylistPlugin.hxx +endif + # # Filter plugins # diff --git a/configure.ac b/configure.ac index 1e3dfb098..b789d02d9 100644 --- a/configure.ac +++ b/configure.ac @@ -547,13 +547,24 @@ AC_ARG_WITH(tremor-includes, dnl --------------------------------------------------------------------------- dnl Mandatory Libraries dnl --------------------------------------------------------------------------- -PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.28 gthread-2.0],, + +AC_ARG_ENABLE(glib, + AS_HELP_STRING([--enable-glib], + [enable GLib usage (default: enabled)]),, + enable_glib=yes) + +if test x$enable_glib = xyes; then + PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.28 gthread-2.0],, [AC_MSG_ERROR([GLib 2.28 is required])]) -if test x$GCC = xyes; then - # suppress warnings in the GLib headers - GLIB_CFLAGS=`echo $GLIB_CFLAGS |sed -e 's,-I/,-isystem /,g'` + if test x$GCC = xyes; then + # suppress warnings in the GLib headers + GLIB_CFLAGS=`echo $GLIB_CFLAGS |sed -e 's,-I/,-isystem /,g'` + fi + + AC_DEFINE(HAVE_GLIB, 1, [Define if GLib is used]) fi +AM_CONDITIONAL(HAVE_GLIB, test x$enable_glib = xyes) dnl --------------------------------------------------------------------------- dnl Protocol Options 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 <glib.h> +#endif #include <assert.h> #include <stdio.h> #include <string.h> +#include <time.h> #ifdef HAVE_SYSLOG #include <syslog.h> #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 <glib.h> +#endif + #include <assert.h> #include <string.h> #include <fcntl.h> #include <stdio.h> #include <time.h> #include <unistd.h> -#include <glib.h> #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 <glib.h> +#endif #include <stdlib.h> @@ -92,6 +94,8 @@ #include <ws2tcpip.h> #endif +#include <limits.h> + static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096; static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10; @@ -359,12 +363,14 @@ 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(); io_thread_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 <algorithm> #include <assert.h> +#include <signal.h> 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 <glib.h> #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 diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx index 7db8dde22..56ef2068d 100644 --- a/test/run_decoder.cxx +++ b/test/run_decoder.cxx @@ -29,7 +29,9 @@ #include "Log.hxx" #include "stdbin.h" +#ifdef HAVE_GLIB #include <glib.h> +#endif #include <assert.h> #include <unistd.h> @@ -192,9 +194,11 @@ int main(int argc, char **argv) decoder_name = argv[1]; decoder.uri = argv[2]; +#ifdef HAVE_GLIB #if !GLIB_CHECK_VERSION(2,32,0) g_thread_init(NULL); #endif +#endif g_log_set_default_handler(my_log_func, NULL); diff --git a/test/run_input.cxx b/test/run_input.cxx index 3817ed418..23316b7c6 100644 --- a/test/run_input.cxx +++ b/test/run_input.cxx @@ -33,7 +33,9 @@ #include "ArchiveList.hxx" #endif +#ifdef HAVE_GLIB #include <glib.h> +#endif #include <unistd.h> #include <stdlib.h> @@ -120,9 +122,11 @@ int main(int argc, char **argv) /* initialize GLib */ +#ifdef HAVE_GLIB #if !GLIB_CHECK_VERSION(2,32,0) g_thread_init(NULL); #endif +#endif g_log_set_default_handler(my_log_func, NULL); |