remove support for PDCurses
[ncmpcpp.git] / configure.ac
blob6cfde691439080b4804e7e1a13aaa112b5245821
1 AC_INIT(configure.ac)
3 AC_CONFIG_HEADERS(config.h)
4 AM_INIT_AUTOMAKE(ncmpcpp, 0.7_pre)
6 AC_PREREQ(2.59)
8 AC_LANG_CPLUSPLUS
9 AC_PROG_CXX
10 AM_PROG_LIBTOOL
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])
16 AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl], [Enable fetching lyrics from the Internet @<:@default=auto@:>@]), [curl=$withval], [curl=auto])
17 AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto])
18 AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto])
20 if test "$outputs" = "yes"; then
21         AC_DEFINE([ENABLE_OUTPUTS], [1], [enables outputs screen])
24 if test "$clock" = "yes"; then
25         AC_DEFINE([ENABLE_CLOCK], [1], [enables clock screen])
28 dnl ================================
29 dnl = checking for -std=c++0x flag =
30 dnl ================================
31 AC_MSG_CHECKING([whether compiler supports -std=c++0x])
32 old_CXXFLAGS="$CXXFLAGS"
33 CXXFLAGS="-std=c++0x"
34 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]])],
35         AC_MSG_RESULT([yes])
36                 std_cpp0x="-std=c++0x",
37         AC_MSG_RESULT([no])
38                 AC_MSG_ERROR([[Your compiler doesn't seem to support C++0x, please upgrade (GCC >= 4.6)]])
40 CXXFLAGS="$old_CXXFLAGS $std_cpp0x"
42 dnl ==========================================
43 dnl = checking for initializer lists support =
44 dnl ==========================================
45 AC_MSG_CHECKING([whether compiler supports initializer lists])
46 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <vector>], [[std::vector<int> test = { 1, 2, 3 }; test.push_back(4);]])],
47         AC_MSG_RESULT([yes]),
48         AC_MSG_RESULT([no])
49                 AC_MSG_ERROR([[Your compiler doesn't seem to support initializer lists, please upgrade (GCC >= 4.6)]])
52 dnl =====================================
53 dnl = checking for auto keyword support =
54 dnl =====================================
55 AC_MSG_CHECKING([whether compiler supports auto keyword])
56 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[auto test = new int; *test = 1;]])],
57         AC_MSG_RESULT([yes]),
58         AC_MSG_RESULT([no])
59                 AC_MSG_ERROR([[Your compiler doesn't seem to support auto keyword, please upgrade (GCC >= 4.6)]])
62 dnl =========================================
63 dnl = checking for lambda functions support =
64 dnl =========================================
65 AC_MSG_CHECKING([whether compiler supports lambda functions])
66 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <functional>], [[int a = 5; std::function<int(int)> f = [&a](int b) { return a + b; }; f(8);]])],
67         AC_MSG_RESULT([yes]),
68         AC_MSG_RESULT([no])
69                 AC_MSG_ERROR([[Your compiler doesn't seem to support lambda functions, please upgrade (GCC >= 4.6)]])
72 dnl ================================================================
73 dnl = checking whether calling derived member function of object   =
74 dnl = passed to lambda without explicit 'this' usage works         =
75 dnl ================================================================
76 AC_MSG_CHECKING([whether calling derived member function passed to lambda without explicit this usage works ])
77 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();]])],
78         AC_MSG_RESULT([yes]),
79         AC_MSG_RESULT([no])
80                 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)]])
83 dnl =========================================
84 dnl = checking for override keyword support =
85 dnl =========================================
86 AH_TEMPLATE([OVERRIDE], [override keyword used in C++11])
87 AC_MSG_CHECKING([whether compiler supports override keyword])
88 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[struct A { virtual void foo() { } }; struct B : public A { virtual void foo() override { } };]], [])],
89         AC_MSG_RESULT([yes])
90                 AC_DEFINE([OVERRIDE], [override]),
91         AC_MSG_RESULT([no])
92                 AC_DEFINE([OVERRIDE], []),
95 dnl =============================
96 dnl = setting boost environment =
97 dnl =============================
98 AS_IF([test -z "${BOOST_LIB_SUFFIX+x}"], [BOOST_LIB_SUFFIX=-mt])
99 AC_ARG_VAR([BOOST_LIB_SUFFIX], [Boost library name suffix [default=-mt]])
101 dnl ======================================
102 dnl = checking for various boost headers =
103 dnl ======================================
104 AC_CHECK_HEADERS([boost/bind.hpp], ,
105         AC_MSG_ERROR(boost/bind.hpp is missing))
106 AC_CHECK_HEADERS([boost/lexical_cast.hpp], ,
107         AC_MSG_ERROR(boost/lexical_cast.hpp is missing))
108 AC_CHECK_HEADERS([boost/algorithm/string.hpp], ,
109         AC_MSG_ERROR(boost/algorithm/string.hpp is missing))
111 dnl =================================
112 dnl = checking for boost.filesystem =
113 dnl =================================
114 AC_CHECK_HEADERS([boost/filesystem.hpp], ,
115         AC_MSG_ERROR(boost/filesystem.hpp is missing)
117 AC_CHECK_LIB(boost_filesystem$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_filesystem$BOOST_LIB_SUFFIX",
118         AC_MSG_ERROR([no boost.filesystem library found])
120 AC_CHECK_LIB(boost_system$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_system$BOOST_LIB_SUFFIX",
121         AC_MSG_ERROR([no boost.system library found])
124 dnl =============================
125 dnl = checking for boost.format =
126 dnl =============================
127 AC_CHECK_HEADERS([boost/format.hpp], ,
128         AC_MSG_ERROR(boost/format.hpp is missing)
131 dnl =============================
132 dnl = checking for boost.locale =
133 dnl =============================
134 AC_CHECK_HEADERS([boost/locale.hpp], ,
135         AC_MSG_ERROR(boost/locale.hpp is missing)
137 AC_CHECK_LIB(boost_locale$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_locale$BOOST_LIB_SUFFIX",
138         AC_MSG_ERROR([no boost.locale library found])
141 dnl =================================
142 dnl = checking for boost.posix_time =
143 dnl =================================
144 AC_CHECK_HEADERS([boost/date_time/posix_time/posix_time.hpp], ,
145         AC_MSG_ERROR(boost/date_time/posix_time/posix_time.hpp is missing)
148 dnl ======================================
149 dnl = checking for boost.program_options =
150 dnl ======================================
151 AC_CHECK_HEADERS([boost/program_options.hpp], ,
152         AC_MSG_ERROR(boost/program_options.hpp is missing)
154 AC_CHECK_LIB(boost_program_options$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_program_options$BOOST_LIB_SUFFIX",
155         AC_MSG_ERROR([no boost.program_options library found])
158 dnl ============================
159 dnl = checking for boost.regex =
160 dnl ============================
161 AC_CHECK_HEADERS([boost/regex.hpp], ,
162         AC_MSG_ERROR(boost/regex.hpp is missing)
164 AC_CHECK_LIB(boost_regex$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_regex$BOOST_LIB_SUFFIX",
165         AC_MSG_ERROR([no boost.regex library found])
168 dnl =============================
169 dnl = checking for boost.thread =
170 dnl =============================
171 AC_DEFINE([BOOST_THREAD_VERSION], [3], [require boost.thread v3])
172 AC_CHECK_HEADERS([boost/thread.hpp], ,
173         AC_MSG_ERROR([boost/thread.hpp is missing or your boost version is too old (boost.thread v3 is required)])
175 AC_CHECK_LIB(boost_thread$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_thread$BOOST_LIB_SUFFIX",
176         AC_MSG_ERROR([no boost.thread library found])
179 dnl ==============================
180 dnl = checking for regex (win32) =
181 dnl ==============================
182 AC_CHECK_LIB(regex, regcomp, LDFLAGS="$LDFLAGS -lregex", )
184 dnl ================================
185 dnl = checking for various headers =
186 dnl ================================
187 AC_CHECK_HEADERS([netinet/tcp.h netinet/in.h], , AC_MSG_ERROR(vital headers missing))
188 AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled))
190 dnl ==============================
191 dnl = checking for libmpdclient2 =
192 dnl ==============================
193 PKG_CHECK_MODULES([libmpdclient], [libmpdclient >= 2.8], [
194         AC_SUBST(libmpdclient_LIBS)
195         AC_SUBST(libmpdclient_CFLAGS)
196         CPPFLAGS="$CPPFLAGS $libmpdclient_CFLAGS"
197         AC_CHECK_HEADERS([mpd/client.h],
198                 LDFLAGS="$LDFLAGS $libmpdclient_LIBS"
199         ,
200                 AC_MSG_ERROR([missing mpd/client.h header])
201         )
203         AC_MSG_ERROR([libmpdclient >= 2.8 is required!])
206 dnl =========================
207 dnl = checking for readline =
208 dnl =========================
209 AC_CHECK_HEADERS([readline/readline.h readline/history.h],
210         AC_CHECK_LIB(readline, rl_initialize, LDFLAGS="$LDFLAGS -lreadline",
211                 AC_MSG_ERROR([readline headers found but there is no readline library to make use of])
212         ),
216 dnl ========================
217 dnl = checking for pthread =
218 dnl ========================
219 AC_CHECK_HEADERS([pthread.h],
220         AC_CHECK_LIB(pthread, pthread_create, LDFLAGS="$LDFLAGS -lpthread",
221                 AC_MSG_ERROR([pthread.h found but there is no pthread library to make use of])
222         ),
225 dnl ========================
226 dnl = checking for ncurses =
227 dnl ========================
228 if test "$unicode" = "yes" ; then
229         curses_config_bin="ncursesw6-config ncursesw5-config"
230         AC_DEFINE([NCMPCPP_UNICODE], [1], [enables unicode support])
231 else
232         curses_config_bin="ncurses6-config ncurses5-config"
235 AC_PATH_PROGS(CURSES_CONFIG, $curses_config_bin)
236 if test "$CURSES_CONFIG" != "" ; then
237         CPPFLAGS="$CPPFLAGS `$CURSES_CONFIG --cflags`"
238         LDFLAGS="$LDFLAGS `$CURSES_CONFIG --libs`"
240 AC_CHECK_LIB(ncursesw, initscr,
241         curses_lib=ncursesw,
242         curses_lib=ncurses
245 AC_CHECK_LIB($curses_lib, initscr,
246         if test "$CURSES_CONFIG" = "" ; then
247                 LDFLAGS="$LDFLAGS -l$curses_lib"
248         fi
249         ,
250         AC_MSG_ERROR([$curses_lib library is required])
251         )
252 AC_CHECK_HEADERS([curses.h], , AC_MSG_ERROR([missing curses.h header]))
254 dnl ======================
255 dnl = checking for fftw3 =
256 dnl ======================
257 if test "$visualizer" = "yes" ; then
258         if test "$fftw" != "no" ; then
259                 PKG_CHECK_MODULES([fftw3], [fftw3 >= 3], [
260                         AC_SUBST(fftw3_LIBS)
261                         AC_SUBST(fftw3_CFLAGS)
262                         CPPFLAGS="$CPPFLAGS $fftw3_CFLAGS"
263                         AC_CHECK_HEADERS([fftw3.h],
264                                 LDFLAGS="$LDFLAGS $fftw3_LIBS"
265                         ,
266                                 if test "$fftw" = "yes" ; then
267                                         AC_MSG_ERROR([missing fftw3.h header])
268                                 fi
269                         )
270                 ],
271                         if test "$fftw" = "yes" ; then
272                                 AC_MSG_ERROR([fftw3 library is required!])
273                         fi
274                 )
275         fi
276         AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen])
279 dnl =====================
280 dnl = checking for curl =
281 dnl =====================
282 if test "$curl" != "no" ; then
283         AC_PATH_PROG(CURL_CONFIG, curl-config)
284         if test "$CURL_CONFIG" != "" ; then
285                 CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
286                 AC_CHECK_LIB(curl, curl_easy_init, LDFLAGS="$LDFLAGS `$CURL_CONFIG --libs`",
287                         if test "$curl" = "yes" ; then
288                                 AC_MSG_ERROR([curl library is required])
289                         fi
290                 )
291                 AC_CHECK_HEADERS([curl/curl.h], ,
292                         if test "$curl" = "yes" ; then
293                                 AC_MSG_ERROR([missing curl.h header])
294                         fi
295                 )
296         else
297                 AC_CHECK_LIB(curl, curl_easy_init, LDFLAGS="$LDFLAGS -lcurl",
298                         if test "$curl" = "yes" ; then
299                                 AC_MSG_ERROR([curl library is required])
300                         fi
301                 )
302         fi
305 dnl =======================
306 dnl = checking for taglib =
307 dnl =======================
308 if test "$taglib" != "no" ; then
309         AC_PATH_PROG(TAGLIB_CONFIG, taglib-config)
310         if test "$TAGLIB_CONFIG" != "" ; then
311                 CPPFLAGS="$CPPFLAGS `$TAGLIB_CONFIG --cflags`"
312                 LDFLAGS="$LDFLAGS `$TAGLIB_CONFIG --libs`"
313                 AC_CHECK_HEADERS([taglib.h], ,
314                         if test "$taglib" = "yes" ; then
315                                 AC_MSG_ERROR([missing taglib.h header])
316                         fi
317                 )
318         else
319                 if test "$taglib" = "yes" ; then
320                         AC_MSG_ERROR([taglib-config executable is missing])
321                 fi
322         fi
325 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile])
326 AC_OUTPUT