spec: Use %license macro to copy license
[platform/upstream/libtheora.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 AC_INIT(libtheora,[1.1.1])
8
9 AC_CANONICAL_HOST
10 AC_CANONICAL_TARGET
11
12 AM_CONFIG_HEADER([config.h])
13 AC_CONFIG_SRCDIR([lib/fdct.c])
14 AM_INIT_AUTOMAKE
15 AM_MAINTAINER_MODE
16
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
23
24 TH_LIB_CURRENT=3
25 TH_LIB_REVISION=10
26 TH_LIB_AGE=3
27 AC_SUBST(TH_LIB_CURRENT)
28 AC_SUBST(TH_LIB_REVISION)
29 AC_SUBST(TH_LIB_AGE)
30
31 THDEC_LIB_CURRENT=2
32 THDEC_LIB_REVISION=4
33 THDEC_LIB_AGE=1
34 AC_SUBST(THDEC_LIB_CURRENT)
35 AC_SUBST(THDEC_LIB_REVISION)
36 AC_SUBST(THDEC_LIB_AGE)
37
38 THENC_LIB_CURRENT=2
39 THENC_LIB_REVISION=2
40 THENC_LIB_AGE=1
41 AC_SUBST(THENC_LIB_CURRENT)
42 AC_SUBST(THENC_LIB_REVISION)
43 AC_SUBST(THENC_LIB_AGE)
44
45 dnl Extra linker options (for version script)
46 THEORA_LDFLAGS=""
47
48 dnl --------------------------------------------------  
49 dnl Check for programs
50 dnl --------------------------------------------------  
51
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"
58
59 AM_PROG_CC_C_O
60 AC_LIBTOOL_WIN32_DLL
61 AM_PROG_LIBTOOL
62
63 dnl Add parameters for aclocal
64 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
65
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])
71 fi
72
73 dnl Check for tools used to build the format specification
74 BUILD_SPEC="false"
75 ac_build_spec=yes
76 AC_ARG_ENABLE(spec,
77      [  --disable-spec          do not build spec ],
78      [
79        if test "x$enableval" = "xno"; then
80          ac_build_spec=$enableval
81        fi
82      ], [
83        ac_build_spec=yes
84      ] )
85 if test "x$ac_build_spec" = "xyes"; then
86   AC_CHECK_PROG(HAVE_PDFLATEX, pdflatex, yes)
87   AC_CHECK_PROG(HAVE_BIBTEX, bibtex, yes)
88   AC_CHECK_PROG(HAVE_TRANSFIG, fig2dev, yes)
89   if test -r doc/spec/spec.tex; then
90    if test "x$HAVE_PDFLATEX" = "xyes"; then
91     if test "x$HAVE_BIBTEX" = "xyes"; then
92       if test "x$HAVE_TRANSFIG" = "xyes"; then
93         tex_pkg_list=`fgrep usepackage doc/spec/spec.tex | grep \{ | grep -v ltablex`
94         tex_pkg_ok="yes"
95         for pkg_line in $tex_pkg_list; do
96           pkg_name=`echo $pkg_line | sed -e 's/.*{\(.*\)}.*/\1/'`
97           AC_MSG_CHECKING([for Tex package $pkg_name])
98           cat >conftest.tex <<_ACEOF
99 \\documentclass{book}
100 $pkg_line
101 \\begin{document}
102 Hello World.
103 \\end{document}
104 _ACEOF
105           if pdflatex -interaction batchmode -halt-on-error conftest < /dev/null > /dev/null 2>&1; then
106             AC_MSG_RESULT([ok])
107           else
108             tex_pkg_ok="no"
109             AC_MSG_RESULT([no])
110           fi
111         done
112         if test -w conftest.tex; then rm conftest.tex; fi
113         if test -w conftest.tex; then rm conftest.aux; fi
114         if test -w conftest.pdf; then rm conftest.pdf; fi
115         if test "x$tex_pkg_ok" = "xyes"; then
116           BUILD_SPEC="true"
117         fi
118       fi
119     fi
120    fi
121   fi
122 fi
123 AM_CONDITIONAL(BUILD_SPEC, $BUILD_SPEC)
124 if test $BUILD_SPEC = "false"; then
125         AC_MSG_WARN([*** Format Specification will not built.])
126 fi
127
128 dnl Check for valgrind
129 VALGRIND_ENVIRONMENT=""
130 ac_enable_valgrind=no
131 AC_ARG_ENABLE(valgrind-testing,
132      [  --enable-valgrind-testing     enable running of tests inside Valgrind ],     [ ac_enable_valgrind=yes ], [ ac_enable_valgrind=no] )
133
134 if test "x${ac_enable_valgrind}" = xyes ; then
135   if test "x${enable_shared}" = xyes ; then
136     VALGRIND_ENVIRONMENT="libtool --mode=execute "
137   fi
138
139   AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
140   if test "x$HAVE_VALGRIND" = xyes ; then
141     VALGRIND_ENVIRONMENT="$VALGRIND_ENVIRONMENT valgrind -q --leak-check=yes --show-reachable=yes --num-callers=100"
142     AC_SUBST(VALGRIND_ENVIRONMENT)
143     TESTS_INFO="Type 'make check' to run test suite. Tests will be run under:
144   ${VALGRIND_ENVIRONMENT}"
145   else
146     TESTS_INFO="Type 'make check' to run test suite (Valgrind not found)"
147   fi
148 else
149   TESTS_INFO="Type 'make check' to run test suite (Valgrind testing not enabled)"
150 fi
151
152 dnl --------------------------------------------------
153 dnl Set build flags based on environment
154 dnl --------------------------------------------------
155
156 dnl Set some target options
157
158 cflags_save="$CFLAGS"
159 if test -z "$GCC"; then
160         case $host in 
161         *)
162                 DEBUG="-g -DDEBUG"
163                 CFLAGS="-O"
164                 PROFILE="-g -p -DDEBUG" ;;
165         esac
166 else
167
168         case $host in 
169         *)
170                 DEBUG="-g -Wall -Wno-parentheses -DDEBUG -D__NO_MATH_INLINES"
171                 CFLAGS="-Wall -Wno-parentheses -O3 -fforce-addr -fomit-frame-pointer -finline-functions -funroll-loops"
172                 PROFILE="-Wall -Wno-parentheses -pg -g -O3 -fno-inline-functions -DDEBUG";;
173         esac
174 fi
175 CFLAGS="$CFLAGS $cflags_save"
176
177 cpu_x86_64=no
178 cpu_x86_32=no
179 AC_ARG_ENABLE(asm,
180     [  --disable-asm           disable assembly optimizations ],
181     [ ac_enable_asm=$enableval ], [ ac_enable_asm=yes] )
182
183 if test "x${ac_enable_asm}" = xyes; then
184   cpu_optimization="no optimization for your platform, please send a patch"
185   case $target_cpu in
186   i[[3456]]86)
187     cpu_x86_32=yes 
188     cpu_optimization="32 bit x86"
189     AC_DEFINE([OC_X86_ASM], [],  [make use of x86 asm optimization])
190     if test "x$target_vendor" = "xapple"; then
191       THEORA_LDFLAGS="$THEORA_LDFLAGS  -Wl,-read_only_relocs,suppress"
192     fi
193       ;;
194   x86_64)
195     cpu_x86_64=yes
196     cpu_optimization="64 bit x86"
197     AC_DEFINE([OC_X86_ASM], [],  [make use of x86 asm optimization])
198     AC_DEFINE([OC_X86_64_ASM], [],  [make use of x86_64 asm optimization])
199     ;;
200   esac
201 else
202   cpu_optimization="disabled"
203 fi
204 AM_CONDITIONAL([CPU_x86_64], [test x$cpu_x86_64 = xyes])
205 AM_CONDITIONAL([CPU_x86_32], [test x$cpu_x86_32 = xyes])
206
207 # Test whenever ld supports -version-script
208 AC_PROG_LD
209 AC_PROG_LD_GNU
210 AC_MSG_CHECKING([how to control symbol export])
211
212 THDEC_VERSION_ARG=""
213 THENC_VERSION_ARG=""
214 TH_VERSION_ARG=""
215 if test "x$lt_cv_prog_gnu_ld" = "xyes"; then
216  case "$target_os" in
217   *mingw*)
218     THEORA_LDFLAGS="$THEORA_LDFLAGS -no-undefined"
219     THDEC_VERSION_ARG="-export-symbols \$(top_srcdir)/win32/xmingw32/libtheoradec-all.def"
220     THENC_VERSION_ARG="-export-symbols \$(top_srcdir)/win32/xmingw32/libtheoraenc-all.def"
221     THENC_VERSION_ARG="$THENC_VERSION_ARG -ltheoradec"
222     THC_VERSION_ARG="-export-symbols \$(top_srcdir)/win32/libtheora.def"
223     AC_MSG_RESULT([-export-symbols])
224     ;;
225   linux* | solaris* )
226     THDEC_VERSION_ARG='-Wl,--version-script=$(srcdir)/Version_script-dec'
227     THENC_VERSION_ARG='-Wl,--version-script=$(srcdir)/Version_script-enc'
228     TH_VERSION_ARG='-Wl,--version-script=$(srcdir)/Version_script'
229     AC_MSG_RESULT([--version-script])
230     ;;
231   *)
232     # build without versioning
233     AC_MSG_RESULT([no])
234     ;;
235  esac
236 else
237  case "$target_os" in
238   darwin*)
239     THDEC_VERSION_ARG='-Wl,-exported_symbols_list,$(srcdir)/theoradec.exp'
240     THENC_VERSION_ARG='-Wl,-exported_symbols_list,$(srcdir)/theoraenc.exp'
241     TH_VERSION_ARG='-Wl,-exported_symbols_list,$(srcdir)/theora.exp'
242     AC_MSG_RESULT([-exported_symbols_list])
243     ;;
244   *)
245     # build without versioning
246     AC_MSG_RESULT([no])
247     ;;
248  esac
249 fi
250  
251 THEORADEC_LDFLAGS="$THEORA_LDFLAGS $THDEC_VERSION_ARG"
252 THEORAENC_LDFLAGS="$THEORA_LDFLAGS $THENC_VERSION_ARG"
253 THEORA_LDFLAGS="$THEORA_LDFLAGS $TH_VERSION_ARG"
254 AC_SUBST(THEORADEC_LDFLAGS)
255 AC_SUBST(THEORAENC_LDFLAGS)
256 AC_SUBST(THEORA_LDFLAGS)
257
258 dnl --------------------------------------------------
259 dnl Checks for support libraries and headers
260 dnl --------------------------------------------------
261
262 dnl check for Ogg
263 HAVE_OGG=no
264
265 dnl first check through pkg-config since it's more flexible
266
267 dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
268 AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
269 if test "x$HAVE_PKG_CONFIG" = "xyes"
270 then
271   PKG_CHECK_MODULES(OGG, ogg >= 1.1, HAVE_OGG=yes, HAVE_OGG=no)
272 fi
273 if test "x$HAVE_OGG" = "xno"
274 then
275   dnl fall back to the old school test
276   XIPH_PATH_OGG(, AC_MSG_ERROR([
277     libogg is required to build this package!
278     please see http://www.xiph.org/ for how to
279     obtain a copy.
280   ]))
281   cflags_save=$CFLAGS
282   libs_save=$LIBS
283   CFLAGS="$CFLAGS $OGG_CFLAGS"
284   LIBS="$LIBS $OGG_LIBS"
285   AC_CHECK_FUNC(oggpackB_read, , [
286     AC_MSG_ERROR([newer libogg version (1.1 or later) required])
287   ])
288   CFLAGS=$cflags_save
289   LIBS=$libs_save
290 fi
291
292
293 dnl check for Vorbis
294 HAVE_VORBIS=no
295
296 dnl first check through pkg-config since it's more flexible
297
298 if test "x$HAVE_PKG_CONFIG" = "xyes"
299 then
300   PKG_CHECK_MODULES(VORBIS, vorbis >= 1.0.1, HAVE_VORBIS=yes, HAVE_VORBIS=no)
301   dnl also set VORBISENC_LIBS since an examples needs it
302   dnl the old .m4 sets this to a value to use on top of VORBIS_LIBS,
303   dnl so we do the same here.
304   VORBISENC_LIBS="-lvorbisenc"
305   AC_SUBST(VORBISENC_LIBS)
306 fi
307 if test "x$HAVE_VORBIS" = "xno"
308 then
309   dnl fall back to the old school test
310   XIPH_PATH_VORBIS(HAVE_VORBIS=yes, HAVE_VORBIS=no)
311 fi
312
313 dnl check for SDL
314 HAVE_SDL=no
315
316 AM_PATH_SDL(,[
317   HAVE_SDL=yes
318   SDL_LIBS=`$SDL_CONFIG --libs`
319 ],AC_MSG_WARN([*** Unable to find SDL -- Not compiling example players ***]))
320
321 dnl check for OSS
322 HAVE_OSS=no
323 AC_CHECK_HEADERS([sys/soundcard.h soundcard.h machine/soundcard.h],[
324   HAVE_OSS=yes
325   break
326 ])
327 if test x$HAVE_OSS != xyes; then
328   AC_MSG_WARN([OSS audio support not found -- not compiling player_example])
329 fi
330
331 dnl OpenBSD needs -lossaudio to use the oss interface
332 OSS_LIBS=
333 case "$target_os" in
334   openbsd*)
335     OSS_LIBS='-lossaudio'
336     ;;
337 esac
338 AC_SUBST(OSS_LIBS)
339
340 dnl check for libpng
341 HAVE_PNG=no
342 if test "x$HAVE_PKG_CONFIG" = "xyes"
343 then
344   PKG_CHECK_MODULES(PNG, libpng, HAVE_PNG=yes, HAVE_PNG=no)
345 fi
346 AC_SUBST(PNG_CFLAGS)
347 AC_SUBST(PNG_LIBS)
348
349 dnl check for libcairo
350 HAVE_CAIRO=no
351 AC_ARG_ENABLE(telemetry,
352     [  --enable-telemetry      enable debugging output controls ],
353     [ ac_enable_telemetry=$enableval ], [ ac_enable_telemetry=no] )
354
355 if test "x${ac_enable_telemetry}" = xyes; then
356    if test "x$HAVE_PKG_CONFIG" = "xyes"
357    then
358      PKG_CHECK_MODULES(CAIRO, cairo, HAVE_CAIRO=yes, HAVE_CAIRO=no)
359      AC_DEFINE([HAVE_CAIRO], [],  [libcairo is available for visual debugging output])  
360    fi
361    if test x$HAVE_CAIRO != xyes; then
362      AC_MSG_WARN([libcairo not found -- not compiling telemetry output support ])
363    fi
364    AC_SUBST(CAIRO_CFLAGS)
365    AC_SUBST(CAIRO_LIBS)
366 fi
367
368 dnl --------------------------------------------------
369 dnl Overall build configuration options
370 dnl --------------------------------------------------
371
372 dnl Configuration option for building of floating point code.
373
374 ac_enable_float=yes
375 AC_ARG_ENABLE(float,
376      [  --disable-float         disable use of floating point code ],
377      [ ac_enable_float=$enableval ], [ ac_enable_float=yes] )
378
379 if test "x${ac_enable_float}" != xyes ; then
380     AC_DEFINE([THEORA_DISABLE_FLOAT], [], 
381   [Define to exclude floating point code from the build])
382 fi
383 AM_CONDITIONAL(THEORA_DISABLE_FLOAT, [test "x${ac_enable_float}" != xyes])
384
385 dnl Configuration option for building of encoding support.
386
387 ac_enable_encode=yes
388 AC_ARG_ENABLE(encode,
389      [  --disable-encode        disable encoding support ],
390      [ ac_enable_encode=$enableval ], [ ac_enable_encode=yes] )
391
392 if test "x${ac_enable_encode}" != xyes ; then
393     AC_DEFINE([THEORA_DISABLE_ENCODE], [],
394   [Define to exclude encode support from the build])
395 else
396     if test x$HAVE_VORBIS = xyes; then
397       BUILDABLE_EXAMPLES="$BUILDABLE_EXAMPLES encoder_example\$(EXEEXT)"
398     else
399       AC_MSG_NOTICE([Vorbis missing, cannot build example encoder])
400     fi
401 fi
402 AM_CONDITIONAL(THEORA_DISABLE_ENCODE, [test "x${ac_enable_encode}" != xyes])
403
404 dnl Configuration option for examples
405
406 ac_enable_examples=yes
407 AC_ARG_ENABLE(examples,
408      [  --disable-examples      disable examples ],
409      [ ac_enable_examples=$enableval ], [ ac_enable_examples=yes] )
410 AM_CONDITIONAL(THEORA_ENABLE_EXAMPLES, [test "x${ac_enable_examples}" != xno])
411
412 dnl --------------------------------------------------
413 dnl Check for headers
414 dnl --------------------------------------------------
415
416 dnl none here
417
418 dnl --------------------------------------------------
419 dnl Check for typedefs, structures, etc
420 dnl --------------------------------------------------
421
422 dnl none
423
424 dnl --------------------------------------------------
425 dnl Check for library functions
426 dnl --------------------------------------------------
427
428 dnl OpenBSD needs -lcompat for ftime() used by dump_video.c
429 AC_SEARCH_LIBS([ftime], [compat])
430
431 dnl substitute the included getopt if the system doesn't support long options
432 AC_CHECK_FUNC(getopt_long,
433               [GETOPT_OBJS=''],
434               [GETOPT_OBJS='getopt.$(OBJEXT) getopt1.$(OBJEXT)'])
435 AC_SUBST(GETOPT_OBJS)
436
437 if test x$HAVE_SDL = xyes -a x$HAVE_OSS = xyes -a x$HAVE_VORBIS = xyes; then
438   BUILDABLE_EXAMPLES="$BUILDABLE_EXAMPLES player_example\$(EXEEXT)"
439 fi
440 if test x$HAVE_PNG = xyes; then
441   BUILDABLE_EXAMPLES="$BUILDABLE_EXAMPLES png2theora\$(EXEEXT)"
442 fi
443 AC_SUBST(BUILDABLE_EXAMPLES)
444
445 dnl --------------------------------------------------
446 dnl Do substitutions
447 dnl --------------------------------------------------
448
449 AC_SUBST(DEBUG)
450 AC_SUBST(PROFILE)
451
452 AC_OUTPUT([
453   Makefile 
454   lib/Makefile
455   include/Makefile include/theora/Makefile
456   examples/Makefile
457   doc/Makefile doc/Doxyfile doc/spec/Makefile
458   tests/Makefile
459   m4/Makefile
460   libtheora.spec
461   theora.pc
462   theora-uninstalled.pc
463   theoradec.pc
464   theoradec-uninstalled.pc
465   theoraenc.pc
466   theoraenc-uninstalled.pc
467 ])
468
469 AS_AC_EXPAND(LIBDIR, ${libdir})
470 AS_AC_EXPAND(INCLUDEDIR, ${includedir})
471 AS_AC_EXPAND(BINDIR, ${bindir})
472 AS_AC_EXPAND(DOCDIR, ${datadir}/doc)
473
474 if test $HAVE_DOXYGEN = "false"; then
475   doc_build="no"
476 else
477   doc_build="yes"
478 fi
479 if test $BUILD_SPEC = "false"; then
480   spec_build="no"
481 else
482   spec_build="yes"
483 fi
484
485 AC_MSG_RESULT([
486 ------------------------------------------------------------------------
487   $PACKAGE $VERSION:  Automatic configuration OK.
488
489   General configuration:
490
491     Encoding support: ........... ${ac_enable_encode}
492     Floating point support: ..... ${ac_enable_float}
493     Assembly optimization: ...... ${cpu_optimization}
494     Debugging telemetry: ........ ${ac_enable_telemetry}
495     Build example code: ......... ${ac_enable_examples}
496     API Documentation: .......... ${doc_build}
497     Format Documentation: ....... ${spec_build}
498
499   Installation paths:
500
501     libtheora: ................... ${LIBDIR}
502     C header files: .............. ${INCLUDEDIR}/theora
503     Documentation: ............... ${DOCDIR}/$PACKAGE
504
505   Building:
506
507     Type 'make' to compile $PACKAGE.
508
509     Type 'make install' to install $PACKAGE.
510
511     ${TESTS_INFO}
512
513   Example programs will be built but not installed.
514 ------------------------------------------------------------------------
515 ])
516