xref: /aosp_15_r20/external/flac/m4/ogg.m4 (revision 600f14f40d737144c998e2ec7a483122d3776fbc)
1*600f14f4SXin Li# Configure paths for libogg
2*600f14f4SXin Li# Jack Moffitt <[email protected]> 10-21-2000
3*600f14f4SXin Li# Shamelessly stolen from Owen Taylor and Manish Singh
4*600f14f4SXin Li
5*600f14f4SXin Lidnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
6*600f14f4SXin Lidnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
7*600f14f4SXin Lidnl
8*600f14f4SXin LiAC_DEFUN([XIPH_PATH_OGG],
9*600f14f4SXin Li[dnl
10*600f14f4SXin Lidnl Get the cflags and libraries
11*600f14f4SXin Lidnl
12*600f14f4SXin LiAC_ARG_WITH(ogg,AS_HELP_STRING([--with-ogg=PFX],[Prefix where libogg is installed (optional)]), ogg_prefix="$withval", ogg_prefix="")
13*600f14f4SXin LiAC_ARG_WITH(ogg-libraries,AS_HELP_STRING([--with-ogg-libraries=DIR],[Directory where libogg library is installed (optional)]), ogg_libraries="$withval", ogg_libraries="")
14*600f14f4SXin LiAC_ARG_WITH(ogg-includes,AS_HELP_STRING([--with-ogg-includes=DIR],[Directory where libogg header files are installed (optional)]), ogg_includes="$withval", ogg_includes="")
15*600f14f4SXin LiAC_ARG_ENABLE(oggtest,AS_HELP_STRING([--disable-oggtest],[Do not try to compile and run a test Ogg program]),, enable_oggtest=yes)
16*600f14f4SXin Li
17*600f14f4SXin Li  if test "x$ogg_libraries" != "x" ; then
18*600f14f4SXin Li    OGG_LIBS="-L$ogg_libraries"
19*600f14f4SXin Li  elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then
20*600f14f4SXin Li    OGG_LIBS=""
21*600f14f4SXin Li  elif test "x$ogg_prefix" != "x" ; then
22*600f14f4SXin Li    OGG_LIBS="-L$ogg_prefix/lib"
23*600f14f4SXin Li  elif test "x$prefix" != "xNONE" ; then
24*600f14f4SXin Li    OGG_LIBS="-L$prefix/lib"
25*600f14f4SXin Li  fi
26*600f14f4SXin Li
27*600f14f4SXin Li  if test "x$ogg_prefix" != "xno" ; then
28*600f14f4SXin Li    OGG_LIBS="$OGG_LIBS -logg"
29*600f14f4SXin Li  fi
30*600f14f4SXin Li
31*600f14f4SXin Li  if test "x$ogg_includes" != "x" ; then
32*600f14f4SXin Li    OGG_CFLAGS="-I$ogg_includes"
33*600f14f4SXin Li  elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then
34*600f14f4SXin Li    OGG_CFLAGS=""
35*600f14f4SXin Li  elif test "x$ogg_prefix" != "x" ; then
36*600f14f4SXin Li    OGG_CFLAGS="-I$ogg_prefix/include"
37*600f14f4SXin Li  elif test "x$prefix" != "xNONE"; then
38*600f14f4SXin Li    OGG_CFLAGS="-I$prefix/include"
39*600f14f4SXin Li  fi
40*600f14f4SXin Li
41*600f14f4SXin Li  AC_MSG_CHECKING(for Ogg)
42*600f14f4SXin Li  if test "x$ogg_prefix" = "xno" ; then
43*600f14f4SXin Li    no_ogg="disabled"
44*600f14f4SXin Li    enable_oggtest="no"
45*600f14f4SXin Li  else
46*600f14f4SXin Li    no_ogg=""
47*600f14f4SXin Li  fi
48*600f14f4SXin Li
49*600f14f4SXin Li
50*600f14f4SXin Li  if test "x$enable_oggtest" = "xyes" ; then
51*600f14f4SXin Li    ac_save_CFLAGS="$CFLAGS"
52*600f14f4SXin Li    ac_save_LIBS="$LIBS"
53*600f14f4SXin Li    CFLAGS="$CFLAGS $OGG_CFLAGS"
54*600f14f4SXin Li    LIBS="$LIBS $OGG_LIBS"
55*600f14f4SXin Lidnl
56*600f14f4SXin Lidnl Now check if the installed Ogg is sufficiently new.
57*600f14f4SXin Lidnl
58*600f14f4SXin Li      rm -f conf.oggtest
59*600f14f4SXin Li      AC_RUN_IFELSE([AC_LANG_SOURCE([[
60*600f14f4SXin Li#include <stdio.h>
61*600f14f4SXin Li#include <stdlib.h>
62*600f14f4SXin Li#include <string.h>
63*600f14f4SXin Li#include <ogg/ogg.h>
64*600f14f4SXin Li
65*600f14f4SXin Liint main ()
66*600f14f4SXin Li{
67*600f14f4SXin Li  system("touch conf.oggtest");
68*600f14f4SXin Li  return 0;
69*600f14f4SXin Li}
70*600f14f4SXin Li
71*600f14f4SXin Li]])],[],[no_ogg=yes],[echo $ac_n "cross compiling; assumed OK... $ac_c"])
72*600f14f4SXin Li       CFLAGS="$ac_save_CFLAGS"
73*600f14f4SXin Li       LIBS="$ac_save_LIBS"
74*600f14f4SXin Li  fi
75*600f14f4SXin Li
76*600f14f4SXin Li  if test "x$no_ogg" = "xdisabled" ; then
77*600f14f4SXin Li     AC_MSG_RESULT(no)
78*600f14f4SXin Li     ifelse([$2], , :, [$2])
79*600f14f4SXin Li  elif test "x$no_ogg" = "x" ; then
80*600f14f4SXin Li     AC_MSG_RESULT(yes)
81*600f14f4SXin Li     ifelse([$1], , :, [$1])
82*600f14f4SXin Li  else
83*600f14f4SXin Li     AC_MSG_RESULT(no)
84*600f14f4SXin Li     if test -f conf.oggtest ; then
85*600f14f4SXin Li       :
86*600f14f4SXin Li     else
87*600f14f4SXin Li       echo "*** Could not run Ogg test program, checking why..."
88*600f14f4SXin Li       CFLAGS="$CFLAGS $OGG_CFLAGS"
89*600f14f4SXin Li       LIBS="$LIBS $OGG_LIBS"
90*600f14f4SXin Li       AC_LINK_IFELSE([AC_LANG_PROGRAM([[
91*600f14f4SXin Li#include <stdio.h>
92*600f14f4SXin Li#include <ogg/ogg.h>
93*600f14f4SXin Li]], [[ return 0; ]])],[ echo "*** The test program compiled, but did not run. This usually means"
94*600f14f4SXin Li       echo "*** that the run-time linker is not finding Ogg or finding the wrong"
95*600f14f4SXin Li       echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
96*600f14f4SXin Li       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
97*600f14f4SXin Li       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
98*600f14f4SXin Li       echo "*** is required on your system"
99*600f14f4SXin Li       echo "***"
100*600f14f4SXin Li       echo "*** If you have an old version installed, it is best to remove it, although"
101*600f14f4SXin Li       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],[ echo "*** The test program failed to compile or link. See the file config.log for the"
102*600f14f4SXin Li       echo "*** exact error that occurred. This usually means Ogg was incorrectly installed"
103*600f14f4SXin Li       echo "*** or that you have moved Ogg since it was installed." ])
104*600f14f4SXin Li       CFLAGS="$ac_save_CFLAGS"
105*600f14f4SXin Li       LIBS="$ac_save_LIBS"
106*600f14f4SXin Li     fi
107*600f14f4SXin Li     OGG_CFLAGS=""
108*600f14f4SXin Li     OGG_LIBS=""
109*600f14f4SXin Li     ifelse([$2], , :, [$2])
110*600f14f4SXin Li  fi
111*600f14f4SXin Li  AC_SUBST(OGG_CFLAGS)
112*600f14f4SXin Li  AC_SUBST(OGG_LIBS)
113*600f14f4SXin Li  rm -f conf.oggtest
114*600f14f4SXin Li])
115