change version to 0.7.4
[ncmpcpp.git] / configure.ac
blob1f638af253e81b2dd8056b13045e685394b78189
1 AC_INIT(configure.ac)
2 AC_CONFIG_HEADERS(config.h)
3 AM_INIT_AUTOMAKE(ncmpcpp, 0.7.4)
5 m4_include([m4/ax_lib_readline.m4])
7 AC_PREREQ(2.59)
9 AC_LANG_CPLUSPLUS
10 AC_PROG_CXX
11 AM_PROG_LIBTOOL
13 AC_ARG_ENABLE(outputs, AS_HELP_STRING([--enable-outputs], [Enable outputs screen @<:@default=no@:>@]), [outputs=$enableval], [outputs=no])
14 AC_ARG_ENABLE(visualizer, AS_HELP_STRING([--enable-visualizer], [Enable music visualizer screen @<:@default=no@:>@]), [visualizer=$enableval], [visualizer=no])
15 AC_ARG_ENABLE(clock, AS_HELP_STRING([--enable-clock], [Enable clock screen @<:@default=no@:>@]), [clock=$enableval], [clock=no])
16 AC_ARG_ENABLE(unicode, AS_HELP_STRING([--enable-unicode], [Enable utf8 support @<:@default=yes@:>@]), [unicode=$enableval], [unicode=yes])
18 AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl], [Enable fetching lyrics from the Internet @<:@default=auto@:>@]), [curl=$withval], [curl=auto])
19 AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto])
20 AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto])
22 if test "$outputs" = "yes"; then
23         AC_DEFINE([ENABLE_OUTPUTS], [1], [enables outputs screen])
26 if test "$clock" = "yes"; then
27         AC_DEFINE([ENABLE_CLOCK], [1], [enables clock screen])
30 dnl ================================
31 dnl = checking for -std=c++0x flag =
32 dnl ================================
33 AC_MSG_CHECKING([whether compiler supports -std=c++0x])
34 old_CXXFLAGS="$CXXFLAGS"
35 CXXFLAGS="-std=c++0x"
36 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]])],
37         AC_MSG_RESULT([yes])
38                 std_cpp0x="-std=c++0x",
39         AC_MSG_RESULT([no])
40                 AC_MSG_ERROR([[Your compiler doesn't seem to support C++0x, please upgrade (GCC >= 4.6)]])
42 CXXFLAGS="$old_CXXFLAGS $std_cpp0x"
44 dnl ==========================================
45 dnl = checking for initializer lists support =
46 dnl ==========================================
47 AC_MSG_CHECKING([whether compiler supports initializer lists])
48 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <vector>], [[std::vector<int> test = { 1, 2, 3 }; test.push_back(4);]])],
49         AC_MSG_RESULT([yes]),
50         AC_MSG_RESULT([no])
51                 AC_MSG_ERROR([[Your compiler doesn't seem to support initializer lists, please upgrade (GCC >= 4.6)]])
54 dnl =====================================
55 dnl = checking for auto keyword support =
56 dnl =====================================
57 AC_MSG_CHECKING([whether compiler supports auto keyword])
58 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[auto test = new int; *test = 1;]])],
59         AC_MSG_RESULT([yes]),
60         AC_MSG_RESULT([no])
61                 AC_MSG_ERROR([[Your compiler doesn't seem to support auto keyword, please upgrade (GCC >= 4.6)]])
64 dnl =========================================
65 dnl = checking for lambda functions support =
66 dnl =========================================
67 AC_MSG_CHECKING([whether compiler supports lambda functions])
68 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <functional>], [[int a = 5; std::function<int(int)> f = [&a](int b) { return a + b; }; f(8);]])],
69         AC_MSG_RESULT([yes]),
70         AC_MSG_RESULT([no])
71                 AC_MSG_ERROR([[Your compiler doesn't seem to support lambda functions, please upgrade (GCC >= 4.6)]])
74 dnl ================================================================
75 dnl = checking whether calling derived member function of object   =
76 dnl = passed to lambda without explicit 'this' usage works         =
77 dnl ================================================================
78 AC_MSG_CHECKING([whether calling derived member function passed to lambda without explicit this usage works ])
79 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();]])],
80         AC_MSG_RESULT([yes]),
81         AC_MSG_RESULT([no])
82                 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)]])
85 dnl =========================================
86 dnl = checking for override keyword support =
87 dnl =========================================
88 AH_TEMPLATE([OVERRIDE], [override keyword used in C++11])
89 AC_MSG_CHECKING([whether compiler supports override keyword])
90 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[struct A { virtual void foo() { } }; struct B : public A { virtual void foo() override { } };]], [])],
91         AC_MSG_RESULT([yes])
92                 AC_DEFINE([OVERRIDE], [override]),
93         AC_MSG_RESULT([no])
94                 AC_DEFINE([OVERRIDE], []),
97 dnl =============================
98 dnl = setting boost environment =
99 dnl =============================
100 AS_IF([test -z "${BOOST_LIB_SUFFIX+x}"], [BOOST_LIB_SUFFIX=])
101 AC_ARG_VAR([BOOST_LIB_SUFFIX], [Boost library name suffix [default=]])
103 dnl ======================================
104 dnl = checking for various boost headers =
105 dnl ======================================
106 AC_CHECK_HEADERS([boost/bind.hpp], ,
107         AC_MSG_ERROR(boost/bind.hpp is missing))
108 AC_CHECK_HEADERS([boost/lexical_cast.hpp], ,
109         AC_MSG_ERROR(boost/lexical_cast.hpp is missing))
110 AC_CHECK_HEADERS([boost/algorithm/string.hpp], ,
111         AC_MSG_ERROR(boost/algorithm/string.hpp is missing))
113 dnl =================================
114 dnl = checking for boost.filesystem =
115 dnl =================================
116 AC_CHECK_HEADERS([boost/filesystem.hpp], ,
117         AC_MSG_ERROR(boost/filesystem.hpp is missing)
119 AC_CHECK_LIB(boost_filesystem$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_filesystem$BOOST_LIB_SUFFIX",
120         AC_MSG_ERROR([no boost.filesystem library found])
122 AC_CHECK_LIB(boost_system$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_system$BOOST_LIB_SUFFIX",
123         AC_MSG_ERROR([no boost.system library found])
126 dnl =============================
127 dnl = checking for boost.format =
128 dnl =============================
129 AC_CHECK_HEADERS([boost/format.hpp], ,
130         AC_MSG_ERROR(boost/format.hpp is missing)
133 dnl =============================
134 dnl = checking for boost.locale =
135 dnl =============================
136 AC_CHECK_HEADERS([boost/locale.hpp], ,
137         AC_MSG_ERROR(boost/locale.hpp is missing)
139 AC_CHECK_LIB(boost_locale$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_locale$BOOST_LIB_SUFFIX",
140         AC_MSG_ERROR([no boost.locale library found])
143 dnl =================================
144 dnl = checking for boost.posix_time =
145 dnl =================================
146 AC_CHECK_HEADERS([boost/date_time/posix_time/posix_time.hpp], ,
147         AC_MSG_ERROR(boost/date_time/posix_time/posix_time.hpp is missing)
150 dnl ======================================
151 dnl = checking for boost.program_options =
152 dnl ======================================
153 AC_CHECK_HEADERS([boost/program_options.hpp], ,
154         AC_MSG_ERROR(boost/program_options.hpp is missing)
156 AC_CHECK_LIB(boost_program_options$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_program_options$BOOST_LIB_SUFFIX",
157         AC_MSG_ERROR([no boost.program_options library found])
160 dnl ============================
161 dnl = checking for boost.regex =
162 dnl ============================
163 AC_CHECK_HEADERS([boost/regex.hpp], ,
164         AC_MSG_ERROR(boost/regex.hpp is missing)
166 AC_CHECK_LIB(boost_regex$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_regex$BOOST_LIB_SUFFIX",
167         AC_MSG_ERROR([no boost.regex library found])
170 dnl ====================
171 dnl = checking for icu =
172 dnl ====================
173 AH_TEMPLATE([BOOST_REGEX_ICU], [boost.regex was compiled with ICU support])
174 PKG_CHECK_MODULES([ICU], [icu-uc], [
175         old_CPPFLAGS="$CPPFLAGS"
176         old_LIBS="$LIBS"
177         AC_SUBST(ICU_CFLAGS)
178         AC_SUBST(ICU_LIBS)
179         CPPFLAGS="$CPPFLAGS $ICU_CFLAGS"
180         LIBS="$LIBS $ICU_LIBS"
181         AC_MSG_CHECKING([whether boost.regex was compiled with ICU support])
182         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_MSG_RESULT([yes])
184                 AC_DEFINE([BOOST_REGEX_ICU], [1]),
185         AC_MSG_RESULT([no])
186                 CPPFLAGS="$old_CPPFLAGS"
187                 LIBS="$old_LIBS",
188         )
189 ], [[]])
191 dnl =============================
192 dnl = checking for boost.thread =
193 dnl =============================
194 AC_DEFINE([BOOST_THREAD_VERSION], [3], [require boost.thread v3])
195 AC_CHECK_HEADERS([boost/thread.hpp], ,
196         AC_MSG_ERROR([boost/thread.hpp is missing or your boost version is too old (boost.thread v3 is required)])
198 AC_CHECK_LIB(boost_thread$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_thread$BOOST_LIB_SUFFIX",
199         AC_MSG_ERROR([no boost.thread library found])
202 dnl ================================
203 dnl = checking for various headers =
204 dnl ================================
205 AC_CHECK_HEADERS([netinet/tcp.h netinet/in.h], , AC_MSG_ERROR(vital headers missing))
206 AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled))
208 dnl ==============================
209 dnl = checking for libmpdclient2 =
210 dnl ==============================
211 PKG_CHECK_MODULES([libmpdclient], [libmpdclient >= 2.8], [
212         AC_SUBST(libmpdclient_CFLAGS)
213         AC_SUBST(libmpdclient_LIBS)
214         CPPFLAGS="$CPPFLAGS $libmpdclient_CFLAGS"
215         AC_CHECK_HEADERS([mpd/client.h],
216                 LIBS="$LIBS $libmpdclient_LIBS"
217         ,
218                 AC_MSG_ERROR([missing mpd/client.h header])
219         )
221         AC_MSG_ERROR([libmpdclient >= 2.8 is required!])
224 dnl =========================
225 dnl = checking for readline =
226 dnl =========================
227 AX_LIB_READLINE
228 if test "$ax_cv_lib_readline" = "no"; then
229   AC_MSG_ERROR([no readline compatible library found])
231 if test "$ax_cv_lib_readline_history" = "no"; then
232   AC_MSG_WARN([readline library has no history functionality])
235 dnl ========================
236 dnl = checking for pthread =
237 dnl ========================
238 AC_CHECK_HEADERS([pthread.h],
239         AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread",
240                 AC_MSG_ERROR([pthread.h found but there is no pthread library to make use of])
241         ),
242         AC_MSG_ERROR([no pthread.h header header file found])
245 dnl ========================
246 dnl = checking for ncurses =
247 dnl ========================
248 if test "$unicode" = "yes" ; then
249         curses_config_bin="ncursesw6-config ncursesw5-config"
250         AC_DEFINE([NCMPCPP_UNICODE], [1], [enables unicode support])
251 else
252         curses_config_bin="ncurses6-config ncurses5-config"
255 AC_PATH_PROGS(CURSES_CONFIG, $curses_config_bin)
256 if test "$CURSES_CONFIG" != "" ; then
257         CPPFLAGS="$CPPFLAGS `$CURSES_CONFIG --cflags`"
258         LIBS="$LIBS `$CURSES_CONFIG --libs`"
260 AC_CHECK_LIB(ncursesw, initscr,
261         curses_lib=ncursesw,
262         curses_lib=ncurses
265 AC_CHECK_LIB($curses_lib, initscr,
266         if test "$CURSES_CONFIG" = "" ; then
267                 LIBS="$LIBS -l$curses_lib"
268         fi
269         ,
270         AC_MSG_ERROR([$curses_lib library is required])
271         )
272 AC_CHECK_HEADERS([curses.h], , AC_MSG_ERROR([missing curses.h header]))
274 dnl ======================
275 dnl = checking for fftw3 =
276 dnl ======================
277 if test "$visualizer" = "yes" ; then
278         if test "$fftw" != "no" ; then
279                 PKG_CHECK_MODULES([fftw3], [fftw3 >= 3], [
280                         AC_SUBST(fftw3_LIBS)
281                         AC_SUBST(fftw3_CFLAGS)
282                         CPPFLAGS="$CPPFLAGS $fftw3_CFLAGS"
283                         AC_CHECK_HEADERS([fftw3.h],
284                                 LIBS="$LIBS $fftw3_LIBS"
285                         ,
286                                 if test "$fftw" = "yes" ; then
287                                         AC_MSG_ERROR([missing fftw3.h header])
288                                 fi
289                         )
290                 ],
291                         if test "$fftw" = "yes" ; then
292                                 AC_MSG_ERROR([fftw3 library is required!])
293                         fi
294                 )
295         fi
296         AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen])
299 dnl =====================
300 dnl = checking for curl =
301 dnl =====================
302 if test "$curl" != "no" ; then
303         AC_PATH_PROG(CURL_CONFIG, curl-config)
304         if test "$CURL_CONFIG" != "" ; then
305                 CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
306                 AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS `$CURL_CONFIG --libs`",
307                         if test "$curl" = "yes" ; then
308                                 AC_MSG_ERROR([curl library is required])
309                         fi
310                 )
311                 AC_CHECK_HEADERS([curl/curl.h], ,
312                         if test "$curl" = "yes" ; then
313                                 AC_MSG_ERROR([missing curl.h header])
314                         fi
315                 )
316         else
317                 AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS -lcurl",
318                         if test "$curl" = "yes" ; then
319                                 AC_MSG_ERROR([curl library is required])
320                         fi
321                 )
322         fi
325 dnl =======================
326 dnl = checking for taglib =
327 dnl =======================
328 if test "$taglib" != "no" ; then
329         AC_PATH_PROG(TAGLIB_CONFIG, taglib-config)
330         if test "$TAGLIB_CONFIG" != "" ; then
331                 CPPFLAGS="$CPPFLAGS `$TAGLIB_CONFIG --cflags`"
332                 LIBS="$LIBS `$TAGLIB_CONFIG --libs`"
333                 AC_CHECK_HEADERS([taglib.h], ,
334                         if test "$taglib" = "yes" ; then
335                                 AC_MSG_ERROR([missing taglib.h header])
336                         fi
337                 )
338         else
339                 if test "$taglib" = "yes" ; then
340                         AC_MSG_ERROR([taglib-config executable is missing])
341                 fi
342         fi
345 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile])
346 AC_OUTPUT