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