1AC_INIT([ncmpcpp], [0.9.2]) 2AC_CONFIG_SRCDIR([configure.ac]) 3AC_CONFIG_HEADERS(config.h) 4AM_INIT_AUTOMAKE([subdir-objects]) 5 6AC_CONFIG_MACRO_DIR([m4]) 7 8AC_PREREQ(2.59) 9 10AC_LANG_CPLUSPLUS 11AC_PROG_CXX 12AC_PROG_LIBTOOL 13 14AC_ARG_ENABLE(outputs, AS_HELP_STRING([--enable-outputs], [Enable outputs screen @<:@default=no@:>@]), [outputs=$enableval], [outputs=no]) 15AC_ARG_ENABLE(visualizer, AS_HELP_STRING([--enable-visualizer], [Enable music visualizer screen @<:@default=no@:>@]), [visualizer=$enableval], [visualizer=no]) 16AC_ARG_ENABLE(clock, AS_HELP_STRING([--enable-clock], [Enable clock screen @<:@default=no@:>@]), [clock=$enableval], [clock=no]) 17 18AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto]) 19AC_ARG_WITH(taglib, AS_HELP_STRING([--with-taglib], [Enable tag editor @<:@default=auto@:>@]), [taglib=$withval], [taglib=auto]) 20AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable LTO (link time optimization) @<:@default=yes@:>@]), [lto=$withval], [lto=yes]) 21 22if test "$outputs" = "yes"; then 23 AC_DEFINE([ENABLE_OUTPUTS], [1], [enables outputs screen]) 24fi 25 26if test "$clock" = "yes"; then 27 AC_DEFINE([ENABLE_CLOCK], [1], [enables clock screen]) 28fi 29 30# -flto 31if test "$lto" != "no"; then 32 AC_MSG_CHECKING([whether compiler supports -flto]) 33 old_CXXFLAGS="$CXXFLAGS" 34 # support specifying the number of threads 35 if test "$lto" != "yes"; then 36 flto="-flto=$lto" 37 else 38 flto="-flto" 39 fi 40 CXXFLAGS="$flto" 41 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]])], 42 AC_MSG_RESULT([yes]), 43 AC_MSG_RESULT([no]) 44 flto="" 45 ) 46 CXXFLAGS="$old_CXXFLAGS $flto" 47fi 48 49# -ftree-vectorize 50AC_MSG_CHECKING([whether compiler supports -ftree-vectorize]) 51old_CXXFLAGS="$CXXFLAGS" 52CXXFLAGS="-ftree-vectorize" 53AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]])], 54 AC_MSG_RESULT([yes]) 55 tree_vectorize="-ftree-vectorize", 56 AC_MSG_RESULT([no]) 57 tree_vectorize="" 58) 59CXXFLAGS="$old_CXXFLAGS $tree_vectorize" 60 61# -ffast-math 62AC_MSG_CHECKING([whether compiler supports -ffast-math]) 63old_CXXFLAGS="$CXXFLAGS" 64CXXFLAGS="-ffast-math" 65AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]])], 66 AC_MSG_RESULT([yes]) 67 fast_math="-ffast-math", 68 AC_MSG_RESULT([no]) 69 fast_math="" 70) 71CXXFLAGS="$old_CXXFLAGS $fast_math" 72 73# -std=c++14 74AC_MSG_CHECKING([whether compiler supports -std=c++14]) 75old_CXXFLAGS="$CXXFLAGS" 76CXXFLAGS="-std=c++14" 77AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]])], 78 AC_MSG_RESULT([yes]) 79 std_cpp14="-std=c++14", 80 AC_MSG_RESULT([no]) 81 AC_MSG_ERROR([[Your compiler doesn't seem to support C++14, please upgrade (GCC >= 5)]]) 82) 83CXXFLAGS="$old_CXXFLAGS $std_cpp14" 84 85# generic lambda expressions support 86AC_MSG_CHECKING([whether compiler supports generic lambda expressions]) 87AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[auto f = [](auto n) { return n*n; }; f(7);]])], 88 AC_MSG_RESULT([yes]), 89 AC_MSG_RESULT([no]) 90 AC_MSG_ERROR([[Your compiler doesn't seem to support generic lambda expressions, please upgrade (GCC >= 5)]]) 91) 92 93# boost 94BOOST_REQUIRE([1.60]) 95AC_SUBST(BOOST_CPPFLAGS) 96CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" 97 98BOOST_STRING_ALGO 99BOOST_FORMAT 100BOOST_HASH 101BOOST_CONVERSION 102BOOST_MATH 103BOOST_OPTIONAL 104BOOST_RANGE 105BOOST_TOKENIZER 106BOOST_TUPLE 107BOOST_VARIANT 108 109BOOST_DATE_TIME 110AC_SUBST(BOOST_DATE_TIME_LDFLAGS) 111AC_SUBST(BOOST_DATE_TIME_LIBS) 112LDFLAGS="$LDFLAGS $BOOST_DATE_TIME_LDFLAGS" 113LIBS="$LIBS $BOOST_DATE_TIME_LIBS" 114 115BOOST_FILESYSTEM 116AC_SUBST(BOOST_FILESYSTEM_LDFLAGS) 117AC_SUBST(BOOST_FILESYSTEM_LIBS) 118LDFLAGS="$LDFLAGS $BOOST_FILESYSTEM_LDFLAGS" 119LIBS="$LIBS $BOOST_FILESYSTEM_LIBS" 120 121BOOST_LOCALE 122AC_SUBST(BOOST_LOCALE_LDFLAGS) 123AC_SUBST(BOOST_LOCALE_LIBS) 124LDFLAGS="$LDFLAGS $BOOST_LOCALE_LDFLAGS" 125LIBS="$LIBS $BOOST_LOCALE_LIBS" 126 127BOOST_PROGRAM_OPTIONS 128AC_SUBST(BOOST_PROGRAM_OPTIONS_LDFLAGS) 129AC_SUBST(BOOST_PROGRAM_OPTIONS_LIBS) 130LDFLAGS="$LDFLAGS $BOOST_PROGRAM_OPTIONS_LDFLAGS" 131LIBS="$LIBS $BOOST_PROGRAM_OPTIONS_LIBS" 132 133BOOST_REGEX 134AC_SUBST(BOOST_REGEX_LDFLAGS) 135AC_SUBST(BOOST_REGEX_LIBS) 136LDFLAGS="$LDFLAGS $BOOST_REGEX_LDFLAGS" 137LIBS="$LIBS $BOOST_REGEX_LIBS" 138 139BOOST_THREAD 140AC_SUBST(BOOST_THREAD_LDFLAGS) 141AC_SUBST(BOOST_THREAD_LIBS) 142LDFLAGS+="$LDFLAGS $BOOST_THREAD_LDFLAGS" 143LIBS="$LIBS $BOOST_THREAD_LIBS" 144 145# icu 146AH_TEMPLATE([BOOST_REGEX_ICU], [boost.regex was compiled with ICU support]) 147PKG_CHECK_MODULES([ICU], [icu-i18n icu-uc], [ 148 old_CPPFLAGS="$CPPFLAGS" 149 old_LIBS="$LIBS" 150 AC_SUBST(ICU_CFLAGS) 151 AC_SUBST(ICU_LIBS) 152 CPPFLAGS="$CPPFLAGS $ICU_CFLAGS -DU_USING_ICU_NAMESPACE=0" 153 LIBS="$LIBS $ICU_LIBS" 154 AC_MSG_CHECKING([whether boost.regex was compiled with ICU support]) 155 AC_LINK_IFELSE([AC_LANG_PROGRAM([ 156 #include <boost/regex/icu.hpp> 157 ], [boost::u32regex rx = boost::make_u32regex("foo"); if (boost::u32regex_search("foobar", rx)) { }])], 158 AC_MSG_RESULT([yes]) 159 AC_DEFINE([BOOST_REGEX_ICU], [1]), 160 AC_MSG_RESULT([no]) 161 CPPFLAGS="$old_CPPFLAGS" 162 LIBS="$old_LIBS", 163 ) 164], [[]]) 165 166# various headers 167AC_CHECK_HEADERS([netinet/tcp.h netinet/in.h], , AC_MSG_ERROR(vital headers missing)) 168AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled)) 169 170# libmpdclient2 171PKG_CHECK_MODULES([libmpdclient], [libmpdclient >= 2.8], [ 172 AC_SUBST(libmpdclient_CFLAGS) 173 AC_SUBST(libmpdclient_LIBS) 174 CPPFLAGS="$CPPFLAGS $libmpdclient_CFLAGS" 175 AC_CHECK_HEADERS([mpd/client.h], 176 LIBS="$LIBS $libmpdclient_LIBS" 177 , 178 AC_MSG_ERROR([missing mpd/client.h header]) 179 ) 180], 181 AC_MSG_ERROR([libmpdclient >= 2.8 is required!]) 182) 183 184# readline 185AX_LIB_READLINE 186if test "$ax_cv_lib_readline" = "no"; then 187 AC_MSG_ERROR([no readline compatible library found]) 188fi 189if test "$ax_cv_lib_readline_history" = "no"; then 190 AC_MSG_WARN([readline library has no history functionality]) 191fi 192 193# pthread 194AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread", 195 AC_MSG_ERROR([pthread library is required]) 196) 197 198# ncursesw 199PKG_CHECK_MODULES([ncursesw], [ncursesw], [ 200 AC_SUBST(ncursesw_CFLAGS) 201 AC_SUBST(ncursesw_LIBS) 202 CPPFLAGS="$CPPFLAGS $ncursesw_CFLAGS" 203 AC_CHECK_HEADERS([curses.h], 204 LIBS="$LIBS $ncursesw_LIBS" 205 , 206 AC_MSG_ERROR([missing curses.h header]) 207 ) 208 AC_CHECK_LIB(ncursesw, initscr, , AC_MSG_ERROR([ncursesw doesn't provide initscr])) 209 AC_MSG_CHECKING([whether curses.h exposes wide-char functions by default]) 210 AC_LINK_IFELSE([AC_LANG_PROGRAM([ 211 #include <curses.h> 212 ], [waddnwstr(stdscr, L"123", 3)])], 213 AC_MSG_RESULT([yes]), 214 AC_MSG_RESULT([no]) 215 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED", 216 ) 217], 218 AC_MSG_ERROR([ncursesw is required!]) 219) 220 221# fftw3 222if test "$visualizer" = "yes" ; then 223 if test "$fftw" != "no" ; then 224 PKG_CHECK_MODULES([fftw3], [fftw3 >= 3], [ 225 AC_SUBST(fftw3_LIBS) 226 AC_SUBST(fftw3_CFLAGS) 227 CPPFLAGS="$CPPFLAGS $fftw3_CFLAGS" 228 AC_CHECK_HEADERS([fftw3.h], 229 LIBS="$LIBS $fftw3_LIBS" 230 , 231 if test "$fftw" = "yes" ; then 232 AC_MSG_ERROR([missing fftw3.h header]) 233 fi 234 ) 235 ], 236 if test "$fftw" = "yes" ; then 237 AC_MSG_ERROR([fftw3 library is required!]) 238 fi 239 ) 240 fi 241 AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen]) 242fi 243 244# libcurl 245PKG_CHECK_MODULES([libcurl], [libcurl], [ 246 AC_SUBST(libcurl_CFLAGS) 247 AC_SUBST(libcurl_LIBS) 248 CPPFLAGS="$CPPFLAGS $libcurl_CFLAGS" 249 AC_CHECK_HEADERS([curl/curl.h], 250 LIBS="$LIBS $libcurl_LIBS" 251 , 252 AC_MSG_ERROR([missing curl/curl.h header]) 253 ) 254], 255 AC_MSG_ERROR([libcurl is required!]) 256) 257 258# taglib 259if test "$taglib" != "no" ; then 260 AC_PATH_PROG(TAGLIB_CONFIG, taglib-config) 261 if test "$TAGLIB_CONFIG" != "" ; then 262 CPPFLAGS="$CPPFLAGS `$TAGLIB_CONFIG --cflags`" 263 LIBS="$LIBS `$TAGLIB_CONFIG --libs`" 264 AC_CHECK_HEADERS([taglib.h], , 265 if test "$taglib" = "yes" ; then 266 AC_MSG_ERROR([missing taglib.h header]) 267 fi 268 ) 269 else 270 if test "$taglib" = "yes" ; then 271 AC_MSG_ERROR([taglib-config executable is missing]) 272 fi 273 fi 274fi 275 276AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile]) 277AC_OUTPUT 278