Recognizes if input is ogg or not.
[xiph.git] / vorbis-tools / acinclude.m4
blob61e9240458b07008936bfe12d189f6c439fc1e5c
1 # Configure paths for libogg
2 # Jack Moffitt <jack@icecast.org> 10-21-2000
3 # Shamelessly stolen from Owen Taylor and Manish Singh
5 dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
6 dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
7 dnl
8 AC_DEFUN([XIPH_PATH_OGG],
9 [dnl 
10 dnl Get the cflags and libraries
11 dnl
12 AC_ARG_WITH(ogg,AC_HELP_STRING([--with-ogg=PFX],[Prefix where libogg is installed (optional)]), ogg_prefix="$withval", ogg_prefix="")
13 AC_ARG_WITH(ogg-libraries,AC_HELP_STRING([--with-ogg-libraries=DIR],[Directory where libogg library is installed (optional)]), ogg_libraries="$withval", ogg_libraries="")
14 AC_ARG_WITH(ogg-includes,AC_HELP_STRING([--with-ogg-includes=DIR],[Directory where libogg header files are installed (optional)]), ogg_includes="$withval", ogg_includes="")
15 AC_ARG_ENABLE(oggtest,AC_HELP_STRING([--disable-oggtest],[Do not try to compile and run a test Ogg program]),, enable_oggtest=yes)
17   if test "x$ogg_libraries" != "x" ; then
18     OGG_LIBS="-L$ogg_libraries"
19   elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then
20     OGG_LIBS=""
21   elif test "x$ogg_prefix" != "x" ; then
22     OGG_LIBS="-L$ogg_prefix/lib"
23   elif test "x$prefix" != "xNONE" ; then
24     OGG_LIBS="-L$prefix/lib"
25   fi
27   if test "x$ogg_prefix" != "xno" ; then
28     OGG_LIBS="$OGG_LIBS -logg"
29   fi
31   if test "x$ogg_includes" != "x" ; then
32     OGG_CFLAGS="-I$ogg_includes"
33   elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then
34     OGG_CFLAGS=""
35   elif test "x$ogg_prefix" != "x" ; then
36     OGG_CFLAGS="-I$ogg_prefix/include"
37   elif test "x$prefix" != "xNONE"; then
38     OGG_CFLAGS="-I$prefix/include"
39   fi
41   AC_MSG_CHECKING(for Ogg)
42   if test "x$ogg_prefix" = "xno" ; then
43     no_ogg="disabled"
44     enable_oggtest="no"
45   else
46     no_ogg=""
47   fi
50   if test "x$enable_oggtest" = "xyes" ; then
51     ac_save_CFLAGS="$CFLAGS"
52     ac_save_LIBS="$LIBS"
53     CFLAGS="$CFLAGS $OGG_CFLAGS"
54     LIBS="$LIBS $OGG_LIBS"
55 dnl
56 dnl Now check if the installed Ogg is sufficiently new.
57 dnl
58       rm -f conf.oggtest
59       AC_TRY_RUN([
60 #include <stdio.h>
61 #include <stdlib.h>
62 #include <string.h>
63 #include <ogg/ogg.h>
65 int main ()
67   system("touch conf.oggtest");
68   return 0;
71 ],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
72        CFLAGS="$ac_save_CFLAGS"
73        LIBS="$ac_save_LIBS"
74   fi
76   if test "x$no_ogg" = "xdisabled" ; then
77      AC_MSG_RESULT(no)
78      ifelse([$2], , :, [$2])
79   elif test "x$no_ogg" = "x" ; then
80      AC_MSG_RESULT(yes)
81      ifelse([$1], , :, [$1])
82   else
83      AC_MSG_RESULT(no)
84      if test -f conf.oggtest ; then
85        :
86      else
87        echo "*** Could not run Ogg test program, checking why..."
88        CFLAGS="$CFLAGS $OGG_CFLAGS"
89        LIBS="$LIBS $OGG_LIBS"
90        AC_TRY_LINK([
91 #include <stdio.h>
92 #include <ogg/ogg.h>
93 ],     [ return 0; ],
94        [ echo "*** The test program compiled, but did not run. This usually means"
95        echo "*** that the run-time linker is not finding Ogg or finding the wrong"
96        echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
97        echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
98        echo "*** to the installed location  Also, make sure you have run ldconfig if that"
99        echo "*** is required on your system"
100        echo "***"
101        echo "*** If you have an old version installed, it is best to remove it, although"
102        echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
103        [ echo "*** The test program failed to compile or link. See the file config.log for the"
104        echo "*** exact error that occured. This usually means Ogg was incorrectly installed"
105        echo "*** or that you have moved Ogg since it was installed. In the latter case, you"
106        echo "*** may want to edit the ogg-config script: $OGG_CONFIG" ])
107        CFLAGS="$ac_save_CFLAGS"
108        LIBS="$ac_save_LIBS"
109      fi
110      OGG_CFLAGS=""
111      OGG_LIBS=""
112      ifelse([$2], , :, [$2])
113   fi
114   AC_SUBST(OGG_CFLAGS)
115   AC_SUBST(OGG_LIBS)
116   rm -f conf.oggtest
119 # Configure paths for libvorbis
120 # Jack Moffitt <jack@icecast.org> 10-21-2000
121 # Shamelessly stolen from Owen Taylor and Manish Singh
123 dnl XIPH_PATH_VORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
124 dnl Test for libvorbis, and define VORBIS_CFLAGS and VORBIS_LIBS
126 AC_DEFUN([XIPH_PATH_VORBIS],
127 [dnl 
128 dnl Get the cflags and libraries
130 AC_ARG_WITH(vorbis,AC_HELP_STRING([--with-vorbis=PFX],[Prefix where libvorbis is installed (optional)]), vorbis_prefix="$withval", vorbis_prefix="")
131 AC_ARG_WITH(vorbis-libraries,AC_HELP_STRING([--with-vorbis-libraries=DIR],[Directory where libvorbis library is installed (optional)]), vorbis_libraries="$withval", vorbis_libraries="")
132 AC_ARG_WITH(vorbis-includes,AC_HELP_STRING([--with-vorbis-includes=DIR],[Directory where libvorbis header files are installed (optional)]), vorbis_includes="$withval", vorbis_includes="")
133 AC_ARG_ENABLE(vorbistest,AC_HELP_STRING([--disable-vorbistest],[Do not try to compile and run a test Vorbis program]),, enable_vorbistest=yes)
135   if test "x$vorbis_libraries" != "x" ; then
136     VORBIS_LIBS="-L$vorbis_libraries"
137   elif test "x$vorbis_prefix" = "xno" || test "x$vorbis_prefix" = "xyes" ; then
138     VORBIS_LIBS=""
139   elif test "x$vorbis_prefix" != "x" ; then
140     VORBIS_LIBS="-L$vorbis_prefix/lib"
141   elif test "x$prefix" != "xNONE"; then
142     VORBIS_LIBS="-L$prefix/lib"
143   fi
145   VORBISFILE_LIBS="$VORBIS_LIBS -lvorbisfile"
146   VORBISENC_LIBS="$VORBIS_LIBS -lvorbisenc"
147   if test "x$vorbis_prefix" != "xno" ; then
148     VORBIS_LIBS="$VORBIS_LIBS -lvorbis"
149   fi
151   if test "x$vorbis_includes" != "x" ; then
152     VORBIS_CFLAGS="-I$vorbis_includes"
153   elif test "x$vorbis_prefix" = "xno" || test "x$vorbis_prefix" = "xyes" ; then
154     VORBIS_CFLAGS=""
155   elif test "x$vorbis_prefix" != "x" ; then
156     VORBIS_CFLAGS="-I$vorbis_prefix/include"
157   elif test "x$prefix" != "xNONE"; then
158     VORBIS_CFLAGS="-I$prefix/include"
159   fi
161   xiph_saved_LIBS="$LIBS"
162   LIBS=""
163   AC_SEARCH_LIBS(cos, m, [VORBIS_LIBS="$VORBIS_LIBS $LIBS"], [
164     AC_MSG_WARN([cos() not found in math library, vorbis installation may not work])
165   ])
166   LIBS="$xiph_saved_LIBS"
168   AC_MSG_CHECKING(for Vorbis)
169   if test "x$vorbis_prefix" = "xno" ; then
170     no_vorbis="disabled"
171     enable_vorbistest="no"
172   else
173     no_vorbis=""
174   fi
177   if test "x$enable_vorbistest" = "xyes" ; then
178     ac_save_CFLAGS="$CFLAGS"
179     ac_save_LIBS="$LIBS"
180     CFLAGS="$CFLAGS $VORBIS_CFLAGS $OGG_CFLAGS"
181     LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
183 dnl Now check if the installed Vorbis is sufficiently new.
185       rm -f conf.vorbistest
186       AC_TRY_RUN([
187 #include <stdio.h>
188 #include <stdlib.h>
189 #include <string.h>
190 #include <vorbis/codec.h>
192 int main ()
194   system("touch conf.vorbistest");
195   return 0;
198 ],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
199        CFLAGS="$ac_save_CFLAGS"
200        LIBS="$ac_save_LIBS"
201   fi
203   if test "x$no_vorbis" = "xdisabled" ; then
204      AC_MSG_RESULT(no)
205      ifelse([$2], , :, [$2])
206   elif test "x$no_vorbis" = "x" ; then
207      AC_MSG_RESULT(yes)
208      ifelse([$1], , :, [$1])
209   else
210      AC_MSG_RESULT(no)
211      if test -f conf.vorbistest ; then
212        :
213      else
214        echo "*** Could not run Vorbis test program, checking why..."
215        CFLAGS="$CFLAGS $VORBIS_CFLAGS"
216        LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
217        AC_TRY_LINK([
218 #include <stdio.h>
219 #include <vorbis/codec.h>
220 ],     [ return 0; ],
221        [ echo "*** The test program compiled, but did not run. This usually means"
222        echo "*** that the run-time linker is not finding Vorbis or finding the wrong"
223        echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your"
224        echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
225        echo "*** to the installed location  Also, make sure you have run ldconfig if that"
226        echo "*** is required on your system"
227        echo "***"
228        echo "*** If you have an old version installed, it is best to remove it, although"
229        echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
230        [ echo "*** The test program failed to compile or link. See the file config.log for the"
231        echo "*** exact error that occured. This usually means Vorbis was incorrectly installed"
232        echo "*** or that you have moved Vorbis since it was installed." ])
233        CFLAGS="$ac_save_CFLAGS"
234        LIBS="$ac_save_LIBS"
235      fi
236      VORBIS_CFLAGS=""
237      VORBIS_LIBS=""
238      VORBISFILE_LIBS=""
239      VORBISENC_LIBS=""
240      ifelse([$2], , :, [$2])
241   fi
242   AC_SUBST(VORBIS_CFLAGS)
243   AC_SUBST(VORBIS_LIBS)
244   AC_SUBST(VORBISFILE_LIBS)
245   AC_SUBST(VORBISENC_LIBS)
246   rm -f conf.vorbistest
249 # ao.m4
250 # Configure paths for libao
251 # Jack Moffitt <jack@icecast.org> 10-21-2000
252 # Shamelessly stolen from Owen Taylor and Manish Singh
254 dnl XIPH_PATH_AO([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
255 dnl Test for libao, and define AO_CFLAGS and AO_LIBS
257 AC_DEFUN([XIPH_PATH_AO],
258 [dnl 
259 dnl Get the cflags and libraries
261 AC_ARG_WITH(ao,AC_HELP_STRING([--with-ao=PFX],[Prefix where libao is installed (optional)]), ao_prefix="$withval", ao_prefix="")
262 AC_ARG_WITH(ao-libraries,AC_HELP_STRING([--with-ao-libraries=DIR],[Directory where libao library is installed (optional)]), ao_libraries="$withval", ao_libraries="")
263 AC_ARG_WITH(ao-includes,AC_HELP_STRING([--with-ao-includes=DIR],[Directory where libao header files are installed (optional)]), ao_includes="$withval", ao_includes="")
264 AC_ARG_ENABLE(aotest,AC_HELP_STRING([--disable-aotest],[Do not try to compile and run a test ao program]),, enable_aotest=yes)
266   if test "x$ao_prefix" != "xno"
267   then
268     if test "x$ao_libraries" != "x" ; then
269       AO_LIBS="-L$ao_libraries"
270   elif test "x$ao_prefix" = "xno" || test "x$ao_prefix" = "xyes" ; then
271     AO_LIBS=""
272     elif test "x$ao_prefix" != "x" -a "x$ao_prefix" != "xyes"; then
273       AO_LIBS="-L$ao_prefix/lib"
274     elif test "x$prefix" != "xNONE"; then
275       AO_LIBS="-L$prefix/lib"
276     fi
278     if test "x$ao_includes" != "x" ; then
279       AO_CFLAGS="-I$ao_includes"
280   elif test "x$ao_prefix" = "xno" || test "x$ao_prefix" = "xyes" ; then
281     AO_CFLAGS=""
282     elif test "x$ao_prefix" != "x" -a "x$ao_prefix" != "xyes"; then
283       AO_CFLAGS="-I$ao_prefix/include"
284     elif test "x$prefix" != "xNONE"; then
285       AO_CFLAGS="-I$prefix/include"
286     fi
288     # see where dl* and friends live
289     AC_CHECK_FUNCS(dlopen, [AO_DL_LIBS=""], [
290       AC_CHECK_LIB(dl, dlopen, [AO_DL_LIBS="-ldl"], [
291         AC_MSG_WARN([could not find dlopen() needed by libao sound drivers
292         your system may not be supported.])
293       ])
294     ])
296   if test "x$ao_prefix" != "xno" ; then
297     AO_LIBS="$AO_LIBS -lao $AO_DL_LIBS"
298   fi
300     AC_MSG_CHECKING(for ao)
301   if test "x$ao_prefix" = "xno" ; then
302     no_ao="disabled"
303     enable_aotest="no"
304   else
305     no_ao=""
306   fi
309     if test "x$enable_aotest" = "xyes" ; then
310       ac_save_CFLAGS="$CFLAGS"
311       ac_save_LIBS="$LIBS"
312       CFLAGS="$CFLAGS $AO_CFLAGS"
313       LIBS="$LIBS $AO_LIBS"
315 dnl Now check if the installed ao is sufficiently new.
317       rm -f conf.aotest
318       AC_TRY_RUN([
319 #include <stdio.h>
320 #include <stdlib.h>
321 #include <string.h>
322 #include <ao/ao.h>
324 int main ()
326   system("touch conf.aotest");
327   return 0;
330 ],, no_ao=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
331        CFLAGS="$ac_save_CFLAGS"
332        LIBS="$ac_save_LIBS"
333     fi
335     if test "x$no_ao" = "xdisabled" ; then
336        AC_MSG_RESULT(no)
337        ifelse([$2], , :, [$2])
338     elif test "x$no_ao" = "x" ; then
339        AC_MSG_RESULT(yes)
340        ifelse([$1], , :, [$1])
341     else
342        AC_MSG_RESULT(no)
343        if test -f conf.aotest ; then
344          :
345        else
346          echo "*** Could not run ao test program, checking why..."
347          CFLAGS="$CFLAGS $AO_CFLAGS"
348          LIBS="$LIBS $AO_LIBS"
349        AC_TRY_LINK([
350 #include <stdio.h>
351 #include <ao/ao.h>
352 ],       [ return 0; ],
353          [ echo "*** The test program compiled, but did not run. This usually means"
354          echo "*** that the run-time linker is not finding ao or finding the wrong"
355          echo "*** version of ao. If it is not finding ao, you'll need to set your"
356          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
357          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
358          echo "*** is required on your system"
359          echo "***"
360          echo "*** If you have an old version installed, it is best to remove it, although"
361          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
362          [ echo "*** The test program failed to compile or link. See the file config.log for the"
363          echo "*** exact error that occured. This usually means ao was incorrectly installed"
364          echo "*** or that you have moved ao since it was installed." ])
365          CFLAGS="$ac_save_CFLAGS"
366          LIBS="$ac_save_LIBS"
367        fi
368        AO_CFLAGS=""
369        AO_LIBS=""
370        ifelse([$2], , :, [$2])
371     fi
372     AC_SUBST(AO_CFLAGS)
373     AC_SUBST(AO_LIBS)
374     rm -f conf.aotest
375   fi
378 dnl This macros shamelessly stolen from
379 dnl http://gcc.gnu.org/ml/gcc-bugs/2001-06/msg01398.html.
380 dnl Written by Bruno Haible.
382 AC_DEFUN([AM_ICONV],
384   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
385   dnl those with the standalone portable GNU libiconv installed).
387   AC_ARG_WITH([libiconv-prefix],
388 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
389     for dir in `echo "$withval" | tr : ' '`; do
390       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
391       if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
392     done
393    ])
395   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
396     am_cv_func_iconv="no, consider installing GNU libiconv"
397     am_cv_lib_iconv=no
398     AC_TRY_LINK([#include <stdlib.h>
399 #include <iconv.h>],
400       [iconv_t cd = iconv_open("","");
401        iconv(cd,NULL,NULL,NULL,NULL);
402        iconv_close(cd);],
403       am_cv_func_iconv=yes)
404     if test "$am_cv_func_iconv" != yes; then
405       am_save_LIBS="$LIBS"
406       LIBS="$LIBS -liconv"
407       AC_TRY_LINK([#include <stdlib.h>
408 #include <iconv.h>],
409         [iconv_t cd = iconv_open("","");
410          iconv(cd,NULL,NULL,NULL,NULL);
411          iconv_close(cd);],
412         am_cv_lib_iconv=yes
413         am_cv_func_iconv=yes)
414       LIBS="$am_save_LIBS"
415     fi
416   ])
417   if test "$am_cv_func_iconv" = yes; then
418     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
419     AC_MSG_CHECKING([for iconv declaration])
420     AC_CACHE_VAL(am_cv_proto_iconv, [
421       AC_TRY_COMPILE([
422 #include <stdlib.h>
423 #include <iconv.h>
424 extern
425 #ifdef __cplusplus
427 #endif
428 #if defined(__STDC__) || defined(__cplusplus)
429 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
430 #else
431 size_t iconv();
432 #endif
433 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
434       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
435     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
436     AC_MSG_RESULT([$]{ac_t:-
437          }[$]am_cv_proto_iconv)
438     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
439       [Define as const if the declaration of iconv() needs const.])
440   fi
441   LIBICONV=
442   if test "$am_cv_lib_iconv" = yes; then
443     LIBICONV="-liconv"
444   fi
445   AC_SUBST(LIBICONV)
448 dnl From Bruno Haible.
450 AC_DEFUN([AM_LANGINFO_CODESET],
452   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
453     [AC_TRY_LINK([#include <langinfo.h>],
454       [char* cs = nl_langinfo(CODESET);],
455       am_cv_langinfo_codeset=yes,
456       am_cv_langinfo_codeset=no)
457     ])
458   if test $am_cv_langinfo_codeset = yes; then
459     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
460       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
461   fi
464 dnl AM_PATH_CURL([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
465 dnl Test for libcurl, and define CURL_CFLAGS and CURL_LIBS
467 AC_DEFUN([AM_PATH_CURL],
468 [dnl 
469 dnl Get the cflags and libraries
471 AC_ARG_WITH(curl,[  --with-curl=PFX   Prefix where libcurl is installed (optional)], curl_prefix="$withval", curl_prefix="")
472 AC_ARG_WITH(curl-libraries,[  --with-curl-libraries=DIR   Directory where libcurl library is installed (optional)], curl_libraries="$withval", curl_libraries="")
473 AC_ARG_WITH(curl-includes,[  --with-curl-includes=DIR   Directory where libcurl header files are installed (optional)], curl_includes="$withval", curl_includes="")
474 AC_ARG_ENABLE(curltest, [  --disable-curltest       Do not try to compile and run a test libcurl program],, enable_curltest=yes)
476 if test "x$curl_prefix" != "xno" ; then
478   if test "x$curl_libraries" != "x" ; then
479     CURL_LIBS="-L$curl_libraries"
480   elif test "x$curl_prefix" != "x" ; then
481     CURL_LIBS="-L$curl_prefix/lib"
482   elif test "x$prefix" != "xNONE" ; then
483     CURL_LIBS="-L$prefix/lib"
484   fi
486   CURL_LIBS="$CURL_LIBS -lcurl"
488   if test "x$curl_includes" != "x" ; then
489     CURL_CFLAGS="-I$curl_includes"
490   elif test "x$curl_prefix" != "x" ; then
491     CURL_CFLAGS="-I$curl_prefix/include"
492   elif test "x$prefix" != "xNONE"; then
493     CURL_CFLAGS="-I$prefix/include"
494   fi
496   AC_MSG_CHECKING(for libcurl)
497   no_curl=""
500   if test "x$enable_curltest" = "xyes" ; then
501     ac_save_CFLAGS="$CFLAGS"
502     ac_save_LIBS="$LIBS"
503     CFLAGS="$CFLAGS $CURL_CFLAGS"
504     LIBS="$LIBS $CURL_LIBS"
506 dnl Now check if the installed libcurl is sufficiently new.
508       rm -f conf.curltest
509       AC_TRY_RUN([
510 #include <stdio.h>
511 #include <stdlib.h>
512 #include <string.h>
513 #include <curl/curl.h>
515 int main ()
517   system("touch conf.curltest");
518   return 0;
521 ],, no_curl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
522        CFLAGS="$ac_save_CFLAGS"
523        LIBS="$ac_save_LIBS"
524   fi
526   if test "x$no_curl" = "x" ; then
527      AC_MSG_RESULT(yes)
528      AC_DEFINE(HAVE_CURL, 1, [Define if you have libcurl.])
529      ifelse([$1], , :, [$1])     
530   else
531      AC_MSG_RESULT(no)
532      if test -f conf.curltest ; then
533        :
534      else
535        echo "*** Could not run libcurl test program, checking why..."
536        CFLAGS="$CFLAGS $CURL_CFLAGS"
537        LIBS="$LIBS $CURL_LIBS"
538        AC_TRY_LINK([
539 #include <stdio.h>
540 #include <curl/curl.h>
541 ],     [ return 0; ],
542        [ echo "*** The test program compiled, but did not run. This usually means"
543        echo "*** that the run-time linker is not finding libcurl or finding the wrong"
544        echo "*** version of libcurl. If it is not finding libcurl, you'll need to set your"
545        echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
546        echo "*** to the installed location  Also, make sure you have run ldconfig if that"
547        echo "*** is required on your system"
548        echo "***"
549        echo "*** If you have an old version installed, it is best to remove it, although"
550        echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
551        [ echo "*** The test program failed to compile or link. See the file config.log for the"
552        echo "*** exact error that occured. This usually means libcurl was incorrectly installed"
553        echo "*** or that you have moved libcurl since it was installed." ])
554        CFLAGS="$ac_save_CFLAGS"
555        LIBS="$ac_save_LIBS"
556      fi
557      CURL_CFLAGS=""
558      CURL_LIBS=""
559      ifelse([$2], , :, [$2])
560   fi
561 else
562   CURL_CFLAGS=""
563   CURL_LIBS=""
565   AC_SUBST(CURL_CFLAGS)
566   AC_SUBST(CURL_LIBS)
567   rm -f conf.curltest
571 dnl ACX_PTHREAD macro by Steven G. Johnson <stevenj@alum.mit.edu> and
572 dnl Alejandro Forero Cuervo <bachue@bachue.com>.  Found at:
573 dnl http://www.gnu.org/software/ac-archive/Installed_Packages/acx_pthread.html
575 AC_DEFUN([ACX_PTHREAD], [
576 AC_REQUIRE([AC_CANONICAL_HOST])
577 acx_pthread_ok=no
579 # First, check if the POSIX threads header, pthread.h, is available.
580 # If it isn't, don't bother looking for the threads libraries.
581 AC_CHECK_HEADER(pthread.h, , acx_pthread_ok=noheader)
583 # We must check for the threads library under a number of different
584 # names; the ordering is very important because some systems
585 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
586 # libraries is broken (non-POSIX).
588 # First of all, check if the user has set any of the PTHREAD_LIBS,
589 # etcetera environment variables, and if threads linking works using
590 # them:
591 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
592         save_CFLAGS="$CFLAGS"
593         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
594         save_LIBS="$LIBS"
595         LIBS="$PTHREAD_LIBS $LIBS"
596         AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
597         AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
598         AC_MSG_RESULT($acx_pthread_ok)
599         if test x"$acx_pthread_ok" = xno; then
600                 PTHREAD_LIBS=""
601                 PTHREAD_CFLAGS=""
602         fi
603         LIBS="$save_LIBS"
604         CFLAGS="$save_CFLAGS"
607 # Create a list of thread flags to try.  Items starting with a "-" are
608 # C compiler flags, and other items are library names, except for "none"
609 # which indicates that we try without any flags at all.
611 acx_pthread_flags="pthreads none -Kthread -kthread lthread pthread -pthread -pthreads -mthreads --thread-safe -mt"
613 # The ordering *is* (sometimes) important.  Some notes on the
614 # individual items follow:
616 # pthreads: AIX (must check this before -lpthread)
617 # none: in case threads are in libc; should be tried before -Kthread and
618 #       other compiler flags to prevent continual compiler warnings
619 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
620 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
621 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
622 # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
623 # -pthreads: Solaris/gcc
624 # -mthreads: Mingw32/gcc, Lynx/gcc
625 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
626 #      doesn't hurt to check since this sometimes defines pthreads too;
627 #      also defines -D_REENTRANT)
628 # pthread: Linux, etcetera
629 # --thread-safe: KAI C++
631 case "${host_cpu}-${host_os}" in
632         *solaris*)
634         # On Solaris (at least, for some versions), libc contains stubbed
635         # (non-functional) versions of the pthreads routines, so link-based
636         # tests will erroneously succeed.  (We need to link with -pthread or
637         # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
638         # a function called by this macro, so we could check for that, but
639         # who knows whether they'll stub that too in a future libc.)  So,
640         # we'll just look for -pthreads and -lpthread first:
641         acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
642         ;;
643 esac
645 if test x"$acx_pthread_ok" = xno; then
646 for flag in $acx_pthread_flags; do
648         case $flag in
649                 none)
650                 AC_MSG_CHECKING([whether pthreads work without any flags])
651                 ;;
653                 -*)
654                 AC_MSG_CHECKING([whether pthreads work with $flag])
655                 PTHREAD_CFLAGS="$flag"
656                 ;;
658                 *)
659                 AC_MSG_CHECKING([for the pthreads library -l$flag])
660                 PTHREAD_LIBS="-l$flag"
661                 ;;
662         esac
664         save_LIBS="$LIBS"
665         save_CFLAGS="$CFLAGS"
666         LIBS="$PTHREAD_LIBS $LIBS"
667         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
669         # Check for various functions.  We must include pthread.h,
670         # since some functions may be macros.  (On the Sequent, we
671         # need a special flag -Kthread to make this header compile.)
672         # We check for pthread_join because it is in -lpthread on IRIX
673         # while pthread_create is in libc.  We check for pthread_attr_init
674         # due to DEC craziness with -lpthreads.  We check for
675         # pthread_cleanup_push because it is one of the few pthread
676         # functions on Solaris that doesn't have a non-functional libc stub.
677         # We try pthread_create on general principles.
678         AC_TRY_LINK([#include <pthread.h>],
679                     [pthread_t th; pthread_join(th, 0);
680                      pthread_attr_init(0); pthread_cleanup_push(0, 0);
681                      pthread_create(0,0,0,0);
682                      pthread_cancel(0); pthread_cleanup_pop(0); ],
683                     [acx_pthread_ok=yes])
685         LIBS="$save_LIBS"
686         CFLAGS="$save_CFLAGS"
688         AC_MSG_RESULT($acx_pthread_ok)
689         if test "x$acx_pthread_ok" = xyes; then
690                 break;
691         fi
693         PTHREAD_LIBS=""
694         PTHREAD_CFLAGS=""
695 done
698 # Various other checks:
699 if test "x$acx_pthread_ok" = xyes; then
700         save_LIBS="$LIBS"
701         LIBS="$PTHREAD_LIBS $LIBS"
702         save_CFLAGS="$CFLAGS"
703         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
705         # Detect AIX lossage: threads are created detached by default
706         # and the JOINABLE attribute has a nonstandard name (UNDETACHED).
707         AC_MSG_CHECKING([for joinable pthread attribute])
708         AC_TRY_LINK([#include <pthread.h>],
709                     [int attr=PTHREAD_CREATE_JOINABLE;],
710                     ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
711         if test x"$ok" = xunknown; then
712                 AC_TRY_LINK([#include <pthread.h>],
713                             [int attr=PTHREAD_CREATE_UNDETACHED;],
714                             ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
715         fi
716         if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
717                 AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
718                           [Define to the necessary symbol if this constant
719                            uses a non-standard name on your system.])
720         fi
721         AC_MSG_RESULT(${ok})
722         if test x"$ok" = xunknown; then
723                 AC_MSG_WARN([we do not know how to create joinable pthreads])
724         fi
726         AC_MSG_CHECKING([if more special flags are required for pthreads])
727         flag=no
728         case "${host_cpu}-${host_os}" in
729                 *-aix* | *-freebsd*)     flag="-D_THREAD_SAFE";;
730                 *solaris* | alpha*-osf*) flag="-D_REENTRANT";;
731         esac
732         AC_MSG_RESULT(${flag})
733         if test "x$flag" != xno; then
734                 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
735         fi
737         LIBS="$save_LIBS"
738         CFLAGS="$save_CFLAGS"
740         # More AIX lossage: must compile with cc_r
741         AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
742 else
743         PTHREAD_CC="$CC"
746 AC_SUBST(PTHREAD_LIBS)
747 AC_SUBST(PTHREAD_CFLAGS)
748 AC_SUBST(PTHREAD_CC)
750 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
751 if test x"$acx_pthread_ok" = xyes; then
752         ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
753         :
754 else
755         acx_pthread_ok=no
756         $2