File: config.m4

package info (click to toggle)
php-memcached 3.1.3%2B2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,432 kB
  • sloc: ansic: 9,903; xml: 1,262; php: 321; pascal: 87; sh: 12; makefile: 5
file content (409 lines) | stat: -rw-r--r-- 15,022 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
dnl vim:se ts=2 sw=2 et:

PHP_ARG_ENABLE(memcached, whether to enable memcached support,
[  --enable-memcached              Enable memcached support])

PHP_ARG_WITH(libmemcached-dir,  for libmemcached,
[  --with-libmemcached-dir=DIR     Set the path to libmemcached install prefix.], yes)

PHP_ARG_ENABLE(memcached-session, whether to enable memcached session handler support,
[  --enable-memcached-session      Enable memcached session handler support], yes, no)

PHP_ARG_ENABLE(memcached-igbinary, whether to enable memcached igbinary serializer support,
[  --enable-memcached-igbinary     Enable memcached igbinary serializer support], no, no)

PHP_ARG_ENABLE(memcached-json, whether to enable memcached json serializer support,
[  --enable-memcached-json         Enable memcached json serializer support], no, no)

PHP_ARG_ENABLE(memcached-msgpack, whether to enable memcached msgpack serializer support,
[  --enable-memcached-msgpack      Enable memcached msgpack serializer support], no, no)

PHP_ARG_ENABLE(memcached-sasl, whether to enable memcached sasl support,
[  --enable-memcached-sasl         Enable memcached sasl support], yes, no)

PHP_ARG_ENABLE(memcached-protocol, whether to enable memcached protocol support,
[  --enable-memcached-protocol     Enable memcached protocol support], no, no)

PHP_ARG_WITH(system-fastlz, whether to use system FastLZ library,
[  --with-system-fastlz            Use system FastLZ library], no, no)

if test -z "$PHP_ZLIB_DIR"; then
PHP_ARG_WITH(zlib-dir, for ZLIB,
[  --with-zlib-dir=DIR             Set the path to ZLIB install prefix.], no)
fi

if test -z "$PHP_DEBUG"; then
  AC_ARG_ENABLE(debug,
  [  --enable-debug          Compile with debugging symbols],[
    PHP_DEBUG=$enableval
  ],[    PHP_DEBUG=no
  ])
fi

