1 # Configure paths for SDL
3 # stolen from Manish Singh
4 # stolen back from Frank Belew
5 # stolen from Manish Singh
6 # Shamelessly stolen from Owen Taylor
8 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
9 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
11 AC_DEFUN([AM_PATH_SDL],
13 dnl Get the cflags and libraries from the sdl-config script
15 AC_ARG_WITH(sdl-static,[ --with-sdl-static Link SDL staticaly (optional)],
16 sdl_static="$withval", sdl_static="")
17 AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
18 sdl_prefix="$withval", sdl_prefix="")
19 AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
20 sdl_exec_prefix="$withval", sdl_exec_prefix="")
21 AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
24 if test x$sdl_exec_prefix != x ; then
25 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
26 if test x${SDL_CONFIG+set} != xset ; then
27 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
30 if test x$sdl_prefix != x ; then
31 sdl_args="$sdl_args --prefix=$sdl_prefix"
32 if test x${SDL_CONFIG+set} != xset ; then
33 SDL_CONFIG=$sdl_prefix/bin/sdl-config
37 AC_REQUIRE([AC_CANONICAL_TARGET])
38 PATH="$prefix/bin:$prefix/usr/bin:$PATH"
39 AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
40 min_sdl_version=ifelse([$1], ,0.11.0,$1)
41 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
43 if test "$SDL_CONFIG" = "no" ; then
46 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
48 if test x"$sdl_static" = x"yes"; then
49 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --static-libs`
51 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
54 sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
55 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
56 sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
57 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
58 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
59 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
60 if test "x$enable_sdltest" = "xyes" ; then
61 ac_save_CFLAGS="$CFLAGS"
62 ac_save_CXXFLAGS="$CXXFLAGS"
64 CFLAGS="$CFLAGS $SDL_CFLAGS"
65 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
66 LIBS="$LIBS $SDL_LIBS"
68 dnl Now check if the installed SDL is sufficiently new. (Also sanity
69 dnl checks the results of sdl-config to some extent
85 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
86 strcpy (new_str, str);
94 int main (int argc, char *argv[])
96 int major, minor, micro;
99 /* This hangs on some systems (?)
100 system ("touch conf.sdltest");
102 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
104 /* HP/UX 9 (%@#!) writes to sscanf strings */
105 tmp_version = my_strdup("$min_sdl_version");
106 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
107 printf("%s, bad version string\n", "$min_sdl_version");
111 if (($sdl_major_version > major) ||
112 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
113 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
119 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
120 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
121 printf("*** best to upgrade to the required version.\n");
122 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
123 printf("*** to point to the correct copy of sdl-config, and remove the file\n");
124 printf("*** config.cache before re-running configure\n");
129 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
130 CFLAGS="$ac_save_CFLAGS"
131 CXXFLAGS="$ac_save_CXXFLAGS"
135 if test "x$no_sdl" = x ; then
137 ifelse([$2], , :, [$2])
140 if test "$SDL_CONFIG" = "no" ; then
141 echo "*** The sdl-config script installed by SDL could not be found"
142 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
143 echo "*** your path, or set the SDL_CONFIG environment variable to the"
144 echo "*** full path to sdl-config."
146 if test -f conf.sdltest ; then
149 echo "*** Could not run SDL test program, checking why..."
150 CFLAGS="$CFLAGS $SDL_CFLAGS"
151 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
152 LIBS="$LIBS $SDL_LIBS"
157 int main(int argc, char *argv[])
160 #define main K_and_R_C_main
162 [ echo "*** The test program compiled, but did not run. This usually means"
163 echo "*** that the run-time linker is not finding SDL or finding the wrong"
164 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
165 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
166 echo "*** to the installed location Also, make sure you have run ldconfig if that"
167 echo "*** is required on your system"
169 echo "*** If you have an old version installed, it is best to remove it, although"
170 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
171 [ echo "*** The test program failed to compile or link. See the file config.log for the"
172 echo "*** exact error that occured. This usually means SDL was incorrectly installed"
173 echo "*** or that you have moved SDL since it was installed. In the latter case, you"
174 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
175 CFLAGS="$ac_save_CFLAGS"
176 CXXFLAGS="$ac_save_CXXFLAGS"
182 ifelse([$3], , :, [$3])
188 dnl ---------------------------------------------------------------------------
189 dnl Macros for wxWindows detection. Typically used in configure.in as:
191 dnl AC_ARG_ENABLE(...)
194 dnl AM_OPTIONS_WXCONFIG
197 dnl AM_PATH_WXCONFIG(2.3.4, wxWin=1)
198 dnl if test "$wxWin" != 1; then
200 dnl wxWindows must be installed on your system
201 dnl but wx-config script couldn't be found.
203 dnl Please check that wx-config is in path, the directory
204 dnl where wxWindows libraries are installed (returned by
205 dnl 'wx-config --libs' command) is in LD_LIBRARY_PATH or
206 dnl equivalent variable and wxWindows version is 2.3.4 or above.
209 dnl CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
210 dnl CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
211 dnl CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
213 dnl LDFLAGS="$LDFLAGS $WX_LIBS"
214 dnl ---------------------------------------------------------------------------
216 dnl ---------------------------------------------------------------------------
217 dnl AM_OPTIONS_WXCONFIG
219 dnl adds support for --wx-prefix, --wx-exec-prefix and --wx-config
220 dnl command line options
221 dnl ---------------------------------------------------------------------------
223 AC_DEFUN([AM_OPTIONS_WXCONFIG],
225 AC_ARG_WITH(wx-prefix, [ --with-wx-prefix=PREFIX Prefix where wxWindows is installed (optional)],
226 wx_config_prefix="$withval", wx_config_prefix="")
227 AC_ARG_WITH(wx-exec-prefix,[ --with-wx-exec-prefix=PREFIX Exec prefix where wxWindows is installed (optional)],
228 wx_config_exec_prefix="$withval", wx_config_exec_prefix="")
229 AC_ARG_WITH(wx-config,[ --with-wx-config=CONFIG wx-config script to use (optional)],
230 wx_config_name="$withval", wx_config_name="")
233 dnl ---------------------------------------------------------------------------
234 dnl AM_PATH_WXCONFIG(VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
236 dnl Test for wxWindows, and define WX_C*FLAGS, WX_LIBS and WX_LIBS_STATIC
237 dnl (the latter is for static linking against wxWindows). Set WX_CONFIG_NAME
238 dnl environment variable to override the default name of the wx-config script
239 dnl to use. Set WX_CONFIG_PATH to specify the full path to wx-config - in this
240 dnl case the macro won't even waste time on tests for its existence.
241 dnl ---------------------------------------------------------------------------
244 dnl Get the cflags and libraries from the wx-config script
246 AC_DEFUN([AM_PATH_WXCONFIG],
248 dnl do we have wx-config name: it can be wx-config or wxd-config or ...
249 if test x${WX_CONFIG_NAME+set} != xset ; then
250 WX_CONFIG_NAME=wx-config
252 if test "x$wx_config_name" != x ; then
253 WX_CONFIG_NAME="$wx_config_name"
256 dnl deal with optional prefixes
257 if test x$wx_config_exec_prefix != x ; then
258 wx_config_args="$wx_config_args --exec-prefix=$wx_config_exec_prefix"
259 WX_LOOKUP_PATH="$wx_config_exec_prefix/bin"
261 if test x$wx_config_prefix != x ; then
262 wx_config_args="$wx_config_args --prefix=$wx_config_prefix"
263 WX_LOOKUP_PATH="$WX_LOOKUP_PATH:$wx_config_prefix/bin"
266 dnl don't search the PATH if WX_CONFIG_NAME is absolute filename
267 if test -x "$WX_CONFIG_NAME" ; then
268 AC_MSG_CHECKING(for wx-config)
269 WX_CONFIG_PATH="$WX_CONFIG_NAME"
270 AC_MSG_RESULT($WX_CONFIG_PATH)
272 AC_PATH_PROG(WX_CONFIG_PATH, $WX_CONFIG_NAME, no, "$WX_LOOKUP_PATH:$PATH")
275 if test "$WX_CONFIG_PATH" != "no" ; then
279 min_wx_version=ifelse([$1], ,2.2.1,$1)
280 AC_MSG_CHECKING(for wxWindows version >= $min_wx_version)
282 WX_CONFIG_WITH_ARGS="$WX_CONFIG_PATH $wx_config_args"
284 WX_VERSION=`$WX_CONFIG_WITH_ARGS --version`
285 wx_config_major_version=`echo $WX_VERSION | \
286 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
287 wx_config_minor_version=`echo $WX_VERSION | \
288 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
289 wx_config_micro_version=`echo $WX_VERSION | \
290 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
292 wx_requested_major_version=`echo $min_wx_version | \
293 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
294 wx_requested_minor_version=`echo $min_wx_version | \
295 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
296 wx_requested_micro_version=`echo $min_wx_version | \
297 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
300 if test $wx_config_major_version -gt $wx_requested_major_version; then
303 if test $wx_config_major_version -eq $wx_requested_major_version; then
304 if test $wx_config_minor_version -gt $wx_requested_minor_version; then
307 if test $wx_config_minor_version -eq $wx_requested_minor_version; then
308 if test $wx_config_micro_version -ge $wx_requested_micro_version; then
316 if test "x$wx_ver_ok" = x ; then
319 WX_LIBS=`$WX_CONFIG_WITH_ARGS --libs`
320 WX_LIBS_STATIC=`$WX_CONFIG_WITH_ARGS --static --libs`
322 dnl starting with version 2.2.6 wx-config has --cppflags argument
324 if test $wx_config_major_version -gt 2; then
327 if test $wx_config_major_version -eq 2; then
328 if test $wx_config_minor_version -gt 2; then
331 if test $wx_config_minor_version -eq 2; then
332 if test $wx_config_micro_version -ge 6; then
340 if test "x$wx_has_cppflags" = x ; then
341 dnl no choice but to define all flags like CFLAGS
342 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
343 WX_CPPFLAGS=$WX_CFLAGS
344 WX_CXXFLAGS=$WX_CFLAGS
346 WX_CFLAGS_ONLY=$WX_CFLAGS
347 WX_CXXFLAGS_ONLY=$WX_CFLAGS
349 dnl we have CPPFLAGS included in CFLAGS included in CXXFLAGS
350 WX_CPPFLAGS=`$WX_CONFIG_WITH_ARGS --cppflags`
351 WX_CXXFLAGS=`$WX_CONFIG_WITH_ARGS --cxxflags`
352 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
354 WX_CFLAGS_ONLY=`echo $WX_CFLAGS | sed "s@^$WX_CPPFLAGS *@@"`
355 WX_CXXFLAGS_ONLY=`echo $WX_CXXFLAGS | sed "s@^$WX_CFLAGS *@@"`
359 if test "x$no_wx" = x ; then
360 AC_MSG_RESULT(yes (version $WX_VERSION))
361 ifelse([$2], , :, [$2])
363 if test "x$WX_VERSION" = x; then
364 dnl no wx-config at all
367 AC_MSG_RESULT(no (version $WX_VERSION is not new enough))
375 ifelse([$3], , :, [$3])
379 AC_SUBST(WX_CPPFLAGS)
381 AC_SUBST(WX_CXXFLAGS)
382 AC_SUBST(WX_CFLAGS_ONLY)
383 AC_SUBST(WX_CXXFLAGS_ONLY)
385 AC_SUBST(WX_LIBS_STATIC)
388 # Configure paths for FreeType2
389 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
392 # AC_CHECK_FT2([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
393 # Test for FreeType 2, and define FT2_CFLAGS and FT2_LIBS.
394 # MINIMUM-VERSION is what libtool reports; the default is `7.0.1' (this is
397 AC_DEFUN([AC_CHECK_FT2],
398 [# Get the cflags and libraries from the freetype-config script
400 AC_ARG_WITH([ft-prefix],
401 AC_HELP_STRING([--with-ft-prefix=PREFIX],
402 [Prefix where FreeType is installed (optional)]),
403 [ft_config_prefix="$withval"],
404 [ft_config_prefix=""])
406 AC_ARG_WITH([ft-exec-prefix],
407 AC_HELP_STRING([--with-ft-exec-prefix=PREFIX],
408 [Exec prefix where FreeType is installed (optional)]),
409 [ft_config_exec_prefix="$withval"],
410 [ft_config_exec_prefix=""])
412 AC_ARG_ENABLE([freetypetest],
413 AC_HELP_STRING([--disable-freetypetest],
414 [Do not try to compile and run a test FreeType program]),
418 if test x$ft_config_exec_prefix != x ; then
419 ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
420 if test x${FT2_CONFIG+set} != xset ; then
421 FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
425 if test x$ft_config_prefix != x ; then
426 ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
427 if test x${FT2_CONFIG+set} != xset ; then
428 FT2_CONFIG=$ft_config_prefix/bin/freetype-config
432 AC_PATH_PROG([FT2_CONFIG], [freetype-config], [no])
434 min_ft_version=m4_if([$1], [], [7.0.1], [$1])
435 AC_MSG_CHECKING([for FreeType -- version >= $min_ft_version])
437 if test "$FT2_CONFIG" = "no" ; then
440 FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
441 FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
442 ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
443 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
444 ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
445 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
446 ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
447 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
448 ft_min_major_version=`echo $min_ft_version | \
449 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
450 ft_min_minor_version=`echo $min_ft_version | \
451 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
452 ft_min_micro_version=`echo $min_ft_version | \
453 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
454 if test x$enable_fttest = xyes ; then
456 if test $ft_config_major_version -lt $ft_min_major_version ; then
459 if test $ft_config_major_version -eq $ft_min_major_version ; then
460 if test $ft_config_minor_version -lt $ft_min_minor_version ; then
463 if test $ft_config_minor_version -eq $ft_min_minor_version ; then
464 if test $ft_config_micro_version -lt $ft_min_micro_version ; then
471 if test x$ft_config_is_lt = xyes ; then
474 ac_save_CFLAGS="$CFLAGS"
476 CFLAGS="$CFLAGS $FT2_CFLAGS"
477 LIBS="$FT2_LIBS $LIBS"
480 # Sanity checks for the results of freetype-config to some extent.
485 #include <ft2build.h>
486 #include FT_FREETYPE_H
496 error = FT_Init_FreeType(&library);
502 FT_Done_FreeType(library);
511 [echo $ECHO_N "cross compiling; assuming OK... $ECHO_C"])
513 CFLAGS="$ac_save_CFLAGS"
515 fi # test $ft_config_version -lt $ft_min_version
516 fi # test x$enable_fttest = xyes
517 fi # test "$FT2_CONFIG" = "no"
519 if test x$no_ft = x ; then
521 m4_if([$2], [], [:], [$2])
524 if test "$FT2_CONFIG" = "no" ; then
527 The freetype-config script installed by FreeType 2 could not be found.
528 If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in
529 your path, or set the FT2_CONFIG environment variable to the
530 full path to freetype-config.
533 if test x$ft_config_is_lt = xyes ; then
536 Your installed version of the FreeType 2 library is too old.
537 If you have different versions of FreeType 2, make sure that
538 correct values for --with-ft-prefix or --with-ft-exec-prefix
539 are used, or set the FT2_CONFIG environment variable to the
540 full path to freetype-config.
545 The FreeType test program failed to run. If your system uses
546 shared libraries and they are installed outside the normal
547 system library path, make sure the variable LD_LIBRARY_PATH
548 (or whatever is appropiate for your system) is correctly set.
555 m4_if([$3], [], [:], [$3])
558 AC_SUBST([FT2_CFLAGS])
559 AC_SUBST([FT2_LIBS])])
561 # end of freetype2.m4
562 # Configure paths for libogg
563 # Jack Moffitt <jack@icecast.org> 10-21-2000
564 # Shamelessly stolen from Owen Taylor and Manish Singh
566 dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
567 dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
569 AC_DEFUN([XIPH_PATH_OGG],
571 dnl Get the cflags and libraries
573 AC_ARG_WITH(ogg,[ --with-ogg=PFX Prefix where libogg is installed (optional)], ogg_prefix="$withval", ogg_prefix="")
574 AC_ARG_WITH(ogg-libraries,[ --with-ogg-libraries=DIR Directory where libogg library is installed (optional)], ogg_libraries="$withval", ogg_libraries="")
575 AC_ARG_WITH(ogg-includes,[ --with-ogg-includes=DIR Directory where libogg header files are installed (optional)], ogg_includes="$withval", ogg_includes="")
576 AC_ARG_ENABLE(oggtest, [ --disable-oggtest Do not try to compile and run a test Ogg program],, enable_oggtest=yes)
578 if test "x$ogg_libraries" != "x" ; then
579 OGG_LIBS="-L$ogg_libraries"
580 elif test "x$ogg_prefix" != "x" ; then
581 OGG_LIBS="-L$ogg_prefix/lib"
582 elif test "x$prefix" != "xNONE" ; then
583 OGG_LIBS="-L$prefix/lib"
586 if test `uname` == Darwin; then
587 OGG_LIBS="$OGG_LIBS -framework Ogg"
589 OGG_LIBS="$OGG_LIBS -logg"
592 if test "x$ogg_includes" != "x" ; then
593 OGG_CFLAGS="-I$ogg_includes"
594 elif test "x$ogg_prefix" != "x" ; then
595 OGG_CFLAGS="-I$ogg_prefix/include"
596 elif test "x$prefix" != "xNONE"; then
597 OGG_CFLAGS="-I$prefix/include"
600 AC_MSG_CHECKING(for Ogg)
604 if test "x$enable_oggtest" = "xyes" ; then
605 ac_save_CFLAGS="$CFLAGS"
607 CFLAGS="$CFLAGS $OGG_CFLAGS"
608 LIBS="$LIBS $OGG_LIBS"
610 dnl Now check if the installed Ogg is sufficiently new.
621 system("touch conf.oggtest");
625 ],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
626 CFLAGS="$ac_save_CFLAGS"
630 if test "x$no_ogg" = "x" ; then
632 ifelse([$1], , :, [$1])
635 if test -f conf.oggtest ; then
638 echo "*** Could not run Ogg test program, checking why..."
639 CFLAGS="$CFLAGS $OGG_CFLAGS"
640 LIBS="$LIBS $OGG_LIBS"
645 [ echo "*** The test program compiled, but did not run. This usually means"
646 echo "*** that the run-time linker is not finding Ogg or finding the wrong"
647 echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
648 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
649 echo "*** to the installed location Also, make sure you have run ldconfig if that"
650 echo "*** is required on your system"
652 echo "*** If you have an old version installed, it is best to remove it, although"
653 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
654 [ echo "*** The test program failed to compile or link. See the file config.log for the"
655 echo "*** exact error that occured. This usually means Ogg was incorrectly installed"
656 echo "*** or that you have moved Ogg since it was installed." ])
657 CFLAGS="$ac_save_CFLAGS"
662 ifelse([$2], , :, [$2])
668 # Configure paths for libvorbis
669 # Jack Moffitt <jack@icecast.org> 10-21-2000
670 # Shamelessly stolen from Owen Taylor and Manish Singh
671 # thomasvs added check for vorbis_bitrate_addblock which is new in rc3
673 dnl XIPH_PATH_VORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
674 dnl Test for libvorbis, and define VORBIS_CFLAGS and VORBIS_LIBS
676 AC_DEFUN([XIPH_PATH_VORBIS],
678 dnl Get the cflags and libraries
680 AC_ARG_WITH(vorbis,[ --with-vorbis=PFX Prefix where libvorbis is installed (optional)], vorbis_prefix="$withval", vorbis_prefix="")
681 AC_ARG_WITH(vorbis-libraries,[ --with-vorbis-libraries=DIR Directory where libvorbis library is installed (optional)], vorbis_libraries="$withval", vorbis_libraries="")
682 AC_ARG_WITH(vorbis-includes,[ --with-vorbis-includes=DIR Directory where libvorbis header files are installed (optional)], vorbis_includes="$withval", vorbis_includes="")
683 AC_ARG_ENABLE(vorbistest, [ --disable-vorbistest Do not try to compile and run a test Vorbis program],, enable_vorbistest=yes)
685 if test "x$vorbis_libraries" != "x" ; then
686 VORBIS_LIBS="-L$vorbis_libraries"
687 elif test "x$vorbis_prefix" != "x" ; then
688 VORBIS_LIBS="-L$vorbis_prefix/lib"
689 elif test "x$prefix" != "xNONE"; then
690 VORBIS_LIBS="-L$prefix/lib"
693 if test `uname` == Darwin; then
694 VORBIS_LIBS="$VORBIS_LIBS -framework Vorbis -lm"
698 VORBIS_LIBS="$VORBIS_LIBS -lvorbis -lm"
699 VORBISFILE_LIBS="-lvorbisfile"
700 VORBISENC_LIBS="-lvorbisenc"
703 if test "x$vorbis_includes" != "x" ; then
704 VORBIS_CFLAGS="-I$vorbis_includes"
705 elif test "x$vorbis_prefix" != "x" ; then
706 VORBIS_CFLAGS="-I$vorbis_prefix/include"
707 elif test "x$prefix" != "xNONE"; then
708 VORBIS_CFLAGS="-I$prefix/include"
712 AC_MSG_CHECKING(for Vorbis)
716 if test "x$enable_vorbistest" = "xyes" ; then
717 ac_save_CFLAGS="$CFLAGS"
719 CFLAGS="$CFLAGS $VORBIS_CFLAGS $OGG_CFLAGS"
720 LIBS="$LIBS $VORBIS_LIBS $VORBISENC_LIBS $OGG_LIBS"
722 dnl Now check if the installed Vorbis is sufficiently new.
724 rm -f conf.vorbistest
729 #include <vorbis/codec.h>
730 #include <vorbis/vorbisenc.h>
738 vorbis_info_init (&vi);
739 vorbis_encode_init (&vi, 2, 44100, -1, 128000, -1);
740 vorbis_analysis_init (&vd, &vi);
741 vorbis_block_init (&vd, &vb);
742 /* this function was added in 1.0rc3, so this is what we're testing for */
743 vorbis_bitrate_addblock (&vb);
745 system("touch conf.vorbistest");
749 ],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
750 CFLAGS="$ac_save_CFLAGS"
754 if test "x$no_vorbis" = "x" ; then
756 ifelse([$1], , :, [$1])
759 if test -f conf.vorbistest ; then
762 echo "*** Could not run Vorbis test program, checking why..."
763 CFLAGS="$CFLAGS $VORBIS_CFLAGS"
764 LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
767 #include <vorbis/codec.h>
769 [ echo "*** The test program compiled, but did not run. This usually means"
770 echo "*** that the run-time linker is not finding Vorbis or finding the wrong"
771 echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your"
772 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
773 echo "*** to the installed location Also, make sure you have run ldconfig if that"
774 echo "*** is required on your system"
776 echo "*** If you have an old version installed, it is best to remove it, although"
777 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
778 [ echo "*** The test program failed to compile or link. See the file config.log for the"
779 echo "*** exact error that occured. This usually means Vorbis was incorrectly installed"
780 echo "*** or that you have moved Vorbis since it was installed." ])
781 CFLAGS="$ac_save_CFLAGS"
788 ifelse([$2], , :, [$2])
790 AC_SUBST(VORBIS_CFLAGS)
791 AC_SUBST(VORBIS_LIBS)
792 AC_SUBST(VORBISFILE_LIBS)
793 AC_SUBST(VORBISENC_LIBS)
794 rm -f conf.vorbistest