Make libcurl a hard dependency

This commit is contained in:
Andrzej Rybczak
2016-11-20 19:14:46 +01:00
parent b018efceb6
commit 5e2626ca0c
18 changed files with 46 additions and 136 deletions

1
NEWS
View File

@@ -8,6 +8,7 @@ ncmpcpp-0.8 (????-??-??)
* Added support for fetching lyrics from tekstowo.pl. * Added support for fetching lyrics from tekstowo.pl.
* The list of lyrics fetchers can now be set via configuration file. * The list of lyrics fetchers can now be set via configuration file.
* Lyrics can now be fetched for songs with no tags. * Lyrics can now be fetched for songs with no tags.
* libcurl dependency is no longer optional.
ncmpcpp-0.7.7 (2016-10-31) ncmpcpp-0.7.7 (2016-10-31)
* Fixed compilation on 32bit platforms. * Fixed compilation on 32bit platforms.

View File

@@ -15,7 +15,6 @@ AC_ARG_ENABLE(visualizer, AS_HELP_STRING([--enable-visualizer], [Enable music vi
AC_ARG_ENABLE(clock, AS_HELP_STRING([--enable-clock], [Enable clock screen @<:@default=no@:>@]), [clock=$enableval], [clock=no]) AC_ARG_ENABLE(clock, AS_HELP_STRING([--enable-clock], [Enable clock screen @<:@default=no@:>@]), [clock=$enableval], [clock=no])
AC_ARG_ENABLE(unicode, AS_HELP_STRING([--enable-unicode], [Enable utf8 support @<:@default=yes@:>@]), [unicode=$enableval], [unicode=yes]) AC_ARG_ENABLE(unicode, AS_HELP_STRING([--enable-unicode], [Enable utf8 support @<:@default=yes@:>@]), [unicode=$enableval], [unicode=yes])
AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl], [Enable fetching lyrics from the Internet @<:@default=auto@:>@]), [curl=$withval], [curl=auto])
AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto]) AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto])
AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto]) AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto])
@@ -232,31 +231,42 @@ if test "$visualizer" = "yes" ; then
AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen]) AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen])
fi fi
dnl ===================== dnl ========================
dnl = checking for curl = dnl = checking for libcurl =
dnl ===================== dnl ========================
if test "$curl" != "no" ; then PKG_CHECK_MODULES([libcurl], [libcurl], [
AC_PATH_PROG(CURL_CONFIG, curl-config) AC_SUBST(libcurl_CFLAGS)
if test "$CURL_CONFIG" != "" ; then AC_SUBST(libcurl_LIBS)
CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`" CPPFLAGS="$CPPFLAGS $libcurl_CFLAGS"
AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS `$CURL_CONFIG --libs`", AC_CHECK_HEADERS([curl/curl.h],
if test "$curl" = "yes" ; then LIBS="$LIBS $libcurl_LIBS"
AC_MSG_ERROR([curl library is required]) ,
fi AC_MSG_ERROR([missing curl/curl.h header])
) )
AC_CHECK_HEADERS([curl/curl.h], , ],
if test "$curl" = "yes" ; then AC_MSG_ERROR([libcurl is required!])
AC_MSG_ERROR([missing curl.h header]) )
fi
) dnl AC_PATH_PROG(CURL_CONFIG, curl-config)
else dnl if test "$CURL_CONFIG" != "" ; then
AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS -lcurl", dnl CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
if test "$curl" = "yes" ; then dnl AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS `$CURL_CONFIG --libs`",
AC_MSG_ERROR([curl library is required]) dnl if test "$curl" = "yes" ; then
fi dnl AC_MSG_ERROR([curl library is required])
) dnl fi
fi dnl )
fi dnl AC_CHECK_HEADERS([curl/curl.h], ,
dnl if test "$curl" = "yes" ; then
dnl AC_MSG_ERROR([missing curl.h header])
dnl fi
dnl )
dnl else
dnl AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS -lcurl",
dnl if test "$curl" = "yes" ; then
dnl AC_MSG_ERROR([curl library is required])
dnl fi
dnl )
dnl fi
dnl ======================= dnl =======================
dnl = checking for taglib = dnl = checking for taglib =

View File

@@ -135,11 +135,8 @@ void initializeScreens()
mySongInfo = new SongInfo; mySongInfo = new SongInfo;
myServerInfo = new ServerInfo; myServerInfo = new ServerInfo;
mySortPlaylistDialog = new SortPlaylistDialog; mySortPlaylistDialog = new SortPlaylistDialog;
# ifdef HAVE_CURL_CURL_H
myLastfm = new Lastfm; myLastfm = new Lastfm;
# endif // HAVE_CURL_CURL_H
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
myTinyTagEditor = new TinyTagEditor; myTinyTagEditor = new TinyTagEditor;
myTagEditor = new TagEditor; myTagEditor = new TagEditor;
@@ -172,11 +169,8 @@ void setResizeFlags()
mySongInfo->hasToBeResized = 1; mySongInfo->hasToBeResized = 1;
myServerInfo->hasToBeResized = 1; myServerInfo->hasToBeResized = 1;
mySortPlaylistDialog->hasToBeResized = 1; mySortPlaylistDialog->hasToBeResized = 1;
# ifdef HAVE_CURL_CURL_H
myLastfm->hasToBeResized = 1; myLastfm->hasToBeResized = 1;
# endif // HAVE_CURL_CURL_H
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
myTinyTagEditor->hasToBeResized = 1; myTinyTagEditor->hasToBeResized = 1;
myTagEditor->hasToBeResized = 1; myTagEditor->hasToBeResized = 1;
@@ -1138,35 +1132,16 @@ void ToggleLyricsUpdateOnSongChange::run()
); );
} }
#ifndef HAVE_CURL_CURL_H
bool ToggleLyricsFetcher::canBeRun()
{
return false;
}
#endif // NOT HAVE_CURL_CURL_H
void ToggleLyricsFetcher::run() void ToggleLyricsFetcher::run()
{ {
# ifdef HAVE_CURL_CURL_H
myLyrics->toggleFetcher(); myLyrics->toggleFetcher();
# endif // HAVE_CURL_CURL_H
} }
#ifndef HAVE_CURL_CURL_H
bool ToggleFetchingLyricsInBackground::canBeRun()
{
return false;
}
#endif // NOT HAVE_CURL_CURL_H
void ToggleFetchingLyricsInBackground::run() void ToggleFetchingLyricsInBackground::run()
{ {
# ifdef HAVE_CURL_CURL_H
Config.fetch_lyrics_in_background = !Config.fetch_lyrics_in_background; Config.fetch_lyrics_in_background = !Config.fetch_lyrics_in_background;
Statusbar::printf("Fetching lyrics for playing songs in background: %1%", Statusbar::printf("Fetching lyrics for playing songs in background: %1%",
Config.fetch_lyrics_in_background ? "on" : "off" Config.fetch_lyrics_in_background ? "on" : "off");
);
# endif // HAVE_CURL_CURL_H
} }
void TogglePlayingSongCentering::run() void TogglePlayingSongCentering::run()
@@ -2003,11 +1978,8 @@ void ApplyFilter::run()
bool Find::canBeRun() bool Find::canBeRun()
{ {
return myScreen == myHelp return myScreen == myHelp
|| myScreen == myLyrics || myScreen == myLyrics
# ifdef HAVE_CURL_CURL_H || myScreen == myLastfm;
|| myScreen == myLastfm
# endif // HAVE_CURL_CURL_H
;
} }
void Find::run() void Find::run()
@@ -2299,18 +2271,12 @@ void ToggleMediaLibrarySortMode::run()
bool RefetchLyrics::canBeRun() bool RefetchLyrics::canBeRun()
{ {
# ifdef HAVE_CURL_CURL_H
return myScreen == myLyrics; return myScreen == myLyrics;
# else
return false;
# endif // HAVE_CURL_CURL_H
} }
void RefetchLyrics::run() void RefetchLyrics::run()
{ {
# ifdef HAVE_CURL_CURL_H
myLyrics->refetchCurrent(); myLyrics->refetchCurrent();
# endif // HAVE_CURL_CURL_H
} }
bool SetSelectedItemsPriority::canBeRun() bool SetSelectedItemsPriority::canBeRun()
@@ -2402,20 +2368,15 @@ void ShowSongInfo::run()
bool ShowArtistInfo::canBeRun() bool ShowArtistInfo::canBeRun()
{ {
#ifdef HAVE_CURL_CURL_H
return myScreen == myLastfm return myScreen == myLastfm
|| (myScreen->isActiveWindow(myLibrary->Tags) || (myScreen->isActiveWindow(myLibrary->Tags)
&& !myLibrary->Tags.empty() && !myLibrary->Tags.empty()
&& Config.media_lib_primary_tag == MPD_TAG_ARTIST) && Config.media_lib_primary_tag == MPD_TAG_ARTIST)
|| currentSong(myScreen); || currentSong(myScreen);
# else
return false;
# endif // NOT HAVE_CURL_CURL_H
} }
void ShowArtistInfo::run() void ShowArtistInfo::run()
{ {
# ifdef HAVE_CURL_CURL_H
if (myScreen == myLastfm) if (myScreen == myLastfm)
{ {
myLastfm->switchTo(); myLastfm->switchTo();
@@ -2441,7 +2402,6 @@ void ShowArtistInfo::run()
myLastfm->queueJob(new LastFm::ArtistInfo(artist, Config.lastfm_preferred_language)); myLastfm->queueJob(new LastFm::ArtistInfo(artist, Config.lastfm_preferred_language));
myLastfm->switchTo(); myLastfm->switchTo();
} }
# endif // HAVE_CURL_CURL_H
} }
bool ShowLyrics::canBeRun() bool ShowLyrics::canBeRun()

View File

@@ -644,9 +644,6 @@ struct ToggleLyricsFetcher: BaseAction
ToggleLyricsFetcher(): BaseAction(Type::ToggleLyricsFetcher, "toggle_lyrics_fetcher") { } ToggleLyricsFetcher(): BaseAction(Type::ToggleLyricsFetcher, "toggle_lyrics_fetcher") { }
private: private:
# ifndef HAVE_CURL_CURL_H
virtual bool canBeRun() override;
# endif // NOT HAVE_CURL_CURL_H
virtual void run() override; virtual void run() override;
}; };
@@ -656,9 +653,6 @@ struct ToggleFetchingLyricsInBackground: BaseAction
: BaseAction(Type::ToggleFetchingLyricsInBackground, "toggle_fetching_lyrics_in_background") { } : BaseAction(Type::ToggleFetchingLyricsInBackground, "toggle_fetching_lyrics_in_background") { }
private: private:
# ifndef HAVE_CURL_CURL_H
virtual bool canBeRun() override;
# endif // NOT HAVE_CURL_CURL_H
virtual void run() override; virtual void run() override;
}; };

View File

@@ -106,9 +106,6 @@ bool configure(int argc, char **argv)
<< " - tag editor\n" << " - tag editor\n"
<< " - tiny tag editor\n" << " - tiny tag editor\n"
# endif # endif
# ifdef HAVE_CURL_CURL_H
<< " - artist info\n"
# endif
# ifdef ENABLE_OUTPUTS # ifdef ENABLE_OUTPUTS
<< " - outputs\n" << " - outputs\n"
# endif # endif
@@ -125,9 +122,6 @@ bool configure(int argc, char **argv)
<< "disabled" << "disabled"
# endif // HAVE_LANGINFO_H # endif // HAVE_LANGINFO_H
<< "\nbuilt with support for:" << "\nbuilt with support for:"
# ifdef HAVE_CURL_CURL_H
<< " curl"
# endif
# ifdef HAVE_FFTW3_H # ifdef HAVE_FFTW3_H
<< " fftw" << " fftw"
# endif # endif

View File

@@ -20,8 +20,6 @@
#include "curl_handle.h" #include "curl_handle.h"
#ifdef HAVE_CURL_CURL_H
#include <cstdlib> #include <cstdlib>
namespace namespace
@@ -62,5 +60,3 @@ std::string Curl::escape(const std::string &s)
curl_free(cs); curl_free(cs);
return result; return result;
} }
#endif // HAVE_CURL_CURL_H

View File

@@ -23,8 +23,6 @@
#include "config.h" #include "config.h"
#ifdef HAVE_CURL_CURL_H
#include <string> #include <string>
#include "curl/curl.h" #include "curl/curl.h"
@@ -35,7 +33,4 @@ namespace Curl
std::string escape(const std::string &s); std::string escape(const std::string &s);
} }
#endif // HAVE_CURL_CURL_H
#endif // NCMPCPP_CURL_HANDLE_H #endif // NCMPCPP_CURL_HANDLE_H

View File

@@ -229,11 +229,9 @@ void write_bindings(NC::Scrollpad &w)
key(w, Type::ToggleSeparatorsBetweenAlbums, "Toggle displaying separators between albums"); key(w, Type::ToggleSeparatorsBetweenAlbums, "Toggle displaying separators between albums");
key(w, Type::JumpToPositionInSong, "Jump to given position in playing song (formats: mm:ss, x%)"); key(w, Type::JumpToPositionInSong, "Jump to given position in playing song (formats: mm:ss, x%)");
key(w, Type::ShowSongInfo, "Show song info"); key(w, Type::ShowSongInfo, "Show song info");
# ifdef HAVE_CURL_CURL_H
key(w, Type::ShowArtistInfo, "Show artist info"); key(w, Type::ShowArtistInfo, "Show artist info");
key(w, Type::ToggleLyricsFetcher, "Toggle lyrics fetcher"); key(w, Type::ToggleLyricsFetcher, "Toggle lyrics fetcher");
key(w, Type::ToggleFetchingLyricsInBackground, "Toggle fetching lyrics for playing songs in background"); key(w, Type::ToggleFetchingLyricsInBackground, "Toggle fetching lyrics for playing songs in background");
# endif // HAVE_CURL_CURL_H
key(w, Type::ShowLyrics, "Show/hide song lyrics"); key(w, Type::ShowLyrics, "Show/hide song lyrics");
w << '\n'; w << '\n';
key(w, Type::Quit, "Quit"); key(w, Type::Quit, "Quit");

View File

@@ -20,8 +20,6 @@
#include "lastfm.h" #include "lastfm.h"
#ifdef HAVE_CURL_CURL_H
#include "helpers.h" #include "helpers.h"
#include "charset.h" #include "charset.h"
#include "global.h" #include "global.h"
@@ -89,5 +87,3 @@ void Lastfm::getResult()
// reset m_worker so it's no longer valid // reset m_worker so it's no longer valid
m_worker = std::future<LastFm::Service::Result>(); m_worker = std::future<LastFm::Service::Result>();
} }
#endif // HVAE_CURL_CURL_H

View File

@@ -23,8 +23,6 @@
#include "config.h" #include "config.h"
#ifdef HAVE_CURL_CURL_H
#include <future> #include <future>
#include <memory> #include <memory>
@@ -77,7 +75,4 @@ private:
extern Lastfm *myLastfm; extern Lastfm *myLastfm;
#endif // HAVE_CURL_CURL_H
#endif // NCMPCPP_LASTFM_H #endif // NCMPCPP_LASTFM_H

View File

@@ -20,8 +20,6 @@
#include "lastfm_service.h" #include "lastfm_service.h"
#ifdef HAVE_CURL_CURL_H
#include <boost/algorithm/string/trim.hpp> #include <boost/algorithm/string/trim.hpp>
#include <boost/locale/conversion.hpp> #include <boost/locale/conversion.hpp>
#include <fstream> #include <fstream>
@@ -210,6 +208,3 @@ Service::Result ArtistInfo::processData(const std::string &data)
} }
} }
#endif

View File

@@ -23,8 +23,6 @@
#include "config.h" #include "config.h"
#ifdef HAVE_CURL_CURL_H
#include <map> #include <map>
#include <string> #include <string>
@@ -75,6 +73,4 @@ protected:
} }
#endif // HAVE_CURL_CURL_H
#endif // NCMPCPP_LASTFM_SERVICE_H #endif // NCMPCPP_LASTFM_SERVICE_H

View File

@@ -105,4 +105,3 @@ private:
extern Lyrics *myLyrics; extern Lyrics *myLyrics;
#endif // NCMPCPP_LYRICS_H #endif // NCMPCPP_LYRICS_H

View File

@@ -21,8 +21,6 @@
#include "config.h" #include "config.h"
#include "curl_handle.h" #include "curl_handle.h"
#ifdef HAVE_CURL_CURL_H
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/join.hpp>
@@ -264,6 +262,3 @@ bool InternetLyricsFetcher::isURLOk(const std::string &url)
URL = url; URL = url;
return false; return false;
} }
#endif // HAVE_CURL_CURL_H

View File

@@ -23,8 +23,6 @@
#include "config.h" #include "config.h"
#ifdef HAVE_CURL_CURL_H
#include <memory> #include <memory>
#include <string> #include <string>
@@ -156,6 +154,4 @@ private:
std::string URL; std::string URL;
}; };
#endif // HAVE_CURL_CURL_H
#endif // NCMPCPP_LYRICS_FETCHER_H #endif // NCMPCPP_LYRICS_FETCHER_H

View File

@@ -51,10 +51,8 @@ std::string screenTypeToString(ScreenType st)
#endif // ENABLE_CLOCK #endif // ENABLE_CLOCK
case ScreenType::Help: case ScreenType::Help:
return "help"; return "help";
#ifdef HAVE_CURL_CURL_H
case ScreenType::Lastfm: case ScreenType::Lastfm:
return "last_fm"; return "last_fm";
#endif // HAVE_CURL_CURL_H
case ScreenType::Lyrics: case ScreenType::Lyrics:
return "lyrics"; return "lyrics";
case ScreenType::MediaLibrary: case ScreenType::MediaLibrary:
@@ -135,10 +133,8 @@ ScreenType stringToScreenType(const std::string &s)
{ {
if (s == "lyrics") if (s == "lyrics")
result = ScreenType::Lyrics; result = ScreenType::Lyrics;
# ifdef HAVE_CURL_CURL_H
else if (s == "last_fm") else if (s == "last_fm")
result = ScreenType::Lastfm; result = ScreenType::Lastfm;
# endif // HAVE_CURL_CURL_H
else if (s == "selected_items_adder") else if (s == "selected_items_adder")
result = ScreenType::SelectedItemsAdder; result = ScreenType::SelectedItemsAdder;
else if (s == "server_info") else if (s == "server_info")
@@ -167,10 +163,8 @@ BaseScreen *toScreen(ScreenType st)
# endif // ENABLE_CLOCK # endif // ENABLE_CLOCK
case ScreenType::Help: case ScreenType::Help:
return myHelp; return myHelp;
# ifdef HAVE_CURL_CURL_H
case ScreenType::Lastfm: case ScreenType::Lastfm:
return myLastfm; return myLastfm;
# endif // HAVE_CURL_CURL_H
case ScreenType::Lyrics: case ScreenType::Lyrics:
return myLyrics; return myLyrics;
case ScreenType::MediaLibrary: case ScreenType::MediaLibrary:

View File

@@ -33,9 +33,7 @@ enum class ScreenType {
Clock, Clock,
# endif // ENABLE_CLOCK # endif // ENABLE_CLOCK
Help, Help,
# ifdef HAVE_CURL_CURL_H
Lastfm, Lastfm,
# endif // HAVE_CURL_CURL_H
Lyrics, Lyrics,
MediaLibrary, MediaLibrary,
# ifdef ENABLE_OUTPUTS # ifdef ENABLE_OUTPUTS

View File

@@ -572,10 +572,8 @@ void Status::Changes::songID(int song_id)
if (!Config.execute_on_song_change.empty()) if (!Config.execute_on_song_change.empty())
res = system(Config.execute_on_song_change.c_str()); res = system(Config.execute_on_song_change.c_str());
# ifdef HAVE_CURL_CURL_H
if (Config.fetch_lyrics_in_background) if (Config.fetch_lyrics_in_background)
myLyrics->fetchInBackground(s); myLyrics->fetchInBackground(s);
# endif // HAVE_CURL_CURL_H
drawTitle(s); drawTitle(s);