Commit d5dfe7d4 authored by Max Kellermann's avatar Max Kellermann

configure.ac: add option "--disable-glib"

Allows building without GLib. This fails to compile currently, because GLib is still used in the MPD core.
parent 0db0b4e3
...@@ -990,14 +990,6 @@ libplaylist_plugins_a_SOURCES = \ ...@@ -990,14 +990,6 @@ libplaylist_plugins_a_SOURCES = \
src/playlist/ExtM3uPlaylistPlugin.hxx \ src/playlist/ExtM3uPlaylistPlugin.hxx \
src/playlist/M3uPlaylistPlugin.cxx \ src/playlist/M3uPlaylistPlugin.cxx \
src/playlist/M3uPlaylistPlugin.hxx \ 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.cxx \
src/playlist/CuePlaylistPlugin.hxx \ src/playlist/CuePlaylistPlugin.hxx \
src/playlist/EmbeddedCuePlaylistPlugin.cxx \ src/playlist/EmbeddedCuePlaylistPlugin.cxx \
...@@ -1024,6 +1016,18 @@ libplaylist_plugins_a_SOURCES += \ ...@@ -1024,6 +1016,18 @@ libplaylist_plugins_a_SOURCES += \
PLAYLIST_LIBS += $(YAJL_LIBS) PLAYLIST_LIBS += $(YAJL_LIBS)
endif 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 # Filter plugins
# #
......
...@@ -547,13 +547,24 @@ AC_ARG_WITH(tremor-includes, ...@@ -547,13 +547,24 @@ AC_ARG_WITH(tremor-includes,
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
dnl Mandatory Libraries dnl Mandatory Libraries
dnl --------------------------------------------------------------------------- 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])]) [AC_MSG_ERROR([GLib 2.28 is required])])
if test x$GCC = xyes; then if test x$GCC = xyes; then
# suppress warnings in the GLib headers # suppress warnings in the GLib headers
GLIB_CFLAGS=`echo $GLIB_CFLAGS |sed -e 's,-I/,-isystem /,g'` GLIB_CFLAGS=`echo $GLIB_CFLAGS |sed -e 's,-I/,-isystem /,g'`
fi
AC_DEFINE(HAVE_GLIB, 1, [Define if GLib is used])
fi fi
AM_CONDITIONAL(HAVE_GLIB, test x$enable_glib = xyes)
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
dnl Protocol Options dnl Protocol Options
......
...@@ -23,18 +23,24 @@ ...@@ -23,18 +23,24 @@
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "util/CharUtil.hxx" #include "util/CharUtil.hxx"
#ifdef HAVE_GLIB
#include <glib.h> #include <glib.h>
#endif
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <time.h>
#ifdef HAVE_SYSLOG #ifdef HAVE_SYSLOG
#include <syslog.h> #include <syslog.h>
#endif #endif
static LogLevel log_threshold = LogLevel::INFO; static LogLevel log_threshold = LogLevel::INFO;
#ifdef HAVE_GLIB
static const char *log_charset; static const char *log_charset;
#endif
static bool enable_timestamp; static bool enable_timestamp;
...@@ -48,12 +54,16 @@ SetLogThreshold(LogLevel _threshold) ...@@ -48,12 +54,16 @@ SetLogThreshold(LogLevel _threshold)
log_threshold = _threshold; log_threshold = _threshold;
} }
#ifdef HAVE_GLIB
void void
SetLogCharset(const char *_charset) SetLogCharset(const char *_charset)
{ {
log_charset = _charset; log_charset = _charset;
} }
#endif
void void
EnableLogTimestamp() EnableLogTimestamp()
{ {
...@@ -142,6 +152,7 @@ LogFinishSysLog() ...@@ -142,6 +152,7 @@ LogFinishSysLog()
static void static void
FileLog(const Domain &domain, const char *message) FileLog(const Domain &domain, const char *message)
{ {
#ifdef HAVE_GLIB
char *converted; char *converted;
if (log_charset != nullptr) { if (log_charset != nullptr) {
...@@ -153,13 +164,16 @@ FileLog(const Domain &domain, const char *message) ...@@ -153,13 +164,16 @@ FileLog(const Domain &domain, const char *message)
message = converted; message = converted;
} else } else
converted = nullptr; converted = nullptr;
#endif
fprintf(stderr, "%s%s: %.*s\n", fprintf(stderr, "%s%s: %.*s\n",
enable_timestamp ? log_date() : "", enable_timestamp ? log_date() : "",
domain.GetName(), domain.GetName(),
chomp_length(message), message); chomp_length(message), message);
#ifdef HAVE_GLIB
g_free(converted); g_free(converted);
#endif
} }
void void
......
...@@ -31,13 +31,16 @@ ...@@ -31,13 +31,16 @@
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "system/FatalError.hxx" #include "system/FatalError.hxx"
#ifdef HAVE_GLIB
#include <glib.h>
#endif
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <glib.h>
#define LOG_LEVEL_SECURE LogLevel::INFO #define LOG_LEVEL_SECURE LogLevel::INFO
...@@ -110,9 +113,11 @@ log_init(bool verbose, bool use_stdout, Error &error) ...@@ -110,9 +113,11 @@ log_init(bool verbose, bool use_stdout, Error &error)
{ {
const struct config_param *param; const struct config_param *param;
#ifdef HAVE_GLIB
const char *charset; const char *charset;
g_get_charset(&charset); g_get_charset(&charset);
SetLogCharset(charset); SetLogCharset(charset);
#endif
if (verbose) if (verbose)
SetLogThreshold(LogLevel::DEBUG); SetLogThreshold(LogLevel::DEBUG);
......
...@@ -79,7 +79,9 @@ ...@@ -79,7 +79,9 @@
#include "ArchiveList.hxx" #include "ArchiveList.hxx"
#endif #endif
#ifdef HAVE_GLIB
#include <glib.h> #include <glib.h>
#endif
#include <stdlib.h> #include <stdlib.h>
...@@ -92,6 +94,8 @@ ...@@ -92,6 +94,8 @@
#include <ws2tcpip.h> #include <ws2tcpip.h>
#endif #endif
#include <limits.h>
static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096; static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096;
static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10; static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10;
...@@ -359,12 +363,14 @@ int mpd_main(int argc, char *argv[]) ...@@ -359,12 +363,14 @@ int mpd_main(int argc, char *argv[])
setlocale(LC_CTYPE,""); setlocale(LC_CTYPE,"");
#endif #endif
#ifdef HAVE_GLIB
g_set_application_name("Music Player Daemon"); g_set_application_name("Music Player Daemon");
#if !GLIB_CHECK_VERSION(2,32,0) #if !GLIB_CHECK_VERSION(2,32,0)
/* enable GLib's thread safety code */ /* enable GLib's thread safety code */
g_thread_init(nullptr); g_thread_init(nullptr);
#endif #endif
#endif
winsock_init(); winsock_init();
io_thread_init(); io_thread_init();
...@@ -473,7 +479,7 @@ int mpd_main(int argc, char *argv[]) ...@@ -473,7 +479,7 @@ int mpd_main(int argc, char *argv[])
} }
if (!glue_state_file_init(error)) { if (!glue_state_file_init(error)) {
g_printerr("%s\n", error.GetMessage()); LogError(error);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <algorithm> #include <algorithm>
#include <assert.h> #include <assert.h>
#include <signal.h>
class SignalMonitor final : private SocketMonitor { class SignalMonitor final : private SocketMonitor {
#ifdef USE_SIGNALFD #ifdef USE_SIGNALFD
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "LogV.hxx" #include "LogV.hxx"
#ifdef WIN32 #ifdef HAVE_GLIB
#include <glib.h> #include <glib.h>
#endif #endif
...@@ -78,12 +78,16 @@ FatalError(const char *msg, const Error &error) ...@@ -78,12 +78,16 @@ FatalError(const char *msg, const Error &error)
FormatFatalError("%s: %s", msg, error.GetMessage()); FormatFatalError("%s: %s", msg, error.GetMessage());
} }
#ifdef HAVE_GLIB
void void
FatalError(const char *msg, GError *error) FatalError(const char *msg, GError *error)
{ {
FormatFatalError("%s: %s", msg, error->message); FormatFatalError("%s: %s", msg, error->message);
} }
#endif
void void
FatalSystemError(const char *msg) FatalSystemError(const char *msg)
{ {
......
...@@ -45,9 +45,11 @@ gcc_noreturn ...@@ -45,9 +45,11 @@ gcc_noreturn
void void
FatalError(const char *msg, const Error &error); FatalError(const char *msg, const Error &error);
#ifdef HAVE_GLIB
gcc_noreturn gcc_noreturn
void void
FatalError(const char *msg, GError *error); FatalError(const char *msg, GError *error);
#endif
/** /**
* Call this after a system call has failed that is not supposed to * Call this after a system call has failed that is not supposed to
......
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
#include "Log.hxx" #include "Log.hxx"
#include "stdbin.h" #include "stdbin.h"
#ifdef HAVE_GLIB
#include <glib.h> #include <glib.h>
#endif
#include <assert.h> #include <assert.h>
#include <unistd.h> #include <unistd.h>
...@@ -192,9 +194,11 @@ int main(int argc, char **argv) ...@@ -192,9 +194,11 @@ int main(int argc, char **argv)
decoder_name = argv[1]; decoder_name = argv[1];
decoder.uri = argv[2]; decoder.uri = argv[2];
#ifdef HAVE_GLIB
#if !GLIB_CHECK_VERSION(2,32,0) #if !GLIB_CHECK_VERSION(2,32,0)
g_thread_init(NULL); g_thread_init(NULL);
#endif #endif
#endif
g_log_set_default_handler(my_log_func, NULL); g_log_set_default_handler(my_log_func, NULL);
......
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
#include "ArchiveList.hxx" #include "ArchiveList.hxx"
#endif #endif
#ifdef HAVE_GLIB
#include <glib.h> #include <glib.h>
#endif
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -120,9 +122,11 @@ int main(int argc, char **argv) ...@@ -120,9 +122,11 @@ int main(int argc, char **argv)
/* initialize GLib */ /* initialize GLib */
#ifdef HAVE_GLIB
#if !GLIB_CHECK_VERSION(2,32,0) #if !GLIB_CHECK_VERSION(2,32,0)
g_thread_init(NULL); g_thread_init(NULL);
#endif #endif
#endif
g_log_set_default_handler(my_log_func, NULL); g_log_set_default_handler(my_log_func, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment