This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.
[tprouty/samba.git] / source / aclocal.m4
1 dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
2 dnl if the cache file is inconsistent with the current host,
3 dnl target and build system types, execute CMD or print a default
4 dnl error message.
5 AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
6     AC_REQUIRE([AC_CANONICAL_SYSTEM])
7     AC_MSG_CHECKING([config.cache system type])
8     if { test x"${ac_cv_host_system_type+set}" = x"set" &&
9          test x"$ac_cv_host_system_type" != x"$host"; } ||
10        { test x"${ac_cv_build_system_type+set}" = x"set" &&
11          test x"$ac_cv_build_system_type" != x"$build"; } ||
12        { test x"${ac_cv_target_system_type+set}" = x"set" &&
13          test x"$ac_cv_target_system_type" != x"$target"; }; then
14         AC_MSG_RESULT([different])
15         ifelse($#, 1, [$1],
16                 [AC_MSG_ERROR(["you must remove config.cache and restart configure"])])
17     else
18         AC_MSG_RESULT([same])
19     fi
20     ac_cv_host_system_type="$host"
21     ac_cv_build_system_type="$build"
22     ac_cv_target_system_type="$target"
23 ])
24
25
26 dnl test whether dirent has a d_off member
27 AC_DEFUN(AC_DIRENT_D_OFF,
28 [AC_CACHE_CHECK([for d_off in dirent], ac_cv_dirent_d_off,
29 [AC_TRY_COMPILE([
30 #include <unistd.h>
31 #include <sys/types.h>
32 #include <dirent.h>], [struct dirent d; d.d_off;],
33 ac_cv_dirent_d_off=yes, ac_cv_dirent_d_off=no)])
34 if test $ac_cv_dirent_d_off = yes; then
35   AC_DEFINE(HAVE_DIRENT_D_OFF,1,[Whether dirent has a d_off member])
36 fi
37 ])
38
39
40 dnl AC_PROG_CC_FLAG(flag)
41 AC_DEFUN(AC_PROG_CC_FLAG,
42 [AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
43 [echo 'void f(){}' > conftest.c
44 if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
45   ac_cv_prog_cc_$1=yes
46 else
47   ac_cv_prog_cc_$1=no
48 fi
49 rm -f conftest*
50 ])])
51
52 dnl see if a declaration exists for a function or variable
53 dnl defines HAVE_function_DECL if it exists
54 dnl AC_HAVE_DECL(var, includes)
55 AC_DEFUN(AC_HAVE_DECL,
56 [
57  AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
58     AC_TRY_COMPILE([$2],[int i = (int)$1],
59         ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
60  if test x"$ac_cv_have_$1_decl" = x"yes"; then
61     AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
62  fi
63 ])
64
65
66 dnl check for a function in a library, but don't
67 dnl keep adding the same library to the LIBS variable.
68 dnl AC_LIBTESTFUNC(lib,func)
69 AC_DEFUN(AC_LIBTESTFUNC,
70 [case "$LIBS" in
71   *-l$1*) AC_CHECK_FUNCS($2) ;;
72   *) AC_CHECK_LIB($1, $2) 
73      AC_CHECK_FUNCS($2)
74   ;;
75   esac
76 ])
77
78 dnl Define an AC_DEFINE with ifndef guard.
79 dnl AC_N_DEFINE(VARIABLE [, VALUE])
80 define(AC_N_DEFINE,
81 [cat >> confdefs.h <<\EOF
82 [#ifndef] $1
83 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
84 [#endif]
85 EOF
86 ])
87
88 dnl Add an #include
89 dnl AC_ADD_INCLUDE(VARIABLE)
90 define(AC_ADD_INCLUDE,
91 [cat >> confdefs.h <<\EOF
92 [#include] $1
93 EOF
94 ])
95
96 dnl Copied from libtool.m4
97 AC_DEFUN(AC_PROG_LD_GNU,
98 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
99 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
100 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
101   ac_cv_prog_gnu_ld=yes
102 else
103   ac_cv_prog_gnu_ld=no
104 fi])
105 ])
106
107 # Configure paths for LIBXML2
108 # Toshio Kuratomi 2001-04-21
109 # Adapted from:
110 # Configure paths for GLIB
111 # Owen Taylor     97-11-3
112
113 dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
114 dnl Test for XML, and define XML_CFLAGS and XML_LIBS
115 dnl
116 AC_DEFUN(AM_PATH_XML2,[ 
117 AC_ARG_WITH(xml-prefix,
118             [  --with-xml-prefix=PFX   Prefix where libxml is installed (optional)],
119             xml_config_prefix="$withval", xml_config_prefix="")
120 AC_ARG_WITH(xml-exec-prefix,
121             [  --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
122             xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
123 AC_ARG_ENABLE(xmltest,
124               [  --disable-xmltest       Do not try to compile and run a test LIBXML program],,
125               enable_xmltest=yes)
126
127   if test x$xml_config_exec_prefix != x ; then
128      xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
129      if test x${XML2_CONFIG+set} != xset ; then
130         XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
131      fi
132   fi
133   if test x$xml_config_prefix != x ; then
134      xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
135      if test x${XML2_CONFIG+set} != xset ; then
136         XML2_CONFIG=$xml_config_prefix/bin/xml2-config
137      fi
138   fi
139
140   AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
141   min_xml_version=ifelse([$1], ,2.0.0,[$1])
142   AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
143   no_xml=""
144   if test "$XML2_CONFIG" = "no" ; then
145     no_xml=yes
146   else
147     XML_CFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
148     XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
149     xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
150            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
151     xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
152            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
153     xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
154            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
155     if test "x$enable_xmltest" = "xyes" ; then
156       ac_save_CFLAGS="$CFLAGS"
157       ac_save_LIBS="$LIBS"
158       CFLAGS="$CFLAGS $XML_CFLAGS"
159       LIBS="$XML_LIBS $LIBS"
160 dnl
161 dnl Now check if the installed libxml is sufficiently new.
162 dnl (Also sanity checks the results of xml2-config to some extent)
163 dnl
164       rm -f conf.xmltest
165       AC_TRY_RUN([
166 #include <stdlib.h>
167 #include <stdio.h>
168 #include <string.h>
169 #include <libxml/xmlversion.h>
170
171 int 
172 main()
173 {
174   int xml_major_version, xml_minor_version, xml_micro_version;
175   int major, minor, micro;
176   char *tmp_version;
177
178   system("touch conf.xmltest");
179
180   /* Capture xml2-config output via autoconf/configure variables */
181   /* HP/UX 9 (%@#!) writes to sscanf strings */
182   tmp_version = (char *)strdup("$min_xml_version");
183   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
184      printf("%s, bad version string from xml2-config\n", "$min_xml_version");
185      exit(1);
186    }
187    free(tmp_version);
188
189    /* Capture the version information from the header files */
190    tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
191    if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
192      printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
193      exit(1);
194    }
195    free(tmp_version);
196
197  /* Compare xml2-config output to the libxml headers */
198   if ((xml_major_version != $xml_config_major_version) ||
199       (xml_minor_version != $xml_config_minor_version) ||
200       (xml_micro_version != $xml_config_micro_version))
201     {
202       printf("*** libxml header files (version %d.%d.%d) do not match\n",
203          xml_major_version, xml_minor_version, xml_micro_version);
204       printf("*** xml2-config (version %d.%d.%d)\n",
205          $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
206       return 1;
207     } 
208 /* Compare the headers to the library to make sure we match */
209   /* Less than ideal -- doesn't provide us with return value feedback, 
210    * only exits if there's a serious mismatch between header and library.
211    */
212     LIBXML_TEST_VERSION;
213
214     /* Test that the library is greater than our minimum version */
215     if ((xml_major_version > major) ||
216         ((xml_major_version == major) && (xml_minor_version > minor)) ||
217         ((xml_major_version == major) && (xml_minor_version == minor) &&
218         (xml_micro_version >= micro)))
219       {
220         return 0;
221        }
222      else
223       {
224         printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
225                xml_major_version, xml_minor_version, xml_micro_version);
226         printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
227            major, minor, micro);
228         printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
229         printf("***\n");
230         printf("*** If you have already installed a sufficiently new version, this error\n");
231         printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
232         printf("*** being found. The easiest way to fix this is to remove the old version\n");
233         printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
234         printf("*** correct copy of xml2-config. (In this case, you will have to\n");
235         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
236         printf("*** so that the correct libraries are found at run-time))\n");
237     }
238   return 1;
239 }
240 ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
241        CFLAGS="$ac_save_CFLAGS"
242        LIBS="$ac_save_LIBS"
243      fi
244   fi
245
246   if test "x$no_xml" = x ; then
247      AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
248      ifelse([$2], , :, [$2])     
249   else
250      AC_MSG_RESULT(no)
251      if test "$XML2_CONFIG" = "no" ; then
252        echo "*** The xml2-config script installed by LIBXML could not be found"
253        echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
254        echo "*** your path, or set the XML2_CONFIG environment variable to the"
255        echo "*** full path to xml2-config."
256      else
257        if test -f conf.xmltest ; then
258         :
259        else
260           echo "*** Could not run libxml test program, checking why..."
261           CFLAGS="$CFLAGS $XML_CFLAGS"
262           LIBS="$LIBS $XML_LIBS"
263           AC_TRY_LINK([
264 #include <libxml/xmlversion.h>
265 #include <stdio.h>
266 ],      [ LIBXML_TEST_VERSION; return 0;],
267         [ echo "*** The test program compiled, but did not run. This usually means"
268           echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
269           echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
270           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
271           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
272           echo "*** is required on your system"
273           echo "***"
274           echo "*** If you have an old version installed, it is best to remove it, although"
275           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
276         [ echo "*** The test program failed to compile or link. See the file config.log for the"
277           echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
278           echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
279           echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
280           CFLAGS="$ac_save_CFLAGS"
281           LIBS="$ac_save_LIBS"
282        fi
283      fi
284
285      XML_CFLAGS=""
286      XML_LIBS=""
287      ifelse([$3], , :, [$3])
288   fi
289   AC_SUBST(XML_CFLAGS)
290   AC_SUBST(XML_LIBS)
291   rm -f conf.xmltest
292 ])
293
294 # =========================================================================
295 # AM_PATH_MYSQL : MySQL library
296
297 dnl AM_PATH_MYSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
298 dnl Test for MYSQL, and define MYSQL_CFLAGS and MYSQL_LIBS
299 dnl
300 AC_DEFUN(AM_PATH_MYSQL,
301 [dnl
302 dnl Get the cflags and libraries from the mysql_config script
303 dnl
304 AC_ARG_WITH(mysql-prefix,[  --with-mysql-prefix=PFX   Prefix where MYSQL is installed (optional)],
305             mysql_prefix="$withval", mysql_prefix="")
306 AC_ARG_WITH(mysql-exec-prefix,[  --with-mysql-exec-prefix=PFX Exec prefix where MYSQL is installed (optional)],
307             mysql_exec_prefix="$withval", mysql_exec_prefix="")
308 AC_ARG_ENABLE(mysqltest, [  --disable-mysqltest       Do not try to compile and run a test MYSQL program],
309          , enable_mysqltest=yes)
310
311   if test x$mysql_exec_prefix != x ; then
312      mysql_args="$mysql_args --exec-prefix=$mysql_exec_prefix"
313      if test x${MYSQL_CONFIG+set} != xset ; then
314         MYSQL_CONFIG=$mysql_exec_prefix/bin/mysql_config
315      fi
316   fi
317   if test x$mysql_prefix != x ; then
318      mysql_args="$mysql_args --prefix=$mysql_prefix"
319      if test x${MYSQL_CONFIG+set} != xset ; then
320         MYSQL_CONFIG=$mysql_prefix/bin/mysql_config
321      fi
322   fi
323
324   AC_REQUIRE([AC_CANONICAL_TARGET])
325   AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no)
326   min_mysql_version=ifelse([$1], ,0.11.0,$1)
327   AC_MSG_CHECKING(for MYSQL - version >= $min_mysql_version)
328   no_mysql=""
329   if test "$MYSQL_CONFIG" = "no" ; then
330     no_mysql=yes
331   else
332     MYSQL_CFLAGS=`$MYSQL_CONFIG $mysqlconf_args --cflags | sed -e "s/'//g"`
333     MYSQL_LIBS=`$MYSQL_CONFIG $mysqlconf_args --libs | sed -e "s/'//g"`
334
335     mysql_major_version=`$MYSQL_CONFIG $mysql_args --version | \
336            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
337     mysql_minor_version=`$MYSQL_CONFIG $mysql_args --version | \
338            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
339     mysql_micro_version=`$MYSQL_CONFIG $mysql_config_args --version | \
340            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
341     if test "x$enable_mysqltest" = "xyes" ; then
342       ac_save_CFLAGS="$CFLAGS"
343       ac_save_LIBS="$LIBS"
344       CFLAGS="$CFLAGS $MYSQL_CFLAGS"
345       LIBS="$LIBS $MYSQL_LIBS"
346 dnl
347 dnl Now check if the installed MYSQL is sufficiently new. (Also sanity
348 dnl checks the results of mysql_config to some extent
349 dnl
350       rm -f conf.mysqltest
351       AC_TRY_RUN([
352 #include <stdio.h>
353 #include <stdlib.h>
354 #include <string.h>
355 #include <mysql.h>
356
357 char*
358 my_strdup (char *str)
359 {
360   char *new_str;
361
362   if (str)
363     {
364       new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
365       strcpy (new_str, str);
366     }
367   else
368     new_str = NULL;
369
370   return new_str;
371 }
372
373 int main (int argc, char *argv[])
374 {
375 int major, minor, micro;
376   char *tmp_version;
377
378   /* This hangs on some systems (?)
379   system ("touch conf.mysqltest");
380   */
381   { FILE *fp = fopen("conf.mysqltest", "a"); if ( fp ) fclose(fp); }
382
383   /* HP/UX 9 (%@#!) writes to sscanf strings */
384   tmp_version = my_strdup("$min_mysql_version");
385   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
386      printf("%s, bad version string\n", "$min_mysql_version");
387      exit(1);
388    }
389
390    if (($mysql_major_version > major) ||
391       (($mysql_major_version == major) && ($mysql_minor_version > minor)) ||
392       (($mysql_major_version == major) && ($mysql_minor_version == minor) && ($mysql_micro_version >= micro)))
393     {
394       return 0;
395     }
396   else
397     {
398       printf("\n*** 'mysql_config --version' returned %d.%d.%d, but the minimum version\n", $mysql_major_version, $mysql_minor_version, $mysql_micro_version);
399       printf("*** of MYSQL required is %d.%d.%d. If mysql_config is correct, then it is\n", major, minor, micro);
400       printf("*** best to upgrade to the required version.\n");
401       printf("*** If mysql_config was wrong, set the environment variable MYSQL_CONFIG\n");
402       printf("*** to point to the correct copy of mysql_config, and remove the file\n");
403       printf("*** config.cache before re-running configure\n");
404       return 1;
405     }
406 }
407
408 ],, no_mysql=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
409        CFLAGS="$ac_save_CFLAGS"
410        LIBS="$ac_save_LIBS"
411      fi
412   fi
413   if test "x$no_mysql" = x ; then
414      AC_MSG_RESULT(yes)
415      ifelse([$2], , :, [$2])
416   else
417      AC_MSG_RESULT(no)
418      if test "$MYSQL_CONFIG" = "no" ; then
419        echo "*** The mysql_config script installed by MYSQL could not be found"
420        echo "*** If MYSQL was installed in PREFIX, make sure PREFIX/bin is in"
421        echo "*** your path, or set the MYSQL_CONFIG environment variable to the"
422        echo "*** full path to mysql_config."
423      else
424        if test -f conf.mysqltest ; then
425         :
426        else
427           echo "*** Could not run MYSQL test program, checking why..."
428           CFLAGS="$CFLAGS $MYSQL_CFLAGS"
429           LIBS="$LIBS $MYSQL_LIBS"
430           AC_TRY_LINK([
431 #include <stdio.h>
432 #include <mysql.h>
433
434 int main(int argc, char *argv[])
435 { return 0; }
436 #undef  main
437 #define main K_and_R_C_main
438 ],      [ return 0; ],
439         [ echo "*** The test program compiled, but did not run. This usually means"
440           echo "*** that the run-time linker is not finding MYSQL or finding the wrong"
441           echo "*** version of MYSQL. If it is not finding MYSQL, you'll need to set your"
442           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
443           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
444           echo "*** is required on your system"
445     echo "***"
446           echo "*** If you have an old version installed, it is best to remove it, although"
447           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
448         [ echo "*** The test program failed to compile or link. See the file config.log for the"
449           echo "*** exact error that occured. This usually means MYSQL was incorrectly installed"
450           echo "*** or that you have moved MYSQL since it was installed. In the latter case, you"
451           echo "*** may want to edit the mysql_config script: $MYSQL_CONFIG" ])
452           CFLAGS="$ac_save_CFLAGS"
453           LIBS="$ac_save_LIBS"
454        fi
455      fi
456      MYSQL_CFLAGS=""
457      MYSQL_LIBS=""
458      ifelse([$3], , :, [$3])
459   fi
460   AC_SUBST(MYSQL_CFLAGS)
461   AC_SUBST(MYSQL_LIBS)
462   rm -f conf.mysqltest
463 ])
464
465 dnl Removes -I/usr/include/? from given variable
466 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
467   ac_new_flags=""
468   for i in [$]$1; do
469     case [$]i in
470     -I/usr/include|-I/usr/include/) ;;
471     *) ac_new_flags="[$]ac_new_flags [$]i" ;;
472     esac
473   done
474   $1=[$]ac_new_flags
475 ])
476     
477 dnl Removes -L/usr/lib/? from given variable
478 AC_DEFUN(LIB_REMOVE_USR_LIB,[
479   ac_new_flags=""
480   for i in [$]$1; do
481     case [$]i in
482     -L/usr/lib|-L/usr/lib/) ;;
483     *) ac_new_flags="[$]ac_new_flags [$]i" ;;
484     esac
485   done
486   $1=[$]ac_new_flags
487 ])
488
489 dnl From Bruno Haible.
490
491 AC_DEFUN(jm_ICONV,
492 [
493   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
494   dnl those with the standalone portable libiconv installed).
495   AC_MSG_CHECKING(for iconv in $1)
496     jm_cv_func_iconv="no"
497     jm_cv_lib_iconv=no
498     jm_cv_giconv=no
499     AC_TRY_LINK([#include <stdlib.h>
500 #include <giconv.h>],
501       [iconv_t cd = iconv_open("","");
502        iconv(cd,NULL,NULL,NULL,NULL);
503        iconv_close(cd);],
504       jm_cv_func_iconv=yes
505       jm_cv_giconv=yes)
506
507     if test "$jm_cv_func_iconv" != yes; then
508       AC_TRY_LINK([#include <stdlib.h>
509 #include <iconv.h>],
510         [iconv_t cd = iconv_open("","");
511          iconv(cd,NULL,NULL,NULL,NULL);
512          iconv_close(cd);],
513         jm_cv_func_iconv=yes)
514
515         if test "$jm_cv_lib_iconv" != yes; then
516           jm_save_LIBS="$LIBS"
517           LIBS="$LIBS -lgiconv"
518           AC_TRY_LINK([#include <stdlib.h>
519 #include <giconv.h>],
520             [iconv_t cd = iconv_open("","");
521              iconv(cd,NULL,NULL,NULL,NULL);
522              iconv_close(cd);],
523             jm_cv_lib_iconv=yes
524             jm_cv_func_iconv=yes
525             jm_cv_giconv=yes)
526           LIBS="$jm_save_LIBS"
527
528       if test "$jm_cv_func_iconv" != yes; then
529         jm_save_LIBS="$LIBS"
530         LIBS="$LIBS -liconv"
531         AC_TRY_LINK([#include <stdlib.h>
532 #include <iconv.h>],
533           [iconv_t cd = iconv_open("","");
534            iconv(cd,NULL,NULL,NULL,NULL);
535            iconv_close(cd);],
536           jm_cv_lib_iconv=yes
537           jm_cv_func_iconv=yes)
538         LIBS="$jm_save_LIBS"
539         fi
540       fi
541     fi
542
543   if test "$jm_cv_func_iconv" = yes; then
544     if test "$jm_cv_giconv" = yes; then
545       AC_DEFINE(HAVE_GICONV, 1, [What header to include for iconv() function: giconv.h])
546       AC_MSG_RESULT(yes)
547       ICONV_FOUND=yes
548     else
549       AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: iconv.h])
550       AC_MSG_RESULT(yes)
551       ICONV_FOUND=yes
552     fi
553   else
554     AC_MSG_RESULT(no)
555   fi
556   if test "$jm_cv_lib_iconv" = yes; then
557     if test "$jm_cv_giconv" = yes; then
558       LIBS="$LIBS -lgiconv"
559     else
560       LIBS="$LIBS -liconv"
561     fi
562   fi
563 ])
564
565 dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR)
566 dnl This function doesn't add -I/usr/include into CFLAGS
567 AC_DEFUN(CFLAGS_ADD_DIR,[
568 if test "$2" != "/usr/include" ; then
569     $1="$$1 -I$2"
570 fi
571 ])
572
573 dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR)
574 dnl This function doesn't add -L/usr/lib into LDFLAGS
575 AC_DEFUN(LIB_ADD_DIR,[
576 if test "$2" != "/usr/lib" ; then
577     $1="$$1 -L$2"
578 fi
579 ])
580
581 dnl AC_ENABLE_SHARED - implement the --enable-shared flag
582 dnl Usage: AC_ENABLE_SHARED[(DEFAULT)]
583 dnl   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
584 dnl   `yes'.
585 AC_DEFUN([AC_ENABLE_SHARED],
586 [define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
587 AC_ARG_ENABLE(shared,
588 changequote(<<, >>)dnl
589 <<  --enable-shared[=PKGS]    build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
590 changequote([, ])dnl
591 [p=${PACKAGE-default}
592 case $enableval in
593 yes) enable_shared=yes ;;
594 no) enable_shared=no ;;
595 *)
596   enable_shared=no
597   # Look at the argument we got.  We use all the common list separators.
598   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
599   for pkg in $enableval; do
600     if test "X$pkg" = "X$p"; then
601       enable_shared=yes
602     fi
603
604   done
605   IFS="$ac_save_ifs"
606   ;;
607 esac],
608 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
609 ])
610
611 dnl AC_ENABLE_STATIC - implement the --enable-static flag
612 dnl Usage: AC_ENABLE_STATIC[(DEFAULT)]
613 dnl   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
614 dnl   `yes'.
615 AC_DEFUN([AC_ENABLE_STATIC],
616 [define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
617 AC_ARG_ENABLE(static,
618 changequote(<<, >>)dnl
619 <<  --enable-static[=PKGS]    build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
620 changequote([, ])dnl
621 [p=${PACKAGE-default}
622 case $enableval in
623 yes) enable_static=yes ;;
624 no) enable_static=no ;;
625 *)
626   enable_static=no
627   # Look at the argument we got.  We use all the common list separators.
628   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
629   for pkg in $enableval; do
630     if test "X$pkg" = "X$p"; then
631       enable_static=yes
632     fi
633   done
634   IFS="$ac_save_ifs"
635   ;;
636 esac],
637 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
638 ])
639
640 dnl AC_DISABLE_STATIC - set the default static flag to --disable-static
641 AC_DEFUN([AC_DISABLE_STATIC],
642 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
643 AC_ENABLE_STATIC(no)])