DONOTMERGE: glut-player: temporary hack for stuttering playback
[liboggplay/davidf-public.git] / configure.ac
blobb44df458e9d21d4f6399c0eaab101a4ce6896e97
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([src/liboggplay/oggplay.c])
5 AC_PREREQ(2.53)
7 AC_CANONICAL_TARGET
9 AM_INIT_AUTOMAKE(liboggplay, 0.0.1)
10 AM_CONFIG_HEADER(config.h)
12 SHARED_VERSION_INFO="1:0:0"
13 SHLIB_VERSION_ARG=""
15 # Checks for programs
16 AC_PROG_CC
17 AC_PROG_LIBTOOL
18 AC_PROG_INSTALL
19 AC_PROG_MAKE_SET
21 AC_C_CONST
22 AC_C_BIGENDIAN
24 AM_PROG_CC_C_O
26 dnl Add parameters for aclocal
27 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
29 dnl Checks for library functions
30 AC_CHECK_FUNCS([assert])
32 # Check for valgrind
33 VALGRIND_ENVIRONMENT=""
34 ac_enable_valgrind=no
35 AC_ARG_ENABLE(valgrind-testing,
36      [  --enable-valgrind-testing     enable running of tests inside Valgrind ],     [ ac_enable_valgrind=yes ], [ ac_enable_valgrind=no] )
38 if test "x${ac_enable_valgrind}" = xyes ; then
39   if test "x${enable_shared}" = xyes ; then
40     VALGRIND_ENVIRONMENT="libtool --mode=execute "
41   fi
43   AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
44   if test "x$HAVE_VALGRIND" = xyes ; then
45     VALGRIND_ENVIRONMENT="$VALGRIND_ENVIRONMENT valgrind -q --leak-check=yes --show-reachable=yes --num-callers=100"
46     AC_SUBST(VALGRIND_ENVIRONMENT)
47     TESTS_INFO="Type 'make check' to run test suite. Tests will be run under:
48   ${VALGRIND_ENVIRONMENT}"
49   else
50     TESTS_INFO="Type 'make check' to run test suite (Valgrind not found)"
51   fi
52 else  TESTS_INFO="Type 'make check' to run test suite (Valgrind testing not enabled)"
55 dnl Overall configuration success flag
56 oggplay_config_ok=yes
58 oggplay_tools="oggplay-info"
59 oggplay_examples="get-stream-info"
60 oggplay_glut=""
62 dnl
63 dnl  Configuration option to add -Werror to all Makefiles
64 dnl
66 AC_ARG_ENABLE(gcc-werror,
67      AC_HELP_STRING([--enable-gcc-werror], [enable -Werror in all Makefiles]),
68      [ ac_enable_gcc_werror=yes ], [ ac_enable_gcc_werror=no] )
70 if test "x${ac_enable_gcc_werror}" = xyes ; then
71   CFLAGS="-Werror $CFLAGS"
74 dnl
75 dnl Configure for target platform
76 dnl
78 case "$target_os" in
79   darwin* | rhapsody*)
80     dnl Disable -Wall and -pedantic for Apple Darwin/Rhapsody.
81     dnl System headers on these systems are broken.
82     temp_CFLAGS=`echo $CFLAGS | sed "s/-Wall -pedantic//"`
83     CFLAGS=$temp_CFLAGS
84     dnl add extra mac-specific directories to include path
85     CFLAGS="$CFLAGS -I/Developer/Headers/FlatCarbon/"
86     HAVE_FRAMEWORKS="yes"
87     AC_SUBST(PLATFORM,"mac")
88     ;;
89   linux* | solaris*)
90     SHLIB_VERSION_ARG="-Wl,--version-script=Version_script"
91     AC_SUBST(PLATFORM,"linux")
92     ;;
93   *)
94     ;;
95 esac
97 dnl Define MACOSX for the benefit of altering link likes
98 dnl in the build for that platform
99 AM_CONDITIONAL(MACOS, test "x$HAVE_FRAMEWORKS" = "xyes")
102 dnl  Detect oggz
105 dnl Minimum required version of liboggz
106 oggplay_OGGZ="0.9.8"
108 PKG_CHECK_MODULES(OGGZ, oggz >= "$oggplay_OGGZ", HAVE_OGGZ="yes", HAVE_OGGZ="no")
110 if test "$HAVE_OGGZ" = "yes" ; then
111   AC_DEFINE(HAVE_OGGZ, [], [Define if have liboggz])
112   AC_SUBST(OGGZ_CFLAGS)
113   AC_SUBST(OGGZ_LIBS)
114 else
115   PKG_CHECK_MODULES(OGGZ, oggz, HAVE_OGGZ="old")
117   if test "$HAVE_OGGZ" = "old" ; then
118     AC_MSG_ERROR([
119 *** The version of liboggz installed on your system is too old. You need
120 *** liboggz version greater than $oggplay_OGGZ to build liboggplay.
122   else
123     AC_MSG_ERROR([
124 *** liboggz-$oggplay_OGGZ or greater does not seem to exist on your system.
125 *** Please install it and run this ./configure again.
127   fi
131 dnl  Detect libfishsound
134 dnl Minimum required version of libfishsound
135 oggplay_FISHSOUND="0.8.0"
137 PKG_CHECK_MODULES(FISHSOUND, fishsound >= "$oggplay_FISHSOUND", HAVE_FISHSOUND="yes", HAVE_FISHSOUND="no")
139 if test "$HAVE_FISHSOUND" = "yes" ; then
140   AC_DEFINE(HAVE_FISHSOUND, [], [Define if have libfishsound])
141   AC_SUBST(FISHSOUND_CFLAGS)
142   AC_SUBST(FISHSOUND_LIBS)
143 else
144   PKG_CHECK_MODULES(FISHSOUND, fishsound, HAVE_FISHSOUND="old")
146   if test "$HAVE_FISHSOUND" = "old" ; then
147     AC_MSG_ERROR([
148 *** The version of libfishsound installed on your system is too old. You need
149 *** at least libfishsound version $oggplay_FISHSOUND to build liboggplay.
151   else
152     AC_MSG_ERROR([
153 *** libfishsound-$oggplay_FISHSOUND or greater does not seem to exist on your system.
154 *** Please install it and run this ./configure again.
156   fi
160 dnl  Detect libtheora
162 PKG_CHECK_MODULES(THEORA, theora)
163 AC_SUBST(THEORA_CFLAGS)
164 AC_SUBST(THEORA_LIBS)
167 dnl  Detect libschroedinger
169 PKG_CHECK_MODULES(SCHRO, schroedinger-1.0 >= 1.0.6, HAVE_SCHRO="yes", HAVE_SCHRO="no")
170 if test "x$HAVE_SCHRO" = "xyes" ; then
171   AC_DEFINE(HAVE_SCHRO, [], [Define if have libschroedinger-1.0])
172   SCHRO_CFLAGS="$SCHRO_CFLAGS"
173   AC_SUBST(SCHRO_CFLAGS)
174   AC_SUBST(SCHRO_LIBS)
175 else
176   AC_MSG_RESULT($HAVE_SCHRO)
180 dnl  Detect libkate
182 PKG_CHECK_MODULES(KATE, kate, HAVE_KATE="yes", HAVE_KATE="no")
183 if test "x$HAVE_KATE" = "xyes" ; then
184   AC_DEFINE(HAVE_KATE, [], [Define if have libkate])
185   AC_SUBST(KATE_CFLAGS)
186   AC_SUBST(KATE_LIBS)
187 else
188   AC_MSG_RESULT($HAVE_KATE)
192 dnl  Detect libtiger
194 AC_ARG_WITH(
195   tiger,
196   AS_HELP_STRING(
197     [--with-tiger],
198     [Enable rendering of Kate streams with the Tiger rendering library, using Pango and Cairo (default autodetect)]
199   ),
200   [use_tiger="$withval"]
202 if test "x$use_tiger" != "xno"; then
203   PKG_CHECK_MODULES(TIGER, tiger >= 0.3.1, HAVE_TIGER="yes", HAVE_TIGER="no")
204   if test "x$HAVE_TIGER" = "xyes" ; then
205     AC_DEFINE(HAVE_TIGER, [], [Define if have libtiger])
206     AC_SUBST(TIGER_CFLAGS)
207     AC_SUBST(TIGER_LIBS)
208   else
209     AC_MSG_RESULT($HAVE_TIGER)
210     if test "x$use_tiger" = "xyes"; then
211       AC_MSG_ERROR([libtiger could not be found and was explicitely requested])
212     fi
213   fi
214 else
215   HAVE_TIGER=no
219 dnl Detect Imlib2 (used by dump-all-streams example)
221 PKG_CHECK_MODULES(IMLIB2, imlib2, HAVE_IMLIB2="yes", HAVE_IMLIB2="no")
222 if test "x$HAVE_IMLIB2" = "xyes" ; then
223   oggplay_tools="$oggplay_tools oggplay-dump-first-frame"
224   AC_DEFINE(HAVE_IMLIB2, [], [Define if have Imlib2])
225   AC_SUBST(IMLIB2_LIBS)
226   AC_SUBST(IMLIB2_CFLAGS)
227 else
228   AC_MSG_RESULT($HAVE_IMLIB2)
230 AM_CONDITIONAL(HAVE_IMLIB2, [test "x$HAVE_IMLIB2" = "xyes"])
235 dnl Detect libsndfile1 (used by dump-all-streams example)
236 dnl 
238 PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.0,
239                   HAVE_LIBSNDFILE1="yes", HAVE_LIBSNDFILE1="no")
241 if test "x$HAVE_LIBSNDFILE1" = xyes ; then
242   oggplay_examples="$oggplay_examples dump-all-streams"
243   AC_DEFINE(HAVE_LIBSNDFILE1, [], [Define if have libsndfile])
244   AC_SUBST(SNDFILE_CFLAGS)
245   AC_SUBST(SNDFILE_LIBS) 
247 AM_CONDITIONAL(HAVE_LIBSNDFILE1, [test "x$HAVE_LIBSNDFILE1" = "xyes"])
250 dnl  Detect pthreads libraries
253 PTHREAD_LIBS=error
254 AC_CHECK_LIB(pthread, pthread_attr_init, PTHREAD_LIBS="-lpthread")
255 if test "x$PTHREAD_LIBS" = xerror; then
256         AC_CHECK_LIB(pthreads, pthread_attr_init, PTHREAD_LIBS="-lpthreads")
258 if test "x$PTHREAD_LIBS" = xerror; then
259         AC_CHECK_LIB(c_r, pthread_attr_init, PTHREAD_LIBS="-lc_r")
261 if test "x$PTHREAD_LIBS" = xerror; then
262         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
264 AC_SUBST(PTHREAD_LIBS)
268 dnl Detect GLUT
271 HAVE_GLUT=no
273 ac_enable_glut=yes
274 AC_ARG_ENABLE(glut,
275      [  --disable-glut          disable building of GLUT player],
276      [ ac_enable_glut=no ], [ ac_enable_glut=yes ])
278 if test "x${ac_enable_glut}" != xno ; then
279   dnl XXX: On MacOSX, assume we have GLUT and OpenGL frameworks
280   if test "x$HAVE_FRAMEWORKS" = "xyes" ; then
281     HAVE_GLUT=yes
282     GLUT_LIBS="-lm"
283     GLUT_FRAMEWORKS="-framework GLUT -framework OpenGL"
284     AC_SUBST(GLUT_LIBS)
285     AC_SUBST(GLUT_FRAMEWORKS)
286   else
287     AC_CHECK_LIB(glut, glutInit, HAVE_GLUT="maybe", , [-lGL -lm "$PTHREAD_LIBS"])
288     if test "x$HAVE_GLUT" = "xmaybe" ; then
289       AC_CHECK_HEADER([GL/glut.h], HAVE_GLUT="yes", HAVE_GLUT="no")
290     fi
291     if test "x$HAVE_GLUT" = xyes ; then
292       GLUT_LIBS="-lglut -lGL -lm $PTHREAD_LIBS"
293       AC_SUBST(GLUT_LIBS)
294     fi
295   fi
296   if test "x$HAVE_GLUT" = xyes ; then
297     oggplay_glut="glut-player"
298     AC_DEFINE([HAVE_GLUT], [], [Define if we have GLUT.])
299   else
300     oggplay_glut="
301   *** glut-player will NOT be built. GLUT could not be found."
302   fi
303 else
304   HAVE_GLUT="disabled"
305   oggplay_glut="
306   (glut-player will NOT be built, disabled by './configure --disable-glut')"
308 AM_CONDITIONAL(HAVE_GLUT, [test "x$HAVE_GLUT" = "xyes"])
310 SEMAPHORE_LIBS="-lpthread"
311 AC_SUBST(SEMAPHORE_LIBS)
313 dnl Use -Wall if we have gcc.
314 dnl changequote(,)dnl
315 if test "x$ac_cv_prog_gcc" = xyes ; then
316   CFLAGS="$CFLAGS -Wall -g"
318 dnl changequote([,])dnl
320 dnl Checks for __attribute__(aligned()) directive
321 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
322     [ac_cv_c_attribute_aligned],
323     [ac_cv_c_attribute_aligned=0
324      CFLAGS_save="${CFLAGS}"
325      CFLAGS="${CFLAGS} -Werror"
326      for ac_cv_c_attr_align_try in 64 32 16 8; do
327        AC_TRY_COMPILE([],
328                       [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
329                       [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
330        if test "$ac_cv_c_attribute_aligned" != 0; then
331          break;
332        fi
333      done
334        CFLAGS="${CFLAGS_save}"])
335 if test "${ac_cv_c_attribute_aligned}" != "0"; then
336   AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
337                      [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
344 dnl  Configuration tests complete -- provide summary of results.
347 if test $oggplay_config_ok = no ; then
349 AC_MSG_RESULT([
350 **************************************************************
352 *** $PACKAGE $VERSION: Automatic configuration FAILED.
354 *** The file config.log has full details.
356 *** The following required libraries are missing or
357 *** misconfigured on your system:
360 if test "x$HAVE_OGGZ" != xyes ; then
361     AC_MSG_RESULT(
362 [*** liboggz, available from http://www.annodex.net/])
365 if test "x$HAVE_FISHSOUND" != xyes ; then
366     AC_MSG_RESULT(
367 [*** libfishsound, available from http://www.annodex.net/])
370 AC_MSG_RESULT(
371 [*** If you install the required libraries from source, you
372 *** need to inform the dynamic linker of their location. If
373 *** you install them in a system-wide directory such as
374 *** /usr/local (the default), you must ensure that
375 *** /usr/local/lib is listed in /etc/ld.so.conf, then run
376 *** ldconfig to update the dynamic linking system.
377 *** Alternatively, you can set your LD_LIBRARY_PATH environment
378 *** variable to include the library installation directory.
382 AC_MSG_RESULT(
383 [**************************************************************
387 AC_MSG_ERROR([
389 *** After fixing the above problems, you must run ./configure again.
393 else
395 AC_SUBST(SHLIB_VERSION_ARG)
396 AC_SUBST(SHARED_VERSION_INFO)
398 AC_OUTPUT([
399 Makefile
400 include/Makefile
401 include/oggplay/Makefile
402 src/Makefile
403 src/liboggplay/Makefile
404 src/liboggplay/Version_script
405 src/examples/Makefile
406 src/tools/Makefile
407 src/tests/Makefile
408 oggplay.pc
409 oggplay-uninstalled.pc
412 AS_AC_EXPAND(LIBDIR, ${libdir})
413 AS_AC_EXPAND(INCLUDEDIR, ${includedir})
414 AS_AC_EXPAND(BINDIR, ${bindir})
416 AC_MSG_RESULT([
417 ------------------------------------------------------------------------
418   $PACKAGE $VERSION:  Automatic configuration OK.
420   Tools (./src/tools):
422     $oggplay_tools
424   Examples (./src/examples):
426     $oggplay_examples $oggplay_glut
428   Installation paths:
430     liboggplay: .................. ${LIBDIR}
431     C header files: .............. ${INCLUDEDIR}/oggplay
433   Building:
435     Type 'make' to compile $PACKAGE.
437     Type 'make install' to install $PACKAGE.
439     ${TESTS_INFO}
441   Example programs will be built but not installed.
443   Kate support: .................. ${HAVE_KATE}
444   Dirac support: ................. ${HAVE_SCHRO}
445   Tiger support: ................. ${HAVE_TIGER}
446 ------------------------------------------------------------------------