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