s4:samldb LDB module - make the "userAccountControl" and "groupType" modify handlers...
[sfrench/samba-autobuild/.git] / lib / util / charset / config.m4
1 dnl SMB_CHECK_ICONV(hdr, msg, action-if-found,action-if-not-found)
2 AC_DEFUN(SMB_CHECK_ICONV,[
3   AC_MSG_CHECKING($2)
4   AC_TRY_RUN([#include <stdlib.h>
5 #include <$1>
6
7 int main()
8 {
9    iconv_t cd = iconv_open("ASCII","UCS-2LE");
10    if (cd == 0 || cd == (iconv_t)-1) return -1;
11    return 0;
12
13    ],
14    [AC_MSG_RESULT(yes); $3],
15    [AC_MSG_RESULT(no); $4],
16    [AC_MSG_RESULT(cross); $4])
17 ])
18
19 dnl SMB_CHECK_ICONV_DIR(dir,action-if-found,action-if-not-found)
20 AC_DEFUN(SMB_CHECK_ICONV_DIR,
21 [
22         save_CPPFLAGS="$CPPFLAGS"
23         save_LDFLAGS="$LDFLAGS"
24         save_LIBS="$LIBS"
25         CPPFLAGS="-I$1/include"
26         LDFLAGS="-L$1/lib"
27         LIBS=-liconv
28
29         SMB_CHECK_ICONV(iconv.h,Whether iconv.h is present,[ AC_DEFINE(HAVE_ICONV_H,1,[Whether iconv.h is present]) $2 ], [
30         LIBS=-lgiconv
31         SMB_CHECK_ICONV(giconv.h,Whether giconv.h is present, [AC_DEFINE(HAVE_GICONV_H,1,[Whether giconv.h is present]) $2],[$3])
32         ])
33
34         CPPFLAGS="$save_CPPFLAGS"
35         LDFLAGS="$save_LDFLAGS"
36         LIBS="$save_LIBS"
37 ])
38
39 ICONV_FOUND=no
40 LOOK_DIRS="/usr /usr/local /sw"
41 AC_ARG_WITH(libiconv,
42 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
43 [
44   if test "$withval" = "no" ; then
45     AC_MSG_ERROR(I won't take no for an answer)
46   else
47      if test "$withval" != "yes" ; then
48         SMB_CHECK_ICONV_DIR($withval, [
49                 ICONV_FOUND=yes; 
50                 ICONV_CPPFLAGS="$CPPFLAGS"
51                 ICONV_LIBS="$LIBS"
52                 ICONV_LDFLAGS="$LDFLAGS"
53                 ], [AC_MSG_ERROR([No iconv library found in $withval])])
54      fi
55   fi
56 ])
57
58 if test x$ICONV_FOUND = xno; then
59         SMB_CHECK_ICONV(iconv.h,
60                 [Whether iconv.h is present], 
61                 [AC_DEFINE(HAVE_ICONV_H,1,[Whether iconv.h is present]) ICONV_FOUND=yes])
62 fi
63
64 for i in $LOOK_DIRS ; do
65         if test x$ICONV_FOUND = xyes; then
66                 break
67         fi
68         
69         SMB_CHECK_ICONV_DIR($i, [
70                 ICONV_FOUND=yes
71                 ICONV_CPPFLAGS="$CPPFLAGS"
72                 ICONV_LIBS="$LIBS"
73                 ICONV_LDFLAGS="$LDFLAGS"
74                 ], [])
75 done
76
77 if test x"$ICONV_FOUND" = x"no"; then 
78     AC_MSG_WARN([Sufficient support for iconv function was not found. 
79     Install libiconv from http://www.gnu.org/software/libiconv/ for better charset compatibility!])
80         SMB_ENABLE(ICONV,NO)
81 else
82         AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether external iconv is available])
83         SMB_ENABLE(ICONV,YES)
84 fi
85
86 SMB_EXT_LIB(ICONV,[${ICONV_LIBS}],[${ICONV_CFLAGS}],[${ICONV_CPPFLAGS}],[${ICONV_LDFLAGS}])