configure.ac 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. # autoconf source script for generating configure
  2. dnl The package_version file will be automatically synced to the git revision
  3. dnl by the update_version script when configured in the repository, but will
  4. dnl remain constant in tarball releases unless it is manually edited.
  5. m4_define([CURRENT_VERSION],
  6. m4_esyscmd([ ./update_version 2>/dev/null || true
  7. if test -e package_version; then
  8. . ./package_version
  9. printf "$PACKAGE_VERSION"
  10. else
  11. printf "unknown"
  12. fi ]))
  13. AC_INIT([opusfile],[CURRENT_VERSION],[opus@xiph.org])
  14. AC_CONFIG_SRCDIR([src/opusfile.c])
  15. AC_CONFIG_MACRO_DIR([m4])
  16. AC_USE_SYSTEM_EXTENSIONS
  17. AC_SYS_LARGEFILE
  18. AM_INIT_AUTOMAKE([1.11 foreign no-define dist-zip subdir-objects])
  19. AM_MAINTAINER_MODE([enable])
  20. LT_INIT
  21. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  22. dnl Library versioning for libtool.
  23. dnl Please update these for releases.
  24. dnl CURRENT, REVISION, AGE
  25. dnl - library source changed -> increment REVISION
  26. dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0
  27. dnl - interfaces added -> increment AGE
  28. dnl - interfaces removed -> AGE = 0
  29. OP_LT_CURRENT=4
  30. OP_LT_REVISION=4
  31. OP_LT_AGE=4
  32. AC_SUBST(OP_LT_CURRENT)
  33. AC_SUBST(OP_LT_REVISION)
  34. AC_SUBST(OP_LT_AGE)
  35. CC_CHECK_CFLAGS_APPEND(
  36. [-std=c89 -pedantic -Wall -Wextra -Wno-parentheses -Wno-long-long])
  37. # Platform-specific tweaks
  38. case $host in
  39. *-mingw*)
  40. # -std=c89 causes some warnings under mingw.
  41. CC_CHECK_CFLAGS_APPEND([-U__STRICT_ANSI__])
  42. # We need WINNT>=0x501 (WindowsXP) for getaddrinfo/freeaddrinfo.
  43. # It's okay to define this even when HTTP support is disabled, as it only
  44. # affects header declarations, not linking (unless we actually use some
  45. # XP-only functions).
  46. AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x501,
  47. [We need at least WindowsXP for getaddrinfo/freeaddrinfo])
  48. host_mingw=true
  49. ;;
  50. esac
  51. AM_CONDITIONAL(OP_WIN32, [test "$host_mingw" = "true"])
  52. AC_ARG_ENABLE([assertions],
  53. AS_HELP_STRING([--enable-assertions], [Enable assertions in code]),,
  54. enable_assertions=no)
  55. AS_IF([test "$enable_assertions" = "yes"], [
  56. AC_DEFINE([OP_ENABLE_ASSERTIONS], [1], [Enable assertions in code])
  57. ])
  58. AC_ARG_ENABLE([http],
  59. AS_HELP_STRING([--disable-http], [Disable HTTP support]),,
  60. enable_http=yes)
  61. AM_COND_IF(OP_WIN32, [
  62. AS_IF([test "$enable_http" != "no"], [
  63. AC_CHECK_HEADER([winsock2.h],, [
  64. AC_MSG_WARN([HTTP support requires a Winsock socket library.])
  65. enable_http=no
  66. ])
  67. ])
  68. ], [
  69. AS_IF([test "$enable_http" != "no"], [
  70. AC_CHECK_HEADER([sys/socket.h],, [
  71. AC_MSG_WARN([HTTP support requires a POSIX socket library.])
  72. enable_http=no
  73. ])
  74. ])
  75. ])
  76. # HTTP support requires either clock_gettime or ftime. clock_gettime is
  77. # used only if time.h defines CLOCK_REALTIME and the function is available
  78. # in the standard library; on platforms such as glibc < 2.17 where -lrt
  79. # or another library would be required, ftime will be used.
  80. AS_IF([test "$enable_http" != "no"], [
  81. AC_MSG_CHECKING([for clock_gettime])
  82. AC_LINK_IFELSE([
  83. AC_LANG_PROGRAM([[#include <time.h>]], [[
  84. struct timespec ts;
  85. return clock_gettime(CLOCK_REALTIME, &ts);
  86. ]])
  87. ], [
  88. AC_MSG_RESULT([yes])
  89. AC_DEFINE([OP_HAVE_CLOCK_GETTIME], [1],
  90. [Enable use of clock_gettime function])
  91. ], [
  92. AC_MSG_RESULT([no])
  93. AC_SEARCH_LIBS(ftime, [compat], , [enable_http=no])
  94. ])
  95. ])
  96. m4_ifndef([PKG_PROG_PKG_CONFIG],
  97. [m4_fatal([Could not locate the pkg-config autoconf macros.
  98. Please make sure pkg-config is installed and, if necessary, set the environment
  99. variable ACLOCAL="aclocal -I/path/to/pkg.m4".])])
  100. AS_IF([test "$enable_http" != "no"], [
  101. openssl="openssl"
  102. AC_DEFINE([OP_ENABLE_HTTP], [1], [Enable HTTP support])
  103. PKG_CHECK_MODULES([URL_DEPS], [openssl])
  104. ])
  105. AM_CONDITIONAL(OP_ENABLE_HTTP, [test "$enable_http" != "no"])
  106. AC_SUBST([openssl])
  107. PKG_CHECK_MODULES([DEPS], [ogg >= 1.3 opus >= 1.0.1])
  108. AC_ARG_ENABLE([fixed-point],
  109. AS_HELP_STRING([--enable-fixed-point], [Enable fixed-point calculation]),,
  110. enable_fixed_point=no)
  111. AC_ARG_ENABLE([float],
  112. AS_HELP_STRING([--disable-float], [Disable floating-point API]),,
  113. enable_float=yes)
  114. AS_IF([test "$enable_float" = "no"],
  115. [enable_fixed_point=yes
  116. AC_DEFINE([OP_DISABLE_FLOAT_API], [1], [Disable floating-point API])
  117. ]
  118. )
  119. AS_IF([test "$enable_fixed_point" = "yes"],
  120. [AC_DEFINE([OP_FIXED_POINT], [1], [Enable fixed-point calculation])],
  121. [dnl This only has to be tested for if float->fixed conversions are required
  122. saved_LIBS="$LIBS"
  123. AC_SEARCH_LIBS([lrintf], [m], [
  124. AC_DEFINE([OP_HAVE_LRINTF], [1], [Enable use of lrintf function])
  125. lrintf_notice="
  126. Library for lrintf() ......... ${ac_cv_search_lrintf}"
  127. ])
  128. LIBS="$saved_LIBS"
  129. ]
  130. )
  131. AC_ARG_ENABLE([examples],
  132. AS_HELP_STRING([--disable-examples], [Do not build example applications]),,
  133. enable_examples=yes)
  134. AM_CONDITIONAL([OP_ENABLE_EXAMPLES], [test "$enable_examples" = "yes"])
  135. AS_CASE(["$ac_cv_search_lrintf"],
  136. ["no"],[],
  137. ["none required"],[],
  138. [lrintf_lib="$ac_cv_search_lrintf"])
  139. AC_SUBST([lrintf_lib])
  140. CC_ATTRIBUTE_VISIBILITY([default], [
  141. CC_FLAG_VISIBILITY([CFLAGS="${CFLAGS} -fvisibility=hidden"])
  142. ])
  143. dnl Check for doxygen
  144. AC_ARG_ENABLE([doc],
  145. AS_HELP_STRING([--disable-doc], [Do not build API documentation]),,
  146. [enable_doc=yes]
  147. )
  148. AS_IF([test "$enable_doc" = "yes"], [
  149. AC_CHECK_PROG([HAVE_DOXYGEN], [doxygen], [yes], [no])
  150. AC_CHECK_PROG([HAVE_DOT], [dot], [yes], [no])
  151. ],[
  152. HAVE_DOXYGEN=no
  153. ])
  154. AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"])
  155. AC_CONFIG_FILES([
  156. Makefile
  157. opusfile.pc
  158. opusurl.pc
  159. opusfile-uninstalled.pc
  160. opusurl-uninstalled.pc
  161. doc/Doxyfile
  162. ])
  163. AC_CONFIG_HEADERS([config.h])
  164. AC_OUTPUT
  165. AC_MSG_NOTICE([
  166. ------------------------------------------------------------------------
  167. $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
  168. Assertions ................... ${enable_assertions}
  169. HTTP support ................. ${enable_http}
  170. Fixed-point .................. ${enable_fixed_point}
  171. Floating-point API ........... ${enable_float}${lrintf_notice}
  172. Hidden visibility ............ ${cc_cv_flag_visibility}
  173. API code examples ............ ${enable_examples}
  174. API documentation ............ ${enable_doc}
  175. ------------------------------------------------------------------------
  176. ])