r3174: added pvfs_is_open() to allow us to check for open files on unlink. We
[gd/samba-autobuild/.git] / source4 / 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_TARGET])
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 dnl AC_PROG_CC_FLAG(flag)
40 AC_DEFUN(AC_PROG_CC_FLAG,
41 [AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
42 [echo 'void f(){}' > conftest.c
43 if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
44   ac_cv_prog_cc_$1=yes
45 else
46   ac_cv_prog_cc_$1=no
47 fi
48 rm -f conftest*
49 ])])
50
51 dnl see if a declaration exists for a function or variable
52 dnl defines HAVE_function_DECL if it exists
53 dnl AC_HAVE_DECL(var, includes)
54 AC_DEFUN(AC_HAVE_DECL,
55 [
56  AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
57     AC_TRY_COMPILE([$2],[int i = (int)$1],
58         ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
59  if test x"$ac_cv_have_$1_decl" = x"yes"; then
60     AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
61  fi
62 ])
63
64
65 dnl check for a function in a library, but don't
66 dnl keep adding the same library to the LIBS variable.
67 dnl AC_LIBTESTFUNC(lib,func)
68 AC_DEFUN(AC_LIBTESTFUNC,
69 [case "$LIBS" in
70   *-l$1*) AC_CHECK_FUNCS($2) ;;
71   *) AC_CHECK_LIB($1, $2) 
72      AC_CHECK_FUNCS($2)
73   ;;
74   esac
75 ])
76
77 # AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION],
78 #              [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
79 #              [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES])
80 # ------------------------------------------------------
81 #
82 # Use a cache variable name containing both the library and function name,
83 # because the test really is for library $1 defining function $3, not
84 # just for library $1.  Separate tests with the same $1 and different $3s
85 # may have different results.
86 #
87 # Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3])
88 # is asking for trouble, since AC_CHECK_LIB($lib, fun) would give
89 # ac_cv_lib_$lib_fun, which is definitely not what was meant.  Hence
90 # the AS_LITERAL_IF indirection.
91 #
92 # FIXME: This macro is extremely suspicious.  It DEFINEs unconditionally,
93 # whatever the FUNCTION, in addition to not being a *S macro.  Note
94 # that the cache does depend upon the function we are looking for.
95 #
96 # It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just
97 # `ac_save_LIBS': there are many macros which don't want to see `LIBS'
98 # changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'.
99 # And ``ac_save_LIBS' is too tempting a name, so let's leave them some
100 # freedom.
101 AC_DEFUN([AC_CHECK_LIB_EXT],
102 [
103 AH_CHECK_LIB_EXT([$1])
104 ac_check_lib_ext_save_LIBS=$LIBS
105 LIBS="-l$1 $$2 $7 $LIBS"
106 AS_LITERAL_IF([$1],
107       [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])],
108       [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl
109
110 m4_ifval([$3],
111  [
112     AH_CHECK_FUNC_EXT([$3])
113     AS_LITERAL_IF([$1],
114               [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])],
115               [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl
116     AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func,
117         [AC_TRY_LINK_FUNC($3,
118                  [AS_VAR_SET(ac_Lib_func, yes);
119                   AS_VAR_SET(ac_Lib_ext, yes)],
120                  [AS_VAR_SET(ac_Lib_func, no);
121                   AS_VAR_SET(ac_Lib_ext, no)])
122         ])
123     AS_IF([test AS_VAR_GET(ac_Lib_func) = yes],
124         [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl
125     AS_VAR_POPDEF([ac_Lib_func])dnl
126  ],[
127     AC_CACHE_CHECK([for -l$1], ac_Lib_ext,
128         [AC_TRY_LINK_FUNC([main],
129                  [AS_VAR_SET(ac_Lib_ext, yes)],
130                  [AS_VAR_SET(ac_Lib_ext, no)])
131         ])
132  ])
133 LIBS=$ac_check_lib_ext_save_LIBS
134
135 AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes],
136     [m4_default([$4], 
137         [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
138                 case "$$2" in
139                     *-l$1*)
140                         ;;
141                     *)
142                         $2="-l$1 $$2"
143                         ;;
144                 esac])
145                 [$6]
146             ],
147             [$5])dnl
148 AS_VAR_POPDEF([ac_Lib_ext])dnl
149 ])# AC_CHECK_LIB_EXT
150
151 # AH_CHECK_LIB_EXT(LIBNAME)
152 # ---------------------
153 m4_define([AH_CHECK_LIB_EXT],
154 [AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1),
155              [Define to 1 if you have the `]$1[' library (-l]$1[).])])
156
157 # AC_CHECK_FUNCS_EXT(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
158 # -----------------------------------------------------------------
159 dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable.
160 dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE)
161 AC_DEFUN([AC_CHECK_FUNC_EXT],
162 [
163     AH_CHECK_FUNC_EXT($1)       
164     ac_check_func_ext_save_LIBS=$LIBS
165     LIBS="$2 $LIBS"
166     AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl
167     AC_CACHE_CHECK([for $1], ac_var,
168         [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
169                 [AS_VAR_SET(ac_var, yes)],
170                 [AS_VAR_SET(ac_var, no)])])
171     LIBS=$ac_check_func_ext_save_LIBS
172     AS_IF([test AS_VAR_GET(ac_var) = yes], 
173             [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3], 
174             [$4])dnl
175 AS_VAR_POPDEF([ac_var])dnl
176 ])# AC_CHECK_FUNC
177
178 # AH_CHECK_FUNC_EXT(FUNCNAME)
179 # ---------------------
180 m4_define([AH_CHECK_FUNC_EXT],
181 [AH_TEMPLATE(AS_TR_CPP(HAVE_$1),
182              [Define to 1 if you have the `]$1[' function.])])
183
184 dnl Define an AC_DEFINE with ifndef guard.
185 dnl AC_N_DEFINE(VARIABLE [, VALUE])
186 define(AC_N_DEFINE,
187 [cat >> confdefs.h <<\EOF
188 [#ifndef] $1
189 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
190 [#endif]
191 EOF
192 ])
193
194 dnl Add an #include
195 dnl AC_ADD_INCLUDE(VARIABLE)
196 define(AC_ADD_INCLUDE,
197 [cat >> confdefs.h <<\EOF
198 [#include] $1
199 EOF
200 ])
201
202 dnl Copied from libtool.m4
203 AC_DEFUN(AC_PROG_LD_GNU,
204 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
205 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
206 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
207   ac_cv_prog_gnu_ld=yes
208 else
209   ac_cv_prog_gnu_ld=no
210 fi])
211 ])
212
213 # Configure paths for LIBXML2
214 # Toshio Kuratomi 2001-04-21
215 # Adapted from:
216 # Configure paths for GLIB
217 # Owen Taylor     97-11-3
218
219 dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
220 dnl Test for XML, and define XML_CFLAGS and XML_LIBS
221 dnl
222 AC_DEFUN(AM_PATH_XML2,[ 
223 AC_ARG_WITH(xml-prefix,
224             [  --with-xml-prefix=PFX   Prefix where libxml is installed (optional)],
225             xml_config_prefix="$withval", xml_config_prefix="")
226 AC_ARG_WITH(xml-exec-prefix,
227             [  --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
228             xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
229 AC_ARG_ENABLE(xmltest,
230               [  --disable-xmltest       Do not try to compile and run a test LIBXML program],,
231               enable_xmltest=yes)
232
233   if test x$xml_config_exec_prefix != x ; then
234      xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
235      if test x${XML2_CONFIG+set} != xset ; then
236         XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
237      fi
238   fi
239   if test x$xml_config_prefix != x ; then
240      xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
241      if test x${XML2_CONFIG+set} != xset ; then
242         XML2_CONFIG=$xml_config_prefix/bin/xml2-config
243      fi
244   fi
245
246   AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
247   min_xml_version=ifelse([$1], ,2.0.0,[$1])
248   AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
249   no_xml=""
250   if test "$XML2_CONFIG" = "no" ; then
251     no_xml=yes
252   else
253     XML_CFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
254     XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
255     xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
256            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
257     xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
258            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
259     xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
260            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
261     if test "x$enable_xmltest" = "xyes" ; then
262       ac_save_CFLAGS="$CFLAGS"
263       ac_save_LIBS="$LIBS"
264       CFLAGS="$CFLAGS $XML_CFLAGS"
265       LIBS="$XML_LIBS $LIBS"
266 dnl
267 dnl Now check if the installed libxml is sufficiently new.
268 dnl (Also sanity checks the results of xml2-config to some extent)
269 dnl
270       rm -f conf.xmltest
271       AC_TRY_RUN([
272 #include <stdlib.h>
273 #include <stdio.h>
274 #include <string.h>
275 #include <libxml/xmlversion.h>
276
277 int 
278 main()
279 {
280   int xml_major_version, xml_minor_version, xml_micro_version;
281   int major, minor, micro;
282   char *tmp_version;
283
284   system("touch conf.xmltest");
285
286   /* Capture xml2-config output via autoconf/configure variables */
287   /* HP/UX 9 (%@#!) writes to sscanf strings */
288   tmp_version = (char *)strdup("$min_xml_version");
289   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
290      printf("%s, bad version string from xml2-config\n", "$min_xml_version");
291      exit(1);
292    }
293    free(tmp_version);
294
295    /* Capture the version information from the header files */
296    tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
297    if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
298      printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
299      exit(1);
300    }
301    free(tmp_version);
302
303  /* Compare xml2-config output to the libxml headers */
304   if ((xml_major_version != $xml_config_major_version) ||
305       (xml_minor_version != $xml_config_minor_version) ||
306       (xml_micro_version != $xml_config_micro_version))
307     {
308       printf("*** libxml header files (version %d.%d.%d) do not match\n",
309          xml_major_version, xml_minor_version, xml_micro_version);
310       printf("*** xml2-config (version %d.%d.%d)\n",
311          $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
312       return 1;
313     } 
314 /* Compare the headers to the library to make sure we match */
315   /* Less than ideal -- doesn't provide us with return value feedback, 
316    * only exits if there's a serious mismatch between header and library.
317    */
318     LIBXML_TEST_VERSION;
319
320     /* Test that the library is greater than our minimum version */
321     if ((xml_major_version > major) ||
322         ((xml_major_version == major) && (xml_minor_version > minor)) ||
323         ((xml_major_version == major) && (xml_minor_version == minor) &&
324         (xml_micro_version >= micro)))
325       {
326         return 0;
327        }
328      else
329       {
330         printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
331                xml_major_version, xml_minor_version, xml_micro_version);
332         printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
333            major, minor, micro);
334         printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
335         printf("***\n");
336         printf("*** If you have already installed a sufficiently new version, this error\n");
337         printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
338         printf("*** being found. The easiest way to fix this is to remove the old version\n");
339         printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
340         printf("*** correct copy of xml2-config. (In this case, you will have to\n");
341         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
342         printf("*** so that the correct libraries are found at run-time))\n");
343     }
344   return 1;
345 }
346 ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
347        CFLAGS="$ac_save_CFLAGS"
348        LIBS="$ac_save_LIBS"
349      fi
350   fi
351
352   if test "x$no_xml" = x ; then
353      AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
354      ifelse([$2], , :, [$2])     
355   else
356      AC_MSG_RESULT(no)
357      if test "$XML2_CONFIG" = "no" ; then
358        echo "*** The xml2-config script installed by LIBXML could not be found"
359        echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
360        echo "*** your path, or set the XML2_CONFIG environment variable to the"
361        echo "*** full path to xml2-config."
362      else
363        if test -f conf.xmltest ; then
364         :
365        else
366           echo "*** Could not run libxml test program, checking why..."
367           CFLAGS="$CFLAGS $XML_CFLAGS"
368           LIBS="$LIBS $XML_LIBS"
369           AC_TRY_LINK([
370 #include <libxml/xmlversion.h>
371 #include <stdio.h>
372 ],      [ LIBXML_TEST_VERSION; return 0;],
373         [ echo "*** The test program compiled, but did not run. This usually means"
374           echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
375           echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
376           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
377           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
378           echo "*** is required on your system"
379           echo "***"
380           echo "*** If you have an old version installed, it is best to remove it, although"
381           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
382         [ echo "*** The test program failed to compile or link. See the file config.log for the"
383           echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
384           echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
385           echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
386           CFLAGS="$ac_save_CFLAGS"
387           LIBS="$ac_save_LIBS"
388        fi
389      fi
390
391      XML_CFLAGS=""
392      XML_LIBS=""
393      ifelse([$3], , :, [$3])
394   fi
395   AC_SUBST(XML_CFLAGS)
396   AC_SUBST(XML_LIBS)
397   rm -f conf.xmltest
398 ])
399
400 # =========================================================================
401 # AM_PATH_MYSQL : MySQL library
402
403 dnl AM_PATH_MYSQL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
404 dnl Test for MYSQL, and define MYSQL_CFLAGS and MYSQL_LIBS
405 dnl
406 AC_DEFUN(AM_PATH_MYSQL,
407 [dnl
408 dnl Get the cflags and libraries from the mysql_config script
409 dnl
410 AC_ARG_WITH(mysql-prefix,[  --with-mysql-prefix=PFX   Prefix where MYSQL is installed (optional)],
411             mysql_prefix="$withval", mysql_prefix="")
412 AC_ARG_WITH(mysql-exec-prefix,[  --with-mysql-exec-prefix=PFX Exec prefix where MYSQL is installed (optional)],
413             mysql_exec_prefix="$withval", mysql_exec_prefix="")
414
415   if test x$mysql_exec_prefix != x ; then
416      mysql_args="$mysql_args --exec-prefix=$mysql_exec_prefix"
417      if test x${MYSQL_CONFIG+set} != xset ; then
418         MYSQL_CONFIG=$mysql_exec_prefix/bin/mysql_config
419      fi
420   fi
421   if test x$mysql_prefix != x ; then
422      mysql_args="$mysql_args --prefix=$mysql_prefix"
423      if test x${MYSQL_CONFIG+set} != xset ; then
424         MYSQL_CONFIG=$mysql_prefix/bin/mysql_config
425      fi
426   fi
427
428   AC_REQUIRE([AC_CANONICAL_TARGET])
429   AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no)
430   AC_MSG_CHECKING(for MYSQL)
431   no_mysql=""
432   if test "$MYSQL_CONFIG" = "no" ; then
433     MYSQL_CFLAGS=""
434     MYSQL_LIBS=""
435     AC_MSG_RESULT(no)
436      ifelse([$2], , :, [$2])
437   else
438     MYSQL_CFLAGS=`$MYSQL_CONFIG $mysqlconf_args --cflags | sed -e "s/'//g"`
439     MYSQL_LIBS=`$MYSQL_CONFIG $mysqlconf_args --libs | sed -e "s/'//g"`
440     AC_MSG_RESULT(yes)
441     ifelse([$1], , :, [$1])
442   fi
443   AC_SUBST(MYSQL_CFLAGS)
444   AC_SUBST(MYSQL_LIBS)
445 ])
446
447 dnl Removes -I/usr/include/? from given variable
448 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
449   ac_new_flags=""
450   for i in [$]$1; do
451     case [$]i in
452     -I/usr/include|-I/usr/include/) ;;
453     *) ac_new_flags="[$]ac_new_flags [$]i" ;;
454     esac
455   done
456   $1=[$]ac_new_flags
457 ])
458     
459 dnl Removes -L/usr/lib/? from given variable
460 AC_DEFUN(LIB_REMOVE_USR_LIB,[
461   ac_new_flags=""
462   for i in [$]$1; do
463     case [$]i in
464     -L/usr/lib|-L/usr/lib/) ;;
465     *) ac_new_flags="[$]ac_new_flags [$]i" ;;
466     esac
467   done
468   $1=[$]ac_new_flags
469 ])
470
471 dnl From Bruno Haible.
472
473 AC_DEFUN(jm_ICONV,
474 [
475   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
476   dnl those with the standalone portable libiconv installed).
477   AC_MSG_CHECKING(for iconv in $1)
478     jm_cv_func_iconv="no"
479     jm_cv_lib_iconv=no
480     jm_cv_giconv=no
481     AC_TRY_LINK([#include <stdlib.h>
482 #include <giconv.h>],
483       [iconv_t cd = iconv_open("","");
484        iconv(cd,NULL,NULL,NULL,NULL);
485        iconv_close(cd);],
486       jm_cv_func_iconv=yes
487       jm_cv_giconv=yes)
488
489     if test "$jm_cv_func_iconv" != yes; then
490       AC_TRY_LINK([#include <stdlib.h>
491 #include <iconv.h>],
492         [iconv_t cd = iconv_open("","");
493          iconv(cd,NULL,NULL,NULL,NULL);
494          iconv_close(cd);],
495         jm_cv_func_iconv=yes)
496
497         if test "$jm_cv_lib_iconv" != yes; then
498           jm_save_LIBS="$LIBS"
499           LIBS="$LIBS -lgiconv"
500           AC_TRY_LINK([#include <stdlib.h>
501 #include <giconv.h>],
502             [iconv_t cd = iconv_open("","");
503              iconv(cd,NULL,NULL,NULL,NULL);
504              iconv_close(cd);],
505             jm_cv_lib_iconv=yes
506             jm_cv_func_iconv=yes
507             jm_cv_giconv=yes)
508           LIBS="$jm_save_LIBS"
509
510       if test "$jm_cv_func_iconv" != yes; then
511         jm_save_LIBS="$LIBS"
512         LIBS="$LIBS -liconv"
513         AC_TRY_LINK([#include <stdlib.h>
514 #include <iconv.h>],
515           [iconv_t cd = iconv_open("","");
516            iconv(cd,NULL,NULL,NULL,NULL);
517            iconv_close(cd);],
518           jm_cv_lib_iconv=yes
519           jm_cv_func_iconv=yes)
520         LIBS="$jm_save_LIBS"
521         fi
522       fi
523     fi
524
525   if test "$jm_cv_func_iconv" = yes; then
526     if test "$jm_cv_giconv" = yes; then
527       AC_DEFINE(HAVE_GICONV, 1, [What header to include for iconv() function: giconv.h])
528       AC_MSG_RESULT(yes)
529       ICONV_FOUND=yes
530     else
531       AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: iconv.h])
532       AC_MSG_RESULT(yes)
533       ICONV_FOUND=yes
534     fi
535   else
536     AC_MSG_RESULT(no)
537   fi
538   if test "$jm_cv_lib_iconv" = yes; then
539     if test "$jm_cv_giconv" = yes; then
540       LIBS="$LIBS -lgiconv"
541     else
542       LIBS="$LIBS -liconv"
543     fi
544   fi
545 ])
546
547 dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR)
548 dnl This function doesn't add -I/usr/include into CFLAGS
549 AC_DEFUN(CFLAGS_ADD_DIR,[
550 if test "$2" != "/usr/include" ; then
551     $1="$$1 -I$2"
552 fi
553 ])
554
555 dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR)
556 dnl This function doesn't add -L/usr/lib into LDFLAGS
557 AC_DEFUN(LIB_ADD_DIR,[
558 if test "$2" != "/usr/lib" ; then
559     $1="$$1 -L$2"
560 fi
561 ])
562
563 sinclude(build/smb_build/public.m4)
564 sinclude(build/smb_build/core.m4)