root/liboggz/trunk/configure.ac

Revision 3719, 13.6 kB (checked in by conrad, 3 months ago)

Apply patch from dryeo, "off_t not always in stdio.h"
Closes ticket:413

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