3 AC_CONFIG_HEADERS(config.h)
4 AM_INIT_AUTOMAKE(ncmpcpp, 0.7_pre)
12 AC_ARG_ENABLE(outputs, AS_HELP_STRING([--enable-outputs], [Enable outputs screen @<:@default=no@:>@]), [outputs=$enableval], [outputs=no])
13 AC_ARG_ENABLE(visualizer, AS_HELP_STRING([--enable-visualizer], [Enable music visualizer screen @<:@default=no@:>@]), [visualizer=$enableval], [visualizer=no])
14 AC_ARG_ENABLE(clock, AS_HELP_STRING([--enable-clock], [Enable clock screen @<:@default=no@:>@]), [clock=$enableval], [clock=no])
15 AC_ARG_ENABLE(unicode, AS_HELP_STRING([--enable-unicode], [Enable utf8 support @<:@default=yes@:>@]), [unicode=$enableval], [unicode=yes])
17 AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl], [Enable fetching lyrics from the Internet @<:@default=auto@:>@]), [curl=$withval], [curl=auto])
18 AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto])
19 AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto])
21 if test "$outputs" = "yes"; then
22 AC_DEFINE([ENABLE_OUTPUTS], [1], [enables outputs screen])
25 if test "$clock" = "yes"; then
26 AC_DEFINE([ENABLE_CLOCK], [1], [enables clock screen])
29 dnl ================================
30 dnl = checking for -std=c++0x flag =
31 dnl ================================
32 AC_MSG_CHECKING([whether compiler supports -std=c++0x])
33 old_CXXFLAGS="$CXXFLAGS"
35 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]])],
37 std_cpp0x="-std=c++0x",
39 AC_MSG_ERROR([[Your compiler doesn't seem to support C++0x, please upgrade (GCC >= 4.6)]])
41 CXXFLAGS="$old_CXXFLAGS $std_cpp0x"
43 dnl ==========================================
44 dnl = checking for initializer lists support =
45 dnl ==========================================
46 AC_MSG_CHECKING([whether compiler supports initializer lists])
47 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <vector>], [[std::vector<int> test = { 1, 2, 3 }; test.push_back(4);]])],
50 AC_MSG_ERROR([[Your compiler doesn't seem to support initializer lists, please upgrade (GCC >= 4.6)]])
53 dnl =====================================
54 dnl = checking for auto keyword support =
55 dnl =====================================
56 AC_MSG_CHECKING([whether compiler supports auto keyword])
57 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[auto test = new int; *test = 1;]])],
60 AC_MSG_ERROR([[Your compiler doesn't seem to support auto keyword, please upgrade (GCC >= 4.6)]])
63 dnl =========================================
64 dnl = checking for lambda functions support =
65 dnl =========================================
66 AC_MSG_CHECKING([whether compiler supports lambda functions])
67 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <functional>], [[int a = 5; std::function<int(int)> f = [&a](int b) { return a + b; }; f(8);]])],
70 AC_MSG_ERROR([[Your compiler doesn't seem to support lambda functions, please upgrade (GCC >= 4.6)]])
73 dnl ================================================================
74 dnl = checking whether calling derived member function of object =
75 dnl = passed to lambda without explicit 'this' usage works =
76 dnl ================================================================
77 AC_MSG_CHECKING([whether calling derived member function passed to lambda without explicit this usage works ])
78 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <functional>], [[struct A { void foo() { } }; struct B : public A { void bar() { std::function<void()> f = [this]() { foo(); }; f(); } } foo; foo.bar();]])],
81 AC_MSG_ERROR([[Your compiler doesn't seem to support calling derived member function of an object passed to lambda as 'this' without explicit 'this' usage, please upgrade (GCC >= 4.6)]])
84 dnl =========================================
85 dnl = checking for override keyword support =
86 dnl =========================================
87 AH_TEMPLATE([OVERRIDE], [override keyword used in C++11])
88 AC_MSG_CHECKING([whether compiler supports override keyword])
89 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[struct A { virtual void foo() { } }; struct B : public A { virtual void foo() override { } };]], [])],
91 AC_DEFINE([OVERRIDE], [override]),
93 AC_DEFINE([OVERRIDE], []),
96 dnl =============================
97 dnl = setting boost environment =
98 dnl =============================
99 AS_IF([test -z "${BOOST_LIB_SUFFIX+x}"], [BOOST_LIB_SUFFIX=])
100 AC_ARG_VAR([BOOST_LIB_SUFFIX], [Boost library name suffix [default=]])
102 dnl ======================================
103 dnl = checking for various boost headers =
104 dnl ======================================
105 AC_CHECK_HEADERS([boost/bind.hpp], ,
106 AC_MSG_ERROR(boost/bind.hpp is missing))
107 AC_CHECK_HEADERS([boost/lexical_cast.hpp], ,
108 AC_MSG_ERROR(boost/lexical_cast.hpp is missing))
109 AC_CHECK_HEADERS([boost/algorithm/string.hpp], ,
110 AC_MSG_ERROR(boost/algorithm/string.hpp is missing))
112 dnl =================================
113 dnl = checking for boost.filesystem =
114 dnl =================================
115 AC_CHECK_HEADERS([boost/filesystem.hpp], ,
116 AC_MSG_ERROR(boost/filesystem.hpp is missing)
118 AC_CHECK_LIB(boost_filesystem$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_filesystem$BOOST_LIB_SUFFIX",
119 AC_MSG_ERROR([no boost.filesystem library found])
121 AC_CHECK_LIB(boost_system$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_system$BOOST_LIB_SUFFIX",
122 AC_MSG_ERROR([no boost.system library found])
125 dnl =============================
126 dnl = checking for boost.format =
127 dnl =============================
128 AC_CHECK_HEADERS([boost/format.hpp], ,
129 AC_MSG_ERROR(boost/format.hpp is missing)
132 dnl =============================
133 dnl = checking for boost.locale =
134 dnl =============================
135 AC_CHECK_HEADERS([boost/locale.hpp], ,
136 AC_MSG_ERROR(boost/locale.hpp is missing)
138 AC_CHECK_LIB(boost_locale$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_locale$BOOST_LIB_SUFFIX",
139 AC_MSG_ERROR([no boost.locale library found])
142 dnl =================================
143 dnl = checking for boost.posix_time =
144 dnl =================================
145 AC_CHECK_HEADERS([boost/date_time/posix_time/posix_time.hpp], ,
146 AC_MSG_ERROR(boost/date_time/posix_time/posix_time.hpp is missing)
149 dnl ======================================
150 dnl = checking for boost.program_options =
151 dnl ======================================
152 AC_CHECK_HEADERS([boost/program_options.hpp], ,
153 AC_MSG_ERROR(boost/program_options.hpp is missing)
155 AC_CHECK_LIB(boost_program_options$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_program_options$BOOST_LIB_SUFFIX",
156 AC_MSG_ERROR([no boost.program_options library found])
159 dnl ============================
160 dnl = checking for boost.regex =
161 dnl ============================
162 AC_CHECK_HEADERS([boost/regex.hpp], ,
163 AC_MSG_ERROR(boost/regex.hpp is missing)
165 AC_CHECK_LIB(boost_regex$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_regex$BOOST_LIB_SUFFIX",
166 AC_MSG_ERROR([no boost.regex library found])
169 dnl ====================
170 dnl = checking for icu =
171 dnl ====================
172 AH_TEMPLATE([BOOST_REGEX_ICU], [boost.regex was compiled with ICU support])
173 PKG_CHECK_MODULES([ICU], [icu-uc], [
174 old_CPPFLAGS="$CPPFLAGS"
178 CPPFLAGS="$CPPFLAGS $ICU_CFLAGS"
179 LIBS="$LIBS $ICU_LIBS"
180 AC_MSG_CHECKING([whether boost.regex was compiled with ICU support])
181 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <boost/regex/icu.hpp>]], [[boost::u32regex rx = boost::make_u32regex("foo"); if (boost::u32regex_search("foobar", rx)) { }]])],
183 AC_DEFINE([BOOST_REGEX_ICU], [1]),
185 CPPFLAGS="$old_CPPFLAGS"
190 dnl =============================
191 dnl = checking for boost.thread =
192 dnl =============================
193 AC_DEFINE([BOOST_THREAD_VERSION], [3], [require boost.thread v3])
194 AC_CHECK_HEADERS([boost/thread.hpp], ,
195 AC_MSG_ERROR([boost/thread.hpp is missing or your boost version is too old (boost.thread v3 is required)])
197 AC_CHECK_LIB(boost_thread$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_thread$BOOST_LIB_SUFFIX",
198 AC_MSG_ERROR([no boost.thread library found])
201 dnl ================================
202 dnl = checking for various headers =
203 dnl ================================
204 AC_CHECK_HEADERS([netinet/tcp.h netinet/in.h], , AC_MSG_ERROR(vital headers missing))
205 AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled))
207 dnl ==============================
208 dnl = checking for libmpdclient2 =
209 dnl ==============================
210 PKG_CHECK_MODULES([libmpdclient], [libmpdclient >= 2.8], [
211 AC_SUBST(libmpdclient_CFLAGS)
212 AC_SUBST(libmpdclient_LIBS)
213 CPPFLAGS="$CPPFLAGS $libmpdclient_CFLAGS"
214 AC_CHECK_HEADERS([mpd/client.h],
215 LIBS="$LIBS $libmpdclient_LIBS"
217 AC_MSG_ERROR([missing mpd/client.h header])
220 AC_MSG_ERROR([libmpdclient >= 2.8 is required!])
223 dnl =========================
224 dnl = checking for readline =
225 dnl =========================
226 AC_CHECK_HEADERS([readline/readline.h readline/history.h],
227 AC_CHECK_LIB(readline, rl_initialize, LIBS="$LIBS -lreadline",
228 AC_MSG_ERROR([readline headers found but there is no readline library to make use of])
230 AC_MSG_ERROR([no readline/readline.h header file found])
234 dnl ========================
235 dnl = checking for pthread =
236 dnl ========================
237 AC_CHECK_HEADERS([pthread.h],
238 AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread",
239 AC_MSG_ERROR([pthread.h found but there is no pthread library to make use of])
241 AC_MSG_ERROR([no pthread.h header header file found])
244 dnl ========================
245 dnl = checking for ncurses =
246 dnl ========================
247 if test "$unicode" = "yes" ; then
248 curses_config_bin="ncursesw6-config ncursesw5-config"
249 AC_DEFINE([NCMPCPP_UNICODE], [1], [enables unicode support])
251 curses_config_bin="ncurses6-config ncurses5-config"
254 AC_PATH_PROGS(CURSES_CONFIG, $curses_config_bin)
255 if test "$CURSES_CONFIG" != "" ; then
256 CPPFLAGS="$CPPFLAGS `$CURSES_CONFIG --cflags`"
257 LIBS="$LIBS `$CURSES_CONFIG --libs`"
259 AC_CHECK_LIB(ncursesw, initscr,
264 AC_CHECK_LIB($curses_lib, initscr,
265 if test "$CURSES_CONFIG" = "" ; then
266 LIBS="$LIBS -l$curses_lib"
269 AC_MSG_ERROR([$curses_lib library is required])
271 AC_CHECK_HEADERS([curses.h], , AC_MSG_ERROR([missing curses.h header]))
273 dnl ======================
274 dnl = checking for fftw3 =
275 dnl ======================
276 if test "$visualizer" = "yes" ; then
277 if test "$fftw" != "no" ; then
278 PKG_CHECK_MODULES([fftw3], [fftw3 >= 3], [
280 AC_SUBST(fftw3_CFLAGS)
281 CPPFLAGS="$CPPFLAGS $fftw3_CFLAGS"
282 AC_CHECK_HEADERS([fftw3.h],
283 LIBS="$LIBS $fftw3_LIBS"
285 if test "$fftw" = "yes" ; then
286 AC_MSG_ERROR([missing fftw3.h header])
290 if test "$fftw" = "yes" ; then
291 AC_MSG_ERROR([fftw3 library is required!])
295 AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen])
298 dnl =====================
299 dnl = checking for curl =
300 dnl =====================
301 if test "$curl" != "no" ; then
302 AC_PATH_PROG(CURL_CONFIG, curl-config)
303 if test "$CURL_CONFIG" != "" ; then
304 CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
305 AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS `$CURL_CONFIG --libs`",
306 if test "$curl" = "yes" ; then
307 AC_MSG_ERROR([curl library is required])
310 AC_CHECK_HEADERS([curl/curl.h], ,
311 if test "$curl" = "yes" ; then
312 AC_MSG_ERROR([missing curl.h header])
316 AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS -lcurl",
317 if test "$curl" = "yes" ; then
318 AC_MSG_ERROR([curl library is required])
324 dnl =======================
325 dnl = checking for taglib =
326 dnl =======================
327 if test "$taglib" != "no" ; then
328 AC_PATH_PROG(TAGLIB_CONFIG, taglib-config)
329 if test "$TAGLIB_CONFIG" != "" ; then
330 CPPFLAGS="$CPPFLAGS `$TAGLIB_CONFIG --cflags`"
331 LIBS="$LIBS `$TAGLIB_CONFIG --libs`"
332 AC_CHECK_HEADERS([taglib.h], ,
333 if test "$taglib" = "yes" ; then
334 AC_MSG_ERROR([missing taglib.h header])
338 if test "$taglib" = "yes" ; then
339 AC_MSG_ERROR([taglib-config executable is missing])
344 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile])