Fix oggplay-dump-first-frame
[liboggplay.git] / configure.ac
blobcf168bf08c003c1d6724d03047154dd9cee74489
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.2.0)
10 AM_CONFIG_HEADER(config.h)
12 SHARED_VERSION_INFO="2:0:1"
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 dnl Check for pkg-config
33 AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
35 dnl Check for doxygen
36 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
37 AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
38 if test $HAVE_DOXYGEN = "false"; then
39              AC_MSG_WARN([*** doxygen not found, docs will not be built])
42 # Check for valgrind
43 VALGRIND_ENVIRONMENT=""
44 ac_enable_valgrind=no
45 AC_ARG_ENABLE(valgrind-testing,
46      [  --enable-valgrind-testing     enable running of tests inside Valgrind ],     [ ac_enable_valgrind=yes ], [ ac_enable_valgrind=no] )
48 if test "x${ac_enable_valgrind}" = xyes ; then
49   if test "x${enable_shared}" = xyes ; then
50     VALGRIND_ENVIRONMENT="libtool --mode=execute "
51   fi
53   AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
54   if test "x$HAVE_VALGRIND" = xyes ; then
55     VALGRIND_ENVIRONMENT="$VALGRIND_ENVIRONMENT valgrind -q --leak-check=yes --show-reachable=yes --num-callers=100"
56     AC_SUBST(VALGRIND_ENVIRONMENT)
57     TESTS_INFO="Type 'make check' to run test suite. Tests will be run under:
58   ${VALGRIND_ENVIRONMENT}"
59   else
60     TESTS_INFO="Type 'make check' to run test suite (Valgrind not found)"
61   fi
62 else  TESTS_INFO="Type 'make check' to run test suite (Valgrind testing not enabled)"
65 dnl Overall configuration success flag
66 oggplay_config_ok=yes
68 oggplay_tools="oggplay-info"
69 oggplay_examples="get-stream-info"
70 oggplay_glut=""
72 dnl
73 dnl  Configuration option to add -Werror to all Makefiles
74 dnl
76 AC_ARG_ENABLE(gcc-werror,
77      AC_HELP_STRING([--enable-gcc-werror], [enable -Werror in all Makefiles]),
78      [ ac_enable_gcc_werror=yes ], [ ac_enable_gcc_werror=no] )
80 if test "x${ac_enable_gcc_werror}" = xyes ; then
81   CFLAGS="-Werror $CFLAGS"
84 dnl
85 dnl Configure for target platform
86 dnl
88 case "$target_os" in
89   darwin* | rhapsody*)
90     dnl Disable -Wall and -pedantic for Apple Darwin/Rhapsody.
91     dnl System headers on these systems are broken.
92     temp_CFLAGS=`echo $CFLAGS | sed "s/-Wall -pedantic//"`
93     CFLAGS=$temp_CFLAGS
94     dnl add extra mac-specific directories to include path
95     CFLAGS="$CFLAGS -I/Developer/Headers/FlatCarbon/"
96     HAVE_FRAMEWORKS="yes"
97     AC_SUBST(PLATFORM,"mac")
98     ;;
99   linux* | solaris* | gnu* | k*bsd*-gnu)
100     SHLIB_VERSION_ARG="-Wl,--version-script=Version_script"
101     AC_SUBST(PLATFORM,"linux")
102     ;;
103   *)
104     ;;
105 esac
107 dnl Define MACOSX for the benefit of altering link likes
108 dnl in the build for that platform
109 AM_CONDITIONAL(MACOS, test "x$HAVE_FRAMEWORKS" = "xyes")
112 dnl  Detect oggz
115 dnl Minimum required version of liboggz
116 oggplay_OGGZ="0.9.8"
118 PKG_CHECK_MODULES(OGGZ, oggz >= "$oggplay_OGGZ", HAVE_OGGZ="yes", HAVE_OGGZ="no")
120 if test "$HAVE_OGGZ" = "yes" ; then
121   AC_DEFINE(HAVE_OGGZ, [], [Define if have liboggz])
122   AC_SUBST(OGGZ_CFLAGS)
123   AC_SUBST(OGGZ_LIBS)
124 else
125   PKG_CHECK_MODULES(OGGZ, oggz, HAVE_OGGZ="old")
127   if test "$HAVE_OGGZ" = "old" ; then
128     AC_MSG_ERROR([
129 *** The version of liboggz installed on your system is too old. You need
130 *** liboggz version greater than $oggplay_OGGZ to build liboggplay.
132   else
133     AC_MSG_ERROR([
134 *** liboggz-$oggplay_OGGZ or greater does not seem to exist on your system.
135 *** Please install it and run this ./configure again.
137   fi
141 dnl  Detect libfishsound
144 dnl Minimum required version of libfishsound
145 oggplay_FISHSOUND="0.9.1"
147 PKG_CHECK_MODULES(FISHSOUND, fishsound >= "$oggplay_FISHSOUND", HAVE_FISHSOUND="yes", HAVE_FISHSOUND="no")
149 if test "$HAVE_FISHSOUND" = "yes" ; then
150   AC_DEFINE(HAVE_FISHSOUND, [], [Define if have libfishsound])
151   AC_SUBST(FISHSOUND_CFLAGS)
152   AC_SUBST(FISHSOUND_LIBS)
153 else
154   PKG_CHECK_MODULES(FISHSOUND, fishsound, HAVE_FISHSOUND="old")
156   if test "$HAVE_FISHSOUND" = "old" ; then
157     AC_MSG_ERROR([
158 *** The version of libfishsound installed on your system is too old. You need
159 *** at least libfishsound version $oggplay_FISHSOUND to build liboggplay.
161   else
162     AC_MSG_ERROR([
163 *** libfishsound-$oggplay_FISHSOUND or greater does not seem to exist on your system.
164 *** Please install it and run this ./configure again.
166   fi
170 dnl  Detect libtheora
172 PKG_CHECK_MODULES(THEORA, theora)
173 AC_SUBST(THEORA_CFLAGS)
174 AC_SUBST(THEORA_LIBS)
177 dnl Detect libskeleton
179 HAVE_SKELETON="no"
180 if test "x$HAVE_PKG_CONFIG" = "xyes" ; then
181   PKG_CHECK_MODULES(SKELETON, skeleton, HAVE_SKELETON="yes", HAVE_SKELETON="no")
183 if test "x$HAVE_SKELETON" = "xyes" ; then
184   AC_DEFINE(HAVE_SKELETON, [], [Define if have libskeleton])
185   AC_SUBST(SKELETON_CFLAGS)
186   AC_SUBST(SKELETON_LIBS)
187 else
188   AC_MSG_RESULT($HAVE_SKELETON)
193 dnl  Detect libkate
195 PKG_CHECK_MODULES(KATE, kate, HAVE_KATE="yes", HAVE_KATE="no")
196 if test "x$HAVE_KATE" = "xyes" ; then
197   AC_DEFINE(HAVE_KATE, [], [Define if have libkate])
198   AC_SUBST(KATE_CFLAGS)
199   AC_SUBST(KATE_LIBS)
200 else
201   AC_MSG_RESULT($HAVE_KATE)
205 dnl  Detect libtiger
207 AC_ARG_WITH(
208   tiger,
209   AS_HELP_STRING(
210     [--with-tiger],
211     [Enable rendering of Kate streams with the Tiger rendering library, using Pango and Cairo (default autodetect)]
212   ),
213   [use_tiger="$withval"]
215 if test "x$use_tiger" != "xno"; then
216   PKG_CHECK_MODULES(TIGER, tiger >= 0.3.1, HAVE_TIGER="yes", HAVE_TIGER="no")
217   if test "x$HAVE_TIGER" = "xyes" ; then
218     AC_DEFINE(HAVE_TIGER, [], [Define if have libtiger])
219     AC_SUBST(TIGER_CFLAGS)
220     AC_SUBST(TIGER_LIBS)
221   else
222     AC_MSG_RESULT($HAVE_TIGER)
223     if test "x$use_tiger" = "xyes"; then
224       AC_MSG_ERROR([libtiger could not be found and was explicitely requested])
225     fi
226   fi
227 else
228   HAVE_TIGER=no
232 dnl Detect Imlib2 (used by dump-all-streams example)
234 PKG_CHECK_MODULES(IMLIB2, imlib2, HAVE_IMLIB2="yes", HAVE_IMLIB2="no")
235 if test "x$HAVE_IMLIB2" = "xyes" ; then
236   oggplay_tools="$oggplay_tools oggplay-dump-first-frame"
237   AC_DEFINE(HAVE_IMLIB2, [], [Define if have Imlib2])
238   AC_SUBST(IMLIB2_LIBS)
239   AC_SUBST(IMLIB2_CFLAGS)
240 else
241   AC_MSG_RESULT($HAVE_IMLIB2)
243 AM_CONDITIONAL(HAVE_IMLIB2, [test "x$HAVE_IMLIB2" = "xyes"])
248 dnl Detect libsndfile1 (used by dump-all-streams example)
249 dnl 
251 PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.0,
252                   HAVE_LIBSNDFILE1="yes", HAVE_LIBSNDFILE1="no")
254 if test "x$HAVE_LIBSNDFILE1" = xyes ; then
255   oggplay_examples="$oggplay_examples dump-all-streams"
256   AC_DEFINE(HAVE_LIBSNDFILE1, [], [Define if have libsndfile])
257   AC_SUBST(SNDFILE_CFLAGS)
258   AC_SUBST(SNDFILE_LIBS) 
260 AM_CONDITIONAL(HAVE_LIBSNDFILE1, [test "x$HAVE_LIBSNDFILE1" = "xyes"])
263 dnl  Detect pthreads libraries
266 PTHREAD_LIBS=error
267 AC_CHECK_LIB(pthread, pthread_attr_init, PTHREAD_LIBS="-lpthread")
268 if test "x$PTHREAD_LIBS" = xerror; then
269         AC_CHECK_LIB(pthreads, pthread_attr_init, PTHREAD_LIBS="-lpthreads")
271 if test "x$PTHREAD_LIBS" = xerror; then
272         AC_CHECK_LIB(c_r, pthread_attr_init, PTHREAD_LIBS="-lc_r")
274 if test "x$PTHREAD_LIBS" = xerror; then
275         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
277 AC_SUBST(PTHREAD_LIBS)
281 dnl Detect GLUT
284 HAVE_GLUT=no
286 ac_enable_glut=yes
287 AC_ARG_ENABLE(glut,
288      [  --disable-glut          disable building of GLUT player],
289      [ ac_enable_glut=no ], [ ac_enable_glut=yes ])
291 if test "x${ac_enable_glut}" != xno ; then
292   dnl XXX: On MacOSX, assume we have GLUT and OpenGL frameworks
293   if test "x$HAVE_FRAMEWORKS" = "xyes" ; then
294     HAVE_GLUT=yes
295     GLUT_LIBS="-lm"
296     GLUT_FRAMEWORKS="-framework GLUT -framework OpenGL"
297     AC_SUBST(GLUT_LIBS)
298     AC_SUBST(GLUT_FRAMEWORKS)
299   else
300     AC_CHECK_LIB(glut, glutInit, HAVE_GLUT="maybe", , [-lGL -lm "$PTHREAD_LIBS"])
301     if test "x$HAVE_GLUT" = "xmaybe" ; then
302       AC_CHECK_HEADER([GL/glut.h], HAVE_GLUT="yes", HAVE_GLUT="no")
303     fi
304     if test "x$HAVE_GLUT" = xyes ; then
305       GLUT_LIBS="-lglut -lGL -lm $PTHREAD_LIBS"
306       AC_SUBST(GLUT_LIBS)
307     fi
308   fi
309   if test "x$HAVE_GLUT" = xyes ; then
310     oggplay_glut="glut-player"
311     AC_DEFINE([HAVE_GLUT], [], [Define if we have GLUT.])
312   else
313     oggplay_glut="
314   *** glut-player will NOT be built. GLUT could not be found."
315   fi
316 else
317   HAVE_GLUT="disabled"
318   oggplay_glut="
319   (glut-player will NOT be built, disabled by './configure --disable-glut')"
321 AM_CONDITIONAL(HAVE_GLUT, [test "x$HAVE_GLUT" = "xyes"])
323 SEMAPHORE_LIBS="-lpthread"
324 AC_SUBST(SEMAPHORE_LIBS)
326 dnl Use -Wall if we have gcc.
327 dnl changequote(,)dnl
328 if test "x$ac_cv_prog_gcc" = xyes ; then
329   CFLAGS="$CFLAGS -Wall -g"
331 dnl changequote([,])dnl
333 dnl Checks for __attribute__(aligned()) directive
334 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
335     [ac_cv_c_attribute_aligned],
336     [ac_cv_c_attribute_aligned=0
337      CFLAGS_save="${CFLAGS}"
338      CFLAGS="${CFLAGS} -Werror"
339      for ac_cv_c_attr_align_try in 64 32 16 8; do
340        AC_TRY_COMPILE([],
341                       [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
342                       [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
343        if test "$ac_cv_c_attribute_aligned" != 0; then
344          break;
345        fi
346      done
347        CFLAGS="${CFLAGS_save}"])
348 if test "${ac_cv_c_attribute_aligned}" != "0"; then
349   AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
350                      [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
357 dnl  Configuration tests complete -- provide summary of results.
360 if test $oggplay_config_ok = no ; then
362 AC_MSG_RESULT([
363 **************************************************************
365 *** $PACKAGE $VERSION: Automatic configuration FAILED.
367 *** The file config.log has full details.
369 *** The following required libraries are missing or
370 *** misconfigured on your system:
373 if test "x$HAVE_OGGZ" != xyes ; then
374     AC_MSG_RESULT(
375 [*** liboggz, available from http://www.annodex.net/])
378 if test "x$HAVE_FISHSOUND" != xyes ; then
379     AC_MSG_RESULT(
380 [*** libfishsound, available from http://www.annodex.net/])
383 AC_MSG_RESULT(
384 [*** If you install the required libraries from source, you
385 *** need to inform the dynamic linker of their location. If
386 *** you install them in a system-wide directory such as
387 *** /usr/local (the default), you must ensure that
388 *** /usr/local/lib is listed in /etc/ld.so.conf, then run
389 *** ldconfig to update the dynamic linking system.
390 *** Alternatively, you can set your LD_LIBRARY_PATH environment
391 *** variable to include the library installation directory.
395 AC_MSG_RESULT(
396 [**************************************************************
400 AC_MSG_ERROR([
402 *** After fixing the above problems, you must run ./configure again.
406 else
408 AC_SUBST(SHLIB_VERSION_ARG)
409 AC_SUBST(SHARED_VERSION_INFO)
411 AC_OUTPUT([
412 Makefile
413 doc/Makefile
414 doc/Doxyfile
415 include/Makefile
416 include/oggplay/Makefile
417 src/Makefile
418 src/liboggplay/Makefile
419 src/liboggplay/Version_script
420 src/examples/Makefile
421 src/tools/Makefile
422 src/tests/Makefile
423 oggplay.pc
424 oggplay-uninstalled.pc
427 AS_AC_EXPAND(LIBDIR, ${libdir})
428 AS_AC_EXPAND(INCLUDEDIR, ${includedir})
429 AS_AC_EXPAND(BINDIR, ${bindir})
430 AS_AC_EXPAND(DOCDIR, ${datadir}/doc)
432 AC_MSG_RESULT([
433 ------------------------------------------------------------------------
434   $PACKAGE $VERSION:  Automatic configuration OK.
436   Tools (./src/tools):
438     $oggplay_tools
440   Examples (./src/examples):
442     $oggplay_examples $oggplay_glut
444   Installation paths:
446     liboggplay: .................. ${LIBDIR}
447     C header files: .............. ${INCLUDEDIR}/oggplay
448     Documentation: ............... ${DOCDIR}/$PACKAGE
450   Building:
452     Type 'make' to compile $PACKAGE.
454     Type 'make install' to install $PACKAGE.
456     ${TESTS_INFO}
458   Example programs will be built but not installed.
460   Kate support: .................. ${HAVE_KATE}
461   Tiger support: ................. ${HAVE_TIGER}
462 ------------------------------------------------------------------------