@@ -16,22 +16,23 @@ AC_DEFUN([IMAP_LIB_CHK],[
16
16
done
17
17
] )
18
18
19
- dnl PHP_IMAP_TEST_BUILD(function, action-if-ok, action-if-not-ok, extra-libs, extra-source )
19
+ dnl PHP_IMAP_TEST_BUILD(function, action-if-ok, action-if-not-ok, extra-libs)
20
20
dnl
21
21
dnl The UW-IMAP c-client library was not originally designed to be a
22
22
dnl shared library. The mm_foo functions are callbacks, and are required
23
23
dnl to be implemented by the program that is linking to c-client. This
24
24
dnl macro does the work of defining them all to no-ops for you. Note
25
- dnl that PHP_TEST_BUILD is a link test; the undefined symbols will only
25
+ dnl that this is a link test; the undefined symbols will only
26
26
dnl cause problems if you actually try to link with c-client. For
27
27
dnl example, if your test is trivial enough to be optimized out, and if
28
28
dnl you link with --as-needed, the test/library may be omitted entirely
29
29
dnl from the final executable. In that case linking will of course
30
30
dnl succeed, but your luck won't necessarily apply at lower optimization
31
31
dnl levels or systems where --as-needed is not used.
32
32
AC_DEFUN ( [ PHP_IMAP_TEST_BUILD] , [
33
- PHP_TEST_BUILD([ $1 ] , [ $2 ] , [ $3 ] , [ $4 ] , [ $5 ]
34
- [
33
+ old_LIBS=$LIBS
34
+ LIBS="$4 $LIBS"
35
+ AC_LINK_IFELSE ( [ AC_LANG_SOURCE ( [
35
36
#if defined(__GNUC__) && __GNUC__ >= 4
36
37
# define PHP_IMAP_EXPORT __attribute__ ((visibility("default")))
37
38
#else
@@ -53,6 +54,18 @@ AC_DEFUN([PHP_IMAP_TEST_BUILD], [
53
54
PHP_IMAP_EXPORT void mm_exists(void){}
54
55
PHP_IMAP_EXPORT void mm_searched(void){}
55
56
PHP_IMAP_EXPORT void mm_expunged(void){}
57
+
58
+ char $1 (void);
59
+ int main(void) {
60
+ $1 ();
61
+ return 0;
62
+ }
63
+ ] ) ] ,[
64
+ LIBS=$old_LIBS
65
+ $2
66
+ ] ,[
67
+ LIBS=$old_LIBS
68
+ $3
56
69
] )
57
70
] )
58
71
@@ -230,9 +243,10 @@ if test "$PHP_IMAP" != "no"; then
230
243
TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD"
231
244
232
245
dnl Check if auth_gss exists
233
- PHP_IMAP_TEST_BUILD(auth_gssapi_valid, [
234
- AC_DEFINE ( HAVE_IMAP_AUTH_GSS , 1 , [ ] )
235
- ] , [ ] , $TST_LIBS)
246
+ PHP_IMAP_TEST_BUILD([ auth_gssapi_valid] ,
247
+ [ AC_DEFINE ( [ HAVE_IMAP_AUTH_GSS] , [ 1] , [ ] ) ] ,
248
+ [ ] ,
249
+ [ $TST_LIBS] )
236
250
237
251
dnl Check if utf8_to_mutf7 exists.
238
252
old_CPPFLAGS="${CPPFLAGS}"
@@ -252,15 +266,12 @@ if test "$PHP_IMAP" != "no"; then
252
266
AC_LANG_POP
253
267
254
268
255
- AC_MSG_CHECKING ( whether rfc822_output_address_list function present )
256
- PHP_TEST_BUILD(foobar, [
257
- AC_MSG_RESULT ( yes )
258
- AC_DEFINE ( HAVE_RFC822_OUTPUT_ADDRESS_LIST , 1 , [ ] )
259
- ] , [
260
- AC_MSG_RESULT ( no )
261
- ] , [
262
- $TST_LIBS
263
- ] , [
269
+ AC_CACHE_CHECK ( [ whether rfc822_output_address_list function is present] ,
270
+ [ php_cv_imap_have_rfc822_output_address_list] ,
271
+ [
272
+ old_LIBS=$LIBS
273
+ LIBS="$TST_LIBS $LIBS"
274
+ AC_LINK_IFELSE ( [ AC_LANG_SOURCE ( [
264
275
#if defined(__GNUC__) && __GNUC__ >= 4
265
276
# define PHP_IMAP_EXPORT __attribute__ ((visibility("default")))
266
277
#else
@@ -285,13 +296,24 @@ if test "$PHP_IMAP" != "no"; then
285
296
void rfc822_output_address_list(void);
286
297
void (*f)(void);
287
298
char foobar () {f = rfc822_output_address_list;}
299
+ char foobar(void);
300
+ int main(void) {
301
+ foobar();
302
+ return 0;
303
+ }
304
+ ] ) ] ,
305
+ [ php_cv_imap_have_rfc822_output_address_list=yes] ,
306
+ [ php_cv_imap_have_rfc822_output_address_list=no] )
307
+ LIBS=$old_LIBS
288
308
] )
309
+ AS_VAR_IF ( [ php_cv_imap_have_rfc822_output_address_list] , [ yes] ,
310
+ [ AC_DEFINE ( [ HAVE_RFC822_OUTPUT_ADDRESS_LIST] , [ 1] ,
311
+ [ Define to 1 if C-client has the 'rfc822_output_address_list' function.] ) ] )
289
312
290
313
AC_MSG_CHECKING ( whether build with IMAP works )
291
- PHP_IMAP_TEST_BUILD(mail_newbody, [
292
- AC_MSG_RESULT ( yes )
293
- ] , [
314
+ PHP_IMAP_TEST_BUILD([ mail_newbody] ,
315
+ [ AC_MSG_RESULT ( yes ) ] , [
294
316
AC_MSG_RESULT ( no )
295
317
AC_MSG_ERROR ( [ build test failed. Please check the config.log for details.] )
296
- ] , $TST_LIBS)
318
+ ] , [ $TST_LIBS] )
297
319
fi
0 commit comments