require MPD >= 0.14
[ncmpcpp.git] / configure.in
blobfc6e5228637564b846a087e5ddbb9478bc94b463
1 AC_INIT(configure.in)
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(ncmpcpp, 0.6_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(iconv, AS_HELP_STRING([--with-iconv], [Enable iconv support (Note: if you use utf-8 system wide, you can disable this) @<:@default=auto@:>@]), [iconv=$withval], [iconv=auto])
19 AC_ARG_WITH(pdcurses, AS_HELP_STRING([--with-pdcurses[=LIBNAME]], [Link against pdcurses instead of ncurses @<:@default=XCurses@:>@]), [pdcurses=$withval], [pdcurses=no])
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 -fno-exceptions flag =
32 dnl =====================================
33 AC_MSG_CHECKING([whether compiler supports -fno-exceptions])
34 old_CXXFLAGS="$CXXFLAGS"
35 CXXFLAGS="-fno-exceptions"
36 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]])],
37         AC_MSG_RESULT([yes])
38                 no_exceptions="-fno-exceptions",
39         AC_MSG_RESULT([no])
41 CXXFLAGS="$old_CXXFLAGS $no_exceptions"
43 dnl ================================
44 dnl = checking for -std=c++0x flag =
45 dnl ================================
46 AC_MSG_CHECKING([whether compiler supports -std=c++0x])
47 old_CXXFLAGS="$CXXFLAGS"
48 CXXFLAGS="-std=c++0x"
49 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]])],
50         AC_MSG_RESULT([yes])
51                 std_cpp0x="-std=c++0x",
52         AC_MSG_RESULT([no])
53                 AC_MSG_ERROR([[Your compiler doesn't seem to support C++0x, please upgrade (GCC >= 4.4)]])
55 CXXFLAGS="$old_CXXFLAGS $std_cpp0x"
57 dnl ==============================
58 dnl = checking for regex (win32) =
59 dnl ==============================
60 AC_CHECK_LIB(regex, regcomp, LDFLAGS="$LDFLAGS -lregex", )
62 dnl ================================
63 dnl = checking for various headers =
64 dnl ================================
65 AC_CHECK_HEADERS([dirent.h regex.h], , AC_MSG_ERROR(vital headers missing))
66 AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled))
68 dnl ==============================
69 dnl = checking for libmpdclient2 =
70 dnl ==============================
71 PKG_CHECK_MODULES([libmpdclient], [libmpdclient >= 2.8], [
72         AC_SUBST(libmpdclient_LIBS)
73         AC_SUBST(libmpdclient_CFLAGS)
74         CPPFLAGS="$CPPFLAGS $libmpdclient_CFLAGS"
75         AC_CHECK_HEADERS([mpd/client.h],
76                 LDFLAGS="$LDFLAGS $libmpdclient_LIBS"
77         ,
78                 AC_MSG_ERROR([missing mpd/client.h header])
79         )
81         AC_MSG_ERROR([libmpdclient >= 2.8 is required!])
84 dnl ========================
85 dnl = checking for pthread =
86 dnl ========================
87 AC_CHECK_HEADERS([pthread.h],
88         AC_CHECK_LIB(pthread, pthread_create, LDFLAGS="$LDFLAGS -lpthread",
89                 AC_MSG_ERROR([pthread.h found but there is no pthread library to make use of])
90         ),
93 dnl ======================
94 dnl = checking for iconv =
95 dnl ======================
96 if test "$iconv" != "no" ; then
97         AC_CHECK_HEADERS([iconv.h],
98                 AC_MSG_CHECKING([whether iconv takes const char **])
99                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]], [[iconv(0, (const char **)0, 0, 0, 0);]])],
100                         AC_MSG_RESULT([yes]) AC_DEFINE([ICONV_CONST], [const], [pass const pointer to iconv]),
101                         AC_MSG_RESULT([no]) AC_DEFINE([ICONV_CONST], [], [pass non-const pointer to iconv]))
102                 AC_CHECK_LIB(iconv, libiconv, LDFLAGS="$LDFLAGS -liconv", )
103         ,
104         if test "$iconv" = "yes"; then
105                 AC_MSG_ERROR([iconv.h header is required])
106         fi
107         )
110 dnl ========================
111 dnl = checking for ncurses =
112 dnl ========================
113 if test "$pdcurses" = "no" ; then
114         if test "$unicode" = "yes" ; then
115                 curses_config_bin="ncursesw6-config ncursesw5-config"
116                 AC_DEFINE([_UTF8], [1], [enables unicode support])
117         else
118                 curses_config_bin="ncurses6-config ncurses5-config"
119         fi
120 else
121         if test "$pdcurses" = "yes" ; then
122                 pdcurses_lib=XCurses
123                 curses_config_bin=xcurses-config
124         else
125                 pdcurses_lib=$pdcurses
126         fi
127         AC_DEFINE([USE_PDCURSES], [1], [enables pdcurses support])
129 AC_PATH_PROGS(CURSES_CONFIG, $curses_config_bin)
130 if test "$CURSES_CONFIG" != "" ; then
131         CPPFLAGS="$CPPFLAGS `$CURSES_CONFIG --cflags`"
132         LDFLAGS="$LDFLAGS `$CURSES_CONFIG --libs`"
134 if test "$pdcurses" = "no" ; then
135         AC_CHECK_LIB(ncursesw, initscr,
136                 curses_lib=ncursesw,
137                 curses_lib=ncurses
138         )
139 else
140         curses_lib=$pdcurses_lib
142 AC_CHECK_LIB($curses_lib, initscr,
143         if test "$CURSES_CONFIG" = "" ; then
144                 LDFLAGS="$LDFLAGS -l$curses_lib"
145         fi
146         ,
147         AC_MSG_ERROR([$curses_lib library is required])
148         )
149 if test "$pdcurses" != "no" ; then
150         AC_CHECK_LIB($curses_lib, Xinitscr, AC_DEFINE([XCURSES], [1], [x11 pdcurses available]), )
152 AC_CHECK_HEADERS([curses.h], , AC_MSG_ERROR([missing curses.h header]))
154 dnl ======================
155 dnl = checking for fftw3 =
156 dnl ======================
157 if test "$visualizer" = "yes" ; then
158         if test "$fftw" != "no" ; then
159                 PKG_CHECK_MODULES([fftw3], [fftw3 >= 3], [
160                         AC_SUBST(fftw3_LIBS)
161                         AC_SUBST(fftw3_CFLAGS)
162                         CPPFLAGS="$CPPFLAGS $fftw3_CFLAGS"
163                         AC_CHECK_HEADERS([fftw3.h],
164                                 LDFLAGS="$LDFLAGS $fftw3_LIBS"
165                         ,
166                                 if test "$fftw" = "yes" ; then
167                                         AC_MSG_ERROR([missing fftw3.h header])
168                                 fi
169                         )
170                 ],
171                         if test "$fftw" = "yes" ; then
172                                 AC_MSG_ERROR([fftw3 library is required!])
173                         fi
174                 )
175         fi
176         AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen])
179 dnl =====================
180 dnl = checking for curl =
181 dnl =====================
182 if test "$curl" != "no" ; then
183         AC_PATH_PROG(CURL_CONFIG, curl-config)
184         if test "$CURL_CONFIG" != "" ; then
185                 CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
186                 AC_CHECK_LIB(curl, curl_easy_init, LDFLAGS="$LDFLAGS `$CURL_CONFIG --libs`",
187                         if test "$curl" = "yes" ; then
188                                 AC_MSG_ERROR([curl library is required])
189                         fi
190                 )
191                 AC_CHECK_HEADERS([curl/curl.h], ,
192                         if test "$curl" = "yes" ; then
193                                 AC_MSG_ERROR([missing curl.h header])
194                         fi
195                 )
196         else
197                 AC_CHECK_LIB(curl, curl_easy_init, LDFLAGS="$LDFLAGS -lcurl",
198                         if test "$curl" = "yes" ; then
199                                 AC_MSG_ERROR([curl library is required])
200                         fi
201                 )
202         fi
205 dnl =======================
206 dnl = checking for taglib =
207 dnl =======================
208 if test "$taglib" != "no" ; then
209         AC_PATH_PROG(TAGLIB_CONFIG, taglib-config)
210         if test "$TAGLIB_CONFIG" != "" ; then
211                 CPPFLAGS="$CPPFLAGS `$TAGLIB_CONFIG --cflags`"
212                 LDFLAGS="$LDFLAGS `$TAGLIB_CONFIG --libs`"
213                 AC_CHECK_HEADERS([taglib.h], ,
214                         if test "$taglib" = "yes" ; then
215                                 AC_MSG_ERROR([missing taglib.h header])
216                         fi
217                 )
218         else
219                 if test "$taglib" = "yes" ; then
220                         AC_MSG_ERROR([taglib-config executable is missing])
221                 fi
222         fi
225 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile])
226 AC_OUTPUT