f148b741443e415c4c192fbf4c4aaa8d2b881362
[opus.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script. -*-m4-*-
2
3 AC_INIT(libcelt/arch.h)
4
5 AM_CONFIG_HEADER([config.h])
6
7 CELT_MAJOR_VERSION=0
8 CELT_MINOR_VERSION=6
9 CELT_MICRO_VERSION=0
10 CELT_EXTRA_VERSION=
11 CELT_VERSION=$CELT_MAJOR_VERSION.$CELT_MINOR_VERSION.$CELT_MICRO_VERSION$CELT_EXTRA_VERSION
12
13 CELT_LT_CURRENT=0
14 CELT_LT_REVISION=0
15 CELT_LT_AGE=0
16
17 AC_SUBST(CELT_LT_CURRENT)
18 AC_SUBST(CELT_LT_REVISION)
19 AC_SUBST(CELT_LT_AGE)
20
21 # For automake.
22 VERSION=$CELT_VERSION
23 PACKAGE=celt
24
25 AC_SUBST(CELT_VERSION)
26
27 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
28 AM_MAINTAINER_MODE
29
30 AC_CANONICAL_HOST
31 AM_PROG_LIBTOOL
32
33 AC_PROG_CC_C99
34 AC_C_BIGENDIAN
35 AC_C_CONST
36 AC_C_INLINE
37 AC_C_RESTRICT
38
39 AC_DEFINE([CELT_BUILD], [], [This is a build of CELT])
40
41 AC_MSG_CHECKING(for C99 variable-size arrays)
42 AC_TRY_COMPILE( , [
43 int foo=10;
44 int array[foo];
45 ],
46 [has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
47 ],
48 has_var_arrays=no
49 )
50 AC_MSG_RESULT($has_var_arrays)
51
52 AC_CHECK_HEADERS([alloca.h getopt.h])
53 AC_MSG_CHECKING(for alloca)
54 AC_TRY_COMPILE( [#include <alloca.h>], [
55 int foo=10;
56 int *array = alloca(foo);
57 ],
58 [
59 has_alloca=yes;
60 if test x$has_var_arrays = "xno" ; then
61 AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
62 fi
63 ],
64 has_alloca=no
65 )
66 AC_MSG_RESULT($has_alloca)
67
68 AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
69
70 AS_IF([test "x$with_ogg" != xno],
71  [XIPH_PATH_OGG([tools="tools"], [tools=""])],
72  [tools=""])
73 AC_SUBST(tools)
74
75 AC_CHECK_LIB(m, sin)
76
77 # Check for getopt_long; if not found, use included source.
78 AC_CHECK_FUNCS([getopt_long],,
79 [# FreeBSD has a gnugetopt library.
80   AC_CHECK_LIB([gnugetopt],[getopt_long],
81 [AC_DEFINE([HAVE_GETOPT_LONG])],
82 [# Use the GNU replacement.
83 AC_LIBOBJ(getopt)
84 AC_LIBOBJ(getopt1)])])
85
86 AC_CHECK_LIB(winmm, main)
87
88 AC_DEFINE_UNQUOTED(CELT_VERSION, "${CELT_VERSION}", [Complete version string])
89 AC_DEFINE_UNQUOTED(CELT_MAJOR_VERSION, ${CELT_MAJOR_VERSION}, [Version major])
90 AC_DEFINE_UNQUOTED(CELT_MINOR_VERSION, ${CELT_MINOR_VERSION}, [Version minor])
91 AC_DEFINE_UNQUOTED(CELT_MICRO_VERSION, ${CELT_MICRO_VERSION}, [Version micro])
92 AC_DEFINE_UNQUOTED(CELT_EXTRA_VERSION, "${CELT_EXTRA_VERSION}", [Version extra])
93
94 AC_ARG_ENABLE(fixed-point, [  --enable-fixed-point    Compile as fixed-point],
95 [if test "$enableval" = yes; then
96   AC_DEFINE([FIXED_POINT], , [Compile as fixed-point])
97   AC_DEFINE([DOUBLE_PRECISION], , [Compile as fixed-point])
98   AC_DEFINE([MIXED_PRECISION], , [Compile as fixed-point])
99 else
100   AC_DEFINE([FLOATING_POINT], , [Compile as floating-point])
101 fi],
102 AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]))
103
104 AC_ARG_ENABLE(fixed-point-debug, [  --enable-fixed-point-debug  Debug fixed-point implementation],
105 [if test "$enableval" = yes; then
106   AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation])
107 fi])
108
109 AC_ARG_ENABLE(static-modes, [  --enable-static-modes],
110 [if test "$enableval" = yes; then
111   AC_DEFINE([STATIC_MODES], , [Static modes])
112 fi])
113
114 AC_ARG_ENABLE(assertions, [  --enable-assertions],
115 [if test "$enableval" = yes; then
116   AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
117 fi])
118
119 AC_ARG_ENABLE(new-plc, [  --enable-new-plc],
120 [if test "$enableval" = yes; then
121   AC_DEFINE([NEW_PLC], , [Use new PLC code])
122 fi])
123
124 saved_CFLAGS="$CFLAGS"
125 CFLAGS="$CFLAGS -fvisibility=hidden"
126 AC_MSG_CHECKING([if ${CXX} supports -fvisibility=hidden])
127 AC_COMPILE_IFELSE([char foo;],
128       [ AC_MSG_RESULT([yes])
129         SYMBOL_VISIBILITY="-fvisibility=hidden" ],
130         AC_MSG_RESULT([no]))
131 CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY"
132 AC_SUBST(SYMBOL_VISIBILITY)
133
134 if test $ac_cv_c_compiler_gnu = yes ; then
135         CFLAGS="$CFLAGS -W -Wstrict-prototypes -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wno-parentheses -Wno-unused-parameter -Wno-sign-compare"
136 fi
137
138 AC_C99_FUNC_LRINTF
139 AC_C99_FUNC_LRINT
140
141 AC_CHECK_SIZEOF(short)
142 AC_CHECK_SIZEOF(int)
143 AC_CHECK_SIZEOF(long)
144 AC_CHECK_SIZEOF(long long)
145
146 if test x$has_char16 = "xyes" ; then
147         case 1 in
148                 $ac_cv_sizeof_short) SIZE16="short";;
149                 $ac_cv_sizeof_int) SIZE16="int";;
150         esac
151 else
152         case 2 in
153                 $ac_cv_sizeof_short) SIZE16="short";;
154                 $ac_cv_sizeof_int) SIZE16="int";;
155         esac
156 fi
157
158 if test x$has_char16 = "xyes" ; then
159         case 2 in
160                 $ac_cv_sizeof_int) SIZE32="int";;
161                 $ac_cv_sizeof_long) SIZE32="long";;
162                 $ac_cv_sizeof_short) SIZE32="short";;
163         esac
164 else
165         case 4 in
166                 $ac_cv_sizeof_int) SIZE32="int";;
167                 $ac_cv_sizeof_long) SIZE32="long";;
168                 $ac_cv_sizeof_short) SIZE32="short";;
169         esac
170 fi
171
172 AC_SUBST(SIZE16)
173 AC_SUBST(SIZE32)
174
175 AC_OUTPUT([Makefile libcelt/Makefile tests/Makefile 
176            celt.pc tools/Makefile libcelt.spec ])
177
178 if test "x$tools" = "x"; then 
179 echo "**IMPORTANT**"
180 echo "You don't seem to have the development package for libogg (libogg-devel) available. Only the library will be built (no encoder/decoder executable)"
181 echo "You can download libogg from http://www.vorbis.com/download.psp"
182 fi
183
184 echo "Type \"make; make install\" to compile and install";