if test "$PHP_MEMCACHED" != "no"; then

  AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  if test "x$PKG_CONFIG" = "xno"; then
    AC_MSG_RESULT([pkg-config not found])
    AC_MSG_ERROR([Please reinstall the pkg-config distribution])
  fi

  dnl # zlib
  if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
    if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
      PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
      PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
    elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
      PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
      PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
    else
      AC_MSG_ERROR([Can't find ZLIB headers under "$PHP_ZLIB_DIR"])
    fi
  else
    for i in /usr/local /usr/local/opt/zlib /usr; do
      if test -f "$i/include/zlib/zlib.h"; then
        PHP_ZLIB_DIR="$i"
        PHP_ZLIB_INCDIR="$i/include/zlib"
      elif test -f "$i/include/zlib.h"; then
        PHP_ZLIB_DIR="$i"
        PHP_ZLIB_INCDIR="$i/include"
      fi
    done
  fi

  AC_MSG_CHECKING([for zlib location])
  if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
    AC_MSG_RESULT([$PHP_ZLIB_DIR])
    PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, MEMCACHED_SHARED_LIBADD)
    PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR)
  else
    AC_MSG_ERROR([memcached support requires ZLIB. Use --with-zlib-dir=<DIR> to specify the prefix where ZLIB headers and library are located])
  fi

  if test "$PHP_MEMCACHED_SESSION" != "no"; then
    AC_MSG_CHECKING([for session includes])
    session_inc_path=""

    if test -f "$abs_srcdir/include/php/ext/session/php_session.h"; then
      session_inc_path="$abs_srcdir/include/php"
    elif test -f "$abs_srcdir/ext/session/php_session.h"; then
      session_inc_path="$abs_srcdir"
    elif test -f "$phpincludedir/ext/session/php_session.h"; then
      session_inc_path="$phpincludedir"
    else
      for i in php php4 php5 php6; do
        if test -f "$prefix/include/$i/ext/session/php_session.h"; then
          session_inc_path="$prefix/include/$i"
        fi
      done
    fi

    if test "$session_inc_path" = ""; then
      AC_MSG_ERROR([Cannot find php_session.h])
    else
      AC_MSG_RESULT([$session_inc_path])
    fi
  fi

  if test "$PHP_MEMCACHED_JSON" != "no"; then
    AC_MSG_CHECKING([for json includes])
    json_inc_path=""

    if test -f "$abs_srcdir/include/php/ext/json/php_json.h"; then
      json_inc_path="$abs_srcdir/include/php"
    elif test -f "$abs_srcdir/ext/json/php_json.h"; then
      json_inc_path="$abs_srcdir"
    elif test -f "$phpincludedir/ext/json/php_json.h"; then
      json_inc_path="$phpincludedir"
    else
      for i in php php4 php5 php6; do
        if test -f "$prefix/include/$i/ext/json/php_json.h"; then
          json_inc_path="$prefix/include/$i"
        fi
      done
    fi
    if test "$json_inc_path" = ""; then
      AC_MSG_ERROR([Cannot find php_json.h])
    else
      AC_DEFINE(HAVE_JSON_API,1,[Whether JSON API is available])
      AC_MSG_RESULT([$json_inc_path])
    fi
  fi

  if test "$PHP_MEMCACHED_IGBINARY" != "no"; then
    AC_MSG_CHECKING([for igbinary includes])
    igbinary_inc_path=""

    if test -f "$abs_srcdir/include/php/ext/igbinary/igbinary.h"; then
      igbinary_inc_path="$abs_srcdir/include/php"
    elif test -f "$abs_srcdir/ext/igbinary/igbinary.h"; then
      igbinary_inc_path="$abs_srcdir"
    elif test -f "$phpincludedir/ext/session/igbinary.h"; then
      igbinary_inc_path="$phpincludedir"
    elif test -f "$phpincludedir/ext/igbinary/igbinary.h"; then
      igbinary_inc_path="$phpincludedir"
    else
      for i in php php4 php5 php6; do
        if test -f "$prefix/include/$i/ext/igbinary/igbinary.h"; then
          igbinary_inc_path="$prefix/include/$i"
        fi
      done
    fi

    if test "$igbinary_inc_path" = ""; then
      AC_MSG_ERROR([Cannot find igbinary.h])
    else
      AC_MSG_RESULT([$igbinary_inc_path])
    fi
  fi

  if test "$PHP_MEMCACHED_MSGPACK" != "no"; then
    AC_MSG_CHECKING([for msgpack includes])
    msgpack_inc_path=""

    if test -f "$abs_srcdir/include/php/ext/msgpack/php_msgpack.h"; then
      msgpack_inc_path="$abs_srcdir/include/php"
    elif test -f "$abs_srcdir/ext/msgpack/php_msgpack.h"; then
      msgpack_inc_path="$abs_srcdir"
    elif test -f "$phpincludedir/ext/session/php_msgpack.h"; then
      msgpack_inc_path="$phpincludedir"
    elif test -f "$phpincludedir/ext/msgpack/php_msgpack.h"; then
      msgpack_inc_path="$phpincludedir"
    else
      for i in php php4 php5 php6; do
        if test -f "$prefix/include/$i/ext/msgpack/php_msgpack.h"; then
          msgpack_inc_path="$prefix/include/$i"
        fi
      done
    fi

    if test "$msgpack_inc_path" = ""; then
      AC_MSG_ERROR([Cannot find php_msgpack.h])
    else
      AC_MSG_RESULT([$msgpack_inc_path])
    fi
  fi

  AC_MSG_CHECKING([for memcached session support])
  if test "$PHP_MEMCACHED_SESSION" != "no"; then
    AC_MSG_RESULT([enabled])
    AC_DEFINE(HAVE_MEMCACHED_SESSION,1,[Whether memcache session handler is enabled])
    SESSION_INCLUDES="-I$session_inc_path"
    ifdef([PHP_ADD_EXTENSION_DEP],
    [
      PHP_ADD_EXTENSION_DEP(memcached, session)
    ])
  else
    SESSION_INCLUDES=""
    AC_MSG_RESULT([disabled])
  fi

  AC_MSG_CHECKING([for memcached igbinary support])
  if test "$PHP_MEMCACHED_IGBINARY" != "no"; then
    AC_MSG_RESULT([enabled])
    AC_DEFINE(HAVE_MEMCACHED_IGBINARY,1,[Whether memcache igbinary serializer is enabled])
    IGBINARY_INCLUDES="-I$igbinary_inc_path"
    ifdef([PHP_ADD_EXTENSION_DEP],
    [
      PHP_ADD_EXTENSION_DEP(memcached, igbinary)
    ])
  else
    IGBINARY_INCLUDES=""
    AC_MSG_RESULT([disabled])
  fi

  AC_MSG_CHECKING([for memcached msgpack support])
  if test "$PHP_MEMCACHED_MSGPACK" != "no"; then
    AC_MSG_RESULT([enabled])
    AC_DEFINE(HAVE_MEMCACHED_MSGPACK,1,[Whether memcache msgpack serializer is enabled])
    MSGPACK_INCLUDES="-I$msgpack_inc_path"
    ifdef([PHP_ADD_EXTENSION_DEP],
    [
      PHP_ADD_EXTENSION_DEP(memcached, msgpack)
    ])
  else
    MSGPACK_INCLUDES=""
    AC_MSG_RESULT([disabled])
  fi

  AC_MSG_CHECKING([for libmemcached location])
  export ORIG_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"

  if test "$PHP_LIBMEMCACHED_DIR" != "no" && test "$PHP_LIBMEMCACHED_DIR" != "yes"; then
    export PKG_CONFIG_PATH="$PHP_LIBMEMCACHED_DIR/$PHP_LIBDIR/pkgconfig"

    if test ! -f "$PHP_LIBMEMCACHED_DIR/include/libmemcached/memcached.h"; then
      AC_MSG_ERROR(Unable to find memcached.h under $PHP_LIBMEMCACHED_DIR)
    fi
  else
    export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/$PHP_LIBDIR/pkgconfig:/usr/$PHP_LIBDIR/pkgconfig:/opt/$PHP_LIBDIR/pkgconfig"
  fi

  if ! $PKG_CONFIG --exists libmemcached; then
    AC_MSG_ERROR([memcached support requires libmemcached. Use --with-libmemcached-dir=<DIR> to specify the prefix where libmemcached headers and library are located])
  else
    PHP_LIBMEMCACHED_VERSION=`$PKG_CONFIG libmemcached --modversion`
    PHP_LIBMEMCACHED_DIR=`$PKG_CONFIG libmemcached --variable=prefix`

    AC_MSG_RESULT([found version $PHP_LIBMEMCACHED_VERSION, under $PHP_LIBMEMCACHED_DIR])

    PHP_LIBMEMCACHED_LIBS=`$PKG_CONFIG libmemcached --libs`
    PHP_LIBMEMCACHED_INCLUDES=`$PKG_CONFIG libmemcached --cflags`

    PHP_EVAL_LIBLINE($PHP_LIBMEMCACHED_LIBS, MEMCACHED_SHARED_LIBADD)
    PHP_EVAL_INCLINE($PHP_LIBMEMCACHED_INCLUDES)

    ORIG_CFLAGS="$CFLAGS"
    CFLAGS="$CFLAGS $INCLUDES"

    dnl # Always check if libmemcached was built with SASL support,
    dnl # because it will require sasl.h even if not used here.
    AC_CACHE_CHECK([for libmemcached sasl.h requirement], ac_cv_memc_sasl_support, [
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libmemcached/memcached.h>]], [[
        #if LIBMEMCACHED_WITH_SASL_SUPPORT
          /* yes */
        #else
        #  error "no sasl support"
        #endif
        ]])],
        [ac_cv_memc_sasl_support="yes"],
        [ac_cv_memc_sasl_support="no"]
      )
    ])

    if test "$ac_cv_memc_sasl_support" = "yes"; then
      AC_CHECK_HEADERS([sasl/sasl.h], [ac_cv_have_memc_sasl_h="yes"], [ac_cv_have_memc_sasl_h="no"])
    fi

    dnl # If libmemcached requires sasl.h but we can't find sasl.h, that's a hard error
    dnl # regardless of the option --enable-memcached-sasl or --disable-memcached-sasl
    AC_MSG_CHECKING([whether to enable sasl support])
    if test "$ac_cv_memc_sasl_support" = "yes" && test "$ac_cv_have_memc_sasl_h" = "no"; then
      AC_MSG_ERROR([no, libmemcached built with sasl required, but sasl.h not found.])
    fi

    if test "$PHP_MEMCACHED_SASL" != "no"; then
      AC_MSG_RESULT(yes)
      if test "$ac_cv_memc_sasl_support" = "yes" && test "$ac_cv_have_memc_sasl_h" = "yes"; then
        PHP_CHECK_LIBRARY(sasl2, sasl_client_init, [PHP_ADD_LIBRARY(sasl2, 1, MEMCACHED_SHARED_LIBADD)])
        AC_DEFINE(HAVE_MEMCACHED_SASL, 1, [Have SASL support])
      else
        AC_MSG_ERROR([no, libmemcached built with sasl disabled. Run configure with --disable-memcached-sasl or update libmemcached with sasl support])
      fi
    else
      AC_MSG_RESULT([no])
    fi

    ORIG_CFLAGS="$CFLAGS"
    ORIG_LIBS="$LIBS"

    CFLAGS="$CFLAGS $PHP_LIBMEMCACHED_INCLUDES"
    LIBS="$LIBS $PHP_LIBMEMCACHED_LIBS"

    AC_CACHE_CHECK([whether memcached_exist is defined], ac_cv_have_memcached_exist, [
      AC_LINK_IFELSE(
        [AC_LANG_PROGRAM([[#include <libmemcached/memcached.h>]],
          [[memcached_exist (NULL, NULL, 0);]])],
          [ac_cv_have_memcached_exist="yes"],
          [ac_cv_have_memcached_exist="no"])
    ])

    CFLAGS="$ORIG_CFLAGS"
    LIBS="$ORIG_LIBS"

    CFLAGS="$CFLAGS $PHP_LIBMEMCACHED_INCLUDES"
    LIBS="$LIBS $PHP_LIBMEMCACHED_LIBS"

    if test "$ac_cv_have_memcached_exist" = "yes"; then
      AC_DEFINE(HAVE_MEMCACHED_EXIST, [1], [Whether memcached_exist is defined])
    fi

    AC_CACHE_CHECK([whether memcached_set_encoding_key is defined], ac_cv_have_memcached_set_encoding_key, [
      AC_LINK_IFELSE(
        [AC_LANG_PROGRAM([[#include <libmemcached/memcached.h>]],
          [[memcached_set_encoding_key (NULL, NULL, 0);]])],
        [ac_cv_have_memcached_set_encoding_key="yes"],
        [ac_cv_have_memcached_set_encoding_key="no"])
    ])

    CFLAGS="$ORIG_CFLAGS"
    LIBS="$ORIG_LIBS"

    if test "$ac_cv_have_memcached_set_encoding_key" = "yes"; then
      AC_DEFINE(HAVE_MEMCACHED_SET_ENCODING_KEY, [1], [Whether memcached_set_encoding_key is defined])
    fi

    PHP_MEMCACHED_FILES="php_memcached.c php_libmemcached_compat.c  g_fmt.c"

    if test "$PHP_SYSTEM_FASTLZ" != "no"; then
      AC_CHECK_HEADERS([fastlz.h], [ac_cv_have_fastlz="yes"], [ac_cv_have_fastlz="no"])
      PHP_CHECK_LIBRARY(fastlz, fastlz_compress,
          [PHP_ADD_LIBRARY(fastlz, 1, MEMCACHED_SHARED_LIBADD)],
          [AC_MSG_ERROR(FastLZ library not found)])
    else
      ac_cv_have_fastlz="no"
      PHP_MEMCACHED_FILES="${PHP_MEMCACHED_FILES} fastlz/fastlz.c"
    fi

    if test "$PHP_MEMCACHED_SESSION" != "no"; then
      PHP_MEMCACHED_FILES="${PHP_MEMCACHED_FILES} php_memcached_session.c"
    fi

    LIBEVENT_INCLUDES=""
    AC_MSG_CHECKING([for memcached protocol support])
    if test "$PHP_MEMCACHED_PROTOCOL" != "no"; then
      AC_MSG_RESULT([enabled])

      AC_CACHE_CHECK([whether libmemcachedprotocol is usable], ac_cv_have_libmemcachedprotocol, [
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libmemcachedprotocol-0.0/handler.h>]],
          [[memcached_binary_protocol_callback_st s_test_impl;
            s_test_impl.interface.v1.delete_object = 0;
          ]])],
          [ac_cv_have_libmemcachedprotocol="yes"],
          [ac_cv_have_libmemcachedprotocol="no"]
        )
      ])

      if test "$ac_cv_have_libmemcachedprotocol" != "yes"; then
        AC_MSG_ERROR([Cannot enable libmemcached protocol])
      fi

      PHP_ADD_LIBRARY_WITH_PATH(memcachedprotocol, $PHP_LIBMEMCACHED_DIR/$PHP_LIBDIR, MEMCACHED_SHARED_LIBADD)

      AC_MSG_CHECKING([for libevent])
      if $PKG_CONFIG --exists libevent; then
        PHP_MEMCACHED_LIBEVENT_VERSION=`$PKG_CONFIG libevent --modversion`
        PHP_MEMCACHED_LIBEVENT_PREFIX=`$PKG_CONFIG libevent --variable=prefix`

        AC_MSG_RESULT([found version $PHP_MEMCACHED_LIBEVENT_VERSION, under $PHP_MEMCACHED_LIBEVENT_PREFIX])
        LIBEVENT_LIBS=`$PKG_CONFIG libevent --libs`
        LIBEVENT_INCLUDES=`$PKG_CONFIG libevent --cflags`

        PHP_EVAL_LIBLINE($LIBEVENT_LIBS, MEMCACHED_SHARED_LIBADD)
        PHP_EVAL_INCLINE($LIBEVENT_INCLUDES)
      else
        AC_MSG_ERROR(Unable to find libevent installation)
      fi
      PHP_MEMCACHED_FILES="${PHP_MEMCACHED_FILES} php_memcached_server.c"
      AC_DEFINE(HAVE_MEMCACHED_PROTOCOL,1,[Whether memcached protocol is enabled])
    else
      AC_MSG_RESULT([disabled])
    fi

    CFLAGS="$ORIG_CFLAGS"

    export PKG_CONFIG_PATH="$ORIG_PKG_CONFIG_PATH"
    PHP_SUBST(MEMCACHED_SHARED_LIBADD)

    PHP_NEW_EXTENSION(memcached, $PHP_MEMCACHED_FILES, $ext_shared,,$SESSION_INCLUDES $IGBINARY_INCLUDES $LIBEVENT_INCLUDES $MSGPACK_INCLUDES)
    if test "ac_cv_have_fastlz" != "yes"; then
      PHP_ADD_BUILD_DIR($ext_builddir/fastlz, 1)
    fi

    ifdef([PHP_ADD_EXTENSION_DEP],
    [
      PHP_ADD_EXTENSION_DEP(memcached, spl, true)
    ])
  fi
fi