randalltux

ncmpcpp configure.ac

Feb 7th, 2015
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.65 KB | None | 0 0
  1. AC_INIT(configure.ac)
  2.  
  3. AC_CONFIG_HEADERS(config.h)
  4. AM_INIT_AUTOMAKE(ncmpcpp, 0.7_pre)
  5.  
  6. AC_PREREQ(2.59)
  7.  
  8. AC_LANG_CPLUSPLUS
  9. AC_PROG_CXX
  10. AM_PROG_LIBTOOL
  11.  
  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])
  19.  
  20. if test "$outputs" = "yes"; then
  21. AC_DEFINE([ENABLE_OUTPUTS], [1], [enables outputs screen])
  22. fi
  23.  
  24. if test "$clock" = "yes"; then
  25. AC_DEFINE([ENABLE_CLOCK], [1], [enables clock screen])
  26. fi
  27.  
  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)]])
  39. )
  40. CXXFLAGS="$old_CXXFLAGS $std_cpp0x"
  41.  
  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)]])
  50. )
  51.  
  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)]])
  60. )
  61.  
  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)]])
  70. )
  71.  
  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)]])
  81. )
  82.  
  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], []),
  93. )
  94.  
  95. dnl ======================================
  96. dnl = checking for various boost headers =
  97. dnl ======================================
  98. AC_CHECK_HEADERS([boost/bind.hpp], ,
  99. AC_MSG_ERROR(boost/bind.hpp is missing))
  100. AC_CHECK_HEADERS([boost/lexical_cast.hpp], ,
  101. AC_MSG_ERROR(boost/lexical_cast.hpp is missing))
  102. AC_CHECK_HEADERS([boost/algorithm/string.hpp], ,
  103. AC_MSG_ERROR(boost/algorithm/string.hpp is missing))
  104.  
  105. dnl =================================
  106. dnl = checking for boost.filesystem =
  107. dnl =================================
  108. AC_CHECK_HEADERS([boost/filesystem.hpp], ,
  109. AC_MSG_ERROR(boost/filesystem.hpp is missing)
  110. )
  111. AC_CHECK_LIB(boost_filesystem$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_filesystem$BOOST_LIB_SUFFIX",
  112. AC_MSG_ERROR([no boost.filesystem library found])
  113. )
  114. AC_CHECK_LIB(boost_system$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_system$BOOST_LIB_SUFFIX",
  115. AC_MSG_ERROR([no boost.system library found])
  116. )
  117.  
  118. dnl =============================
  119. dnl = checking for boost.format =
  120. dnl =============================
  121. AC_CHECK_HEADERS([boost/format.hpp], ,
  122. AC_MSG_ERROR(boost/format.hpp is missing)
  123. )
  124.  
  125. dnl =============================
  126. dnl = checking for boost.locale =
  127. dnl =============================
  128. AC_CHECK_HEADERS([boost/locale.hpp], ,
  129. AC_MSG_ERROR(boost/locale.hpp is missing)
  130. )
  131. AC_CHECK_LIB(boost_locale$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_locale$BOOST_LIB_SUFFIX",
  132. AC_MSG_ERROR([no boost.locale library found])
  133. )
  134.  
  135. dnl =================================
  136. dnl = checking for boost.posix_time =
  137. dnl =================================
  138. AC_CHECK_HEADERS([boost/date_time/posix_time/posix_time.hpp], ,
  139. AC_MSG_ERROR(boost/date_time/posix_time/posix_time.hpp is missing)
  140. )
  141.  
  142. dnl ======================================
  143. dnl = checking for boost.program_options =
  144. dnl ======================================
  145. AC_CHECK_HEADERS([boost/program_options.hpp], ,
  146. AC_MSG_ERROR(boost/program_options.hpp is missing)
  147. )
  148. AC_CHECK_LIB(boost_program_options$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_program_options$BOOST_LIB_SUFFIX",
  149. AC_MSG_ERROR([no boost.program_options library found])
  150. )
  151.  
  152. dnl ============================
  153. dnl = checking for boost.regex =
  154. dnl ============================
  155. AC_CHECK_HEADERS([boost/regex.hpp], ,
  156. AC_MSG_ERROR(boost/regex.hpp is missing)
  157. )
  158. AC_CHECK_LIB(boost_regex$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_regex$BOOST_LIB_SUFFIX",
  159. AC_MSG_ERROR([no boost.regex library found])
  160. )
  161.  
  162. dnl =============================
  163. dnl = checking for boost.thread =
  164. dnl =============================
  165. AC_DEFINE([BOOST_THREAD_VERSION], [3], [require boost.thread v3])
  166. AC_CHECK_HEADERS([boost/thread.hpp], ,
  167. AC_MSG_ERROR([boost/thread.hpp is missing or your boost version is too old (boost.thread v3 is required)])
  168. )
  169. AC_CHECK_LIB(boost_thread$BOOST_LIB_SUFFIX, main, LDFLAGS="$LDFLAGS -lboost_thread$BOOST_LIB_SUFFIX",
  170. AC_MSG_ERROR([no boost.thread library found])
  171. )
  172.  
  173. dnl ==============================
  174. dnl = checking for regex (win32) =
  175. dnl ==============================
  176. AC_CHECK_LIB(regex, regcomp, LDFLAGS="$LDFLAGS -lregex", )
  177.  
  178. dnl ================================
  179. dnl = checking for various headers =
  180. dnl ================================
  181. AC_CHECK_HEADERS([netinet/tcp.h netinet/in.h], , AC_MSG_ERROR(vital headers missing))
  182. AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled))
  183.  
  184. dnl ==============================
  185. dnl = checking for libmpdclient2 =
  186. dnl ==============================
  187. PKG_CHECK_MODULES([libmpdclient], [libmpdclient >= 2.8], [
  188. AC_SUBST(libmpdclient_LIBS)
  189. AC_SUBST(libmpdclient_CFLAGS)
  190. CPPFLAGS="$CPPFLAGS $libmpdclient_CFLAGS"
  191. AC_CHECK_HEADERS([mpd/client.h],
  192. LDFLAGS="$LDFLAGS $libmpdclient_LIBS"
  193. ,
  194. AC_MSG_ERROR([missing mpd/client.h header])
  195. )
  196. ],
  197. AC_MSG_ERROR([libmpdclient >= 2.8 is required!])
  198. )
  199.  
  200. dnl =========================
  201. dnl = checking for readline =
  202. dnl =========================
  203. AC_CHECK_HEADERS([readline/readline.h readline/history.h],
  204. AC_CHECK_LIB(readline, rl_initialize, LDFLAGS="$LDFLAGS -lreadline",
  205. AC_MSG_ERROR([readline headers found but there is no readline library to make use of])
  206. ),
  207. )
  208.  
  209.  
  210. dnl ========================
  211. dnl = checking for pthread =
  212. dnl ========================
  213. AC_CHECK_HEADERS([pthread.h],
  214. AC_CHECK_LIB(pthread, pthread_create, LDFLAGS="$LDFLAGS -lpthread",
  215. AC_MSG_ERROR([pthread.h found but there is no pthread library to make use of])
  216. ),
  217. )
  218.  
  219. dnl ========================
  220. dnl = checking for ncurses =
  221. dnl ========================
  222. if test "$unicode" = "yes" ; then
  223. curses_config_bin="ncursesw6-config ncursesw5-config"
  224. AC_DEFINE([NCMPCPP_UNICODE], [1], [enables unicode support])
  225. else
  226. curses_config_bin="ncurses6-config ncurses5-config"
  227. fi
  228.  
  229. AC_PATH_PROGS(CURSES_CONFIG, $curses_config_bin)
  230. if test "$CURSES_CONFIG" != "" ; then
  231. CPPFLAGS="$CPPFLAGS `$CURSES_CONFIG --cflags`"
  232. LDFLAGS="$LDFLAGS `$CURSES_CONFIG --libs`"
  233. fi
  234. AC_CHECK_LIB(ncursesw, initscr,
  235. curses_lib=ncursesw,
  236. curses_lib=ncurses
  237. )
  238.  
  239. AC_CHECK_LIB($curses_lib, initscr,
  240. if test "$CURSES_CONFIG" = "" ; then
  241. LDFLAGS="$LDFLAGS -l$curses_lib"
  242. fi
  243. ,
  244. AC_MSG_ERROR([$curses_lib library is required])
  245. )
  246. AC_CHECK_HEADERS([curses.h], , AC_MSG_ERROR([missing curses.h header]))
  247.  
  248. dnl ======================
  249. dnl = checking for fftw3 =
  250. dnl ======================
  251. if test "$visualizer" = "yes" ; then
  252. if test "$fftw" != "no" ; then
  253. PKG_CHECK_MODULES([fftw3], [fftw3 >= 3], [
  254. AC_SUBST(fftw3_LIBS)
  255. AC_SUBST(fftw3_CFLAGS)
  256. CPPFLAGS="$CPPFLAGS $fftw3_CFLAGS"
  257. AC_CHECK_HEADERS([fftw3.h],
  258. LDFLAGS="$LDFLAGS $fftw3_LIBS"
  259. ,
  260. if test "$fftw" = "yes" ; then
  261. AC_MSG_ERROR([missing fftw3.h header])
  262. fi
  263. )
  264. ],
  265. if test "$fftw" = "yes" ; then
  266. AC_MSG_ERROR([fftw3 library is required!])
  267. fi
  268. )
  269. fi
  270. AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen])
  271. fi
  272.  
  273. dnl =====================
  274. dnl = checking for curl =
  275. dnl =====================
  276. if test "$curl" != "no" ; then
  277. AC_PATH_PROG(CURL_CONFIG, curl-config)
  278. if test "$CURL_CONFIG" != "" ; then
  279. CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
  280. AC_CHECK_LIB(curl, curl_easy_init, LDFLAGS="$LDFLAGS `$CURL_CONFIG --libs`",
  281. if test "$curl" = "yes" ; then
  282. AC_MSG_ERROR([curl library is required])
  283. fi
  284. )
  285. AC_CHECK_HEADERS([curl/curl.h], ,
  286. if test "$curl" = "yes" ; then
  287. AC_MSG_ERROR([missing curl.h header])
  288. fi
  289. )
  290. else
  291. AC_CHECK_LIB(curl, curl_easy_init, LDFLAGS="$LDFLAGS -lcurl",
  292. if test "$curl" = "yes" ; then
  293. AC_MSG_ERROR([curl library is required])
  294. fi
  295. )
  296. fi
  297. fi
  298.  
  299. dnl =======================
  300. dnl = checking for taglib =
  301. dnl =======================
  302. if test "$taglib" != "no" ; then
  303. AC_PATH_PROG(TAGLIB_CONFIG, taglib-config)
  304. if test "$TAGLIB_CONFIG" != "" ; then
  305. CPPFLAGS="$CPPFLAGS `$TAGLIB_CONFIG --cflags`"
  306. LDFLAGS="$LDFLAGS `$TAGLIB_CONFIG --libs`"
  307. AC_CHECK_HEADERS([taglib.h], ,
  308. if test "$taglib" = "yes" ; then
  309. AC_MSG_ERROR([missing taglib.h header])
  310. fi
  311. )
  312. else
  313. if test "$taglib" = "yes" ; then
  314. AC_MSG_ERROR([taglib-config executable is missing])
  315. fi
  316. fi
  317. fi
  318.  
  319. AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile])
  320. AC_OUTPUT
Advertisement
Add Comment
Please, Sign In to add comment