Enable parallel builds on TravisCI
[platform/upstream/libvorbis.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script
2
3 dnl ------------------------------------------------
4 dnl Initialization and Versioning
5 dnl ------------------------------------------------
6
7
8 AC_INIT([libvorbis],[1.3.5],[vorbis-dev@xiph.org])
9
10 AC_CONFIG_MACRO_DIR([m4])
11
12 AC_CONFIG_SRCDIR([lib/mdct.c])
13
14 AC_CANONICAL_TARGET([])
15
16 AM_INIT_AUTOMAKE
17 AM_MAINTAINER_MODE
18
19 dnl Add parameters for aclocal
20 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
21
22 dnl Library versioning
23 dnl - library source changed -> increment REVISION
24 dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0
25 dnl - interfaces added -> increment AGE
26 dnl - interfaces removed -> AGE = 0
27
28 V_LIB_CURRENT=4
29 V_LIB_REVISION=8
30 V_LIB_AGE=4
31
32 VF_LIB_CURRENT=6
33 VF_LIB_REVISION=7
34 VF_LIB_AGE=3
35
36 VE_LIB_CURRENT=2
37 VE_LIB_REVISION=11
38 VE_LIB_AGE=0
39
40 AC_SUBST(V_LIB_CURRENT)
41 AC_SUBST(V_LIB_REVISION)
42 AC_SUBST(V_LIB_AGE)
43 AC_SUBST(VF_LIB_CURRENT)
44 AC_SUBST(VF_LIB_REVISION)
45 AC_SUBST(VF_LIB_AGE)
46 AC_SUBST(VE_LIB_CURRENT)
47 AC_SUBST(VE_LIB_REVISION)
48 AC_SUBST(VE_LIB_AGE)
49
50 dnl --------------------------------------------------
51 dnl Check for programs
52 dnl --------------------------------------------------
53
54 dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2"
55 dnl if $CFLAGS is blank
56 cflags_save="$CFLAGS"
57 AC_PROG_CC
58 AC_PROG_CPP
59 CFLAGS="$cflags_save"
60
61 AC_C_INLINE
62
63 AC_LIBTOOL_WIN32_DLL
64 AC_PROG_LIBTOOL
65 AM_PROG_CC_C_O
66
67 dnl Check for doxygen
68 if test "x$enable_docs" = xyes; then
69   AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
70   if test $HAVE_DOXYGEN = "false"; then
71     AC_MSG_WARN([*** doxygen not found, API documentation will not be built])
72   fi
73 else
74   HAVE_DOXYGEN=false
75 fi
76 AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
77
78 dnl latex tools for the specification document
79 AC_ARG_ENABLE(docs,
80         AC_HELP_STRING([--enable-docs], [build the documentation]))
81
82 if test "x$enable_docs" = xyes; then
83   AC_CHECK_PROGS([PDFLATEX], pdflatex, [/bin/false])
84   AC_CHECK_PROGS([HTLATEX], htlatex, [/bin/false])
85   if test "x$PDFLATEX" = x/bin/false || test "x$HTLATEX" = x/bin/false; then
86     enable_docs=no
87     AC_MSG_WARN([Documentation will not be built!])
88   fi
89 fi
90
91 AM_CONDITIONAL(BUILD_DOCS, [test "x$enable_docs" = xyes])
92
93 AC_ARG_ENABLE(examples,
94   AS_HELP_STRING([--enable-examples], [build the examples]))
95
96 AM_CONDITIONAL(BUILD_EXAMPLES, [test "x$enable_examples" = xyes])
97
98 dnl --------------------------------------------------
99 dnl Set build flags based on environment
100 dnl --------------------------------------------------
101
102 dnl Set some target options
103
104 cflags_save="$CFLAGS"
105 if test -z "$GCC"; then
106         case $host in
107         *-*-irix*)
108                 dnl If we're on IRIX, we wanna use cc even if gcc
109                 dnl is there (unless the user has overriden us)...
110                 if test -z "$CC"; then
111                         CC=cc
112                 fi
113                 DEBUG="-g -signed"
114                 CFLAGS="-O2 -w -signed"
115                 PROFILE="-p -g3 -O2 -signed" ;;
116         sparc-sun-solaris*)
117                 DEBUG="-v -g"
118                 CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
119                 PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc" ;;
120         *)
121                 DEBUG="-g"
122                 CFLAGS="-O"
123                 PROFILE="-g -p" ;;
124         esac
125 else
126
127         AC_MSG_CHECKING([GCC version])
128         GCC_VERSION=`$CC -dumpversion`
129         AC_MSG_RESULT([$GCC_VERSION])
130         case $host in
131         *86-*-linux*)
132                 DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
133                 CFLAGS="-O3 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char"
134 #               PROFILE="-Wall -Wextra -pg -g -O3 -ffast-math -D_REENTRANT -fsigned-char -fno-inline -static"
135                 PROFILE="-Wall -Wextra -pg -g -O3 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char -fno-inline"
136
137                 # glibc < 2.1.3 has a serious FP bug in the math inline header
138                 # that will cripple Vorbis.  Look to see if the magic FP stack
139                 # clobber is missing in the mathinline header, thus indicating
140                 # the buggy version
141
142                 AC_EGREP_CPP(log10.*fldlg2.*fxch,[
143                                 #define __LIBC_INTERNAL_MATH_INLINES 1
144                                 #define __OPTIMIZE__
145                                 #include <math.h>
146                                 ],bad=maybe,bad=no)
147                 if test ${bad} = "maybe" ;then
148                       AC_EGREP_CPP(log10.*fldlg2.*fxch.*st\([[0123456789]]*\),
149                                         [
150                                         #define __LIBC_INTERNAL_MATH_INLINES 1
151                                         #define __OPTIMIZE__
152                                         #include <math.h>
153                                         ],bad=no,bad=yes)
154                 fi
155                 if test ${bad} = "yes" ;then
156  AC_MSG_WARN([                                                        ])
157  AC_MSG_WARN([********************************************************])
158  AC_MSG_WARN([* The glibc headers on this machine have a serious bug *])
159  AC_MSG_WARN([* in /usr/include/bits/mathinline.h  This bug affects  *])
160  AC_MSG_WARN([* all floating point code, not just Ogg, built on this *])
161  AC_MSG_WARN([* machine.  Upgrading to glibc 2.1.3 is strongly urged *])
162  AC_MSG_WARN([* to correct the problem.  Note that upgrading glibc   *])
163  AC_MSG_WARN([* will not fix any previously built programs; this is  *])
164  AC_MSG_WARN([* a compile-time bug.                                  *])
165  AC_MSG_WARN([* To work around the problem for this build of Ogg,    *])
166  AC_MSG_WARN([* autoconf is disabling all math inlining.  This will  *])
167  AC_MSG_WARN([* hurt Ogg performace but is necessary for an Ogg that *])
168  AC_MSG_WARN([* will actually work.  Once glibc is upgraded, rerun   *])
169  AC_MSG_WARN([* configure and make to build with inlining.           *])
170  AC_MSG_WARN([********************************************************])
171  AC_MSG_WARN([                                                        ])
172
173                 CFLAGS=${OPT}" -D__NO_MATH_INLINES"
174                 PROFILE=${PROFILE}" -D__NO_MATH_INLINES"
175                 fi;;
176         powerpc-*-linux*spe)
177                 DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES"
178                 CFLAGS="-O3 -Wall -Wextra -ffast-math -mfused-madd -D_REENTRANT"
179                 PROFILE="-pg -g -O3 -ffast-math -mfused-madd -D_REENTRANT";;
180         powerpc-*-linux*)
181                 DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES"
182                 CFLAGS="-O3 -Wall -Wextra -ffast-math -mfused-madd -mcpu=750 -D_REENTRANT"
183                 PROFILE="-pg -g -O3 -ffast-math -mfused-madd -mcpu=750 -D_REENTRANT";;
184         *-*-linux*)
185                 DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
186                 CFLAGS="-O3 -Wall -Wextra -ffast-math -D_REENTRANT -fsigned-char"
187                 PROFILE="-pg -g -O3 -ffast-math -D_REENTRANT -fsigned-char";;
188         sparc-sun-*)
189                 sparc_cpu=""
190                 AC_MSG_CHECKING([if gcc supports -mv8])
191                 old_cflags="$CFLAGS"
192                 CFLAGS="$CFLAGS -mv8"
193                 AC_TRY_COMPILE(, [return 0;], [
194                         AC_MSG_RESULT([yes])
195                         sparc_cpu="-mv8"
196                 ])
197                 CFLAGS="$old_cflags"
198                 DEBUG="-g -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char $sparc_cpu"
199                 CFLAGS="-O3 -Wall -Wextra -ffast-math -D__NO_MATH_INLINES -fsigned-char $sparc_cpu"
200                 PROFILE="-pg -g -O3 -D__NO_MATH_INLINES -fsigned-char $sparc_cpu" ;;
201         *-*-darwin*)
202                 DEBUG="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -O0 -fsigned-char"
203                 CFLAGS="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -O3 -ffast-math -fsigned-char"
204                 PROFILE="-DDARWIN -fno-common -force_cpusubtype_ALL -Wall -g -pg -O3 -ffast-math -fsigned-char";;
205         *-*-os2*)
206                 # Use -W instead of -Wextra because gcc on OS/2 is an old version.
207                 DEBUG="-g -Wall -W -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
208                 CFLAGS="-O3 -Wall -W -ffast-math -D_REENTRANT -fsigned-char"
209                 PROFILE="-pg -g -O3 -ffast-math -D_REENTRANT -fsigned-char";;
210         *)
211                 DEBUG="-g -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char"
212                 CFLAGS="-O3 -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char"
213                 PROFILE="-O3 -g -pg -D__NO_MATH_INLINES -fsigned-char" ;;
214         esac
215
216         AC_ADD_CFLAGS([-Wdeclaration-after-statement])
217 fi
218 CFLAGS="$CFLAGS $cflags_save"
219
220 dnl --------------------------------------------------
221 dnl Check for headers
222 dnl --------------------------------------------------
223
224 AC_CHECK_HEADER(memory.h,CFLAGS="$CFLAGS -DUSE_MEMORY_H",:)
225
226 dnl --------------------------------------------------
227 dnl Check for typedefs, structures, etc
228 dnl --------------------------------------------------
229
230 dnl none
231
232 dnl --------------------------------------------------
233 dnl Check for libraries
234 dnl --------------------------------------------------
235
236 AC_CHECK_LIB(m, cos, VORBIS_LIBS="-lm", VORBIS_LIBS="")
237 AC_CHECK_LIB(pthread, pthread_create, pthread_lib="-lpthread", :)
238
239 PKG_PROG_PKG_CONFIG
240
241 HAVE_OGG=no
242 if test "x$PKG_CONFIG" != "x"
243 then
244   PKG_CHECK_MODULES(OGG, ogg >= 1.0, HAVE_OGG=yes, HAVE_OGG=no)
245 fi
246 if test "x$HAVE_OGG" = "xno"
247 then
248   dnl fall back to the old school test
249   XIPH_PATH_OGG(, AC_MSG_ERROR(must have Ogg installed!))
250   libs_save=$LIBS
251   LIBS="$OGG_LIBS $VORBIS_LIBS"
252   AC_CHECK_FUNC(oggpack_writealign, , AC_MSG_ERROR(Ogg >= 1.0 required !))
253   LIBS=$libs_save
254 fi
255
256 dnl --------------------------------------------------
257 dnl Check for library functions
258 dnl --------------------------------------------------
259
260 AC_FUNC_ALLOCA
261 AC_FUNC_MEMCMP
262
263 dnl --------------------------------------------------
264 dnl Do substitutions
265 dnl --------------------------------------------------
266
267 AC_SUBST(VORBIS_LIBS)
268 AC_SUBST(DEBUG)
269 AC_SUBST(PROFILE)
270 AC_SUBST(pthread_lib)
271
272 dnl The following line causes the libtool distributed with the source
273 dnl to be replaced if the build system has a more recent version.
274 AC_SUBST(LIBTOOL_DEPS)
275
276 AC_CONFIG_FILES([
277 Makefile
278 m4/Makefile
279 lib/Makefile
280 lib/modes/Makefile
281 lib/books/Makefile
282 lib/books/coupled/Makefile
283 lib/books/uncoupled/Makefile
284 lib/books/floor/Makefile
285 doc/Makefile doc/vorbisfile/Makefile doc/vorbisenc/Makefile doc/libvorbis/Makefile
286 doc/Doxyfile
287 include/Makefile include/vorbis/Makefile
288 examples/Makefile
289 test/Makefile
290 vq/Makefile
291 libvorbis.spec
292 vorbis.pc
293 vorbisenc.pc
294 vorbisfile.pc
295 vorbis-uninstalled.pc
296 vorbisenc-uninstalled.pc
297 vorbisfile-uninstalled.pc
298 ])
299 AC_CONFIG_HEADERS([config.h])
300
301 AC_OUTPUT