removed debug printf...
[speexdsp.git] / acinclude.m4
1 AC_DEFUN(AC_FIND_FILE,
2 [
3 $3=NONE
4 for i in $2;
5 do
6   for j in $1;
7   do
8     if test -r "$i/$j"; then
9       $3=$i
10       break 2
11     fi
12   done
13 done
14 ])
15
16 AC_DEFUN(AC_PATH_LIBOGG,
17 [
18 OGG_LIBS="-logg"
19
20 AC_MSG_CHECKING([for libogg])
21
22 ac_ogg_includes=NONE ac_ogg_libraries=NONE ac_ogg_bindir=NONE
23 ogg_libraries=""
24 ogg_includes=""
25 AC_ARG_WITH(ogg-dir,
26     [  --with-ogg-dir=DIR       where the root of OGG is installed ],
27     [  ac_ogg_includes="$withval"/include
28        ac_ogg_libraries="$withval"/lib
29     ])
30
31 AC_ARG_WITH(ogg-includes,
32     [  --with-ogg-includes=DIR  where the OGG includes are. ],
33     [  
34        ac_ogg_includes="$withval"
35     ])
36     
37 ogg_libs_given=no
38
39 AC_ARG_WITH(ogg-libraries,
40     [  --with-ogg-libraries=DIR where the OGG library is installed.],
41     [  ac_ogg_libraries="$withval"
42        ogg_libs_given=yes
43     ])
44
45 ogg_incdirs="/usr/include /usr/lib/ogg/include /opt/include /usr/local/ogg/include /usr/include/ogg /usr/include /usr/local/include"
46 if test ! "$ac_ogg_includes" = "NONE"; then
47   ogg_incdirs="$ac_ogg_includes $ac_ogg_includes/.. $ogg_incdirs"
48 fi
49 AC_FIND_FILE(ogg/ogg.h, $ogg_incdirs, ogg_incdir)
50 echo "Ogg includes in $ogg_incdir"
51
52
53 ogg_libdirs="$ac_ogg_libraries /usr/lib/ogg/lib /usr/lib /opt/lib /usr/local/ogg/lib /usr/local/lib /usr/lib/ogg /usr/local/lib"
54 test -n "$OGGDIR" && ogg_libdirs="$OGGDIR/lib $OGGDIR $ogg_libdirs"
55 if test ! "$ac_ogg_libraries" = "NONE"; then
56   ogg_libdirs="$ac_ogg_libraries $ogg_libdirs"
57 fi
58
59 test=NONE
60 ogg_libdir=NONE
61 for dir in $ogg_libdirs; do
62   try="ls -1 $dir/libogg*"
63   if test=`eval $try 2> /dev/null`; then ogg_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
64 done
65
66 echo "Ogg libraries in $ogg_libdir"
67
68 if test "$ogg_libdir" = "NONE" || test "$ogg_incdir" = "NONE"; then
69    have_libogg=no
70 else
71    have_libogg=yes
72    AC_DEFINE(HAVE_LIBOGG)
73 fi
74
75 OGG_INCLUDES="-I$ogg_incdir"
76 OGG_LDFLAGS="-L$ogg_libdir"
77
78
79 AC_SUBST(OGG_LIBS)
80 AC_SUBST(OGG_INCLUDES)
81 AC_SUBST(OGG_LDFLAGS)
82
83 ])
84
85 AC_DEFUN(AC_PATH_OGG,
86 [
87 LIBOGG="-logg"
88
89 AC_MSG_CHECKING([for libogg])
90
91 LIBOGG="$LIBOGG"
92 ac_ogg_includes=NO ac_ogg_libraries=NO ac_ogg_bindir=NO
93 ogg_libraries=""
94 ogg_includes=""
95 AC_ARG_WITH(ogg-dir,
96     [  --with-ogg-dir=DIR       where the root of OGG is installed ],
97     [  ac_ogg_includes="$withval"/include
98        ac_ogg_libraries="$withval"/lib
99        ac_ogg_bindir="$withval"/bin
100     ])
101
102 AC_ARG_WITH(ogg-includes,
103     [  --with-ogg-includes=DIR  where the OGG includes are. ],
104     [  
105        ac_ogg_includes="$withval"
106     ])
107     
108 ogg_libs_given=no
109
110 AC_ARG_WITH(ogg-libraries,
111     [  --with-ogg-libraries=DIR where the OGG library is installed.],
112     [  ac_ogg_libraries="$withval"
113        ogg_libs_given=yes
114     ])
115 AC_CACHE_VAL(ac_cv_have_ogg,
116 [#try to guess OGG locations
117
118 ogg_incdirs="/usr/lib/ogg/include /opt/include /usr/local/ogg/include /usr/include/ogg /usr/include /usr/local/include $OGGINC"
119 test -n "$OGGDIR" && ogg_incdirs="$OGGDIR/include $OGGDIR $ogg_incdirs"
120 ogg_incdirs="$ac_ogg_includes $ogg_incdirs"
121 AC_FIND_FILE(ogg/ogg.h, $ogg_incdirs, ogg_incdir)
122 echo $ogg_incdir
123 ac_ogg_includes="$ogg_incdir"
124
125 ogg_libdirs="/usr/lib/ogg/lib /usr/lib /opt/lib /usr/local/ogg/lib /usr/local/lib /usr/lib/ogg /usr/local/lib $OGGLIB"
126 test -n "$OGGDIR" && ogg_libdirs="$OGGDIR/lib $OGGDIR $ogg_libdirs"
127 if test ! "$ac_ogg_libraries" = "NO"; then
128   ogg_libdirs="$ac_ogg_libraries $ogg_libdirs"
129 fi
130
131 test=NONE
132 ogg_libdir=NONE
133 for dir in $ogg_libdirs; do
134   try="ls -1 $dir/libogg*"
135   if test=`eval $try 2> /dev/null`; then ogg_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
136 done
137
138 ac_ogg_libraries="$ogg_libdir"
139
140 ac_cxxflags_safe="$CXXFLAGS"
141 ac_ldflags_safe="$LDFLAGS"
142 ac_libs_safe="$LIBS"
143
144 INCLUDE="$INCLUDE -I$ogg_incdir $all_includes"
145 LDFLAGS="-L$ogg_libdir $all_libraries"
146 #LIBS="$LIBS $LIBOGG"
147
148 CXXFLAGS="$ac_cxxflags_safe"
149 LDFLAGS="$ac_ldflags_safe"
150 #LIBS="$ac_libs_safe"
151
152 if test "$ac_ogg_includes" = NO || test "$ac_ogg_libraries" = NO; then
153   ac_cv_have_ogg="have_ogg=no"
154   ac_ogg_notfound=""
155   if test "$ac_ogg_includes" = NO; then
156     if test "$ac_ogg_libraries" = NO; then
157       ac_ogg_notfound="(headers and libraries)";
158     else
159       ac_ogg_notfound="(headers)";
160     fi
161   else
162     ac_ogg_notfound="(libraries)";
163   fi
164
165 else
166   have_ogg="yes"
167 fi
168 ])
169
170 eval "$ac_cv_have_ogg"
171
172 if test "$have_ogg" != yes; then
173   AC_MSG_RESULT([$have_ogg]);
174 else
175   ac_cv_have_ogg="have_ogg=yes \
176     ac_ogg_includes=$ac_ogg_includes ac_ogg_libraries=$ac_ogg_libraries"
177   AC_MSG_RESULT([libraries $ac_ogg_libraries, headers $ac_ogg_includes])
178   
179   ogg_libraries="$ac_ogg_libraries"
180   ogg_includes="$ac_ogg_includes"
181   AC_DEFINE(HAVE_LIBOGG)
182 fi
183
184 dnl if test ! "$ogg_libs_given" = "yes"; then
185 dnl CHECK_OGG_DIRECT(ogg_libraries= ,[])
186 dnl fi
187
188 AC_SUBST(ogg_libraries)
189 AC_SUBST(ogg_includes)
190
191 if test "$ogg_includes" = "/usr/include" || "$ogg_includes" = "$x_includes" || test -z "$ogg_includes"; then
192  OGG_INCLUDES="";
193 else
194  OGG_INCLUDES="-I$ogg_includes"
195  all_includes="$OGG_INCLUDES $all_includes"
196 fi
197
198 if test "$ogg_libraries" = "$x_libraries" || test -z "$ogg_libraries"; then
199  OGG_LDFLAGS=""
200 LIBOGG=""
201 else
202  OGG_LDFLAGS="-L$ogg_libraries"
203 LIBOGG='-logg'
204  all_libraries="$OGG_LDFLAGS $all_libraries"
205 fi
206
207 AC_SUBST(OGG_INCLUDES)
208 AC_SUBST(OGG_LDFLAGS)
209
210 AC_SUBST(LIBOGG)
211
212 ])