1# Process this file with autoconf to produce a configure script.
2AC_INIT
3AC_CONFIG_SRCDIR([src/liboggz/oggz.c])
4
5AC_PREREQ(2.53)
6
7AC_CANONICAL_TARGET
8
9AM_INIT_AUTOMAKE(liboggz, 1.1.1)
10AM_CONFIG_HEADER(config.h)
11
12################################################################################
13# Set the shared versioning info, according to section 6.3 of the libtool info #
14# pages. CURRENT:REVISION:AGE must be updated immediately before each release: #
15#                                                                              #
16#   * If the library source code has changed at all since the last             #
17#     update, then increment REVISION (`C:R:A' becomes `C:r+1:A').             #
18#                                                                              #
19#   * If any interfaces have been added, removed, or changed since the         #
20#     last update, increment CURRENT, and set REVISION to 0.                   #
21#                                                                              #
22#   * If any interfaces have been added since the last public release,         #
23#     then increment AGE.                                                      #
24#                                                                              #
25#   * If any interfaces have been removed since the last public release,       #
26#     then set AGE to 0.                                                       #
27#                                                                              #
28################################################################################
29SHARED_VERSION_INFO="8:0:6"
30SHLIB_VERSION_ARG=""
31
32# Checks for programs.
33AC_PROG_CC
34AC_PROG_CPP
35AC_PROG_INSTALL
36AC_PROG_LN_S
37AC_PROG_MAKE_SET
38AC_PROG_LIBTOOL
39
40AC_C_CONST
41AC_C_BIGENDIAN
42
43dnl Add parameters for aclocal
44AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
45
46# Checks for header files.
47AC_HEADER_STDC
48AC_CHECK_HEADERS([fcntl.h inttypes.h stdlib.h string.h sys/types.h unistd.h])
49
50# Checks for typedefs, structures, and compiler characteristics.
51AC_TYPE_OFF_T
52AC_TYPE_SIZE_T
53
54dnl Check whether the compiler allows signed enums.
55dnl Re: http://lists.xiph.org/pipermail/ogg-dev/2008-July/001108.html
56dnl
57dnl "The ISO C standard, in section 6.7.2.2 "enumeration specifiers",
58dnl paragraph 4, says
59dnl
60dnl   Each enumerated type shall be compatible with *char*, a signed
61dnl   integer type, or an unsigned integer type.  The choice of type is
62dnl   implementation-defined, but shall be capable of representing the
63dnl   values of all the members of the declaration."
64dnl
65dnl -- http://gcc.gnu.org/ml/gcc-bugs/2000-09/msg00271.html
66AC_MSG_CHECKING([if $CC allows signed enums])
67
68ac_save_CFLAGS="$CFLAGS"
69CFLAGS="$CFLAGS -Wall -Wextra -Werror"
70AC_TRY_COMPILE([], [
71               void t (void)
72               {
73                 enum {A, B} a=A;
74                 if (a < 0) {}
75               } ],
76               [ AC_DEFINE([ALLOW_SIGNED_ENUMS], [],
77                           [Define if the compiler implements enums as signed values.])
78                 AC_MSG_RESULT(yes) ],
79               [ AC_MSG_RESULT(no) ])
80CFLAGS="$ac_save_CFLAGS"
81
82# Checks for library functions.
83AC_CHECK_FUNCS([memmove])
84
85# Check for pkg-config
86AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
87
88# Check for doxygen
89AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
90AM_CONDITIONAL(HAVE_DOXYGEN,$HAVE_DOXYGEN)
91if test $HAVE_DOXYGEN = "false"; then
92             AC_MSG_WARN([*** doxygen not found, docs will not be built])
93fi
94
95# Check for man2html
96AC_CHECK_PROG(HAVE_MAN2HTML, man2html, true, false)
97AM_CONDITIONAL(HAVE_MAN2HTML, $HAVE_MAN2HTML)
98
99# Check for valgrind
100VALGRIND_ENVIRONMENT=""
101ac_enable_valgrind=no
102AC_ARG_ENABLE(valgrind-testing,
103     AC_HELP_STRING([--enable-valgrind-testing], [enable running of tests inside Valgrind]),
104     [ ac_enable_valgrind=yes ], [ ac_enable_valgrind=no] )
105
106if test "x${ac_enable_valgrind}" = xyes ; then
107  if test "x${enable_shared}" = xyes ; then
108    VALGRIND_ENVIRONMENT="libtool --mode=execute "
109  fi
110
111  AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
112  if test "x$HAVE_VALGRIND" = xyes ; then
113    VALGRIND_ENVIRONMENT="$VALGRIND_ENVIRONMENT valgrind -q --leak-check=yes --show-reachable=yes --num-callers=50"
114    AC_SUBST(VALGRIND_ENVIRONMENT)
115    TESTS_INFO="Test suite will be run under:
116    ${VALGRIND_ENVIRONMENT}"
117  else
118    TESTS_INFO="(Valgrind not found)"
119  fi
120else
121  TESTS_INFO="(Valgrind testing not enabled)"
122fi
123
124dnl Checks for libraries.
125LIBS=""
126
127# check for getopt in a separate library
128HAVE_GETOPT=no
129AC_CHECK_LIB(getopt, getopt, HAVE_GETOPT="yes")
130if test "x$HAVE_GETOPT" = xyes ; then
131  GETOPT_LIBS="-lgetopt"
132  AC_SUBST(GETOPT_LIBS)
133fi
134
135# check for getopt_long in standard library
136HAVE_GETOPT_LONG=no
137AC_CHECK_FUNC(getopt_long, HAVE_GETOPT_LONG="yes")
138if test "x$HAVE_GETOPT_LONG" = xyes ; then
139  AC_DEFINE(HAVE_GETOPT_LONG, [], [Define to 1 if you have the 'getopt_long' function])
140fi
141
142dnl Overall configuration success flag
143oggz_config_ok=yes
144
145oggz_read_programs=""
146oggz_rw_programs=""
147
148dnl
149dnl  Configuration option for building of experimental code.
150dnl
151
152ac_enable_experimental=no
153AC_ARG_ENABLE(experimental,
154     AC_HELP_STRING([--enable-experimental], [enable building of experimental code]),
155     [ ac_enable_experimental=yes ])
156
157if test "x${ac_enable_experimental}" = xyes ; then
158    AC_DEFINE(OGGZ_CONFIG_EXPERIMENTAL, [], [Define to build experimental code])
159fi
160
161dnl
162dnl  Configuration option for building of reading support.
163dnl
164
165ac_enable_read=yes
166AC_ARG_ENABLE(read,
167     AC_HELP_STRING([--disable-read], [disable building of reading support]),
168     [ ac_enable_read=no ], [ ac_enable_read=yes] )
169
170if test "x${ac_enable_read}" = xyes ; then
171    AC_DEFINE(OGGZ_CONFIG_READ, [1], [Build reading support])
172    oggz_read_programs="oggz-dump oggz-info oggz-scan oggz-codecs"
173else
174    AC_DEFINE(OGGZ_CONFIG_READ, [0], [Do not build reading support])
175fi
176AM_CONDITIONAL(OGGZ_CONFIG_READ, test "x${ac_enable_read}" = xyes)
177
178dnl
179dnl  Configuration option for building of writing support.
180dnl
181
182ac_enable_write=yes
183AC_ARG_ENABLE(write,
184     AC_HELP_STRING([--disable-write], [disable building of writing support]),
185     [ ac_enable_write=no ], [ ac_enable_write=yes] )
186
187if test "x${ac_enable_write}" = xyes ; then
188    AC_DEFINE(OGGZ_CONFIG_WRITE, [1], [Build writing support])
189    if test "x${ac_enable_read}" = xyes ; then
190      oggz_rw_programs="oggz-rip oggz-merge oggz-chop oggz-comment oggz-sort oggz-validate"
191    fi
192else
193    AC_DEFINE(OGGZ_CONFIG_WRITE, [0], [Do not build writing support])
194fi
195AM_CONDITIONAL(OGGZ_CONFIG_WRITE, test "x${ac_enable_write}" = xyes)
196
197dnl
198dnl  Check read/write option sanity
199dnl
200if test "x${ac_enable_read}" = xno && test "x${ac_enable_write}" = xno ; then
201  AC_MSG_ERROR([
202***
203*** You have attempted to explicitly disable both writing and reading.
204***
205])
206fi
207
208dnl
209dnl Detect Ogg
210dnl
211
212HAVE_OGG=no
213if test "x$HAVE_PKG_CONFIG" = "xyes" ; then
214  PKG_CHECK_MODULES(OGG, ogg >= 1.0, HAVE_OGG=yes, HAVE_OGG=no)
215fi
216
217if test "x$HAVE_OGG" = "xno" ; then
218  XIPH_PATH_OGG(HAVE_OGG="yes", HAVE_OGG="no")
219  if test "x$HAVE_OGG" = xno ; then
220    oggz_config_ok="no"
221    AC_CHECK_LIB(ogg, ogg_stream_init, HAVE_OGG="maybe")
222  fi
223fi
224
225AM_CONDITIONAL(HAVE_OGG, [test "x$HAVE_OGG" = "xyes"])
226
227dnl Check for const-correct version of <ogg/ogg.h>
228dnl In libogg changeset:14463, function prototypes like:
229dnl      ogg_page_bos (ogg_page * og);
230dnl were changed to:
231dnl     ogg_page_bos (const ogg_page * og);
232dnl If we are compiling with -Werror, we need to know this.
233if test "x$HAVE_OGG" = "xyes" ; then
234    AC_MSG_CHECKING([if ogg_page_bos() takes a const argument])
235    ac_save_CFLAGS="$CFLAGS"
236    ac_save_LIBS="$LIBS"
237    CFLAGS="$CFLAGS -Wall -Werror $OGG_CFLAGS"
238    LIBS="$LIBS $OGG_LIBS"
239
240    AC_TRY_COMPILE([#include <ogg/ogg.h>],
241                   [int f(const ogg_page * cog){return ogg_page_bos(cog);}],
242                   [ AC_DEFINE([OGG_H_CONST_CORRECT], [], [Define if <ogg/ogg.h> is const-correct])
243                     AC_MSG_RESULT(yes) ],
244                   [ AC_MSG_RESULT(no) ])
245
246    CFLAGS="$ac_save_CFLAGS"
247    LIBS="$ac_save_LIBS"
248fi
249
250dnl Large file support
251dnl Adapted from: libsndfile by Erik de Castro Lopo
252dnl
253dnl Find an appropriate type for oggz_off_t
254dnl On systems supporting files larger than 2 Gig, oggz_off_t must be a
255dnl 64 bit value. Unfortunately there is more than one way of ensuring
256dnl this so need to do some pretty rigourous testing here.
257
258unset ac_cv_sizeof_off_t
259
260AC_CHECK_SIZEOF(off_t, 1)
261
262case "$host_os" in
263    mingw*)
264        TYPEOF_OGGZ_OFF_T="__int64"
265        OGGZ_OFF_MAX="0x7FFFFFFFFFFFFFFFLL"
266        SIZEOF_OGGZ_OFF_T=8
267        ;;
268    *)
269        if test "x$ac_cv_sizeof_off_t" = "x8" ; then
270            # If sizeof (off_t) is 8, no further checking is needed.
271            TYPEOF_OGGZ_OFF_T="off_t"
272            OGGZ_OFF_MAX="0x7FFFFFFFFFFFFFFFLL"
273            SIZEOF_OGGZ_OFF_T=8
274        else
275            # Check for common 64 bit file offset types.
276            AC_CHECK_SIZEOF(loff_t,1)       # Fake default value.
277            AC_CHECK_SIZEOF(off64_t,1)      # Fake default value.
278
279            TYPEOF_OGGZ_OFF_T="unknown"
280            if test "x$ac_cv_sizeof_loff_t" = "x8" ; then
281                TYPEOF_OGGZ_OFF_T="loff_t"
282                SIZEOF_OGGZ_OFF_T=8
283            elif test "x$ac_cv_sizeof_off64_t" = "x8" ; then
284                TYPEOF_OGGZ_OFF_T="off64_t"
285                SIZEOF_OGGZ_OFF_T=8
286            fi
287
288            # Save the old sizeof (off_t) value  and then unset it to see if it
289            # changes when Large File Support is enabled.
290
291            pre_largefile_sizeof_off_t=$ac_cv_sizeof_off_t
292            unset ac_cv_sizeof_off_t
293
294            AC_SYS_EXTRA_LARGEFILE
295
296            if test "x$ac_cv_sys_largefile_CFLAGS" = "xno" ; then
297                ac_cv_sys_largefile_CFLAGS=""
298            fi
299            if test "x$ac_cv_sys_largefile_LDFLAGS" = "xno" ; then
300                ac_cv_sys_largefile_LDFLAGS=""
301            fi
302            if test "x$ac_cv_sys_largefile_LIBS" = "xno" ; then
303                ac_cv_sys_largefile_LIBS=""
304            fi
305
306            AC_CHECK_SIZEOF(off_t,1)        # Fake default value.
307
308            if test "x$ac_cv_sizeof_off_t" = "x8" ; then
309                    OGGZ_OFF_MAX="0x7FFFFFFFFFFFFFFFLL"
310            elif test "x$ac_cv_sizeof_off_t" = "x$pre_largefile_sizeof_off_t" ; then
311                AC_MSG_WARN([[This machine does not seem to support 64 bit file offsets.]])
312                TYPEOF_OGGZ_OFF_T="off_t"
313                SIZEOF_OGGZ_OFF_T=$ac_cv_sizeof_off_t
314            elif test "x$TYPEOF_OGGZ_OFF_T" = "xunknown" ; then
315                echo
316                echo "*** The configure process has determined that this system is capable"
317                echo "*** of Large File Support but has not been able to find a type which"
318                echo "*** is an unambiguous 64 bit file offset."
319                echo "*** Please contact the author to help resolve this problem."
320                echo
321                AC_MSG_ERROR([[Bad file offset type.]])
322            fi
323        fi
324    ;;
325    esac
326
327if test $SIZEOF_OGGZ_OFF_T = 4 ; then
328    OGGZ_OFF_MAX="0x7FFFFFFF"
329    PRI_OGGZ_OFF_T="l"
330elif test $SIZEOF_OGGZ_OFF_T = 8 ; then
331    PRI_OGGZ_OFF_T="ll"
332fi
333
334dnl The following configured variables are written into the public header
335dnl <oggz/oggz_off_t_generated.h>:
336dnl   oggz_off_t (typedef)
337dnl   PRI_OGGZ_OFF_T (printf format)
338
339AC_SUBST(TYPEOF_OGGZ_OFF_T)
340AC_SUBST(PRI_OGGZ_OFF_T)
341
342dnl SIZEOF_OGGZ_OFF_T and OGGZ_OFF_MAX are only used internally by liboggz
343AC_DEFINE_UNQUOTED([SIZEOF_OGGZ_OFF_T],${SIZEOF_OGGZ_OFF_T}, [Set to sizeof (long) if unknown.])
344AC_SUBST(SIZEOF_OGGZ_OFF_T)
345
346AC_DEFINE_UNQUOTED([OGGZ_OFF_MAX],${OGGZ_OFF_MAX}, [Set to maximum allowed value of sf_count_t type.])
347AC_SUBST(OGGZ_OFF_MAX)
348
349AC_CHECK_TYPES(ssize_t)
350AC_CHECK_SIZEOF(ssize_t,4)
351
352# MacOS 10.4 only declares timezone for _XOPEN_SOURCE. Check for this.
353AC_MSG_CHECKING([for timezone])
354AC_COMPILE_IFELSE(
355  AC_LANG_PROGRAM([#include <time.h>], [
356    int seconds = 1234567;
357    seconds -= timezone;
358  ]), AC_MSG_RESULT([ok]),
359  AC_MSG_RESULT([no])
360  AC_MSG_CHECKING([for timezone with _XOPEN_SOURCE])
361  AC_COMPILE_IFELSE(
362    AC_LANG_PROGRAM([
363#define _XOPEN_SOURCE
364#include <time.h>
365    ], [
366      int seconds = 1234567;
367      seconds -= timezone;
368    ]),
369   dnl _XOPEN_SOURCE is required
370    AC_MSG_RESULT([ok])
371    AC_DEFINE([_XOPEN_SOURCE], [1],
372      [Some systems need _XOPEN_SOURCE for timezone]),
373   dnl it didn't work even with _XOPEN_SOURCE; httpdate will break
374    AC_MSG_RESULT([no])
375  )
376)
377
378# Checks for typedefs, structures, and compiler characteristics.
379
380dnl Add some useful warnings if we have gcc.
381dnl changequote(,)dnl
382if test "x$ac_cv_prog_gcc" = xyes ; then
383  CFLAGS="$CFLAGS -Wall -Wextra -g -std=gnu99 -Wdeclaration-after-statement -Wno-unused"
384fi
385dnl changequote([,])dnl
386
387dnl
388dnl  Configuration option to add -Werror to all Makefiles
389dnl
390
391AC_ARG_ENABLE(gcc-werror,
392     AC_HELP_STRING([--enable-gcc-werror], [enable -Werror in all Makefiles]),
393     [ ac_enable_gcc_werror=yes ], [ ac_enable_gcc_werror=no] )
394
395if test "x${ac_enable_gcc_werror}" = xyes ; then
396  CFLAGS="-Werror $CFLAGS"
397fi
398
399dnl
400dnl Shared library symbol versioning and hiding
401dnl
402
403case "$target_os" in
404  linux* | solaris*|k*bsd*-gnu*|gnu*)
405    SHLIB_VERSION_ARG="-Wl,--version-script=Version_script"
406    ;;
407  *)
408    ;;
409esac
410
411# Checks for library functions.
412
413dnl
414dnl  Configuration tests complete -- provide summary of results.
415dnl
416
417if test $oggz_config_ok = no ; then
418
419AC_MSG_RESULT([
420**************************************************************
421
422*** $PACKAGE $VERSION: Automatic configuration FAILED.
423
424*** The file config.log has full details.
425
426*** The following required libraries are missing or
427*** misconfigured on your system:
428])
429
430if test "x$HAVE_OGG" != xyes ; then
431    AC_MSG_RESULT(
432[*** libogg, available from  http://www.xiph.org/ogg/])
433fi
434if test "x$HAVE_OGG" = xmaybe ; then
435    AC_MSG_RESULT(
436[      Development files missing: The libogg library binary seems to be
437      installed, but building of a test program failed.
438])
439fi
440
441AC_MSG_RESULT(
442[*** If you install the required libraries from source, you
443*** need to inform the dynamic linker of their location. If
444*** you install them in a system-wide directory such as
445*** /usr/local (the default), you must ensure that
446*** /usr/local/lib is listed in /etc/ld.so.conf, then run
447*** ldconfig to update the dynamic linking system.
448*** Alternatively, you can set your LD_LIBRARY_PATH environment
449*** variable to include the library installation directory.
450])
451
452
453AC_MSG_RESULT(
454[**************************************************************
455])
456
457
458AC_MSG_ERROR([
459***
460*** After fixing the above problems, you must run ./configure again.
461***
462])
463
464else
465
466AS_AC_EXPAND(LIBDIR, ${libdir})
467AS_AC_EXPAND(INCLUDEDIR, ${includedir})
468AS_AC_EXPAND(BINDIR, ${bindir})
469AS_AC_EXPAND(DOCDIR, ${datadir}/doc)
470
471AC_SUBST(BINDIR)
472
473AC_SUBST(SHLIB_VERSION_ARG)
474AC_SUBST(SHARED_VERSION_INFO)
475
476AC_OUTPUT([
477Makefile
478doc/Makefile
479doc/Doxyfile
480include/Makefile
481include/oggz/Makefile
482include/oggz/oggz_off_t_generated.h
483src/Makefile
484src/liboggz/Version_script
485src/liboggz/Makefile
486src/tools/Makefile
487src/tools/oggz-diff
488src/tools/oggz-chop/Makefile
489src/tests/Makefile
490src/examples/Makefile
491apache/oggz-chop.conf
492oggz.pc
493oggz-uninstalled.pc
494])
495
496AC_MSG_RESULT([
497------------------------------------------------------------------------
498  $PACKAGE $VERSION:  Automatic configuration OK.
499
500  General configuration:
501
502    Experimental code: ........... ${ac_enable_experimental}
503    Reading support: ............. ${ac_enable_read}
504    Writing support: ............. ${ac_enable_write}
505
506  Tools:
507
508    ${oggz_read_programs}
509    ${oggz_rw_programs}
510
511  Installation paths:
512
513    liboggz: ..................... ${LIBDIR}
514    Tools: ....................... ${BINDIR}
515    C header files: .............. ${INCLUDEDIR}/oggz
516    Documentation: ............... ${DOCDIR}/$PACKAGE
517
518  Building:
519
520    Type 'make' to compile $PACKAGE.
521
522    Type 'make install' to install $PACKAGE.
523
524    Type 'make check' to test $PACKAGE using the unit and functional tests
525    contained in the src/tests directory.
526    ${TESTS_INFO}
527
528  Example programs will be built but not installed.
529------------------------------------------------------------------------
530])
531
532
533fi
534