Add a function to query the Opus version
[opus.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script. -*-m4-*-
2
3 AC_INIT(src/opus_encoder.c)
4
5 AM_CONFIG_HEADER([config.h])
6
7 dnl enable silent rules on automake 1.11 and later
8 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
9
10 OPUS_MAJOR_VERSION=0
11 OPUS_MINOR_VERSION=9
12 OPUS_MICRO_VERSION=6
13 OPUS_EXTRA_VERSION=
14 OPUS_VERSION=$OPUS_MAJOR_VERSION.$OPUS_MINOR_VERSION.$OPUS_MICRO_VERSION$OPUS_EXTRA_VERSION
15 LIBOPUS_SUFFIX=0
16
17 OPUS_LT_CURRENT=0
18 OPUS_LT_REVISION=0
19 OPUS_LT_AGE=0
20
21 AC_SUBST(OPUS_LT_CURRENT)
22 AC_SUBST(OPUS_LT_REVISION)
23 AC_SUBST(OPUS_LT_AGE)
24 AC_SUBST(LIBOPUS_SUFFIX)
25
26 # For automake.
27 VERSION=$OPUS_VERSION
28 PACKAGE=opus
29
30 AC_SUBST(OPUS_VERSION)
31
32 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
33 AM_MAINTAINER_MODE
34
35 AC_CANONICAL_HOST
36 AM_PROG_LIBTOOL
37
38 AC_PROG_CC_C99
39 AC_C_BIGENDIAN
40 AC_C_CONST
41 AC_C_INLINE
42 AC_C_RESTRICT
43
44 AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
45
46 AC_MSG_CHECKING(for C99 variable-size arrays)
47 AC_TRY_COMPILE( , [
48 int foo=10;
49 int array[foo];
50 ],
51 [has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
52 ],
53 has_var_arrays=no
54 )
55 AC_MSG_RESULT($has_var_arrays)
56
57 AC_CHECK_HEADERS([alloca.h getopt.h])
58 AC_MSG_CHECKING(for alloca)
59 AC_TRY_COMPILE( [#include <alloca.h>], [
60 int foo=10;
61 int *array = alloca(foo);
62 ],
63 [
64 has_alloca=yes;
65 if test x$has_var_arrays = "xno" ; then
66 AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
67 fi
68 ],
69 has_alloca=no
70 )
71 AC_MSG_RESULT($has_alloca)
72
73 AC_CHECK_LIB(m, sin)
74
75 AC_DEFINE_UNQUOTED(OPUS_VERSION, "${OPUS_VERSION}", [Complete version string])
76 AC_DEFINE_UNQUOTED(OPUS_MAJOR_VERSION, ${OPUS_MAJOR_VERSION}, [Version major])
77 AC_DEFINE_UNQUOTED(OPUS_MINOR_VERSION, ${OPUS_MINOR_VERSION}, [Version minor])
78 AC_DEFINE_UNQUOTED(OPUS_MICRO_VERSION, ${OPUS_MICRO_VERSION}, [Version micro])
79 AC_DEFINE_UNQUOTED(OPUS_EXTRA_VERSION, "${OPUS_EXTRA_VERSION}", [Version extra])
80
81 has_float_approx=no
82 #case "$host_cpu" in
83 #i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
84 #  has_float_approx=yes
85 #  ;;
86 #esac    
87
88 ac_enable_fixed="no";
89 AC_ARG_ENABLE(fixed-point, [  --enable-fixed-point    compile as fixed-point],
90 [if test "$enableval" = yes; then
91   ac_enable_fixed="yes";
92   AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point])
93 else
94   AC_DEFINE([FLOATING_POINT], , [Compile as floating-point])
95 fi],
96 AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]))
97
98 ac_enable_fixed_debug="no"
99 AC_ARG_ENABLE(fixed-point-debug, [  --enable-fixed-point-debug  debug fixed-point implementation],
100 [if test "$enableval" = yes; then
101   ac_enable_fixed_debug="yes"
102   AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation])
103 fi])
104
105 ac_enable_custom_modes="no"
106 AC_ARG_ENABLE(custom-modes, [  --enable-custom-modes        Enable non-Opus modes, like 44.1 kHz and powers of two ],
107 [if test "$enableval" = yes; then
108   ac_enable_custom_modes="yes"
109   AC_DEFINE([CUSTOM_MODES], , [Custom modes])
110 fi])
111
112 float_approx=$has_float_approx
113 AC_ARG_ENABLE(float-approx, [  --enable-float-approx   enable fast approximations for floating point],
114     [ if test "$enableval" = yes; then
115     AC_WARN([Floating point approximations are not supported on all platforms.])
116     float_approx=yes
117     else
118     float_approx=no
119     fi], [ float_approx=$has_float_approx ])
120
121 if test "x${float_approx}" = "xyes"; then
122     AC_DEFINE([FLOAT_APPROX], , [Float approximations])
123 fi
124
125 ac_enable_assertions="no"
126 AC_ARG_ENABLE(assertions, [  --enable-assertions     enable additional software error checking],
127 [if test "$enableval" = yes; then
128   ac_enable_assertions="yes"
129   AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
130 fi])
131
132 if test "$OPUS_BUILD" != "true" ; then
133 saved_CFLAGS="$CFLAGS"
134 CFLAGS="$CFLAGS -fvisibility=hidden"
135 AC_MSG_CHECKING([if ${CXX} supports -fvisibility=hidden])
136 AC_COMPILE_IFELSE([char foo;],
137       [ AC_MSG_RESULT([yes])
138         SYMBOL_VISIBILITY="-fvisibility=hidden" ],
139         AC_MSG_RESULT([no]))
140 CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY"
141 AC_SUBST(SYMBOL_VISIBILITY)
142 fi
143
144 if test $ac_cv_c_compiler_gnu = yes ; then
145         CFLAGS="$CFLAGS -W -Wstrict-prototypes -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wno-parentheses -Wno-unused-parameter -Wno-sign-compare"
146 fi
147
148 AC_CHECK_FUNCS([lrintf])
149 AC_CHECK_FUNCS([lrint])
150
151 AC_CHECK_SIZEOF(short)
152 AC_CHECK_SIZEOF(int)
153 AC_CHECK_SIZEOF(long)
154 AC_CHECK_SIZEOF(long long)
155
156 if test x$has_char16 = "xyes" ; then
157         case 1 in
158                 $ac_cv_sizeof_short) SIZE16="short";;
159                 $ac_cv_sizeof_int) SIZE16="int";;
160         esac
161 else
162         case 2 in
163                 $ac_cv_sizeof_short) SIZE16="short";;
164                 $ac_cv_sizeof_int) SIZE16="int";;
165         esac
166 fi
167
168 if test x$has_char16 = "xyes" ; then
169         case 2 in
170                 $ac_cv_sizeof_int) SIZE32="int";;
171                 $ac_cv_sizeof_long) SIZE32="long";;
172                 $ac_cv_sizeof_short) SIZE32="short";;
173         esac
174 else
175         case 4 in
176                 $ac_cv_sizeof_int) SIZE32="int";;
177                 $ac_cv_sizeof_long) SIZE32="long";;
178                 $ac_cv_sizeof_short) SIZE32="short";;
179         esac
180 fi
181
182 AC_SUBST(SIZE16)
183 AC_SUBST(SIZE32)
184
185 if test "$OPUS_BUILD" = "true" ; then
186 AC_DEFINE(OPUS_BUILD, [], [We're part of Opus])
187 fi
188
189 AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
190
191 AC_OUTPUT([Makefile])
192
193 AC_MSG_RESULT([
194 ------------------------------------------------------------------------
195   $PACKAGE $VERSION:  Automatic configuration OK.
196   
197     Compiler support:
198
199       C99 var arrays: ................ ${has_var_arrays}
200       C99 lrintf: .................... ${ac_cv_func_lrintf}
201       Alloca: ........................ ${has_alloca}
202     
203     General configuration:
204     
205       Fast float approximations: ..... ${float_approx}
206       Fixed point support: ........... ${ac_enable_fixed}
207       Fixed point debugging: ......... ${ac_enable_fixed_debug}
208       Custom modes: .................. ${ac_enable_custom_modes}
209       Assertion checking: ............ ${ac_enable_assertions}
210 ------------------------------------------------------------------------
211 ])
212
213 echo "Type \"make; make install\" to compile and install";
214 echo "Type \"make check\" to run the test suite";