configure.ac 5.7 KB

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