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