configure: require c++14 compatible compiler
[ncmpcpp.git] / configure.ac
blob4b888c7a686c5f2654f9fa00bdaa9bdbc9386d29
1 AC_INIT(configure.ac)
2 AC_CONFIG_HEADERS(config.h)
3 AM_INIT_AUTOMAKE(ncmpcpp, 0.8_dev)
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++14 flag =
32 dnl ================================
33 AC_MSG_CHECKING([whether compiler supports -std=c++14])
34 old_CXXFLAGS="$CXXFLAGS"
35 CXXFLAGS="-std=c++14"
36 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]])],
37         AC_MSG_RESULT([yes])
38                 std_cpp14="-std=c++14",
39         AC_MSG_RESULT([no])
40                 AC_MSG_ERROR([[Your compiler doesn't seem to support C++14, please upgrade (GCC >= 5)]])
42 CXXFLAGS="$old_CXXFLAGS $std_cpp14"
44 dnl ===================================================
45 dnl = checking for generic lambda expressions support =
46 dnl ===================================================
47 AC_MSG_CHECKING([whether compiler supports generic lambda expressions])
48 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[auto f = [](auto n) { return n*n; }; f(7);]])],
49         AC_MSG_RESULT([yes]),
50         AC_MSG_RESULT([no])
51                 AC_MSG_ERROR([[Your compiler doesn't seem to support generic lambda expressions, please upgrade (GCC >= 5)]])
54 dnl =============================
55 dnl = setting boost environment =
56 dnl =============================
57 AS_IF([test -z "${BOOST_LIB_SUFFIX+x}"], [BOOST_LIB_SUFFIX=])
58 AC_ARG_VAR([BOOST_LIB_SUFFIX], [Boost library name suffix [default=]])
60 dnl ======================================
61 dnl = checking for various boost headers =
62 dnl ======================================
63 AC_CHECK_HEADERS([boost/bind.hpp], ,
64         AC_MSG_ERROR(boost/bind.hpp is missing))
65 AC_CHECK_HEADERS([boost/lexical_cast.hpp], ,
66         AC_MSG_ERROR(boost/lexical_cast.hpp is missing))
67 AC_CHECK_HEADERS([boost/algorithm/string.hpp], ,
68         AC_MSG_ERROR(boost/algorithm/string.hpp is missing))
70 dnl =================================
71 dnl = checking for boost.filesystem =
72 dnl =================================
73 AC_CHECK_HEADERS([boost/filesystem.hpp], ,
74         AC_MSG_ERROR(boost/filesystem.hpp is missing)
76 AC_CHECK_LIB(boost_filesystem$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_filesystem$BOOST_LIB_SUFFIX",
77         AC_MSG_ERROR([no boost.filesystem library found])
79 AC_CHECK_LIB(boost_system$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_system$BOOST_LIB_SUFFIX",
80         AC_MSG_ERROR([no boost.system library found])
83 dnl =============================
84 dnl = checking for boost.format =
85 dnl =============================
86 AC_CHECK_HEADERS([boost/format.hpp], ,
87         AC_MSG_ERROR(boost/format.hpp is missing)
90 dnl =============================
91 dnl = checking for boost.locale =
92 dnl =============================
93 AC_CHECK_HEADERS([boost/locale.hpp], ,
94         AC_MSG_ERROR(boost/locale.hpp is missing)
96 AC_CHECK_LIB(boost_locale$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_locale$BOOST_LIB_SUFFIX",
97         AC_MSG_ERROR([no boost.locale library found])
100 dnl =================================
101 dnl = checking for boost.posix_time =
102 dnl =================================
103 AC_CHECK_HEADERS([boost/date_time/posix_time/posix_time.hpp], ,
104         AC_MSG_ERROR(boost/date_time/posix_time/posix_time.hpp is missing)
107 dnl ======================================
108 dnl = checking for boost.program_options =
109 dnl ======================================
110 AC_CHECK_HEADERS([boost/program_options.hpp], ,
111         AC_MSG_ERROR(boost/program_options.hpp is missing)
113 AC_CHECK_LIB(boost_program_options$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_program_options$BOOST_LIB_SUFFIX",
114         AC_MSG_ERROR([no boost.program_options library found])
117 dnl ============================
118 dnl = checking for boost.regex =
119 dnl ============================
120 AC_CHECK_HEADERS([boost/regex.hpp], ,
121         AC_MSG_ERROR(boost/regex.hpp is missing)
123 AC_CHECK_LIB(boost_regex$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_regex$BOOST_LIB_SUFFIX",
124         AC_MSG_ERROR([no boost.regex library found])
127 dnl ====================
128 dnl = checking for icu =
129 dnl ====================
130 AH_TEMPLATE([BOOST_REGEX_ICU], [boost.regex was compiled with ICU support])
131 PKG_CHECK_MODULES([ICU], [icu-uc], [
132         old_CPPFLAGS="$CPPFLAGS"
133         old_LIBS="$LIBS"
134         AC_SUBST(ICU_CFLAGS)
135         AC_SUBST(ICU_LIBS)
136         CPPFLAGS="$CPPFLAGS $ICU_CFLAGS"
137         LIBS="$LIBS $ICU_LIBS"
138         AC_MSG_CHECKING([whether boost.regex was compiled with ICU support])
139         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <boost/regex/icu.hpp>]], [[boost::u32regex rx = boost::make_u32regex("foo"); if (boost::u32regex_search("foobar", rx)) { }]])],
140         AC_MSG_RESULT([yes])
141                 AC_DEFINE([BOOST_REGEX_ICU], [1]),
142         AC_MSG_RESULT([no])
143                 CPPFLAGS="$old_CPPFLAGS"
144                 LIBS="$old_LIBS",
145         )
146 ], [[]])
148 dnl =============================
149 dnl = checking for boost.thread =
150 dnl =============================
151 AC_DEFINE([BOOST_THREAD_VERSION], [3], [require boost.thread v3])
152 AC_CHECK_HEADERS([boost/thread.hpp], ,
153         AC_MSG_ERROR([boost/thread.hpp is missing or your boost version is too old (boost.thread v3 is required)])
155 AC_CHECK_LIB(boost_thread$BOOST_LIB_SUFFIX, main, LIBS="$LIBS -lboost_thread$BOOST_LIB_SUFFIX",
156         AC_MSG_ERROR([no boost.thread library found])
159 dnl ================================
160 dnl = checking for various headers =
161 dnl ================================
162 AC_CHECK_HEADERS([netinet/tcp.h netinet/in.h], , AC_MSG_ERROR(vital headers missing))
163 AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled))
165 dnl ==============================
166 dnl = checking for libmpdclient2 =
167 dnl ==============================
168 PKG_CHECK_MODULES([libmpdclient], [libmpdclient >= 2.8], [
169         AC_SUBST(libmpdclient_CFLAGS)
170         AC_SUBST(libmpdclient_LIBS)
171         CPPFLAGS="$CPPFLAGS $libmpdclient_CFLAGS"
172         AC_CHECK_HEADERS([mpd/client.h],
173                 LIBS="$LIBS $libmpdclient_LIBS"
174         ,
175                 AC_MSG_ERROR([missing mpd/client.h header])
176         )
178         AC_MSG_ERROR([libmpdclient >= 2.8 is required!])
181 dnl =========================
182 dnl = checking for readline =
183 dnl =========================
184 AX_LIB_READLINE
185 if test "$ax_cv_lib_readline" = "no"; then
186   AC_MSG_ERROR([no readline compatible library found])
188 if test "$ax_cv_lib_readline_history" = "no"; then
189   AC_MSG_WARN([readline library has no history functionality])
192 dnl ========================
193 dnl = checking for pthread =
194 dnl ========================
195 AC_CHECK_HEADERS([pthread.h],
196         AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread",
197                 AC_MSG_ERROR([pthread.h found but there is no pthread library to make use of])
198         ),
199         AC_MSG_ERROR([no pthread.h header header file found])
202 dnl ========================
203 dnl = checking for ncurses =
204 dnl ========================
205 if test "$unicode" = "yes" ; then
206         curses_config_bin="ncursesw6-config ncursesw5-config"
207         AC_DEFINE([NCMPCPP_UNICODE], [1], [enables unicode support])
208 else
209         curses_config_bin="ncurses6-config ncurses5-config"
212 AC_PATH_PROGS(CURSES_CONFIG, $curses_config_bin)
213 if test "$CURSES_CONFIG" != "" ; then
214         CPPFLAGS="$CPPFLAGS `$CURSES_CONFIG --cflags`"
215         LIBS="$LIBS `$CURSES_CONFIG --libs`"
217 AC_CHECK_LIB(ncursesw, initscr,
218         curses_lib=ncursesw,
219         curses_lib=ncurses
222 AC_CHECK_LIB($curses_lib, initscr,
223         if test "$CURSES_CONFIG" = "" ; then
224                 LIBS="$LIBS -l$curses_lib"
225         fi
226         ,
227         AC_MSG_ERROR([$curses_lib library is required])
228         )
229 AC_CHECK_HEADERS([curses.h], , AC_MSG_ERROR([missing curses.h header]))
231 dnl ======================
232 dnl = checking for fftw3 =
233 dnl ======================
234 if test "$visualizer" = "yes" ; then
235         if test "$fftw" != "no" ; then
236                 PKG_CHECK_MODULES([fftw3], [fftw3 >= 3], [
237                         AC_SUBST(fftw3_LIBS)
238                         AC_SUBST(fftw3_CFLAGS)
239                         CPPFLAGS="$CPPFLAGS $fftw3_CFLAGS"
240                         AC_CHECK_HEADERS([fftw3.h],
241                                 LIBS="$LIBS $fftw3_LIBS"
242                         ,
243                                 if test "$fftw" = "yes" ; then
244                                         AC_MSG_ERROR([missing fftw3.h header])
245                                 fi
246                         )
247                 ],
248                         if test "$fftw" = "yes" ; then
249                                 AC_MSG_ERROR([fftw3 library is required!])
250                         fi
251                 )
252         fi
253         AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen])
256 dnl =====================
257 dnl = checking for curl =
258 dnl =====================
259 if test "$curl" != "no" ; then
260         AC_PATH_PROG(CURL_CONFIG, curl-config)
261         if test "$CURL_CONFIG" != "" ; then
262                 CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
263                 AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS `$CURL_CONFIG --libs`",
264                         if test "$curl" = "yes" ; then
265                                 AC_MSG_ERROR([curl library is required])
266                         fi
267                 )
268                 AC_CHECK_HEADERS([curl/curl.h], ,
269                         if test "$curl" = "yes" ; then
270                                 AC_MSG_ERROR([missing curl.h header])
271                         fi
272                 )
273         else
274                 AC_CHECK_LIB(curl, curl_easy_init, LIBS="$LIBS -lcurl",
275                         if test "$curl" = "yes" ; then
276                                 AC_MSG_ERROR([curl library is required])
277                         fi
278                 )
279         fi
282 dnl =======================
283 dnl = checking for taglib =
284 dnl =======================
285 if test "$taglib" != "no" ; then
286         AC_PATH_PROG(TAGLIB_CONFIG, taglib-config)
287         if test "$TAGLIB_CONFIG" != "" ; then
288                 CPPFLAGS="$CPPFLAGS `$TAGLIB_CONFIG --cflags`"
289                 LIBS="$LIBS `$TAGLIB_CONFIG --libs`"
290                 AC_CHECK_HEADERS([taglib.h], ,
291                         if test "$taglib" = "yes" ; then
292                                 AC_MSG_ERROR([missing taglib.h header])
293                         fi
294                 )
295         else
296                 if test "$taglib" = "yes" ; then
297                         AC_MSG_ERROR([taglib-config executable is missing])
298                 fi
299         fi
302 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile])
303 AC_OUTPUT