configure.ac 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. AC_INIT([audiowmark],[0.6.1])
  2. AC_CONFIG_SRCDIR([src/audiowmark.cc])
  3. AC_CONFIG_AUX_DIR([build-aux])
  4. AC_CONFIG_MACRO_DIR([m4])
  5. AC_CONFIG_HEADERS([config.h])
  6. AM_INIT_AUTOMAKE([foreign])
  7. AC_PROG_CXX
  8. LT_INIT
  9. dnl
  10. dnl sndfile
  11. dnl
  12. AC_DEFUN([AC_SNDFILE_REQUIREMENTS],
  13. [
  14. PKG_CHECK_MODULES(SNDFILE, [sndfile])
  15. AC_SUBST(SNDFILE_CFLAGS)
  16. AC_SUBST(SNDFILE_LIBS)
  17. ])
  18. dnl
  19. dnl libmpg123
  20. dnl
  21. AC_DEFUN([AC_LIBMPG123_REQUIREMENTS],
  22. [
  23. PKG_CHECK_MODULES(LIBMPG123, [libmpg123])
  24. AC_SUBST(LIBMPG123_CFLAGS)
  25. AC_SUBST(LIBMPG123_LIBS)
  26. ])
  27. dnl
  28. dnl zita resampler
  29. dnl
  30. AC_DEFUN([AC_ZITA_REQUIREMENTS],
  31. [
  32. AC_LIB_HAVE_LINKFLAGS([zita-resampler])
  33. if test "x$HAVE_LIBZITA_RESAMPLER" = "xno"; then
  34. AC_MSG_ERROR([You need to install libzita-resampler to build this package.])
  35. fi
  36. ])
  37. dnl ffmpeg stuff
  38. AC_DEFUN([AC_FFMPEG_REQUIREMENTS],
  39. [
  40. PKG_CHECK_MODULES(FFMPEG, libavcodec libavformat libavutil libswresample)
  41. ])
  42. dnl FFTW3
  43. AC_DEFUN([AC_FFTW_CHECK],
  44. [
  45. dnl this used to be optional, but is currently required
  46. PKG_CHECK_MODULES(FFTW, [fftw3f])
  47. SPECTMORPH_HAVE_FFTW=1
  48. if test $SPECTMORPH_HAVE_FFTW -gt 0; then
  49. fftw_save_CFLAGS="$CFLAGS"
  50. CFLAGS="$CFLAGS $FFTW_CFLAGS"
  51. AC_MSG_CHECKING([whether FFTW is recent enough])
  52. AC_COMPILE_IFELSE([
  53. AC_LANG_SOURCE([
  54. #include "fftw3.h"
  55. int x = FFTW_WISDOM_ONLY;
  56. ])
  57. ],[
  58. AC_MSG_RESULT([yes])
  59. ],[
  60. AC_MSG_RESULT([no])
  61. SPECTMORPH_HAVE_FFTW=0
  62. ])
  63. fi
  64. CFLAGS="$fftw_save_CFLAGS"
  65. AC_DEFINE_UNQUOTED(SPECTMORPH_HAVE_FFTW, $SPECTMORPH_HAVE_FFTW, [Whether libfftw3 is available])
  66. ])
  67. AC_SNDFILE_REQUIREMENTS
  68. AC_LIBMPG123_REQUIREMENTS
  69. AC_ZITA_REQUIREMENTS
  70. AC_FFTW_CHECK
  71. AM_PATH_LIBGCRYPT
  72. dnl -------------------- ffmpeg is optional ----------------------------
  73. AC_ARG_WITH([ffmpeg], [AS_HELP_STRING([--with-ffmpeg], [build against ffmpeg libraries])], [], [with_ffmpeg=no])
  74. if test "x$with_ffmpeg" != "xno"; then
  75. AC_FFMPEG_REQUIREMENTS
  76. HAVE_FFMPEG=1
  77. else
  78. HAVE_FFMPEG=0
  79. fi
  80. AC_DEFINE_UNQUOTED(HAVE_FFMPEG, $HAVE_FFMPEG, [whether ffmpeg libs are available])
  81. AM_CONDITIONAL([COND_WITH_FFMPEG], [test "x$with_ffmpeg" != "xno"])
  82. dnl -------------------------------------------------------------------------
  83. dnl --------------- building documentation is optional ----------------------
  84. AC_ARG_WITH([docs], [AS_HELP_STRING([--with-docs], [build documentation])], [], [with_docs=no])
  85. AM_CONDITIONAL([COND_WITH_DOCS], [test "x$with_docs" != "xno"])
  86. dnl -------------------------------------------------------------------------
  87. dnl -------------------- address sanitizer ----------------------------------
  88. AC_ARG_ENABLE([asan], [AS_HELP_STRING([--enable-asan], [build using address sanitizer])],
  89. [
  90. CXXFLAGS="$CXXFLAGS -fsanitize=address -fno-omit-frame-pointer -fstack-protector-all -fno-inline"
  91. LDFLAGS="$LDFLAGS -lasan"
  92. ],
  93. [
  94. enable_asan=no
  95. ])
  96. dnl -------------------------------------------------------------------------
  97. dnl -------------------- undefined behaviour sanitizer ----------------------
  98. AC_ARG_ENABLE([ubsan], [AS_HELP_STRING([--enable-ubsan], [build using undefined behaviour sanitizer])],
  99. [
  100. CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-omit-frame-pointer -fstack-protector-all -fno-inline"
  101. LDFLAGS="$LDFLAGS -lubsan"
  102. ],
  103. [
  104. enable_ubsan=no
  105. ])
  106. dnl -------------------------------------------------------------------------
  107. dnl -------------------- thread sanitizer -----------------------------------
  108. AC_ARG_ENABLE([tsan], [AS_HELP_STRING([--enable-tsan], [build using thread sanitizer])],
  109. [
  110. CXXFLAGS="$CXXFLAGS -fsanitize=thread -fno-omit-frame-pointer -fstack-protector-all -fno-inline"
  111. LDFLAGS="$LDFLAGS -ltsan"
  112. ],
  113. [
  114. enable_tsan=no
  115. ])
  116. dnl -------------------------------------------------------------------------
  117. dnl -------------------- leak sanitizer -------------------------------------
  118. AC_ARG_ENABLE([lsan], [AS_HELP_STRING([--enable-lsan], [build using leak sanitizer])],
  119. [
  120. CXXFLAGS="$CXXFLAGS -fsanitize=leak -fno-omit-frame-pointer -fstack-protector-all -fno-inline"
  121. LDFLAGS="$LDFLAGS -llsan"
  122. ],
  123. [
  124. enable_lsan=no
  125. ])
  126. dnl -------------------------------------------------------------------------
  127. dnl -------------------- glibcxx assertions ----------------------------------
  128. AC_ARG_ENABLE(debug-cxx,AS_HELP_STRING([--enable-debug-cxx], [setup compiler flags to do C++ STL debug checks]),
  129. [
  130. CXXFLAGS="$CXXFLAGS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC"
  131. ],
  132. [
  133. enable_debug_cxx=no
  134. ])
  135. dnl -------------------------------------------------------------------------
  136. # need c++14 mode
  137. AX_CXX_COMPILE_STDCXX_14(ext)
  138. # use -Wall / -pthread if available
  139. AC_LANG_PUSH([C++])
  140. AX_CHECK_COMPILE_FLAG([-Wall], [CXXFLAGS="$CXXFLAGS -Wall"])
  141. AX_CHECK_COMPILE_FLAG([-pthread], [CXXFLAGS="$CXXFLAGS -pthread"])
  142. AC_LANG_POP([C++])
  143. # Less cluttered build output
  144. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  145. AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile tests/test-common.sh docs/Makefile])
  146. AC_OUTPUT
  147. # Output summary message
  148. echo
  149. echo "---------------------------------------------------------------------------"
  150. echo "$PACKAGE_NAME $PACKAGE_VERSION"
  151. echo "---------------------------------------------------------------------------"
  152. echo " Use address sanitizer. . . . . . . .: $enable_asan (for debugging)"
  153. echo " Use undefined behaviour sanitizer. .: $enable_ubsan (for debugging)"
  154. echo " Use thread sanitizer . . . . . . . .: $enable_tsan (for debugging)"
  155. echo " Use leak sanitizer . . . . . . . . .: $enable_lsan (for debugging)"
  156. echo " Use stdc++ debug mode. . . . . . . .: $enable_debug_cxx (for debugging)"
  157. echo " Use ffmpeg libs. . . . . . . . . . .: $with_ffmpeg (use --with-ffmpeg to enable, required for HLS)"
  158. echo " Build developer documentation . . .: $with_docs (use --with-docs to enable)"