Recognizes if input is ogg or not.
[xiph/unicode.git] / theora / configure.ac
blob5a0989c0f10b8b950bf01e5dc726ff5e5882bd83
1 dnl Process this file with autoconf to produce a configure script
3 dnl ------------------------------------------------
4 dnl Initialization and Versioning
5 dnl ------------------------------------------------
7 AC_INIT(libtheora,[1.0beta4svn])
9 AC_CANONICAL_HOST
10 AC_CANONICAL_TARGET
12 AM_CONFIG_HEADER([config.h])
13 AC_CONFIG_SRCDIR([lib/enc/dct.c])
14 AM_INIT_AUTOMAKE
15 AM_MAINTAINER_MODE
17 dnl Library versioning
18 dnl CURRENT, REVISION, AGE
19 dnl - library source changed -> increment REVISION
20 dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0
21 dnl - interfaces added -> increment AGE
22 dnl - interfaces removed -> AGE = 0
24 TH_LIB_CURRENT=3
25 TH_LIB_REVISION=3
26 TH_LIB_AGE=3
27 AC_SUBST(TH_LIB_CURRENT)
28 AC_SUBST(TH_LIB_REVISION)
29 AC_SUBST(TH_LIB_AGE)
31 THDEC_LIB_CURRENT=1
32 THDEC_LIB_REVISION=0
33 THDEC_LIB_AGE=0
34 AC_SUBST(THDEC_LIB_CURRENT)
35 AC_SUBST(THDEC_LIB_REVISION)
36 AC_SUBST(THDEC_LIB_AGE)
38 THENC_LIB_CURRENT=1
39 THENC_LIB_REVISION=0
40 THENC_LIB_AGE=0
41 AC_SUBST(THENC_LIB_CURRENT)
42 AC_SUBST(THENC_LIB_REVISION)
43 AC_SUBST(THENC_LIB_AGE)
45 dnl Extra linker options (for version script)
46 THEORA_LDFLAGS=""
48 dnl --------------------------------------------------  
49 dnl Check for programs
50 dnl --------------------------------------------------  
52 dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2"
53 dnl if $CFLAGS is blank
54 cflags_save="$CFLAGS"
55 AC_PROG_CC
56 AC_PROG_CPP
57 CFLAGS="$cflags_save"
59 AM_PROG_CC_C_O
60 AC_LIBTOOL_WIN32_DLL
61 AM_PROG_LIBTOOL
63 dnl Add parameters for aclocal
64 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
66 dnl Check for doxygen
67 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
68 AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
69 if test $HAVE_DOXYGEN = "false"; then
70         AC_MSG_WARN([*** doxygen not found, API documentation will not be built])
73 dnl Check for tools used to build the format specification
74 AC_CHECK_PROG(HAVE_PDFLATEX, pdflatex, yes)
75 AC_CHECK_PROG(HAVE_BIBTEX, bibtex, yes)
76 AC_CHECK_PROG(HAVE_TRANSFIG, fig2dev, yes)
77 BUILD_SPEC="false"
78 if test -r doc/spec/spec.tex; then
79  if test "x$HAVE_PDFLATEX" = "xyes"; then
80   if test "x$HAVE_BIBTEX" = "xyes"; then
81     if test "x$HAVE_TRANSFIG" = "xyes"; then
82       tex_pkg_list=`fgrep usepackage doc/spec/spec.tex | grep \{ | grep -v ltablex`
83       tex_pkg_ok="yes"
84       for pkg_line in $tex_pkg_list; do
85         pkg_name=`echo $pkg_line | sed -e 's/.*{\(.*\)}.*/\1/'`
86         AC_MSG_CHECKING([for Tex package $pkg_name])
87         cat >conftest.tex <<_ACEOF
88 \\documentclass{book}
89 $pkg_line
90 \\begin{document}
91 Hello World.
92 \\end{document}
93 _ACEOF
94         if pdflatex -interaction batchmode -halt-on-error conftest < /dev/null > /dev/null 2>&1; then
95           AC_MSG_RESULT([ok])
96         else
97           tex_pkg_ok="no"
98           AC_MSG_RESULT([no])
99         fi
100       done
101       if test -w conftest.tex; then rm conftest.tex; fi
102       if test -w conftest.tex; then rm conftest.aux; fi
103       if test -w conftest.pdf; then rm conftest.pdf; fi
104       if test "x$tex_pkg_ok" = "xyes"; then
105         BUILD_SPEC="true"
106       fi
107     fi
108   fi
109  fi
111 AM_CONDITIONAL(BUILD_SPEC, $BUILD_SPEC)
112 if test $BUILD_SPEC = "false"; then
113         AC_MSG_WARN([*** Format Specification will not built.])
116 dnl Check for valgrind
117 VALGRIND_ENVIRONMENT=""
118 ac_enable_valgrind=no
119 AC_ARG_ENABLE(valgrind-testing,
120      [  --enable-valgrind-testing     enable running of tests inside Valgrind ],     [ ac_enable_valgrind=yes ], [ ac_enable_valgrind=no] )
122 if test "x${ac_enable_valgrind}" = xyes ; then
123   if test "x${enable_shared}" = xyes ; then
124     VALGRIND_ENVIRONMENT="libtool --mode=execute "
125   fi
127   AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
128   if test "x$HAVE_VALGRIND" = xyes ; then
129     VALGRIND_ENVIRONMENT="$VALGRIND_ENVIRONMENT valgrind -q --leak-check=yes --show-reachable=yes --num-callers=100"
130     AC_SUBST(VALGRIND_ENVIRONMENT)
131     TESTS_INFO="Type 'make check' to run test suite. Tests will be run under:
132   ${VALGRIND_ENVIRONMENT}"
133   else
134     TESTS_INFO="Type 'make check' to run test suite (Valgrind not found)"
135   fi
136 else
137   TESTS_INFO="Type 'make check' to run test suite (Valgrind testing not enabled)"
140 dnl --------------------------------------------------
141 dnl Set build flags based on environment
142 dnl --------------------------------------------------
144 dnl Set some target options
146 cflags_save="$CFLAGS"
147 if test -z "$GCC"; then
148         case $host in 
149         *)
150                 DEBUG="-g -DDEBUG"
151                 CFLAGS="-O"
152                 PROFILE="-g -p -DDEBUG" ;;
153         esac
154 else
156         case $host in 
157         *)
158                 DEBUG="-g -Wall -Wno-parentheses -DDEBUG -D__NO_MATH_INLINES"
159                 CFLAGS="-Wall -Wno-parentheses -O3 -fforce-addr -fomit-frame-pointer -finline-functions -funroll-loops"
160                 PROFILE="-Wall -Wno-parentheses -pg -g -O3 -fno-inline-functions -DDEBUG";;
161         esac
163 CFLAGS="$CFLAGS $cflags_save"
165 cpu_x86_64=no
166 cpu_x86_32=no
167 AC_ARG_ENABLE(asm,
168     [  --disable-asm           disable assembly optimizations ],
169     [ ac_enable_asm=$enableval ], [ ac_enable_asm=yes] )
171 if test "x${ac_enable_asm}" = xyes; then
172   cpu_optimization="no optimization for your platform, please send a patch"
173   case $target_cpu in
174   i[[3456]]86)
175     cpu_x86_32=yes 
176     cpu_optimization="32 bit x86"
177     AC_DEFINE([USE_ASM], [],  [make use of asm optimization])
178     if test "x$target_vendor" = "xapple"; then
179       THEORA_LDFLAGS="$THEORA_LDFLAGS  -Wl,-read_only_relocs,suppress"
180     fi
181     
182     AC_DEFINE([OC_X86ASM], [], [enable x86 assambler optimization])
183       ;;
184   x86_64)
185     cpu_x86_64=yes
186     cpu_optimization="64 bit x86"
187     AC_DEFINE([USE_ASM], [],  [make use of asm optimization])  
188     AC_DEFINE([OC_X86ASM], [], [enable x86 assambler optimization])
189     ;;
190   esac
191 else
192   cpu_optimization="disabled"
194 AM_CONDITIONAL([CPU_x86_64], [test x$cpu_x86_64 = xyes])
195 AM_CONDITIONAL([CPU_x86_32], [test x$cpu_x86_32 = xyes])
196 AM_CONDITIONAL(OC_X86ASM,[test x$ac_enable_asm = xyes])
198 # Test whenever ld supports -version-script
199 AC_PROG_LD
200 AC_PROG_LD_GNU
201 AC_MSG_CHECKING([library versioning support])
203 THDEC_VERSION_ARG=""
204 THENC_VERSION_ARG=""
205 TH_VERSION_ARG=""
206 if test "x$lt_cv_prog_gnu_ld" = "xyes"; then
207  case "$target_os" in
208   *mingw*)
209     THEORA_LDFLAGS="$THEORA_LDFLAGS -no-undefined"
210     THDEC_VERSION_ARG="-export-symbols \$(top_srcdir)/win32/xmingw32/libtheoradec-all.def"
211     THENC_VERSION_ARG="-export-symbols \$(top_srcdir)/win32/xmingw32/libtheoraenc-all.def"
212     THENC_VERSION_ARG="$THENC_VERSION_ARG -ltheoradec"
213     THC_VERSION_ARG="-export-symbols \$(top_srcdir)/win32/libtheora.def"
214     AC_MSG_RESULT([no])
215     ;;
216   linux* | solaris* )
217     THDEC_VERSION_ARG='-Wl,--version-script=$(srcdir)/Version_script-dec'
218     THENC_VERSION_ARG='-Wl,--version-script=$(srcdir)/Version_script-enc'
219     TH_VERSION_ARG='-Wl,--version-script=$(srcdir)/Version_script'
220     AC_MSG_RESULT([yes])
221     ;;
222   *)
223     # build without versioning
224     AC_MSG_RESULT([no])
225     ;;
226  esac
229 THEORADEC_LDFLAGS="$THEORA_LDFLAGS $THDEC_VERSION_ARG"
230 THEORAENC_LDFLAGS="$THEORA_LDFLAGS $THENC_VERSION_ARG"
231 THEORA_LDFLAGS="$THEORA_LDFLAGS $TH_VERSION_ARG"
232 AC_SUBST(THEORADEC_LDFLAGS)
233 AC_SUBST(THEORAENC_LDFLAGS)
234 AC_SUBST(THEORA_LDFLAGS)
236 dnl --------------------------------------------------
237 dnl Checks for support libraries and headers
238 dnl --------------------------------------------------
240 dnl check for Ogg
241 HAVE_OGG=no
243 dnl first check through pkg-config since it's more flexible
245 dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
246 AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
247 if test "x$HAVE_PKG_CONFIG" = "xyes"
248 then
249   PKG_CHECK_MODULES(OGG, ogg >= 1.1, HAVE_OGG=yes, HAVE_OGG=no)
251 if test "x$HAVE_OGG" = "xno"
252 then
253   dnl fall back to the old school test
254   XIPH_PATH_OGG(, AC_MSG_ERROR([
255     libogg is required to build this package!
256     please see http://www.xiph.org/ for how to
257     obtain a copy.
258   ]))
259   cflags_save=$CFLAGS
260   libs_save=$LIBS
261   CFLAGS="$CFLAGS $OGG_CFLAGS"
262   LIBS="$LIBS $OGG_LIBS"
263   AC_CHECK_FUNC(oggpackB_read, , [
264     AC_MSG_ERROR([newer libogg version (1.1 or later) required])
265   ])
266   CFLAGS=$cflags_save
267   LIBS=$libs_save
271 dnl check for Vorbis
272 HAVE_VORBIS=no
274 dnl first check through pkg-config since it's more flexible
276 if test "x$HAVE_PKG_CONFIG" = "xyes"
277 then
278   PKG_CHECK_MODULES(VORBIS, vorbis >= 1.0.1, HAVE_VORBIS=yes, HAVE_VORBIS=no)
279   dnl also set VORBISENC_LIBS since an examples needs it
280   dnl the old .m4 sets this to a value to use on top of VORBIS_LIBS,
281   dnl so we do the same here.
282   VORBISENC_LIBS="-lvorbisenc"
283   AC_SUBST(VORBISENC_LIBS)
285 if test "x$HAVE_VORBIS" = "xno"
286 then
287   dnl fall back to the old school test
288   XIPH_PATH_VORBIS(HAVE_VORBIS=yes, HAVE_VORBIS=no)
291 dnl check for SDL
292 HAVE_SDL=no
294 AM_PATH_SDL(,[
295   HAVE_SDL=yes
296   SDL_LIBS=`$SDL_CONFIG --libs`
297 ],AC_MSG_WARN([*** Unable to find SDL -- Not compiling example players ***]))
299 dnl check for OSS
300 HAVE_OSS=no
302 AC_CHECK_HEADERS([sys/soundcard.h soundcard.h machine/soundcard.h],[
303   HAVE_OSS=yes
304   break
306 if test x$HAVE_OSS != xyes; then
307   AC_MSG_WARN([OSS audio support not found -- not compiling player_example])
310 dnl check for libpng
311 HAVE_PNG=no
312 if test "x$HAVE_PKG_CONFIG" = "xyes"
313 then
314   PKG_CHECK_MODULES(PNG, libpng, HAVE_PNG=yes, HAVE_PNG=no)
316 AC_SUBST(PNG_CFLAGS)
317 AC_SUBST(PNG_LIBS)
319 dnl --------------------------------------------------
320 dnl Overall build configuration options
321 dnl --------------------------------------------------
323 dnl Configuration option for building of floating point code.
325 ac_enable_float=yes
326 AC_ARG_ENABLE(float,
327      [  --disable-float         disable use of floating point code ],
328      [ ac_enable_float=$enableval ], [ ac_enable_float=yes] )
330 if test "x${ac_enable_float}" != xyes ; then
331     AC_DEFINE([THEORA_DISABLE_FLOAT], [], 
332   [Define to exclude floating point code from the build])
334 AM_CONDITIONAL(THEORA_DISABLE_FLOAT, [test "x${ac_enable_float}" != xyes])
336 dnl Configuration option for building of encoding support.
338 ac_enable_encode=yes
339 AC_ARG_ENABLE(encode,
340      [  --disable-encode        disable encoding support ],
341      [ ac_enable_encode=$enableval ], [ ac_enable_encode=yes] )
343 if test "x${ac_enable_encode}" != xyes ; then
344     AC_DEFINE([THEORA_DISABLE_ENCODE], [],
345   [Define to exclude encode support from the build])
346 else
347     if test x$HAVE_VORBIS = xyes; then
348       BUILDABLE_EXAMPLES="$BUILDABLE_EXAMPLES encoder_example\$(EXEEXT)"
349     else
350       AC_MSG_NOTICE([Vorbis missing, cannot build example encoder])
351     fi
353 AM_CONDITIONAL(THEORA_DISABLE_ENCODE, [test "x${ac_enable_encode}" != xyes])
355 dnl Configuration option for examples
357 ac_enable_examples=yes
358 AC_ARG_ENABLE(examples,
359      [  --disable-examples      disable examples ],
360      [ ac_enable_examples=$enableval ], [ ac_enable_examples=yes] )
361 AM_CONDITIONAL(THEORA_ENABLE_EXAMPLES, [test "x${ac_enable_examples}" != xno])
363 dnl --------------------------------------------------
364 dnl Check for headers
365 dnl --------------------------------------------------
367 dnl none here
369 dnl --------------------------------------------------
370 dnl Check for typedefs, structures, etc
371 dnl --------------------------------------------------
373 dnl none
375 dnl --------------------------------------------------
376 dnl Check for library functions
377 dnl --------------------------------------------------
379 dnl substitute the included getopt if the system doesn't support long options
380 AC_CHECK_FUNC(getopt_long,
381               [GETOPT_OBJS=''],
382               [GETOPT_OBJS='getopt.$(OBJEXT) getopt1.$(OBJEXT)'])
383 AC_SUBST(GETOPT_OBJS)
385 if test x$HAVE_SDL = xyes -a x$HAVE_OSS = xyes -a x$HAVE_VORBIS = xyes; then
386   BUILDABLE_EXAMPLES="$BUILDABLE_EXAMPLES player_example"
388 if test x$HAVE_PNG = xyes; then
389   BUILDABLE_EXAMPLES="$BUILDABLE_EXAMPLES png2theora"
391 AC_SUBST(BUILDABLE_EXAMPLES)
393 dnl --------------------------------------------------
394 dnl Do substitutions
395 dnl --------------------------------------------------
397 AC_SUBST(DEBUG)
398 AC_SUBST(PROFILE)
400 AC_OUTPUT([
401   Makefile 
402   lib/Makefile
403   include/Makefile include/theora/Makefile
404   examples/Makefile
405   doc/Makefile doc/Doxyfile doc/spec/Makefile
406   tests/Makefile
407   m4/Makefile
408   libtheora.spec
409   theora.pc
410   theora-uninstalled.pc
411   theoradec.pc
412   theoradec-uninstalled.pc
413   theoraenc.pc
414   theoraenc-uninstalled.pc
417 AS_AC_EXPAND(LIBDIR, ${libdir})
418 AS_AC_EXPAND(INCLUDEDIR, ${includedir})
419 AS_AC_EXPAND(BINDIR, ${bindir})
420 AS_AC_EXPAND(DOCDIR, ${datadir}/doc)
422 if test $HAVE_DOXYGEN = "false"; then
423   doc_build="no"
424 else
425   doc_build="yes"
427 if test $BUILD_SPEC = "false"; then
428   spec_build="no"
429 else
430   spec_build="yes"
433 AC_MSG_RESULT([
434 ------------------------------------------------------------------------
435   $PACKAGE $VERSION:  Automatic configuration OK.
437   General configuration:
439     Encoding support: ........... ${ac_enable_encode}
440     Floating point support: ..... ${ac_enable_float}
441     Assembly optimization: ...... ${cpu_optimization}
442     Build example code: ......... ${ac_enable_examples}
443     API Documentation: .......... ${doc_build}
444     Format Documentation: ....... ${spec_build}
446   Installation paths:
448     libtheora: ................... ${LIBDIR}
449     C header files: .............. ${INCLUDEDIR}/theora
450     Documentation: ............... ${DOCDIR}/$PACKAGE
452   Building:
454     Type 'make' to compile $PACKAGE.
456     Type 'make install' to install $PACKAGE.
458     ${TESTS_INFO}
460   Example programs will be built but not installed.
461 ------------------------------------------------------------------------