Enable versioning on kfree-bsd-gnu to be the same as linux
[liboggplay.git] / configure.ac
blob7c707defbdfa8516d80f02e3e307e10a914163a1
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 libkate
179 PKG_CHECK_MODULES(KATE, kate, HAVE_KATE="yes", HAVE_KATE="no")
180 if test "x$HAVE_KATE" = "xyes" ; then
181   AC_DEFINE(HAVE_KATE, [], [Define if have libkate])
182   AC_SUBST(KATE_CFLAGS)
183   AC_SUBST(KATE_LIBS)
184 else
185   AC_MSG_RESULT($HAVE_KATE)
189 dnl  Detect libtiger
191 AC_ARG_WITH(
192   tiger,
193   AS_HELP_STRING(
194     [--with-tiger],
195     [Enable rendering of Kate streams with the Tiger rendering library, using Pango and Cairo (default autodetect)]
196   ),
197   [use_tiger="$withval"]
199 if test "x$use_tiger" != "xno"; then
200   PKG_CHECK_MODULES(TIGER, tiger >= 0.3.1, HAVE_TIGER="yes", HAVE_TIGER="no")
201   if test "x$HAVE_TIGER" = "xyes" ; then
202     AC_DEFINE(HAVE_TIGER, [], [Define if have libtiger])
203     AC_SUBST(TIGER_CFLAGS)
204     AC_SUBST(TIGER_LIBS)
205   else
206     AC_MSG_RESULT($HAVE_TIGER)
207     if test "x$use_tiger" = "xyes"; then
208       AC_MSG_ERROR([libtiger could not be found and was explicitely requested])
209     fi
210   fi
211 else
212   HAVE_TIGER=no
216 dnl Detect Imlib2 (used by dump-all-streams example)
218 PKG_CHECK_MODULES(IMLIB2, imlib2, HAVE_IMLIB2="yes", HAVE_IMLIB2="no")
219 if test "x$HAVE_IMLIB2" = "xyes" ; then
220   oggplay_tools="$oggplay_tools oggplay-dump-first-frame"
221   AC_DEFINE(HAVE_IMLIB2, [], [Define if have Imlib2])
222   AC_SUBST(IMLIB2_LIBS)
223   AC_SUBST(IMLIB2_CFLAGS)
224 else
225   AC_MSG_RESULT($HAVE_IMLIB2)
227 AM_CONDITIONAL(HAVE_IMLIB2, [test "x$HAVE_IMLIB2" = "xyes"])
232 dnl Detect libsndfile1 (used by dump-all-streams example)
233 dnl 
235 PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.0,
236                   HAVE_LIBSNDFILE1="yes", HAVE_LIBSNDFILE1="no")
238 if test "x$HAVE_LIBSNDFILE1" = xyes ; then
239   oggplay_examples="$oggplay_examples dump-all-streams"
240   AC_DEFINE(HAVE_LIBSNDFILE1, [], [Define if have libsndfile])
241   AC_SUBST(SNDFILE_CFLAGS)
242   AC_SUBST(SNDFILE_LIBS) 
244 AM_CONDITIONAL(HAVE_LIBSNDFILE1, [test "x$HAVE_LIBSNDFILE1" = "xyes"])
247 dnl  Detect pthreads libraries
250 PTHREAD_LIBS=error
251 AC_CHECK_LIB(pthread, pthread_attr_init, PTHREAD_LIBS="-lpthread")
252 if test "x$PTHREAD_LIBS" = xerror; then
253         AC_CHECK_LIB(pthreads, pthread_attr_init, PTHREAD_LIBS="-lpthreads")
255 if test "x$PTHREAD_LIBS" = xerror; then
256         AC_CHECK_LIB(c_r, pthread_attr_init, PTHREAD_LIBS="-lc_r")
258 if test "x$PTHREAD_LIBS" = xerror; then
259         AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
261 AC_SUBST(PTHREAD_LIBS)
265 dnl Detect GLUT
268 HAVE_GLUT=no
270 ac_enable_glut=yes
271 AC_ARG_ENABLE(glut,
272      [  --disable-glut          disable building of GLUT player],
273      [ ac_enable_glut=no ], [ ac_enable_glut=yes ])
275 if test "x${ac_enable_glut}" != xno ; then
276   dnl XXX: On MacOSX, assume we have GLUT and OpenGL frameworks
277   if test "x$HAVE_FRAMEWORKS" = "xyes" ; then
278     HAVE_GLUT=yes
279     GLUT_LIBS="-lm"
280     GLUT_FRAMEWORKS="-framework GLUT -framework OpenGL"
281     AC_SUBST(GLUT_LIBS)
282     AC_SUBST(GLUT_FRAMEWORKS)
283   else
284     AC_CHECK_LIB(glut, glutInit, HAVE_GLUT="maybe", , [-lGL -lm "$PTHREAD_LIBS"])
285     if test "x$HAVE_GLUT" = "xmaybe" ; then
286       AC_CHECK_HEADER([GL/glut.h], HAVE_GLUT="yes", HAVE_GLUT="no")
287     fi
288     if test "x$HAVE_GLUT" = xyes ; then
289       GLUT_LIBS="-lglut -lGL -lm $PTHREAD_LIBS"
290       AC_SUBST(GLUT_LIBS)
291     fi
292   fi
293   if test "x$HAVE_GLUT" = xyes ; then
294     oggplay_glut="glut-player"
295     AC_DEFINE([HAVE_GLUT], [], [Define if we have GLUT.])
296   else
297     oggplay_glut="
298   *** glut-player will NOT be built. GLUT could not be found."
299   fi
300 else
301   HAVE_GLUT="disabled"
302   oggplay_glut="
303   (glut-player will NOT be built, disabled by './configure --disable-glut')"
305 AM_CONDITIONAL(HAVE_GLUT, [test "x$HAVE_GLUT" = "xyes"])
307 SEMAPHORE_LIBS="-lpthread"
308 AC_SUBST(SEMAPHORE_LIBS)
310 dnl Use -Wall if we have gcc.
311 dnl changequote(,)dnl
312 if test "x$ac_cv_prog_gcc" = xyes ; then
313   CFLAGS="$CFLAGS -Wall -g"
315 dnl changequote([,])dnl
317 dnl Checks for __attribute__(aligned()) directive
318 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
319     [ac_cv_c_attribute_aligned],
320     [ac_cv_c_attribute_aligned=0
321      CFLAGS_save="${CFLAGS}"
322      CFLAGS="${CFLAGS} -Werror"
323      for ac_cv_c_attr_align_try in 64 32 16 8; do
324        AC_TRY_COMPILE([],
325                       [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
326                       [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
327        if test "$ac_cv_c_attribute_aligned" != 0; then
328          break;
329        fi
330      done
331        CFLAGS="${CFLAGS_save}"])
332 if test "${ac_cv_c_attribute_aligned}" != "0"; then
333   AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
334                      [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
341 dnl  Configuration tests complete -- provide summary of results.
344 if test $oggplay_config_ok = no ; then
346 AC_MSG_RESULT([
347 **************************************************************
349 *** $PACKAGE $VERSION: Automatic configuration FAILED.
351 *** The file config.log has full details.
353 *** The following required libraries are missing or
354 *** misconfigured on your system:
357 if test "x$HAVE_OGGZ" != xyes ; then
358     AC_MSG_RESULT(
359 [*** liboggz, available from http://www.annodex.net/])
362 if test "x$HAVE_FISHSOUND" != xyes ; then
363     AC_MSG_RESULT(
364 [*** libfishsound, available from http://www.annodex.net/])
367 AC_MSG_RESULT(
368 [*** If you install the required libraries from source, you
369 *** need to inform the dynamic linker of their location. If
370 *** you install them in a system-wide directory such as
371 *** /usr/local (the default), you must ensure that
372 *** /usr/local/lib is listed in /etc/ld.so.conf, then run
373 *** ldconfig to update the dynamic linking system.
374 *** Alternatively, you can set your LD_LIBRARY_PATH environment
375 *** variable to include the library installation directory.
379 AC_MSG_RESULT(
380 [**************************************************************
384 AC_MSG_ERROR([
386 *** After fixing the above problems, you must run ./configure again.
390 else
392 AC_SUBST(SHLIB_VERSION_ARG)
393 AC_SUBST(SHARED_VERSION_INFO)
395 AC_OUTPUT([
396 Makefile
397 doc/Makefile
398 doc/Doxyfile
399 include/Makefile
400 include/oggplay/Makefile
401 src/Makefile
402 src/liboggplay/Makefile
403 src/liboggplay/Version_script
404 src/examples/Makefile
405 src/tools/Makefile
406 src/tests/Makefile
407 oggplay.pc
408 oggplay-uninstalled.pc
411 AS_AC_EXPAND(LIBDIR, ${libdir})
412 AS_AC_EXPAND(INCLUDEDIR, ${includedir})
413 AS_AC_EXPAND(BINDIR, ${bindir})
414 AS_AC_EXPAND(DOCDIR, ${datadir}/doc)
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
432     Documentation: ............... ${DOCDIR}/$PACKAGE
434   Building:
436     Type 'make' to compile $PACKAGE.
438     Type 'make install' to install $PACKAGE.
440     ${TESTS_INFO}
442   Example programs will be built but not installed.
444   Kate support: .................. ${HAVE_KATE}
445   Tiger support: ................. ${HAVE_TIGER}
446 ------------------------------------------------------------------------