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

Ron's avatar
Ron committed
3 4 5 6
dnl The package_version file will be automatically synced to the git revision
dnl by the update_version script when configured in the repository, but will
dnl remain constant in tarball releases unless it is manually edited.
m4_define([CURRENT_VERSION],
7 8
          m4_esyscmd([ ./update_version 2>/dev/null || true
                       if test -e package_version; then
Ron's avatar
Ron committed
9 10 11 12 13
                           . ./package_version
                           printf "$PACKAGE_VERSION"
                       else
                           printf "unknown"
                       fi ]))
Ron's avatar
Ron committed
14 15 16

AC_INIT([opusfile],[CURRENT_VERSION],[opus@xiph.org])
AC_CONFIG_SRCDIR([src/opusfile.c])
Ron's avatar
Ron committed
17
AC_CONFIG_MACRO_DIR([m4])
18 19 20 21

AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE

22
AM_INIT_AUTOMAKE([1.11 foreign no-define dist-zip subdir-objects])
Ron's avatar
Ron committed
23
AM_MAINTAINER_MODE([enable])
24 25 26 27 28 29 30 31 32 33 34 35
LT_INIT

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

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

Ralph Giles's avatar
Ralph Giles committed
36
OP_LT_CURRENT=4
37
OP_LT_REVISION=2
Ralph Giles's avatar
Ralph Giles committed
38
OP_LT_AGE=4
39 40 41 42 43

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

44 45 46 47 48 49 50 51
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__])
52 53 54 55 56
    # 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,
Timothy B. Terriberry's avatar
Timothy B. Terriberry committed
57
     [We need at least WindowsXP for getaddrinfo/freeaddrinfo])
58 59 60
    host_mingw=true
    ;;
esac
Ron's avatar
Ron committed
61
AM_CONDITIONAL(OP_WIN32, test "$host_mingw" = "true")
62

63 64 65 66
AC_ARG_ENABLE([assertions],
  AS_HELP_STRING([--enable-assertions], [Enable assertions in code]),,
  enable_assertions=no)

Ron's avatar
Ron committed
67
AS_IF([test "$enable_assertions" = "yes"], [
68 69 70 71 72 73 74
  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)

75
AM_COND_IF(OP_WIN32,
Ron's avatar
Ron committed
76
  AS_IF([test "$enable_http" != "no"],
77 78 79 80 81
    AC_CHECK_HEADER([winsock2.h],,
      AC_MSG_WARN([HTTP support requires a Winsock socket library.])
      enable_http=no
    )
  ),
Ron's avatar
Ron committed
82
  AS_IF([test "$enable_http" != "no"],
83 84 85 86 87 88
    AC_CHECK_HEADER([sys/socket.h],,
      AC_MSG_WARN([HTTP support requires a POSIX socket library.])
      enable_http=no
    )
  )
)
89
AC_SEARCH_LIBS(ftime, [compat], , [enable_http=no])
90

91 92 93 94 95
m4_ifndef([PKG_PROG_PKG_CONFIG],
  [m4_fatal([Could not locate the pkg-config autoconf macros.
Please make sure pkg-config is installed and, if necessary, set the environment
variable ACLOCAL="aclocal -I/path/to/pkg.m4".])])

Ron's avatar
Ron committed
96
AS_IF([test "$enable_http" != "no"], [
Ron's avatar
Ron committed
97
   openssl="openssl"
98
   AC_DEFINE([OP_ENABLE_HTTP], [1], [Enable HTTP support])
99
   PKG_CHECK_MODULES([URL_DEPS], [openssl])
100
])
Ron's avatar
Ron committed
101
AM_CONDITIONAL(OP_ENABLE_HTTP, [test "$enable_http" != "no"])
Ron's avatar
Ron committed
102
AC_SUBST([openssl])
103

104
PKG_CHECK_MODULES([DEPS], [ogg >= 1.3 opus >= 1.0.1])
105 106 107 108 109 110 111 112

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)

Ron's avatar
Ron committed
113
AS_IF([test "$enable_float" = "no"],
114 115 116 117 118
  [enable_fixed_point=yes
   AC_DEFINE([OP_DISABLE_FLOAT_API], [1], [Disable floating-point API])
  ]
)

Ron's avatar
Ron committed
119
AS_IF([test "$enable_fixed_point" = "yes"],
120 121
  [AC_DEFINE([OP_FIXED_POINT], [1], [Enable fixed-point calculation])],
  [dnl This only has to be tested for if float->fixed conversions are required
Ron's avatar
Ron committed
122
   saved_LIBS="$LIBS"
123 124 125
   AC_SEARCH_LIBS([lrintf], [m], [
      AC_DEFINE([OP_HAVE_LRINTF], [1], [Enable use of lrintf function])
      lrintf_notice="
126
    Library for lrintf() ......... ${ac_cv_search_lrintf}"
127
   ])
Ron's avatar
Ron committed
128
   LIBS="$saved_LIBS"
129 130
  ]
)
Ron's avatar
Ron committed
131

132
AC_ARG_ENABLE([examples],
133
  AS_HELP_STRING([--disable-examples], [Do not build example applications]),,
134 135 136
  enable_examples=yes)
AM_CONDITIONAL([OP_ENABLE_EXAMPLES], [test "$enable_examples" = "yes"])

Ron's avatar
Ron committed
137 138 139 140 141 142
AS_CASE(["$ac_cv_search_lrintf"],
  ["no"],[],
  ["none required"],[],
  [lrintf_lib="$ac_cv_search_lrintf"])

AC_SUBST([lrintf_lib])
143 144 145 146 147 148 149 150 151 152

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]
)
Ron's avatar
Ron committed
153 154 155

AS_IF([test "$enable_doc" = "yes"], [
  AC_CHECK_PROG([HAVE_DOXYGEN], [doxygen], [yes], [no])
156
  AC_CHECK_PROG([HAVE_DOT], [dot], [yes], [no])
Ron's avatar
Ron committed
157 158 159 160 161
],[
  HAVE_DOXYGEN=no
])

AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"])
162

Ron's avatar
Ron committed
163
AC_CONFIG_FILES([
164
  Makefile
165
  opusfile.pc
166
  opusurl.pc
167
  opusfile-uninstalled.pc
168
  opusurl-uninstalled.pc
169 170
  doc/Doxyfile
])
171
AC_CONFIG_HEADERS([config.h])
Ron's avatar
Ron committed
172
AC_OUTPUT
173 174

AC_MSG_NOTICE([
175
------------------------------------------------------------------------
Ron's avatar
Ron committed
176
  $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
177 178 179 180 181 182 183 184 185

    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}

186
    API code examples ............ ${enable_examples}
187 188
    API documentation ............ ${enable_doc}
------------------------------------------------------------------------
189
])