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.
* The list of lyrics fetchers can now be set via configuration file.
* Lyrics can now be fetched for songs with no tags.
* libcurl dependency is no longer optional.
ncmpcpp-0.7.7 (2016-10-31)
* 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(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(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])
fi
dnl =====================
dnl = checking for curl =
dnl =====================
if test "$curl" != "no" ; then
AC_PATH_PROG(CURL_CONFIG, curl-config)
if test "$CURL_CONFIG" != "" ; then
CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS `$CURL_CONFIG --libs`",
if test "$curl" = "yes" ; then
AC_MSG_ERROR([curl library is required])
fi
)
AC_CHECK_HEADERS([curl/curl.h], ,
if test "$curl" = "yes" ; then
AC_MSG_ERROR([missing curl.h header])
fi
)
else
AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS -lcurl",
if test "$curl" = "yes" ; then
AC_MSG_ERROR([curl library is required])
fi
)
fi
fi
dnl ========================
dnl = checking for libcurl =
dnl ========================
PKG_CHECK_MODULES([libcurl], [libcurl], [
AC_SUBST(libcurl_CFLAGS)
AC_SUBST(libcurl_LIBS)
CPPFLAGS="$CPPFLAGS $libcurl_CFLAGS"
AC_CHECK_HEADERS([curl/curl.h],
LIBS="$LIBS $libcurl_LIBS"
,
AC_MSG_ERROR([missing curl/curl.h header])
)
],
AC_MSG_ERROR([libcurl is required!])
)
dnl AC_PATH_PROG(CURL_CONFIG, curl-config)
dnl if test "$CURL_CONFIG" != "" ; then
dnl CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
dnl AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS `$CURL_CONFIG --libs`",
dnl if test "$curl" = "yes" ; then
dnl AC_MSG_ERROR([curl library is required])
dnl fi
dnl )
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 = checking for taglib =

View File

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

View File

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

View File

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

View File

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

View File

@@ -23,8 +23,6 @@
#include "config.h"
#ifdef HAVE_CURL_CURL_H
#include <string>
#include "curl/curl.h"
@@ -35,7 +33,4 @@ namespace Curl
std::string escape(const std::string &s);
}
#endif // HAVE_CURL_CURL_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::JumpToPositionInSong, "Jump to given position in playing song (formats: mm:ss, x%)");
key(w, Type::ShowSongInfo, "Show song info");
# ifdef HAVE_CURL_CURL_H
key(w, Type::ShowArtistInfo, "Show artist info");
key(w, Type::ToggleLyricsFetcher, "Toggle lyrics fetcher");
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");
w << '\n';
key(w, Type::Quit, "Quit");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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