configure.ac 4.31 KB
Newer Older
1 2 3
# autoconf source script for generating configure

AC_INIT([opusfile], m4_esyscmd([doc/git-version.sh]))
4 5 6 7 8

AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE

AM_INIT_AUTOMAKE([1.11 foreign])
Ron's avatar
Ron committed
9
AM_MAINTAINER_MODE([enable])
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
LT_INIT

m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

AC_CONFIG_MACRO_DIR([m4])

dnl Library versioning for libtool.
dnl Please update these for releases.
dnl CURRENT, REVISION, AGE
dnl - library source changed -> increment REVISION
dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0
dnl - interfaces added -> increment AGE
dnl - interfaces removed -> AGE = 0

OP_LT_CURRENT=0
25
OP_LT_REVISION=1
26 27 28 29 30 31
OP_LT_AGE=0

AC_SUBST(OP_LT_CURRENT)
AC_SUBST(OP_LT_REVISION)
AC_SUBST(OP_LT_AGE)

32 33 34 35 36 37 38 39
CC_CHECK_CFLAGS_APPEND(
  [-std=c89 -pedantic -Wall -Wextra -Wno-parentheses -Wno-long-long])

# Platform-specific tweaks
case $host in
  *-mingw*)
    # -std=c89 causes some warnings under mingw.
    CC_CHECK_CFLAGS_APPEND([-U__STRICT_ANSI__])
40 41 42 43 44 45
    # We need WINNT>=0x501 (WindowsXP) for getaddrinfo/freeaddrinfo.
    # It's okay to define this even when HTTP support is disabled, as it only
    #  affects header declarations, not linking (unless we actually use some
    #  XP-only functions).
    AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x501,
     [We need at least WindowsXP for getaddrinfo/freaddrinfo])
46 47 48 49 50
    host_mingw=true
    ;;
esac
AM_CONDITIONAL(OP_WIN32, test "x$host_mingw" = xtrue)

51 52 53 54 55 56 57 58 59 60 61 62
AC_ARG_ENABLE([assertions],
  AS_HELP_STRING([--enable-assertions], [Enable assertions in code]),,
  enable_assertions=no)

AS_IF([test "x$enable_assertions" = "xyes"], [
  AC_DEFINE([OP_ENABLE_ASSERTIONS], [1], [Enable assertions in code])
])

AC_ARG_ENABLE([http],
  AS_HELP_STRING([--disable-http], [Disable HTTP support]),,
  enable_http=yes)

63 64 65 66 67 68 69 70 71 72 73 74 75 76
AM_COND_IF(OP_WIN32,
  AS_IF([test "x$enable_http" != "xno"],
    AC_CHECK_HEADER([winsock2.h],,
      AC_MSG_WARN([HTTP support requires a Winsock socket library.])
      enable_http=no
    )
  ),
  AS_IF([test "x$enable_http" != "xno"],
    AC_CHECK_HEADER([sys/socket.h],,
      AC_MSG_WARN([HTTP support requires a POSIX socket library.])
      enable_http=no
    )
  )
)
77 78 79

AS_IF([test "x$enable_http" != "xno"], [
   openssl="openssl"
80 81
   AC_DEFINE([OP_ENABLE_HTTP], [1], [Enable HTTP support])
])
82
AM_CONDITIONAL(OP_ENABLE_HTTP, [test "x$enable_http" != "xno"])
Timothy B. Terriberry's avatar
Timothy B. Terriberry committed
83
AC_SUBST(openssl)
84

85
PKG_CHECK_MODULES([DEPS], [ogg >= 1.3 opus >= 1.0.1 ${openssl}])
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

AC_ARG_ENABLE([fixed-point],
  AS_HELP_STRING([--enable-fixed-point], [Enable fixed-point calculation]),,
  enable_fixed_point=no)
AC_ARG_ENABLE([float],
  AS_HELP_STRING([--disable-float], [Disable floating-point API]),,
  enable_float=yes)

AS_IF([test "x$enable_float" = "xno"],
  [enable_fixed_point=yes
   AC_DEFINE([OP_DISABLE_FLOAT_API], [1], [Disable floating-point API])
  ]
)

AS_IF([test "x$enable_fixed_point" = "xyes"],
  [AC_DEFINE([OP_FIXED_POINT], [1], [Enable fixed-point calculation])],
  [dnl This only has to be tested for if float->fixed conversions are required
   AC_SEARCH_LIBS([lrintf], [m], [
      AC_DEFINE([OP_HAVE_LRINTF], [1], [Enable use of lrintf function])
      lrintf_notice="
106
    Library for lrintf() ......... ${ac_cv_search_lrintf}"
107 108 109
   ])
  ]
)
110 111 112 113 114
lrintf_lib="$ac_cv_search_lrintf"
AS_IF([test "x$ac_cv_search_lrintf" = "xnone required"],
  [lrintf_lib=""]
)
AC_SUBST(lrintf_lib)
115 116 117 118 119 120 121 122 123 124

CC_ATTRIBUTE_VISIBILITY([default], [
  CC_FLAG_VISIBILITY([CFLAGS="${CFLAGS} -fvisibility=hidden"])
])

dnl Check for doxygen
AC_ARG_ENABLE([doc],
  AS_HELP_STRING([--disable-doc], [Do not build API documentation]),,
  [enable_doc=yes]
)
125 126 127 128
AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, yes, no)
if test "$HAVE_DOXYGEN" != "yes" -o "$enable_doc" != "yes" ; then
  HAVE_DOXYGEN="no"
  enable_doc="no"
129
fi
130
AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes])
131 132 133

AC_OUTPUT([
  Makefile
Timothy B. Terriberry's avatar
Timothy B. Terriberry committed
134 135
  opusfile.pc
  opusfile-uninstalled.pc
136 137 138 139
  doc/Doxyfile
])

AC_MSG_NOTICE([
140 141 142 143 144 145 146 147 148 149 150 151 152
------------------------------------------------------------------------
  $PACKAGE $VERSION: Automatic configuration OK.

    Assertions ................... ${enable_assertions}

    HTTP support ................. ${enable_http}
    Fixed-point .................. ${enable_fixed_point}
    Floating-point API ........... ${enable_float}${lrintf_notice}

    Hidden visibility ............ ${cc_cv_flag_visibility}

    API documentation ............ ${enable_doc}
------------------------------------------------------------------------
153
])