6
minimum_libevent_version="1.4.11"
9
6
[ --enable-fpm EXPERIMENTAL: Enable building of the fpm SAPI executable], no, no)
11
dnl libevent check function {{{
12
dnl @synopsis AC_LIB_EVENT([MINIMUM-VERSION])
14
dnl Test for the libevent library of a particular version (or newer).
15
dnl Source: http://svn.apache.org/repos/asf/incubator/thrift/trunk/aclocal/ax_lib_event.m4
16
dnl Modified: This file was modified for autoconf-2.13 and the PHP_ARG_WITH macro.
18
dnl If no path to the installed libevent is given, the macro will first try
19
dnl using no -I or -L flags, then searches under /usr, /usr/local, /opt,
20
dnl and /opt/libevent.
21
dnl If these all fail, it will try the $LIBEVENT_ROOT environment variable.
23
dnl This macro requires that #include <sys/types.h> works and defines u_char.
26
dnl AC_SUBST(LIBEVENT_CFLAGS)
27
dnl AC_SUBST(LIBEVENT_LIBS)
29
dnl And (if libevent is found):
30
dnl AC_DEFINE(HAVE_LIBEVENT)
32
dnl It also leaves the shell variables "success" and "ac_have_libevent"
33
dnl set to "yes" or "no".
35
dnl NOTE: This macro does not currently work for cross-compiling,
36
dnl but it can be easily modified to allow it. (grep "cross").
38
dnl @category InstalledPackages
40
dnl @version 2007-09-12
41
dnl @license AllPermissive
43
dnl Copyright (C) 2009 David Reiss
44
dnl Copying and distribution of this file, with or without modification,
45
dnl are permitted in any medium without royalty provided the copyright
46
dnl notice and this notice are preserved.
48
AC_DEFUN([AC_LIB_EVENT_DO_CHECK],
51
CPPFLAGS_SAVED="$CPPFLAGS"
52
LDFLAGS_SAVED="$LDFLAGS"
54
LD_LIBRARY_PATH_SAVED="$LD_LIBRARY_PATH"
56
# Set our flags if we are checking a specific directory.
57
if test -n "$ac_libevent_path" ; then
58
LIBEVENT_CPPFLAGS="-I$ac_libevent_path/include"
60
if test -z "$PHP_LIBDIR"; then
61
LIBEVENT_LDFLAGS="-L$ac_libevent_path/lib"
63
LIBEVENT_LDFLAGS="-L$ac_libevent_path/$PHP_LIBDIR"
66
LD_LIBRARY_PATH="$ac_libevent_path/lib:$LD_LIBRARY_PATH"
72
# Required flag for libevent.
73
LIBEVENT_LIBS="-levent"
75
# Prepare the environment for compilation.
76
CPPFLAGS="$CPPFLAGS $LIBEVENT_CPPFLAGS"
77
LDFLAGS="$LDFLAGS $LIBEVENT_LDFLAGS"
78
LIBS="$LIBS $LIBEVENT_LIBS"
82
export LD_LIBRARY_PATH
86
# Compile, link, and run the program. This checks:
87
# - event.h is available for including.
88
# - event_get_version() is available for linking.
89
# - The event version string is lexicographically greater
90
# than the required version.
92
#include <sys/types.h>
95
int main(int argc, char *argv[])
97
const char* lib_version = event_get_version();
98
const char* wnt_version = "$WANT_LIBEVENT_VERSION";
100
/* If we reached the end of the want version. We have it. */
101
if (*wnt_version == '\0' || *wnt_version == '-') {
104
/* If the want version continues but the lib version does not, */
105
/* we are missing a letter. We don't have it. */
106
if (*lib_version == '\0' || *lib_version == '-') {
110
/* In the 1.4 version numbering style, if there are more digits */
111
/* in one version than the other, that one is higher. */
114
lib_version[lib_digits] >= '0' &&
115
lib_version[lib_digits] <= '9';
120
wnt_version[wnt_digits] >= '0' &&
121
wnt_version[wnt_digits] <= '9';
124
if (lib_digits > wnt_digits) {
127
if (lib_digits < wnt_digits) {
130
/* If we have greater than what we want. We have it. */
131
if (*lib_version > *wnt_version) {
134
/* If we have less, we don't. */
135
if (*lib_version < *wnt_version) {
148
CPPFLAGS="$CPPFLAGS_SAVED"
149
LDFLAGS="$LDFLAGS_SAVED"
151
LD_LIBRARY_PATH="$LD_LIBRARY_PATH_SAVED"
154
AC_DEFUN([AC_LIB_EVENT],
157
PHP_ARG_WITH(libevent-dir,,
158
[ --with-libevent-dir[=PATH] libevent install prefix, for fpm SAPI. (default: /usr/local)], /usr/local, yes)
160
if test "$PHP_LIBEVENT_DIR" != "no"; then
161
WANT_LIBEVENT_VERSION=ifelse([$1], ,1.2,$1)
163
AC_MSG_CHECKING(for libevent >= $WANT_LIBEVENT_VERSION install prefix)
165
libevent_prefix=$ac_default_prefix
166
if test $prefix != "NONE" -a $prefix != "" -a $prefix != "no" ; then
167
libevent_prefix=$prefix
170
if test "$PHP_LIBEVENT_DIR" = "yes"; then
171
PHP_LIBEVENT_DIR=$libevent_prefix
174
if test "$PHP_LIBEVENT_DIR" != "yes" && test "$PHP_LIBEVENT_DIR" != "/usr/local"; then
175
dnl don't try to be too smart, check only $PHP_LIBEVENT_DIR if specified
176
ac_libevent_path=$PHP_LIBEVENT_DIR
177
AC_LIB_EVENT_DO_CHECK
178
if test "$success" = "no"; then
179
AC_MSG_ERROR([Could not find libevent >= $WANT_LIBEVENT_VERSION in $PHP_LIBEVENT_DIR])
182
dnl check default prefixes then
183
for ac_libevent_path in "" $PHP_LIBEVENT_DIR /usr /usr/local /opt /opt/local /opt/libevent ; do
184
AC_LIB_EVENT_DO_CHECK
185
if test "$success" = "yes"; then
191
if test "$success" != "yes" ; then
194
AC_MSG_ERROR([libevent >= $WANT_LIBEVENT_VERSION could not be found])
196
AC_MSG_RESULT($ac_libevent_path)
198
AC_DEFINE(HAVE_LIBEVENT, 1, [define if libevent is available])
201
LIBEVENT_LIBS="-levent"
203
if test -n "$ac_libevent_path"; then
204
LIBEVENT_CFLAGS="-I$ac_libevent_path/include"
205
LIBEVENT_LIBS="-L$ac_libevent_path/$PHP_LIBDIR $LIBEVENT_LIBS"
206
LIBEVENT_PATH="$ac_libevent_path/$PHP_LIBDIR"
209
AC_SUBST(LIBEVENT_CFLAGS)
210
AC_SUBST(LIBEVENT_LIBS)
211
AC_SUBST(LIBEVENT_PATH)
214
AC_MSG_ERROR([FPM requires libevent >= $WANT_LIBEVENT_VERSION. Please specify libevent install prefix with --with-libevent-dir=yes])
220
8
dnl configure checks {{{
221
9
AC_DEFUN([AC_FPM_STDLIBS],
223
AC_CHECK_FUNCS(setenv clearenv)
11
AC_CHECK_FUNCS(setenv clearenv setproctitle)
225
13
AC_SEARCH_LIBS(socket, socket)
226
14
AC_SEARCH_LIBS(inet_addr, nsl)
291
AC_DEFUN([AC_FPM_BUILTIN_ATOMIC],
293
AC_MSG_CHECKING([if gcc supports __sync_bool_compare_and_swap])
297
return (__sync_bool_compare_and_swap(&variable, 1, 2)
298
&& __sync_add_and_fetch(&variable, 1)) ? 1 : 0;
302
AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() a.o.])
309
AC_DEFUN([AC_FPM_LQ],
313
AC_MSG_CHECKING([for TCP_INFO])
315
AC_TRY_COMPILE([ #include <netinet/tcp.h> ], [struct tcp_info ti; int x = TCP_INFO;], [
322
if test "$have_lq" = "tcp_info"; then
323
AC_DEFINE([HAVE_LQ_TCP_INFO], 1, [do we have TCP_INFO?])
326
if test "$have_lq" = "no" ; then
327
AC_MSG_CHECKING([for SO_LISTENQLEN])
329
AC_TRY_COMPILE([ #include <sys/socket.h> ], [int x = SO_LISTENQLIMIT; int y = SO_LISTENQLEN;], [
336
if test "$have_lq" = "tcp_info"; then
337
AC_DEFINE([HAVE_LQ_SO_LISTENQ], 1, [do we have SO_LISTENQxxx?])
504
343
AC_MSG_CHECKING(for FPM build)
505
344
if test "$PHP_FPM" != "no"; then
506
345
AC_MSG_RESULT($PHP_FPM)
508
AC_LIB_EVENT([$minimum_libevent_version])
510
PHP_ADD_LIBRARY_WITH_PATH(event, $LIBEVENT_PATH)
512
PHP_TEST_BUILD(event_init, [ ], [
514
AC_MSG_ERROR([build test failed. Please check the config.log for details.])
351
AC_FPM_BUILTIN_ATOMIC
522
354
PHP_ARG_WITH(fpm-user,,
523
355
[ --with-fpm-user[=USER] Set the user for php-fpm to run as. (default: nobody)], nobody, no)
538
370
php_fpm_group="$PHP_FPM_GROUP"
541
PHP_SUBST_OLD(fpm_version)
542
373
PHP_SUBST_OLD(php_fpm_user)
543
374
PHP_SUBST_OLD(php_fpm_group)
544
375
php_fpm_sysconfdir=`eval echo $sysconfdir`
545
376
PHP_SUBST_OLD(php_fpm_sysconfdir)
546
377
php_fpm_localstatedir=`eval echo $localstatedir`
547
378
PHP_SUBST_OLD(php_fpm_localstatedir)
379
php_fpm_prefix=`eval echo $prefix`
380
PHP_SUBST_OLD(php_fpm_prefix)
549
AC_DEFINE_UNQUOTED(PHP_FPM_VERSION, "$fpm_version", [fpm version])
550
382
AC_DEFINE_UNQUOTED(PHP_FPM_USER, "$php_fpm_user", [fpm user name])
551
383
AC_DEFINE_UNQUOTED(PHP_FPM_GROUP, "$php_fpm_group", [fpm group name])
553
PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.1)
385
PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.8)
554
386
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/fpm/Makefile.frag], [$abs_srcdir/sapi/fpm], [sapi/fpm])
556
388
SAPI_FPM_PATH=sapi/fpm/php-fpm