Recognizes if input is ogg or not.
[xiph.git] / vorbis-tools / configure.ac
blob163117406406de7b41dab54aa78a3f4897d7a827
1 dnl Process this file with autoconf to produce a configure script
3 dnl ------------------------------------------------
4 dnl Initialization
5 dnl ------------------------------------------------
7 AC_INIT(oggenc/encode.c)
9 AC_CANONICAL_HOST
10 AC_CANONICAL_TARGET
12 AC_PREREQ(2.53)
14 AM_INIT_AUTOMAKE([vorbis-tools],[1.2.1])
15 AM_MAINTAINER_MODE
17 AM_CONFIG_HEADER([config.h])
19 AC_USE_SYSTEM_EXTENSIONS
21 dnl --------------------------------------------------  
22 dnl Check for programs
23 dnl --------------------------------------------------  
25 dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2"
26 dnl if $CFLAGS is blank
27 cflags_save="$CFLAGS"
28 AC_PROG_CC
29 CFLAGS="$cflags_save"
31 AC_PROG_LIBTOOL
33 ALL_LINGUAS="be cs da en_GB es fr hr hu nl ro ru sk sv uk vi"
34 AM_GNU_GETTEXT
36 dnl --------------------------------------------------
37 dnl System checks
38 dnl --------------------------------------------------
40 AC_SYS_LARGEFILE
41 AC_C_BIGENDIAN
43 dnl --------------------------------------------------
44 dnl Set build flags based on environment
45 dnl --------------------------------------------------
47 cflags_save="$CFLAGS"
48 if test -z "$GCC"; then
49         case $host in
50         *-*-irix*)
51                 DEBUG="-g -signed"
52                 CFLAGS="-O2 -w -signed"
53                 PROFILE="-p -g3 -O2 -signed"
54                 ;;
55         sparc-sun-solaris*)
56                 DEBUG="-v -g"
57                 CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
58                 PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc"
59                 ;;
60         *)
61                 DEBUG="-g"
62                 CFLAGS="-O"
63                 PROFILE="-g -p"
64                 ;;
65         esac
66 else
67         case $host in
68         *-*-linux*)
69                 DEBUG="-g -Wall -fsigned-char"
70                 CFLAGS="-O2 -Wall -ffast-math -fsigned-char"
71                 PROFILE="-Wall -W -pg -g -O2 -ffast-math -fsigned-char"
72                 ;;
73         sparc-sun-*)
74                 DEBUG="-g -Wall -fsigned-char -mv8"
75                 CFLAGS="-O20 -ffast-math -fsigned-char -mv8"
76                 PROFILE="-pg -g -O20 -fsigned-char -mv8"
77                 ;;
78         *-*-darwin*)
79                 DEBUG="-fno-common -g -Wall -fsigned-char"
80                 CFLAGS="-fno-common -O4 -Wall -fsigned-char -ffast-math"
81                 PROFILE="-fno-common -O4 -Wall -pg -g -fsigned-char -ffast-math"
82                 ;;
83         *)
84                 DEBUG="-g -Wall -fsigned-char"
85                 CFLAGS="-O2 -fsigned-char"
86                 PROFILE="-O2 -g -pg -fsigned-char"
87                 ;;
88         esac
90 CFLAGS="$CFLAGS $cflags_save"
91 DEBUG="$DEBUG $cflags_save"
92 PROFILE="$PROFILE $cflags_save"
94 dnl --------------------------------------------------
95 dnl Allow tools to be selectively built
96 dnl --------------------------------------------------
97 AC_ARG_ENABLE(ogg123, [  --disable-ogg123   Skip building ogg123], build_ogg123="$enableval", build_ogg123="yes")
98 AC_ARG_ENABLE(oggdec, [  --disable-oggdec   Skip building oggdec], build_oggdec="$enableval", build_oggdec="yes")
99 AC_ARG_ENABLE(oggenc, [  --disable-oggenc   Skip building oggenc], build_oggenc="$enableval", build_oggenc="yes")
100 AC_ARG_ENABLE(ogginfo,[  --disable-ogginfo  Skip building ogginfo], build_ogginfo="$enableval", build_ogginfo="yes")
101 AC_ARG_ENABLE(vcut,   [  --disable-vcut     Skip building vcut], build_vcut="$enableval", build_vcut="no")
102 AC_ARG_ENABLE(vorbiscomment, [  --disable-vorbiscomment   Skip building vorbiscomment], build_vorbiscomment="$enableval", build_vorbiscomment="yes")
103 AC_ARG_WITH(flac,     [  --without-flac     Do not compile FLAC support], build_flac="$withval", build_flac="yes")
104 AC_ARG_WITH(speex,    [  --without-speex    Do not compile Speex support], build_speex="$withval", build_speex="yes")
105 AC_ARG_WITH(kate,     [  --without-kate     Do not compile Kate support], build_kate="$withval", build_kate="yes")
107 dnl --------------------------------------------------
108 dnl Check for generally needed libraries
109 dnl --------------------------------------------------
111 HAVE_OGG=no
112 dnl first check through pkg-config
113 dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
114 AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
115 if test "x$HAVE_PKG_CONFIG" = "xyes"
116 then
117   PKG_CHECK_MODULES(OGG, ogg >= 1.0, HAVE_OGG=yes, HAVE_OGG=no)
119 if test "x$HAVE_OGG" = "xno"
120 then
121   dnl fall back to the old school test
122   XIPH_PATH_OGG(,AC_MSG_ERROR(Ogg needed!))
123   libs_save=$LIBS
124   LIBS="$OGG_LIBS $VORBIS_LIBS"
125   AC_CHECK_FUNC(oggpack_writealign, , AC_MSG_ERROR(Ogg >= 1.0 required !))
126   LIBS=$libs_save
129 dnl check for Vorbis
130 HAVE_VORBIS=no
132 dnl first check through pkg-config since it's more flexible
134 if test "x$HAVE_PKG_CONFIG" = "xyes"
135 then
136   PKG_CHECK_MODULES(VORBIS, vorbis >= 1.1.1, HAVE_VORBIS=yes, HAVE_VORBIS=no)
137   dnl also set VORBISENC_LIBS since an examples needs it
138   dnl the old .m4 sets this to a value to use on top of VORBIS_LIBS,
139   dnl so we do the same here.
140   VORBISENC_LIBS="-lvorbisenc"
141   VORBISFILE_LIBS="-lvorbisfile"
142   AC_SUBST(VORBISENC_LIBS)
143   AC_SUBST(VORBISFILE_LIBS)
145 if test "x$HAVE_VORBIS" = "xno"
146 then
147   dnl fall back to the old school test
148   XIPH_PATH_VORBIS(,AC_MSG_ERROR(Vorbis needed!))
153 SHARE_LIBS='$(top_builddir)/share/libutf8.a $(top_builddir)/share/libgetopt.a'
154 SHARE_CFLAGS='-I$(top_srcdir)/include'
156 I18N_CFLAGS='-I$(top_srcdir)/intl'
157 I18N_LIBS=$INTLLIBS
159 SOCKET_LIBS=
160 AC_CHECK_LIB(socket, socket, SOCKET_LIBS="-lsocket")
161 AC_CHECK_LIB(nsl, gethostbyname, SOCKET_LIBS="-lnsl $SOCKET_LIBS")
164 dnl --------------------------------------------------
165 dnl Check for ogg123 critical libraries and other optional libraries
166 dnl --------------------------------------------------
168 dnl curl is an optional dependancy of ogg123
169 if test "x$HAVE_PKG_CONFIG" = "xyes"; then
170   PKG_CHECK_MODULES(CURL, libcurl, HAVE_CURL=yes, HAVE_CURL=no)
171   if test "x$HAVE_CURL" = "xno"; then
172     AM_PATH_CURL(HAVE_CURL=yes, HAVE_CURL=no; AC_MSG_WARN(libcurl missing))
173   fi
174 else
175   AM_PATH_CURL(HAVE_CURL=yes, HAVE_CURL=no; AC_MSG_WARN(libcurl missing))
177 if test "x$HAVE_CURL" = "xyes"; then
178   AC_DEFINE(HAVE_CURL,1,[Defined if we have libcurl])
181 if test "x$build_ogg123" = xyes; then
182   AC_MSG_RESULT([checking for ogg123 requirements])
183   XIPH_PATH_AO(,build_ogg123=no; AC_MSG_WARN(libao missing))
185   ACX_PTHREAD(,build_ogg123=no; AC_MSG_WARN(POSIX threads missing))
188 dnl -------------------- FLAC ----------------------
190 FLAC_LIBS=""
191 if test "x$build_flac" = xyes; then
193   AC_CHECK_LIB(m,log,FLAC_LIBS="-lm")
195   dnl First check for libFLAC-1.1.3 or later. As of libFLAC 1.1.3,
196   dnl OggFLAC functionality has been rolled into libFLAC rather
197   dnl than being in a separate libOggFLAC library.
199   AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_init_ogg_stream],
200     have_libFLAC=yes, have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS])
202   if test "x$have_libFLAC" = xyes; then
203     FLAC_LIBS="-lFLAC $FLAC_LIBS $OGG_LIBS"
204   else
205     dnl Check for libFLAC prior to 1.1.3
206     AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_process_single],
207       [have_libFLAC=yes; FLAC_LIBS="-lFLAC $FLAC_LIBS"],
208       AC_MSG_WARN([libFLAC missing])
209       have_libFLAC=no, [$FLAC_LIBS]
210     )
212     AC_CHECK_LIB(OggFLAC, [OggFLAC__stream_decoder_new],
213       [FLAC_LIBS="-lOggFLAC $FLAC_LIBS $OGG_LIBS"],
214       AC_MSG_WARN([libOggFLAC missing])
215       have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS]
216     )
217   fi
219   AC_CHECK_HEADER(FLAC/stream_decoder.h,,
220     AC_MSG_WARN(libFLAC headers missing)
221     have_libFLAC=no,[ ])
223   if test "x$have_libFLAC" = xyes; then
224      AC_DEFINE(HAVE_LIBFLAC, 1, [Defined if we have libFLAC])
225   else
226      build_flac="no"
227      FLAC_LIBS=""
228   fi
230 AM_CONDITIONAL(HAVE_LIBFLAC, test "x$have_libFLAC" = "xyes")
231 AC_SUBST(FLAC_LIBS)
233 dnl ------------------- Speex ------------------------
235 SPEEX_LIBS=""
236 if test "x$build_speex" = xyes; then
237   AC_CHECK_LIB(m,log,SPEEX_LIBS="-lm")
238   AC_CHECK_LIB(speex, [speex_decoder_init],
239     [have_libspeex=yes; SPEEX_LIBS="-lspeex $SPEEX_LIBS"],
240     AC_MSG_WARN(libspeex missing)
241     have_libspeex=no, [$SPEEX_LIBS]
242   )
243   AC_CHECK_HEADER(speex/speex.h,,
244     AC_MSG_WARN(libspeex headers missing)
245     have_libspeex=no,[ ])
247   if test "x$have_libspeex" = xyes; then
248     AC_DEFINE(HAVE_LIBSPEEX, 1, [Defined if we have libspeex])
249   else
250     build_speex="no"
251     SPEEX_LIBS=""
252   fi
254 AM_CONDITIONAL(HAVE_LIBSPEEX, test "x$have_libspeex" = "xyes")
255 AC_SUBST(SPEEX_LIBS)
257 dnl ------------------- Kate -------------------------
259 KATE_CFLAGS=""
260 KATE_LIBS=""
261 if test "x$build_kate" = xyes; then
262   AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
263   if test "x$HAVE_PKG_CONFIG" = "xyes"
264   then
265     PKG_CHECK_MODULES(KATE, oggkate, HAVE_KATE=yes, HAVE_KATE=no)
266   fi
267   if test "x$HAVE_KATE" = "xno"
268   then
269     dnl fall back to the old school test
270     AC_CHECK_LIB(m,log,KATE_LIBS="-lm")
271     AC_CHECK_LIB(kate, [kate_decode_init],
272       [HAVE_KATE=yes; KATE_LIBS="-lkate $KATE_LIBS $OGG_LIBS"],
273       AC_MSG_WARN(libkate missing)
274       HAVE_KATE=no, [$KATE_LIBS $OGG_LIBS]
275     )
276     AC_CHECK_LIB(oggkate, [kate_ogg_decode_headerin],
277       [HAVE_KATE=yes; KATE_LIBS="-loggkate $KATE_LIBS $OGG_LIBS"],
278       AC_MSG_WARN(libkate missing)
279       HAVE_KATE=no, [$KATE_LIBS $OGG_LIBS]
280     )
281     AC_CHECK_HEADER(kate/kate.h,,
282       AC_MSG_WARN(libkate headers missing)
283       HAVE_KATE=no,[ ])
284     AC_CHECK_HEADER(kate/oggkate.h,,
285       AC_MSG_WARN(liboggkate headers missing)
286       HAVE_KATE=no,[ ])
288   fi
289   if test "x$HAVE_KATE" = xyes; then
290     AC_DEFINE(HAVE_KATE, 1, [Defined if we have libkate])
291   else
292     build_kate="no"
293     KATE_CFLAGS=""
294     KATE_LIBS=""
295   fi
297 AM_CONDITIONAL(HAVE_KATE, test "x$HAVE_KATE" = "xyes")
298 AC_SUBST(KATE_CFLAGS)
299 AC_SUBST(KATE_LIBS)
301 dnl --------------------------------------------------
302 dnl Check for headers
303 dnl --------------------------------------------------
305 AC_CHECK_HEADERS([fcntl.h unistd.h])
307 dnl --------------------------------------------------
308 dnl Check for library functions
309 dnl --------------------------------------------------
311 AC_FUNC_ALLOCA
312 AM_ICONV
313 AC_CHECK_FUNCS(atexit on_exit fcntl select stat chmod)
314 AM_LANGINFO_CODESET
316 dnl --------------------------------------------------
317 dnl Work around FHS stupidity
318 dnl --------------------------------------------------
320 if test -z "$mandir"; then
321     if test "$prefix" = "/usr"; then
322         MANDIR='$(datadir)/man'
323     else
324         MANDIR='$(prefix)/man'
325     fi
326 else
327     MANDIR=$mandir
329 AC_SUBST(MANDIR)
332 dnl --------------------------------------------------
333 dnl Do substitutions
334 dnl --------------------------------------------------
336 # add optional subdirs to the build
337 OPT_SUBDIRS=""
338 if test "x$build_ogg123" = xyes; then
339   OPT_SUBDIRS="$OPT_SUBDIRS ogg123"
341 if test "x$build_oggenc" = xyes; then
342   OPT_SUBDIRS="$OPT_SUBDIRS oggenc"
344 if test "x$build_oggdec" = xyes; then
345   OPT_SUBDIRS="$OPT_SUBDIRS oggdec"
347 if test "x$build_ogginfo" = xyes; then
348   OPT_SUBDIRS="$OPT_SUBDIRS ogginfo"
350 if test "x$build_vcut" = xyes; then
351   OPT_SUBDIRS="$OPT_SUBDIRS vcut"
353 if test "x$build_vorbiscomment" = xyes; then
354   OPT_SUBDIRS="$OPT_SUBDIRS vorbiscomment"
356 AC_SUBST(OPT_SUBDIRS)
358 AC_SUBST(DEBUG)
359 AC_SUBST(PROFILE)
360 AC_SUBST(SOCKET_LIBS)
361 AC_SUBST(SHARE_CFLAGS)
362 AC_SUBST(SHARE_LIBS)
363 AC_SUBST(CURL_CFLAGS)
364 AC_SUBST(CURL_LIBS)
365 AC_SUBST(I18N_CFLAGS)
366 AC_SUBST(I18N_LIBS)
368 AC_OUTPUT([
369 Makefile
370 m4/Makefile
371 po/Makefile.in
372 intl/Makefile
373 include/Makefile
374 share/Makefile
375 win32/Makefile
376 oggdec/Makefile
377 oggenc/Makefile
378 oggenc/man/Makefile
379 ogg123/Makefile
380 vorbiscomment/Makefile
381 vcut/Makefile
382 ogginfo/Makefile
383 debian/Makefile
386 if test "x$build_oggenc" = xyes -a "x$have_libFLAC" != xyes; then
387     AC_MSG_WARN([FLAC and/or OggFLAC libraries or headers missing, oggenc 
388 will NOT be built with FLAC read support.])
391 if test "x$build_ogg123" != xyes; then
392     AC_MSG_WARN([Prerequisites for ogg123 not met, ogg123 will be skipped.
393 Please ensure that you have POSIX threads, libao, and (optionally) libcurl
394 libraries and headers present if you would like to build ogg123.])
395 else
396     if test "x$have_libFLAC" != xyes; then
397         AC_MSG_WARN([FLAC and/or OggFLAC libraries or headers missing, ogg123 
398 will NOT be built with FLAC read support.])
399     fi
400     if test "x$have_libspeex" != xyes; then
401         AC_MSG_WARN([Speex libraries and/or headers missing, ogg123 
402 will NOT be built with Speex read support.])
403     fi
404     if test "x$HAVE_CURL" != xyes; then
405         AC_MSG_WARN([curl libraries and/or headers missing, ogg123 
406 will NOT be built with http support.])
407     fi
408     if test "x$HAVE_KATE" != xyes; then
409         AC_MSG_WARN([Kate libraries and/or headers missing, ogginfo 
410 will be built with LIMITED Kate read support.])
411     fi