Busybox: Upgrade to 1.21.1 (stable). lsof active.
[tomato.git] / release / src / router / php / ext / imap / config.m4
blob3ad7c107ddac1e489d64edf7221cd79ae045d42d
1 dnl
2 dnl $Id$
3 dnl
5 AC_DEFUN([IMAP_INC_CHK],[if test -r "$i$1/c-client.h"; then
6     AC_DEFINE(HAVE_IMAP2000, 1, [ ])
7     IMAP_DIR=$i
8     IMAP_INC_DIR=$i$1
9     break
10   elif test -r "$i$1/rfc822.h"; then 
11     IMAP_DIR=$i; 
12     IMAP_INC_DIR=$i$1
13         break
16 AC_DEFUN([IMAP_LIB_CHK],[
17   str="$IMAP_DIR/$1/lib$lib.*"
18   for i in `echo $str`; do
19     test -r $i && IMAP_LIBDIR=$IMAP_DIR/$1 && break 2
20   done
23 dnl PHP_IMAP_TEST_BUILD(function, action-if-ok, action-if-not-ok, extra-libs)
24 AC_DEFUN([PHP_IMAP_TEST_BUILD], [
25   PHP_TEST_BUILD([$1], [$2], [$3], [$4],
26   [
27 #if defined(__GNUC__) && __GNUC__ >= 4
28 # define PHP_IMAP_EXPORT __attribute__ ((visibility("default")))
29 #else
30 # define PHP_IMAP_EXPORT
31 #endif
33     PHP_IMAP_EXPORT void mm_log(void){}
34     PHP_IMAP_EXPORT void mm_dlog(void){}
35     PHP_IMAP_EXPORT void mm_flags(void){}
36     PHP_IMAP_EXPORT void mm_fatal(void){}
37     PHP_IMAP_EXPORT void mm_critical(void){}
38     PHP_IMAP_EXPORT void mm_nocritical(void){}
39     PHP_IMAP_EXPORT void mm_notify(void){}
40     PHP_IMAP_EXPORT void mm_login(void){}
41     PHP_IMAP_EXPORT void mm_diskerror(void){}
42     PHP_IMAP_EXPORT void mm_status(void){}
43     PHP_IMAP_EXPORT void mm_lsub(void){}
44     PHP_IMAP_EXPORT void mm_list(void){}
45     PHP_IMAP_EXPORT void mm_exists(void){}
46     PHP_IMAP_EXPORT void mm_searched(void){}
47     PHP_IMAP_EXPORT void mm_expunged(void){}
48   ])
51 AC_DEFUN([PHP_IMAP_KRB_CHK], [
52   if test "$PHP_KERBEROS" != "no"; then
53     PHP_SETUP_KERBEROS(IMAP_SHARED_LIBADD,
54     [
55       AC_DEFINE(HAVE_IMAP_KRB,1,[ ])
56     ], [
57       AC_MSG_ERROR([Kerberos libraries not found. 
58       
59       Check the path given to --with-kerberos (if no path is given, searches in /usr/kerberos, /usr/local and /usr )
60       ])
61     ])
62   else
63     AC_EGREP_HEADER(auth_gss, $IMAP_INC_DIR/linkage.h, [
64       AC_MSG_ERROR([This c-client library is built with Kerberos support. 
66       Add --with-kerberos to your configure line. Check config.log for details.
67       ])
68     ])
69   fi
72 AC_DEFUN([PHP_IMAP_SSL_CHK], [
73   if test "$PHP_IMAP_SSL" != "no"; then
74     if test "$PHP_OPENSSL" = ""; then
75       PHP_OPENSSL='no'
76     fi
77     PHP_SETUP_OPENSSL(IMAP_SHARED_LIBADD,
78     [
79       AC_DEFINE(HAVE_IMAP_SSL,1,[ ])
80     ], [
81       AC_MSG_ERROR([OpenSSL libraries not found. 
82       
83       Check the path given to --with-openssl-dir and output in config.log)
84       ])
85     ])
86   elif test -f "$IMAP_INC_DIR/linkage.c"; then
87     AC_EGREP_HEADER(ssl_onceonlyinit, $IMAP_INC_DIR/linkage.c, [
88       AC_MSG_ERROR([This c-client library is built with SSL support. 
90       Add --with-imap-ssl to your configure line. Check config.log for details.
91       ])
92     ])
93   fi
97 PHP_ARG_WITH(imap,for IMAP support,
98 [  --with-imap[=DIR]       Include IMAP support. DIR is the c-client install prefix])
100 PHP_ARG_WITH(kerberos,for IMAP Kerberos support,
101 [  --with-kerberos[=DIR]     IMAP: Include Kerberos support. DIR is the Kerberos install prefix], no, no)
103 PHP_ARG_WITH(imap-ssl,for IMAP SSL support,
104 [  --with-imap-ssl[=DIR]     IMAP: Include SSL support. DIR is the OpenSSL install prefix], no, no)
107 if test "$PHP_IMAP" != "no"; then  
108     PHP_SUBST(IMAP_SHARED_LIBADD)
109     PHP_NEW_EXTENSION(imap, php_imap.c, $ext_shared)
110     AC_DEFINE(HAVE_IMAP,1,[ ])
112     for i in $PHP_IMAP /usr/local /usr; do
113       IMAP_INC_CHK()
114       el[]IMAP_INC_CHK(/include/c-client)
115       el[]IMAP_INC_CHK(/include/imap)
116       el[]IMAP_INC_CHK(/include)
117       el[]IMAP_INC_CHK(/imap)
118       el[]IMAP_INC_CHK(/c-client)
119       fi
120     done
122     dnl Check for c-client version 2004
123     AC_EGREP_HEADER(mail_fetch_overview_sequence, $IMAP_INC_DIR/mail.h, [
124       AC_DEFINE(HAVE_IMAP2004,1,[ ])
125     ])
127     dnl Check for new version of the utf8_mime2text() function
128     old_CFLAGS=$CFLAGS
129     CFLAGS="-I$IMAP_INC_DIR"
130     AC_CACHE_CHECK(for utf8_mime2text signature, ac_cv_utf8_mime2text,
131       AC_TRY_COMPILE([
132 #include <stdio.h>
133 #include <c-client.h>
134       ],[
135         SIZEDTEXT *src, *dst;
136         utf8_mime2text(src, dst);
137       ],[
138         ac_cv_utf8_mime2text=old
139       ],[
140         ac_cv_utf8_mime2text=new
141       ])
142     )
143     if test "$ac_cv_utf8_mime2text" = "new"; then
144       AC_DEFINE(HAVE_NEW_MIME2TEXT, 1, [Whether utf8_mime2text() has new signature])
145     fi
146     CFLAGS=$old_CFLAGS
148     old_CFLAGS=$CFLAGS
149     CFLAGS="-I$IMAP_INC_DIR"
150     AC_CACHE_CHECK(for U8T_DECOMPOSE, ac_cv_u8t_canonical,
151       AC_TRY_COMPILE([
152 #include <c-client.h>
153       ],[
154          int i = U8T_CANONICAL;
155       ],[
156          ac_cv_u8t_decompose=yes
157       ],[
158          ac_cv_u8t_decompose=no
159       ])
160     )
161     CFLAGS=$old_CFLAGS
163     if test "$ac_cv_u8t_decompose" = "no" && test "$ac_cv_utf8_mime2text" = "new"; then
164                 AC_MSG_ERROR([utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.])
165     fi
166     if test "$ac_cv_u8t_decompose" = "yes" && test "$ac_cv_utf8_mime2text" = "old"; then
167                 AC_MSG_ERROR([utf8_mime2text() has old signature, but U8T_CANONICAL is present. This should not happen. Check config.log for additional information.])
168     fi
170     dnl Check for c-client version 2001
171     old_CPPFLAGS=$CPPFLAGS
172     CPPFLAGS=-I$IMAP_INC_DIR
173     AC_EGREP_CPP(this_is_true, [
174 #include "imap4r1.h"
175 #if defined(IMAPSSLPORT)
176       this_is_true
177 #endif
178     ],[
179       AC_DEFINE(HAVE_IMAP2001, 1, [ ])
180     ],[])
181     CPPFLAGS=$old_CPPFLAGS
183     PHP_CHECK_LIBRARY(pam, pam_start, 
184     [
185       PHP_ADD_LIBRARY(pam,, IMAP_SHARED_LIBADD)
186       AC_DEFINE(HAVE_LIBPAM,1,[ ])
187     ])
189     PHP_CHECK_LIBRARY(crypt, crypt, 
190     [
191       PHP_ADD_LIBRARY(crypt,, IMAP_SHARED_LIBADD)
192       AC_DEFINE(HAVE_LIBCRYPT,1,[ ])
193     ])
194             
195     PHP_EXPAND_PATH($IMAP_DIR, IMAP_DIR)
197     if test -z "$IMAP_DIR"; then
198       AC_MSG_ERROR(Cannot find rfc822.h. Please check your c-client installation.)
199     fi
201     if test -r "$IMAP_DIR/c-client/c-client.a"; then
202       ln -s "$IMAP_DIR/c-client/c-client.a" "$IMAP_DIR/c-client/libc-client.a" >/dev/null 2>&1
203     elif test -r "$IMAP_DIR/$PHP_LIBDIR/c-client.a"; then
204       ln -s "$IMAP_DIR/$PHP_LIBDIR/c-client.a" "$IMAP_DIR/$PHP_LIBDIR/libc-client.a" >/dev/null 2>&1
205     fi
207     for lib in c-client4 c-client imap; do
208       IMAP_LIB=$lib
209       IMAP_LIB_CHK($PHP_LIBDIR)
210       IMAP_LIB_CHK(c-client)
211     done
213     if test -z "$IMAP_LIBDIR"; then
214       AC_MSG_ERROR(Cannot find imap library (libc-client.a). Please check your c-client installation.)
215     fi
217     PHP_ADD_INCLUDE($IMAP_INC_DIR)
218     PHP_ADD_LIBRARY_DEFER($IMAP_LIB,, IMAP_SHARED_LIBADD)
219     PHP_ADD_LIBPATH($IMAP_LIBDIR, IMAP_SHARED_LIBADD)
220     PHP_IMAP_KRB_CHK
221     PHP_IMAP_SSL_CHK
223     dnl Test the build in the end
224     TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD"
226     dnl Check if auth_gss exists
227     PHP_IMAP_TEST_BUILD(auth_gssapi_valid, [
228       AC_DEFINE(HAVE_IMAP_AUTH_GSS, 1, [ ])
229     ], [], $TST_LIBS)
231     dnl Check if utf8_to_mutf7 exists
232     PHP_IMAP_TEST_BUILD(utf8_to_mutf7, [
233       AC_DEFINE(HAVE_IMAP_MUTF7, 1, [ ])
234     ], [], $TST_LIBS)
236     AC_MSG_CHECKING(whether rfc822_output_address_list function present)
237     PHP_TEST_BUILD(foobar, [
238       AC_MSG_RESULT(yes)
239       AC_DEFINE(HAVE_RFC822_OUTPUT_ADDRESS_LIST, 1, [ ])
240     ], [
241       AC_MSG_RESULT(no)
242         ], [
243       $TST_LIBS
244     ], [
245 #if defined(__GNUC__) && __GNUC__ >= 4
246 # define PHP_IMAP_EXPORT __attribute__ ((visibility("default")))
247 #else
248 # define PHP_IMAP_EXPORT
249 #endif
251       PHP_IMAP_EXPORT void mm_log(void){}
252       PHP_IMAP_EXPORT void mm_dlog(void){}
253       PHP_IMAP_EXPORT void mm_flags(void){}
254       PHP_IMAP_EXPORT void mm_fatal(void){}
255       PHP_IMAP_EXPORT void mm_critical(void){}
256       PHP_IMAP_EXPORT void mm_nocritical(void){}
257       PHP_IMAP_EXPORT void mm_notify(void){}
258       PHP_IMAP_EXPORT void mm_login(void){}
259       PHP_IMAP_EXPORT void mm_diskerror(void){}
260       PHP_IMAP_EXPORT void mm_status(void){}
261       PHP_IMAP_EXPORT void mm_lsub(void){}
262       PHP_IMAP_EXPORT void mm_list(void){}
263       PHP_IMAP_EXPORT void mm_exists(void){}
264       PHP_IMAP_EXPORT void mm_searched(void){}
265       PHP_IMAP_EXPORT void mm_expunged(void){}
266       void rfc822_output_address_list(void);
267       void (*f)(void);
268       char foobar () {f = rfc822_output_address_list;}
269     ])
271     AC_MSG_CHECKING(whether build with IMAP works)
272     PHP_IMAP_TEST_BUILD(mail_newbody, [
273       AC_MSG_RESULT(yes)
274     ], [
275       AC_MSG_RESULT(no)
276       AC_MSG_ERROR([build test failed. Please check the config.log for details.])
277     ], $TST_LIBS)